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; const STATUS_ARCHIVED = 100;
public static function getNameForStatus($status) { public static function getNameForStatus($status) {
static $map = array( $map = array(
self::STATUS_ACTIVE => 'Active', self::STATUS_ACTIVE => pht('Active'),
self::STATUS_ARCHIVED => 'Archived', self::STATUS_ARCHIVED => pht('Archived'),
); );
return idx($map, coalesce($status, '?'), 'Unknown'); 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() { public static function getStatusMap() {
return array( return array(
self::STATUS_ACTIVE => 'Active', self::STATUS_ACTIVE => 'Active',

View file

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

View file

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