mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Enable task editing in Maniphest.
Summary: Test Plan: Reviewers: CC:
This commit is contained in:
parent
bec2a1230c
commit
fd1318bf4c
10 changed files with 99 additions and 23 deletions
|
@ -45,7 +45,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'aphront-headsup-action-list-view-css' =>
|
'aphront-headsup-action-list-view-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/099b7588/rsrc/css/aphront/headsup-action-list-view.css',
|
'uri' => '/res/8fd91c1d/rsrc/css/aphront/headsup-action-list-view.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -147,8 +147,8 @@ phutil_register_library_map(array(
|
||||||
'ManiphestController' => 'applications/maniphest/controller/base',
|
'ManiphestController' => 'applications/maniphest/controller/base',
|
||||||
'ManiphestDAO' => 'applications/maniphest/storage/base',
|
'ManiphestDAO' => 'applications/maniphest/storage/base',
|
||||||
'ManiphestTask' => 'applications/maniphest/storage/task',
|
'ManiphestTask' => 'applications/maniphest/storage/task',
|
||||||
'ManiphestTaskCreateController' => 'applications/maniphest/controller/createtask',
|
|
||||||
'ManiphestTaskDetailController' => 'applications/maniphest/controller/taskdetail',
|
'ManiphestTaskDetailController' => 'applications/maniphest/controller/taskdetail',
|
||||||
|
'ManiphestTaskEditController' => 'applications/maniphest/controller/taskedit',
|
||||||
'ManiphestTaskListController' => 'applications/maniphest/controller/tasklist',
|
'ManiphestTaskListController' => 'applications/maniphest/controller/tasklist',
|
||||||
'ManiphestTaskListView' => 'applications/maniphest/view/tasklist',
|
'ManiphestTaskListView' => 'applications/maniphest/view/tasklist',
|
||||||
'ManiphestTaskPriority' => 'applications/maniphest/constants/priority',
|
'ManiphestTaskPriority' => 'applications/maniphest/constants/priority',
|
||||||
|
@ -392,8 +392,8 @@ phutil_register_library_map(array(
|
||||||
'ManiphestController' => 'PhabricatorController',
|
'ManiphestController' => 'PhabricatorController',
|
||||||
'ManiphestDAO' => 'PhabricatorLiskDAO',
|
'ManiphestDAO' => 'PhabricatorLiskDAO',
|
||||||
'ManiphestTask' => 'ManiphestDAO',
|
'ManiphestTask' => 'ManiphestDAO',
|
||||||
'ManiphestTaskCreateController' => 'ManiphestController',
|
|
||||||
'ManiphestTaskDetailController' => 'ManiphestController',
|
'ManiphestTaskDetailController' => 'ManiphestController',
|
||||||
|
'ManiphestTaskEditController' => 'ManiphestController',
|
||||||
'ManiphestTaskListController' => 'ManiphestController',
|
'ManiphestTaskListController' => 'ManiphestController',
|
||||||
'ManiphestTaskListView' => 'AphrontView',
|
'ManiphestTaskListView' => 'AphrontView',
|
||||||
'ManiphestTaskSelectorSearchController' => 'ManiphestController',
|
'ManiphestTaskSelectorSearchController' => 'ManiphestController',
|
||||||
|
|
|
@ -144,7 +144,8 @@ class AphrontDefaultApplicationConfiguration
|
||||||
'$' => 'ManiphestTaskListController',
|
'$' => 'ManiphestTaskListController',
|
||||||
'view/(?P<view>\w+)/$' => 'ManiphestTaskListController',
|
'view/(?P<view>\w+)/$' => 'ManiphestTaskListController',
|
||||||
'task/' => array(
|
'task/' => array(
|
||||||
'create/' => 'ManiphestTaskCreateController',
|
'create/$' => 'ManiphestTaskEditController',
|
||||||
|
'edit/(?P<id>\d+)/$' => 'ManiphestTaskEditController',
|
||||||
),
|
),
|
||||||
'transaction/' => array(
|
'transaction/' => array(
|
||||||
'save/' => 'ManiphestTransactionSaveController',
|
'save/' => 'ManiphestTransactionSaveController',
|
||||||
|
|
|
@ -26,6 +26,9 @@ final class ManiphestTransactionType {
|
||||||
|
|
||||||
const TYPE_ATTACH = 'attach';
|
const TYPE_ATTACH = 'attach';
|
||||||
|
|
||||||
|
const TYPE_TITLE = 'title';
|
||||||
|
const TYPE_DESCRIPTION = 'description';
|
||||||
|
|
||||||
public static function getTransactionTypeMap() {
|
public static function getTransactionTypeMap() {
|
||||||
return array(
|
return array(
|
||||||
self::TYPE_NONE => 'Comment',
|
self::TYPE_NONE => 'Comment',
|
||||||
|
|
|
@ -130,7 +130,7 @@ class ManiphestTaskDetailController extends ManiphestController {
|
||||||
|
|
||||||
$action = new AphrontHeadsupActionView();
|
$action = new AphrontHeadsupActionView();
|
||||||
$action->setName('Edit Task');
|
$action->setName('Edit Task');
|
||||||
$action->setURI('/maniphest/edit/'.$task->getID().'/');
|
$action->setURI('/maniphest/task/edit/'.$task->getID().'/');
|
||||||
$action->setClass('action-edit');
|
$action->setClass('action-edit');
|
||||||
$actions[] = $action;
|
$actions[] = $action;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||||
phutil_require_module('phabricator', 'infrastructure/javelin/api');
|
phutil_require_module('phabricator', 'infrastructure/javelin/api');
|
||||||
phutil_require_module('phabricator', 'view/form/base');
|
phutil_require_module('phabricator', 'view/form/base');
|
||||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||||
|
phutil_require_module('phabricator', 'view/layout/headsup/action');
|
||||||
|
phutil_require_module('phabricator', 'view/layout/headsup/actionlist');
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
|
@ -16,35 +16,61 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ManiphestTaskCreateController extends ManiphestController {
|
class ManiphestTaskEditController extends ManiphestController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = idx($data, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
|
||||||
$task = new ManiphestTask();
|
if ($this->id) {
|
||||||
|
$task = id(new ManiphestTask())->load($this->id);
|
||||||
$task->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
|
if (!$task) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$task = new ManiphestTask();
|
||||||
|
$task->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
|
||||||
|
$task->setAuthorPHID($user->getPHID());
|
||||||
|
}
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$e_title = true;
|
$e_title = true;
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$task->setTitle($request->getStr('title'));
|
|
||||||
$task->setAuthorPHID($user->getPHID());
|
$changes = array();
|
||||||
$task->setDescription($request->getStr('description'));
|
|
||||||
|
$new_title = $request->getStr('title');
|
||||||
|
$new_desc = $request->getStr('description');
|
||||||
|
|
||||||
|
if ($task->getID()) {
|
||||||
|
if ($new_title != $task->getTitle()) {
|
||||||
|
$changes[ManiphestTransactionType::TYPE_TITLE] = $new_title;
|
||||||
|
}
|
||||||
|
if ($new_desc != $task->getDescription()) {
|
||||||
|
$changes[ManiphestTransactionType::TYPE_DESCRIPTION] = $new_desc;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$task->setTitle($new_title);
|
||||||
|
$task->setDescription($new_desc);
|
||||||
|
}
|
||||||
|
|
||||||
$owner_tokenizer = $request->getArr('assigned_to');
|
$owner_tokenizer = $request->getArr('assigned_to');
|
||||||
$owner_phid = reset($owner_tokenizer);
|
$owner_phid = reset($owner_tokenizer);
|
||||||
|
|
||||||
if (!strlen($task->getTitle())) {
|
if (!strlen($new_title)) {
|
||||||
$e_title = 'Required';
|
$e_title = 'Required';
|
||||||
$errors[] = 'Title is required.';
|
$errors[] = 'Title is required.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$errors) {
|
if (!$errors) {
|
||||||
$changes = array();
|
|
||||||
|
|
||||||
$changes[ManiphestTransactionType::TYPE_STATUS] =
|
$changes[ManiphestTransactionType::TYPE_STATUS] =
|
||||||
ManiphestTaskStatus::STATUS_OPEN;
|
ManiphestTaskStatus::STATUS_OPEN;
|
||||||
|
@ -80,9 +106,11 @@ class ManiphestTaskCreateController extends ManiphestController {
|
||||||
->setURI('/T'.$task->getID());
|
->setURI('/T'.$task->getID());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$task->setCCPHIDs(array(
|
if (!$task->getID()) {
|
||||||
$user->getPHID(),
|
$task->setCCPHIDs(array(
|
||||||
));
|
$user->getPHID(),
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$phids = array_merge(
|
$phids = array_merge(
|
||||||
|
@ -119,6 +147,16 @@ class ManiphestTaskCreateController extends ManiphestController {
|
||||||
$cc_value = array();
|
$cc_value = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($task->getID()) {
|
||||||
|
$cancel_uri = '/T'.$task->getID();
|
||||||
|
$button_name = 'Save Task';
|
||||||
|
$header_name = 'Edit Task';
|
||||||
|
} else {
|
||||||
|
$cancel_uri = '/maniphest/';
|
||||||
|
$button_name = 'Create Task';
|
||||||
|
$header_name = 'Create New Task';
|
||||||
|
}
|
||||||
|
|
||||||
$form = new AphrontFormView();
|
$form = new AphrontFormView();
|
||||||
$form
|
$form
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
@ -155,11 +193,12 @@ class ManiphestTaskCreateController extends ManiphestController {
|
||||||
->setValue($task->getDescription()))
|
->setValue($task->getDescription()))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->setValue('Create Task'));
|
->addCancelButton($cancel_uri)
|
||||||
|
->setValue($button_name));
|
||||||
|
|
||||||
$panel = new AphrontPanelView();
|
$panel = new AphrontPanelView();
|
||||||
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
||||||
$panel->setHeader('Create New Task');
|
$panel->setHeader($header_name);
|
||||||
$panel->appendChild($form);
|
$panel->appendChild($form);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/404');
|
||||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||||
phutil_require_module('phabricator', 'applications/maniphest/constants/priority');
|
phutil_require_module('phabricator', 'applications/maniphest/constants/priority');
|
||||||
phutil_require_module('phabricator', 'applications/maniphest/constants/status');
|
phutil_require_module('phabricator', 'applications/maniphest/constants/status');
|
||||||
|
@ -23,4 +24,4 @@ phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('ManiphestTaskCreateController.php');
|
phutil_require_source('ManiphestTaskEditController.php');
|
|
@ -49,6 +49,12 @@ class ManiphestTransactionEditor {
|
||||||
case ManiphestTransactionType::TYPE_ATTACH:
|
case ManiphestTransactionType::TYPE_ATTACH:
|
||||||
$old = $task->getAttached();
|
$old = $task->getAttached();
|
||||||
break;
|
break;
|
||||||
|
case ManiphestTransactionType::TYPE_TITLE:
|
||||||
|
$old = $task->getTitle();
|
||||||
|
break;
|
||||||
|
case ManiphestTransactionType::TYPE_DESCRIPTION:
|
||||||
|
$old = $task->getDescription();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception('Unknown action type.');
|
throw new Exception('Unknown action type.');
|
||||||
}
|
}
|
||||||
|
@ -84,6 +90,12 @@ class ManiphestTransactionEditor {
|
||||||
case ManiphestTransactionType::TYPE_ATTACH:
|
case ManiphestTransactionType::TYPE_ATTACH:
|
||||||
$task->setAttached($new);
|
$task->setAttached($new);
|
||||||
break;
|
break;
|
||||||
|
case ManiphestTransactionType::TYPE_TITLE:
|
||||||
|
$task->setTitle($new);
|
||||||
|
break;
|
||||||
|
case ManiphestTransactionType::TYPE_DESCRIPTION:
|
||||||
|
$task->setDescription($new);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception('Unknown action type.');
|
throw new Exception('Unknown action type.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,16 @@ class ManiphestTransactionDetailView extends AphrontView {
|
||||||
$new = $transaction->getNewValue();
|
$new = $transaction->getNewValue();
|
||||||
$old = $transaction->getOldValue();
|
$old = $transaction->getOldValue();
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
|
case ManiphestTransactionType::TYPE_TITLE:
|
||||||
|
$verb = 'Retitled';
|
||||||
|
$desc = 'changed the title from '.$this->renderString($old).
|
||||||
|
' to '.$this->renderString($new);
|
||||||
|
break;
|
||||||
|
case ManiphestTransactionType::TYPE_DESCRIPTION:
|
||||||
|
// TODO: show the changes somehow.
|
||||||
|
$verb = 'Edited';
|
||||||
|
$desc = 'updated the task description';
|
||||||
|
break;
|
||||||
case ManiphestTransactionType::TYPE_NONE:
|
case ManiphestTransactionType::TYPE_NONE:
|
||||||
$verb = 'Commented On';
|
$verb = 'Commented On';
|
||||||
$desc = 'added a comment';
|
$desc = 'added a comment';
|
||||||
|
@ -279,4 +289,12 @@ class ManiphestTransactionDetailView extends AphrontView {
|
||||||
return implode(', ', $links);
|
return implode(', ', $links);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function renderString($string) {
|
||||||
|
if ($this->forEmail) {
|
||||||
|
return '"'.$string.'"';
|
||||||
|
} else {
|
||||||
|
return '"'.phutil_escape_html($string).'"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue