1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-21 19:19:12 +01:00

Move inline edit from task lists to EditEngine

Summary: Ref T9908. Fixes T8903. This moves the inline edit from task lists (but not from workboards) over to editengine.

Test Plan:
  - Edited a task from a draggable list.
  - Edited a task from an undraggable list.
  - Edited a task, changed projects, saw refresh show correct projects.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8903, T9908

Differential Revision: https://secure.phabricator.com/D14711
This commit is contained in:
epriestley 2015-12-08 14:29:53 -08:00
parent d3452967e0
commit 21be67e87a
5 changed files with 80 additions and 17 deletions

View file

@ -37,7 +37,7 @@ abstract class ManiphestController extends PhabricatorController {
return $crumbs;
}
protected function renderSingleTask(ManiphestTask $task) {
public function renderSingleTask(ManiphestTask $task) {
$request = $this->getRequest();
$user = $request->getUser();

View file

@ -5,6 +5,7 @@ final class ManiphestTaskEditProController extends ManiphestController {
public function handleRequest(AphrontRequest $request) {
return id(new ManiphestEditEngine())
->setController($this)
->addContextParameter('ungrippable')
->buildResponse();
}

View file

@ -83,16 +83,6 @@ final class ManiphestEditEngine
->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'))
@ -103,6 +93,16 @@ final class ManiphestEditEngine
->setSingleValue($object->getOwnerPHID())
->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'))
@ -189,4 +189,32 @@ final class ManiphestEditEngine
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();
}
}

View file

@ -111,7 +111,7 @@ final class ManiphestTaskListView extends ManiphestView {
));
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');
}

View file

@ -22,6 +22,7 @@ abstract class PhabricatorEditEngine
private $controller;
private $isCreate;
private $editEngineConfiguration;
private $contextParameters = array();
final public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
@ -51,6 +52,11 @@ abstract class PhabricatorEditEngine
return PhabricatorApplication::getByClass($app_class);
}
final public function addContextParameter($key) {
$this->contextParameters[] = $key;
return $this;
}
/* -( Managing Fields )---------------------------------------------------- */
@ -879,12 +885,32 @@ abstract class PhabricatorEditEngine
$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 @@ abstract class PhabricatorEditEngine
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 @@ abstract class PhabricatorEditEngine
$submit_button = $this->getObjectEditButtonText($object);
}
if (!$request->isAjax()) {
$form->appendControl(
id(new AphrontFormSubmitControl())
->addCancelButton($cancel_uri)
->setValue($submit_button));
}
return $form;
}