Show open tasks on project pages

Summary: This is pretty basic but gets us most of the way there I think. Could
use some style tweaks at some point.
Test Plan: Looked at a project page with open tasks, and one without open tasks.
Reviewed By: tuomaspelkonen
Reviewers: cadamo, aran, jungejason, tuomaspelkonen
CC: aran, tuomaspelkonen, epriestley
Differential Revision: 609
This commit is contained in:
epriestley
2011-07-07 14:01:55 -07:00
parent 81e3ec5998
commit 30dbdf322d
3 changed files with 116 additions and 61 deletions

View File

@@ -111,76 +111,122 @@ class PhabricatorProjectProfileController
$profile->getBlurb(), $profile->getBlurb(),
'//Nothing is known about this elusive project.//'); '//Nothing is known about this elusive project.//');
$factory = new DifferentialMarkupEngineFactory(); $factory = new DifferentialMarkupEngineFactory();
$engine = $factory->newDifferentialCommentMarkupEngine(); $engine = $factory->newDifferentialCommentMarkupEngine();
$blurb = $engine->markupText($blurb); $blurb = $engine->markupText($blurb);
$affiliations = $project->loadAffiliations(); $affiliations = $project->loadAffiliations();
$phids = array_merge( $phids = array_merge(
array($project->getAuthorPHID()), array($project->getAuthorPHID()),
mpull($affiliations, 'getUserPHID')); mpull($affiliations, 'getUserPHID'));
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles(); ->loadHandles();
$affiliated = array(); $affiliated = array();
foreach ($affiliations as $affiliation) { foreach ($affiliations as $affiliation) {
$user = $handles[$affiliation->getUserPHID()]->renderLink(); $user = $handles[$affiliation->getUserPHID()]->renderLink();
$role = phutil_escape_html($affiliation->getRole()); $role = phutil_escape_html($affiliation->getRole());
$status = null; $status = null;
if ($affiliation->getStatus() == 'former') { if ($affiliation->getStatus() == 'former') {
$role = '<em>Former '.$role.'</em>'; $role = '<em>Former '.$role.'</em>';
} }
$affiliated[] = '<li>'.$user.' &mdash; '.$role.$status.'</li>'; $affiliated[] = '<li>'.$user.' &mdash; '.$role.$status.'</li>';
} }
if ($affiliated) { if ($affiliated) {
$affiliated = '<ul>'.implode("\n", $affiliated).'</ul>'; $affiliated = '<ul>'.implode("\n", $affiliated).'</ul>';
} else { } else {
$affiliated = '<p><em>No one is affiliated with this project.</em></p>'; $affiliated = '<p><em>No one is affiliated with this project.</em></p>';
} }
$timestamp = phabricator_format_timestamp($project->getDateCreated()); $timestamp = phabricator_format_timestamp($project->getDateCreated());
$status = PhabricatorProjectStatus::getNameForStatus( $status = PhabricatorProjectStatus::getNameForStatus(
$project->getStatus()); $project->getStatus());
$content = $content =
'<div class="phabricator-profile-info-group"> '<div class="phabricator-profile-info-group">
<h1 class="phabricator-profile-info-header">Basic Information</h1> <h1 class="phabricator-profile-info-header">Basic Information</h1>
<div class="phabricator-profile-info-pane"> <div class="phabricator-profile-info-pane">
<table class="phabricator-profile-info-table"> <table class="phabricator-profile-info-table">
<tr> <tr>
<th>Creator</th> <th>Creator</th>
<td>'.$handles[$project->getAuthorPHID()]->renderLink().'</td> <td>'.$handles[$project->getAuthorPHID()]->renderLink().'</td>
</tr> </tr>
<tr> <tr>
<th>Status</th> <th>Status</th>
<td><strong>'.phutil_escape_html($status).'</strong></td> <td><strong>'.phutil_escape_html($status).'</strong></td>
</tr> </tr>
<tr> <tr>
<th>Created</th> <th>Created</th>
<td>'.$timestamp.'</td> <td>'.$timestamp.'</td>
</tr> </tr>
<tr> <tr>
<th>PHID</th> <th>PHID</th>
<td>'.phutil_escape_html($project->getPHID()).'</td> <td>'.phutil_escape_html($project->getPHID()).'</td>
</tr> </tr>
<tr> <tr>
<th>Blurb</th> <th>Blurb</th>
<td>'.$blurb.'</td> <td>'.$blurb.'</td>
</tr> </tr>
</table> </table>
</div> </div>
</div>'; </div>';
$content .= $content .=
'<div class="phabricator-profile-info-group"> '<div class="phabricator-profile-info-group">
<h1 class="phabricator-profile-info-header">Resources</h1> <h1 class="phabricator-profile-info-header">Resources</h1>
<div class="phabricator-profile-info-pane">'. <div class="phabricator-profile-info-pane">'.
$affiliated. $affiliated.
'</div> '</div>
</div>'; </div>';
$query = id(new ManiphestTaskQuery())
->withProjects(array($project->getPHID()))
->withStatus(ManiphestTaskQuery::STATUS_OPEN)
->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY)
->setLimit(10)
->setCalculateRows(true);
$tasks = $query->execute();
$count = $query->getRowCount();
$task_views = array();
foreach ($tasks as $task) {
$view = id(new ManiphestTaskSummaryView())
->setTask($task)
->setHandles($handles)
->setUser($this->getRequest()->getUser());
$task_views[] = $view->render();
}
if (empty($tasks)) {
$task_views = '<em>No open tasks.</em>';
} else {
$task_views = implode('', $task_views);
}
$open = number_format($count);
$more_link = phutil_render_tag(
'a',
array(
'href' => '/maniphest/view/all/?projects='.$project->getPHID(),
),
"View All Open Tasks \xC2\xBB");
$content .=
'<div class="phabricator-profile-info-group">
<h1 class="phabricator-profile-info-header">'.
"Open Tasks ({$open})".
'</h1>'.
'<div class="phabricator-profile-info-pane">'.
$task_views.
'<div class="phabricator-profile-info-pane-more-link">'.
$more_link.
'</div>'.
'</div>
</div>';
return $content; return $content;
} }

View File

@@ -9,6 +9,8 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/differential/parser/markup'); phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/maniphest/query');
phutil_require_module('phabricator', 'applications/maniphest/view/tasksummary');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/project/constants/status'); phutil_require_module('phabricator', 'applications/project/constants/status');
phutil_require_module('phabricator', 'applications/project/controller/base'); phutil_require_module('phabricator', 'applications/project/controller/base');

View File

@@ -95,3 +95,10 @@ img.phabricator-profile-image {
width: 280px; width: 280px;
margin: 10px; margin: 10px;
} }
.phabricator-profile-info-pane-more-link {
text-align: right;
padding: .25em;
font-weight: bold;
margin: .5em 1em 0;
}