1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Convert Projects to use ObjectItemList

Summary: Converts the old table to a new item list, also added ability to link icons on right side of item stack.

Test Plan: Tested adding removing, sorting of projects both active and inactive.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4960
This commit is contained in:
Chad Little 2013-02-14 13:07:35 -08:00
parent 1e5d1f6534
commit fb32a64d84
3 changed files with 54 additions and 37 deletions

View file

@ -6,14 +6,23 @@ final class PhabricatorProjectStatus {
const STATUS_ARCHIVED = 100;
public static function getNameForStatus($status) {
static $map = array(
self::STATUS_ACTIVE => 'Active',
self::STATUS_ARCHIVED => 'Archived',
$map = array(
self::STATUS_ACTIVE => pht('Active'),
self::STATUS_ARCHIVED => pht('Archived'),
);
return idx($map, coalesce($status, '?'), 'Unknown');
}
public static function getIconForStatus($status) {
$map = array(
self::STATUS_ACTIVE => 'check',
self::STATUS_ARCHIVED => 'disable',
);
return idx($map, $status);
}
public static function getStatusMap() {
return array(
self::STATUS_ACTIVE => 'Active',

View file

@ -79,7 +79,6 @@ final class PhabricatorProjectListController
$group = idx($groups, $phid, array());
$task_count = count($group);
$population = count($members);
if ($profile) {
@ -89,51 +88,48 @@ final class PhabricatorProjectListController
$blurb = null;
}
$tasks_href = pht('%d Open Task(s)', $task_count);
$rows[] = array(
phutil_tag(
'a',
array(
'href' => '/project/view/'.$project->getID().'/',
),
$project->getName()),
$project->getName(),
'/project/view/'.$project->getID().'/',
PhabricatorProjectStatus::getNameForStatus($project->getStatus()),
PhabricatorProjectStatus::getIconForStatus($project->getStatus()),
$blurb,
$population,
pht('%d Member(s)', $population),
phutil_tag(
'a',
array(
'href' => '/maniphest/view/all/?projects='.$phid,
),
$task_count),
$tasks_href),
'/project/edit/'.$project->getID().'/',
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
pht('Project'),
pht('Status'),
pht('Description'),
pht('Population'),
pht('Open Tasks'),
));
$table->setColumnClasses(
array(
'pri',
'',
'wide',
'',
''
));
$list = new PhabricatorObjectItemListView();
$list->setStackable();
foreach ($rows as $row) {
$item = id(new PhabricatorObjectItemView())
->setHeader($row[0])
->setHref($row[1])
->addIcon($row[3], $row[2])
->addIcon('edit', pht('Edit Project'), $row[7])
->addAttribute($row[4])
->addAttribute($row[5])
->addAttribute($row[6]);
$list->addItem($item);
}
$panel = new AphrontPanelView();
$panel->setHeader($table_header);
$panel->appendChild($table);
$panel->setNoBackground();
$panel->appendChild($pager);
$header = id(new PhabricatorHeaderView())
->setHeader($table_header);
$nav->appendChild($panel);
$nav->appendChild(
array(
$header,
$list,
$pager,
));
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
$crumbs->addCrumb(

View file

@ -48,10 +48,11 @@ final class PhabricatorObjectItemView extends AphrontView {
return $this->header;
}
public function addIcon($icon, $label = null) {
public function addIcon($icon, $label = null, $href = null) {
$this->icons[] = array(
'icon' => $icon,
'label' => $label,
'href' => $href,
);
return $this;
}
@ -100,12 +101,23 @@ final class PhabricatorObjectItemView extends AphrontView {
),
$spec['label']);
if ($spec['href']) {
$icon_href = phutil_tag(
'a',
array('href' => $spec['href']),
array($label, $icon)
);
} else {
$icon_href = array($label, $icon);
}
$icon_list[] = phutil_tag(
'li',
array(
'class' => 'phabricator-object-item-icon',
),
array($label, $icon));
$icon_href);
}
$icons = phutil_tag(