mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Move Nuance Items to two-column views
Summary: Ref T10537. Test Plan: {F1164796} {F1164797} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10537 Differential Revision: https://secure.phabricator.com/D15444
This commit is contained in:
parent
2da9fcafbf
commit
ee155ce8d2
5 changed files with 138 additions and 135 deletions
|
@ -1429,9 +1429,9 @@ phutil_register_library_map(array(
|
|||
'NuanceImportCursorPHIDType' => 'applications/nuance/phid/NuanceImportCursorPHIDType.php',
|
||||
'NuanceItem' => 'applications/nuance/storage/NuanceItem.php',
|
||||
'NuanceItemController' => 'applications/nuance/controller/NuanceItemController.php',
|
||||
'NuanceItemEditController' => 'applications/nuance/controller/NuanceItemEditController.php',
|
||||
'NuanceItemEditor' => 'applications/nuance/editor/NuanceItemEditor.php',
|
||||
'NuanceItemListController' => 'applications/nuance/controller/NuanceItemListController.php',
|
||||
'NuanceItemManageController' => 'applications/nuance/controller/NuanceItemManageController.php',
|
||||
'NuanceItemPHIDType' => 'applications/nuance/phid/NuanceItemPHIDType.php',
|
||||
'NuanceItemQuery' => 'applications/nuance/query/NuanceItemQuery.php',
|
||||
'NuanceItemSearchEngine' => 'applications/nuance/query/NuanceItemSearchEngine.php',
|
||||
|
@ -5692,9 +5692,9 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationTransactionInterface',
|
||||
),
|
||||
'NuanceItemController' => 'NuanceController',
|
||||
'NuanceItemEditController' => 'NuanceController',
|
||||
'NuanceItemEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'NuanceItemListController' => 'NuanceItemController',
|
||||
'NuanceItemManageController' => 'NuanceController',
|
||||
'NuanceItemPHIDType' => 'PhabricatorPHIDType',
|
||||
'NuanceItemQuery' => 'NuanceQuery',
|
||||
'NuanceItemSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
|
|
|
@ -42,8 +42,7 @@ final class PhabricatorNuanceApplication extends PhabricatorApplication {
|
|||
'item/' => array(
|
||||
$this->getQueryRoutePattern() => 'NuanceItemListController',
|
||||
'view/(?P<id>[1-9]\d*)/' => 'NuanceItemViewController',
|
||||
'edit/(?P<id>[1-9]\d*)/' => 'NuanceItemEditController',
|
||||
'new/' => 'NuanceItemEditController',
|
||||
'manage/(?P<id>[1-9]\d*)/' => 'NuanceItemManageController',
|
||||
),
|
||||
'source/' => array(
|
||||
$this->getQueryRoutePattern() => 'NuanceSourceListController',
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class NuanceItemEditController extends NuanceController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$item = id(new NuanceItemQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->executeOne();
|
||||
if (!$item) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$title = pht('Item %d', $item->getID());
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($title);
|
||||
$crumbs->addTextCrumb(pht('Edit'));
|
||||
|
||||
$properties = $this->buildPropertyView($item);
|
||||
$actions = $this->buildActionView($item);
|
||||
$properties->setActionList($actions);
|
||||
|
||||
$box = id(new PHUIObjectBoxView())
|
||||
->setHeaderText($title)
|
||||
->addPropertyList($properties);
|
||||
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$item,
|
||||
new NuanceItemTransactionQuery());
|
||||
|
||||
$timeline->setShouldTerminate(true);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$box,
|
||||
$timeline,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
));
|
||||
}
|
||||
|
||||
private function buildPropertyView(NuanceItem $item) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$properties = id(new PHUIPropertyListView())
|
||||
->setUser($viewer)
|
||||
->setObject($item);
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Date Created'),
|
||||
phabricator_datetime($item->getDateCreated(), $viewer));
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Requestor'),
|
||||
$viewer->renderHandle($item->getRequestorPHID()));
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Source'),
|
||||
$viewer->renderHandle($item->getSourcePHID()));
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Queue'),
|
||||
$viewer->renderHandle($item->getQueuePHID()));
|
||||
|
||||
$source = $item->getSource();
|
||||
$definition = $source->getDefinition();
|
||||
|
||||
$definition->renderItemEditProperties(
|
||||
$viewer,
|
||||
$item,
|
||||
$properties);
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
private function buildActionView(NuanceItem $item) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $item->getID();
|
||||
|
||||
$actions = id(new PhabricatorActionListView())
|
||||
->setUser($viewer);
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('View Item'))
|
||||
->setIcon('fa-eye')
|
||||
->setHref($this->getApplicationURI("item/view/{$id}/")));
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
final class NuanceItemManageController extends NuanceController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$item = id(new NuanceItemQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$item) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$title = pht('Item %d', $item->getID());
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(
|
||||
pht('Items'),
|
||||
$this->getApplicationURI('item/'));
|
||||
$crumbs->addTextCrumb(
|
||||
$title,
|
||||
$item->getURI());
|
||||
$crumbs->addTextCrumb(pht('Manage'));
|
||||
$crumbs->setBorder(true);
|
||||
|
||||
$properties = $this->buildPropertyView($item);
|
||||
$curtain = $this->buildCurtain($item);
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($title);
|
||||
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$item,
|
||||
new NuanceItemTransactionQuery());
|
||||
$timeline->setShouldTerminate(true);
|
||||
|
||||
$view = id(new PHUITwoColumnView())
|
||||
->setHeader($header)
|
||||
->setCurtain($curtain)
|
||||
->addPropertySection(pht('DETAILS'), $properties)
|
||||
->setMainColumn($timeline);
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle($title)
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild($view);
|
||||
}
|
||||
|
||||
private function buildPropertyView(NuanceItem $item) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$properties = id(new PHUIPropertyListView())
|
||||
->setUser($viewer);
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Date Created'),
|
||||
phabricator_datetime($item->getDateCreated(), $viewer));
|
||||
|
||||
$requestor_phid = $item->getRequestorPHID();
|
||||
if ($requestor_phid) {
|
||||
$requestor_view = $viewer->renderHandle($requestor_phid);
|
||||
} else {
|
||||
$requestor_view = phutil_tag('em', array(), pht('None'));
|
||||
}
|
||||
$properties->addProperty(pht('Requestor'), $requestor_view);
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Source'),
|
||||
$viewer->renderHandle($item->getSourcePHID()));
|
||||
|
||||
$queue_phid = $item->getQueuePHID();
|
||||
if ($queue_phid) {
|
||||
$queue_view = $viewer->renderHandle($queue_phid);
|
||||
} else {
|
||||
$queue_view = phutil_tag('em', array(), pht('None'));
|
||||
}
|
||||
$properties->addProperty(pht('Queue'), $queue_view);
|
||||
|
||||
$source = $item->getSource();
|
||||
$definition = $source->getDefinition();
|
||||
|
||||
$definition->renderItemEditProperties(
|
||||
$viewer,
|
||||
$item,
|
||||
$properties);
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
private function buildCurtain(NuanceItem $item) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $item->getID();
|
||||
|
||||
$curtain = $this->newCurtainView($item);
|
||||
|
||||
$curtain->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('View Item'))
|
||||
->setIcon('fa-eye')
|
||||
->setHref($item->getURI()));
|
||||
|
||||
return $curtain;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -17,32 +17,34 @@ final class NuanceItemViewController extends NuanceController {
|
|||
$title = pht('Item %d', $item->getID());
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(
|
||||
pht('Items'),
|
||||
$this->getApplicationURI('item/'));
|
||||
$crumbs->addTextCrumb($title);
|
||||
$crumbs->setBorder(true);
|
||||
|
||||
$properties = $this->buildPropertyView($item);
|
||||
$actions = $this->buildActionView($item);
|
||||
$properties->setActionList($actions);
|
||||
$curtain = $this->buildCurtain($item);
|
||||
|
||||
$box = id(new PHUIObjectBoxView())
|
||||
->setHeaderText($title)
|
||||
->addPropertyList($properties);
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($title);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$box,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
));
|
||||
$view = id(new PHUITwoColumnView())
|
||||
->setHeader($header)
|
||||
->setCurtain($curtain)
|
||||
->addPropertySection(pht('DETAILS'), $properties);
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle($title)
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild($view);
|
||||
}
|
||||
|
||||
private function buildPropertyView(NuanceItem $item) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$properties = id(new PHUIPropertyListView())
|
||||
->setUser($viewer)
|
||||
->setObject($item);
|
||||
->setUser($viewer);
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Date Created'),
|
||||
|
@ -59,27 +61,24 @@ final class NuanceItemViewController extends NuanceController {
|
|||
return $properties;
|
||||
}
|
||||
|
||||
private function buildActionView(NuanceItem $item) {
|
||||
private function buildCurtain(NuanceItem $item) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $item->getID();
|
||||
|
||||
$actions = id(new PhabricatorActionListView())
|
||||
->setUser($viewer);
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$viewer,
|
||||
$item,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Edit Item'))
|
||||
->setIcon('fa-pencil')
|
||||
->setHref($this->getApplicationURI("item/edit/{$id}/"))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
$curtain = $this->newCurtainView($item);
|
||||
|
||||
return $actions;
|
||||
$curtain->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Manage Item'))
|
||||
->setIcon('fa-cogs')
|
||||
->setHref($this->getApplicationURI("item/manage/{$id}/")));
|
||||
|
||||
return $curtain;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue