diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index cc16cb4e88..45a9aa2b96 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1622,6 +1622,7 @@ phutil_register_library_map(array( 'NuanceItemActionController' => 'applications/nuance/controller/NuanceItemActionController.php', 'NuanceItemCommand' => 'applications/nuance/storage/NuanceItemCommand.php', 'NuanceItemCommandQuery' => 'applications/nuance/query/NuanceItemCommandQuery.php', + 'NuanceItemCommandSpec' => 'applications/nuance/command/NuanceItemCommandSpec.php', 'NuanceItemCommandTransaction' => 'applications/nuance/xaction/NuanceItemCommandTransaction.php', 'NuanceItemController' => 'applications/nuance/controller/NuanceItemController.php', 'NuanceItemEditor' => 'applications/nuance/editor/NuanceItemEditor.php', @@ -6744,6 +6745,7 @@ phutil_register_library_map(array( 'PhabricatorPolicyInterface', ), 'NuanceItemCommandQuery' => 'NuanceQuery', + 'NuanceItemCommandSpec' => 'Phobject', 'NuanceItemCommandTransaction' => 'NuanceItemTransactionType', 'NuanceItemController' => 'NuanceController', 'NuanceItemEditor' => 'PhabricatorApplicationTransactionEditor', diff --git a/src/applications/nuance/command/NuanceItemCommandSpec.php b/src/applications/nuance/command/NuanceItemCommandSpec.php new file mode 100644 index 0000000000..d449e54833 --- /dev/null +++ b/src/applications/nuance/command/NuanceItemCommandSpec.php @@ -0,0 +1,37 @@ +commandKey = $command_key; + return $this; + } + + public function getCommandKey() { + return $this->commandKey; + } + + public function setName($name) { + $this->name = $name; + return $this; + } + + public function getName() { + return $this->name; + } + + public function setIcon($icon) { + $this->icon = $icon; + return $this; + } + + public function getIcon() { + return $this->icon; + } + +} diff --git a/src/applications/nuance/controller/NuanceQueueWorkController.php b/src/applications/nuance/controller/NuanceQueueWorkController.php index 3d6308664d..fb979c4e02 100644 --- a/src/applications/nuance/controller/NuanceQueueWorkController.php +++ b/src/applications/nuance/controller/NuanceQueueWorkController.php @@ -54,16 +54,25 @@ final class NuanceQueueWorkController $item = head($items); - $curtain = $this->buildCurtain($queue); + $curtain = $this->buildCurtain($queue, $item); $timeline = $this->buildTransactionTimeline( $item, new NuanceItemTransactionQuery()); $timeline->setShouldTerminate(true); + $impl = $item->getImplementation() + ->setViewer($viewer); + + $work_content = $impl->buildItemWorkView($item); + $view = id(new PHUITwoColumnView()) ->setCurtain($curtain) - ->setMainColumn($timeline); + ->setMainColumn( + array( + $work_content, + $timeline, + )); return $this->newPage() ->setTitle($title) @@ -71,12 +80,28 @@ final class NuanceQueueWorkController ->appendChild($view); } - private function buildCurtain(NuanceQueue $queue) { + private function buildCurtain(NuanceQueue $queue, NuanceItem $item) { $viewer = $this->getViewer(); $id = $queue->getID(); $curtain = $this->newCurtainView(); + $impl = $item->getImplementation(); + $commands = $impl->buildWorkCommands($item); + + foreach ($commands as $command) { + $command_key = $command->getCommandKey(); + + $item_id = $item->getID(); + + $curtain->addAction( + id(new PhabricatorActionView()) + ->setName($command->getName()) + ->setIcon($command->getIcon()) + ->setHref("queue/command/{$id}/{$command_key}/{$item_id}/")) + ->setWorkflow(true); + } + $curtain->addAction( id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_DIVIDER)); diff --git a/src/applications/nuance/item/NuanceFormItemType.php b/src/applications/nuance/item/NuanceFormItemType.php index ee2f923d08..401d20fd87 100644 --- a/src/applications/nuance/item/NuanceFormItemType.php +++ b/src/applications/nuance/item/NuanceFormItemType.php @@ -13,4 +13,38 @@ final class NuanceFormItemType return pht('Complaint'); } + protected function newWorkCommands(NuanceItem $item) { + return array( + $this->newCommand('trash') + ->setIcon('fa-trash') + ->setName(pht('Throw In Trash')), + ); + } + + protected function newItemView(NuanceItem $item) { + $viewer = $this->getViewer(); + + $content = $item->getItemProperty('complaint'); + $content_view = id(new PHUIRemarkupView($viewer, $content)) + ->setContextObject($item); + + $content_section = id(new PHUIPropertyListView()) + ->addTextContent( + phutil_tag( + 'div', + array( + 'class' => 'phabricator-remarkup', + ), + $content_view)); + + $content_box = id(new PHUIObjectBoxView()) + ->setHeaderText(pht('Complaint')) + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) + ->appendChild($content_section); + + return array( + $content_box, + ); + } + } diff --git a/src/applications/nuance/item/NuanceItemType.php b/src/applications/nuance/item/NuanceItemType.php index ff89108f4a..c0c78c9efa 100644 --- a/src/applications/nuance/item/NuanceItemType.php +++ b/src/applications/nuance/item/NuanceItemType.php @@ -32,6 +32,10 @@ abstract class NuanceItemType return $this->newItemView($item); } + final public function buildItemWorkView(NuanceItem $item) { + return $this->newItemView($item); + } + protected function newItemView(NuanceItem $item) { return null; } @@ -104,6 +108,10 @@ abstract class NuanceItemType return null; } + final public function buildWorkCommands(NuanceItem $item) { + return $this->newWorkCommands($item); + } + final public function applyCommand( NuanceItem $item, NuanceItemCommand $command) { @@ -159,4 +167,8 @@ abstract class NuanceItemType return id(new PhabricatorNuanceApplication())->getPHID(); } + protected function newCommand($command_key) { + return id(new NuanceItemCommandSpec()) + ->setCommandKey($command_key); + } }