diff --git a/src/applications/maniphest/controller/ManiphestController.php b/src/applications/maniphest/controller/ManiphestController.php --- a/src/applications/maniphest/controller/ManiphestController.php +++ b/src/applications/maniphest/controller/ManiphestController.php @@ -37,7 +37,7 @@ return $crumbs; } - protected function renderSingleTask(ManiphestTask $task) { + public function renderSingleTask(ManiphestTask $task) { $request = $this->getRequest(); $user = $request->getUser(); diff --git a/src/applications/maniphest/controller/ManiphestTaskEditProController.php b/src/applications/maniphest/controller/ManiphestTaskEditProController.php --- a/src/applications/maniphest/controller/ManiphestTaskEditProController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditProController.php @@ -5,6 +5,7 @@ public function handleRequest(AphrontRequest $request) { return id(new ManiphestEditEngine()) ->setController($this) + ->addContextParameter('ungrippable') ->buildResponse(); } diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php --- a/src/applications/maniphest/editor/ManiphestEditEngine.php +++ b/src/applications/maniphest/editor/ManiphestEditEngine.php @@ -83,16 +83,6 @@ ->setTransactionType(ManiphestTransaction::TYPE_TITLE) ->setIsRequired(true) ->setValue($object->getTitle()), - id(new PhabricatorSelectEditField()) - ->setKey('status') - ->setLabel(pht('Status')) - ->setDescription(pht('Status of the task.')) - ->setTransactionType(ManiphestTransaction::TYPE_STATUS) - ->setIsCopyable(true) - ->setValue($object->getStatus()) - ->setOptions($status_map) - ->setCommentActionLabel(pht('Change Status')) - ->setCommentActionDefaultValue($default_status), id(new PhabricatorUsersEditField()) ->setKey('owner') ->setAliases(array('ownerPHID', 'assign', 'assigned')) @@ -104,6 +94,16 @@ ->setCommentActionLabel(pht('Assign / Claim')) ->setCommentActionDefaultValue($owner_value), id(new PhabricatorSelectEditField()) + ->setKey('status') + ->setLabel(pht('Status')) + ->setDescription(pht('Status of the task.')) + ->setTransactionType(ManiphestTransaction::TYPE_STATUS) + ->setIsCopyable(true) + ->setValue($object->getStatus()) + ->setOptions($status_map) + ->setCommentActionLabel(pht('Change Status')) + ->setCommentActionDefaultValue($default_status), + id(new PhabricatorSelectEditField()) ->setKey('priority') ->setLabel(pht('Priority')) ->setDescription(pht('Priority of the task.')) @@ -189,4 +189,32 @@ return $priority_map; } + protected function newEditResponse( + AphrontRequest $request, + $object, + array $xactions) { + $viewer = $this->getViewer(); + $controller = $this->getController(); + + if ($request->isAjax()) { + + // Reload the task to make sure we pick up the final task state. + $task = id(new ManiphestTaskQuery()) + ->setViewer($viewer) + ->withIDs(array($object->getID())) + ->needSubscriberPHIDs(true) + ->needProjectPHIDs(true) + ->executeOne(); + + $payload = array( + 'tasks' => $controller->renderSingleTask($task), + 'data' => array(), + ); + + return id(new AphrontAjaxResponse())->setContent($payload); + } + + return parent::newEditResponse(); + } + } diff --git a/src/applications/maniphest/view/ManiphestTaskListView.php b/src/applications/maniphest/view/ManiphestTaskListView.php --- a/src/applications/maniphest/view/ManiphestTaskListView.php +++ b/src/applications/maniphest/view/ManiphestTaskListView.php @@ -111,7 +111,7 @@ )); if ($this->showBatchControls) { - $href = new PhutilURI('/maniphest/task/edit/'.$task->getID().'/'); + $href = new PhutilURI('/maniphest/editpro/'.$task->getID().'/'); if (!$this->showSubpriorityControls) { $href->setQueryParam('ungrippable', 'true'); } diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php --- a/src/applications/transactions/editengine/PhabricatorEditEngine.php +++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php @@ -22,6 +22,7 @@ private $controller; private $isCreate; private $editEngineConfiguration; + private $contextParameters = array(); final public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; @@ -51,6 +52,11 @@ return PhabricatorApplication::getByClass($app_class); } + final public function addContextParameter($key) { + $this->contextParameters[] = $key; + return $this; + } + /* -( Managing Fields )---------------------------------------------------- */ @@ -879,12 +885,32 @@ $header_text = $this->getObjectEditTitleText($object); } + $form = $this->buildEditForm($object, $fields); + + if ($request->isAjax()) { + if ($this->getIsCreate()) { + $cancel_uri = $this->getObjectCreateCancelURI($object); + $submit_button = $this->getObjectCreateButtonText($object); + } else { + $cancel_uri = $this->getObjectEditCancelURI($object); + $submit_button = $this->getObjectEditButtonText($object); + } + + return $this->getController() + ->newDialog() + ->setWidth(AphrontDialogView::WIDTH_FULL) + ->setTitle($header_text) + ->setValidationException($validation_exception) + ->appendForm($form) + ->addCancelButton($cancel_uri) + ->addSubmitButton($submit_button); + } + $header = id(new PHUIHeaderView()) ->setHeader($header_text) ->addActionLink($action_button); $crumbs = $this->buildCrumbs($object, $final = true); - $form = $this->buildEditForm($object, $fields); $box = id(new PHUIObjectBoxView()) ->setUser($viewer) @@ -908,10 +934,16 @@ private function buildEditForm($object, array $fields) { $viewer = $this->getViewer(); + $controller = $this->getController(); + $request = $controller->getRequest(); $form = id(new AphrontFormView()) ->setUser($viewer); + foreach ($this->contextParameters as $param) { + $form->addHiddenInput($param, $request->getStr($param)); + } + foreach ($fields as $field) { $field->appendToForm($form); } @@ -924,10 +956,12 @@ $submit_button = $this->getObjectEditButtonText($object); } - $form->appendControl( - id(new AphrontFormSubmitControl()) - ->addCancelButton($cancel_uri) - ->setValue($submit_button)); + if (!$request->isAjax()) { + $form->appendControl( + id(new AphrontFormSubmitControl()) + ->addCancelButton($cancel_uri) + ->setValue($submit_button)); + } return $form; }