Differential D19853 Diff 47434 src/applications/maniphest/controller/ManiphestTaskDetailController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/controller/ManiphestTaskDetailController.php
Show First 20 Lines • Show All 275 Lines • ▼ Show 20 Lines | private function buildCurtain( | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setName(pht('Edit Task')) | ->setName(pht('Edit Task')) | ||||
->setIcon('fa-pencil') | ->setIcon('fa-pencil') | ||||
->setHref($this->getApplicationURI("/task/edit/{$id}/")) | ->setHref($this->getApplicationURI("/task/edit/{$id}/")) | ||||
->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
->setWorkflow($workflow_edit)); | ->setWorkflow($workflow_edit)); | ||||
$edit_config = $edit_engine->loadDefaultEditConfiguration($task); | $subtype_map = $task->newEditEngineSubtypeMap(); | ||||
$can_create = (bool)$edit_config; | $subtask_options = $subtype_map->getCreateFormsForSubtype( | ||||
$edit_engine, | |||||
$task); | |||||
if ($can_create) { | // If no forms are available, we want to show the user an error. | ||||
$form_key = $edit_config->getIdentifier(); | // If one form is available, we take them user directly to the form. | ||||
$edit_uri = id(new PhutilURI("/task/edit/form/{$form_key}/")) | // If two or more forms are available, we give the user a choice. | ||||
// The "subtask" controller handles the first case (no forms) and the | |||||
// third case (more than one form). In the case of one form, we link | |||||
// directly to the form. | |||||
$subtask_uri = "/task/subtask/{$id}/"; | |||||
$subtask_workflow = true; | |||||
if (count($subtask_options) == 1) { | |||||
$subtask_form = head($subtask_options); | |||||
$form_key = $subtask_form->getIdentifier(); | |||||
$subtask_uri = id(new PhutilURI("/task/edit/form/{$form_key}/")) | |||||
->setQueryParam('parent', $id) | ->setQueryParam('parent', $id) | ||||
->setQueryParam('template', $id) | ->setQueryParam('template', $id) | ||||
->setQueryParam('status', ManiphestTaskStatus::getDefaultStatus()); | ->setQueryParam('status', ManiphestTaskStatus::getDefaultStatus()); | ||||
$edit_uri = $this->getApplicationURI($edit_uri); | $subtask_workflow = false; | ||||
} else { | |||||
// TODO: This will usually give us a somewhat-reasonable error page, but | |||||
// could be a bit cleaner. | |||||
$edit_uri = "/task/edit/{$id}/"; | |||||
$edit_uri = $this->getApplicationURI($edit_uri); | |||||
} | } | ||||
$subtask_uri = $this->getApplicationURI($subtask_uri); | |||||
$subtask_item = id(new PhabricatorActionView()) | $subtask_item = id(new PhabricatorActionView()) | ||||
->setName(pht('Create Subtask')) | ->setName(pht('Create Subtask')) | ||||
->setHref($edit_uri) | ->setHref($subtask_uri) | ||||
->setIcon('fa-level-down') | ->setIcon('fa-level-down') | ||||
->setDisabled(!$can_create) | ->setDisabled(!$subtask_options) | ||||
->setWorkflow(!$can_create); | ->setWorkflow($subtask_workflow); | ||||
$relationship_list = PhabricatorObjectRelationshipList::newForObject( | $relationship_list = PhabricatorObjectRelationshipList::newForObject( | ||||
$viewer, | $viewer, | ||||
$task); | $task); | ||||
$submenu_actions = array( | $submenu_actions = array( | ||||
$subtask_item, | $subtask_item, | ||||
ManiphestTaskHasParentRelationship::RELATIONSHIPKEY, | ManiphestTaskHasParentRelationship::RELATIONSHIPKEY, | ||||
▲ Show 20 Lines • Show All 281 Lines • Show Last 20 Lines |