mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 21:10: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' =>
|
||||
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',
|
||||
'requires' =>
|
||||
array(
|
||||
|
|
|
@ -147,8 +147,8 @@ phutil_register_library_map(array(
|
|||
'ManiphestController' => 'applications/maniphest/controller/base',
|
||||
'ManiphestDAO' => 'applications/maniphest/storage/base',
|
||||
'ManiphestTask' => 'applications/maniphest/storage/task',
|
||||
'ManiphestTaskCreateController' => 'applications/maniphest/controller/createtask',
|
||||
'ManiphestTaskDetailController' => 'applications/maniphest/controller/taskdetail',
|
||||
'ManiphestTaskEditController' => 'applications/maniphest/controller/taskedit',
|
||||
'ManiphestTaskListController' => 'applications/maniphest/controller/tasklist',
|
||||
'ManiphestTaskListView' => 'applications/maniphest/view/tasklist',
|
||||
'ManiphestTaskPriority' => 'applications/maniphest/constants/priority',
|
||||
|
@ -392,8 +392,8 @@ phutil_register_library_map(array(
|
|||
'ManiphestController' => 'PhabricatorController',
|
||||
'ManiphestDAO' => 'PhabricatorLiskDAO',
|
||||
'ManiphestTask' => 'ManiphestDAO',
|
||||
'ManiphestTaskCreateController' => 'ManiphestController',
|
||||
'ManiphestTaskDetailController' => 'ManiphestController',
|
||||
'ManiphestTaskEditController' => 'ManiphestController',
|
||||
'ManiphestTaskListController' => 'ManiphestController',
|
||||
'ManiphestTaskListView' => 'AphrontView',
|
||||
'ManiphestTaskSelectorSearchController' => 'ManiphestController',
|
||||
|
|
|
@ -144,7 +144,8 @@ class AphrontDefaultApplicationConfiguration
|
|||
'$' => 'ManiphestTaskListController',
|
||||
'view/(?P<view>\w+)/$' => 'ManiphestTaskListController',
|
||||
'task/' => array(
|
||||
'create/' => 'ManiphestTaskCreateController',
|
||||
'create/$' => 'ManiphestTaskEditController',
|
||||
'edit/(?P<id>\d+)/$' => 'ManiphestTaskEditController',
|
||||
),
|
||||
'transaction/' => array(
|
||||
'save/' => 'ManiphestTransactionSaveController',
|
||||
|
|
|
@ -26,6 +26,9 @@ final class ManiphestTransactionType {
|
|||
|
||||
const TYPE_ATTACH = 'attach';
|
||||
|
||||
const TYPE_TITLE = 'title';
|
||||
const TYPE_DESCRIPTION = 'description';
|
||||
|
||||
public static function getTransactionTypeMap() {
|
||||
return array(
|
||||
self::TYPE_NONE => 'Comment',
|
||||
|
|
|
@ -125,12 +125,12 @@ class ManiphestTaskDetailController extends ManiphestController {
|
|||
implode("\n", $table).
|
||||
'</table>';
|
||||
|
||||
|
||||
|
||||
$actions = array();
|
||||
|
||||
|
||||
$action = new AphrontHeadsupActionView();
|
||||
$action->setName('Edit Task');
|
||||
$action->setURI('/maniphest/edit/'.$task->getID().'/');
|
||||
$action->setURI('/maniphest/task/edit/'.$task->getID().'/');
|
||||
$action->setClass('action-edit');
|
||||
$actions[] = $action;
|
||||
|
||||
|
@ -143,7 +143,7 @@ class ManiphestTaskDetailController extends ManiphestController {
|
|||
$action->setName('Edit Differential Revisions');
|
||||
$action->setClass('action-attach unavailable');
|
||||
$actions[] = $action;
|
||||
|
||||
|
||||
$action_list = new AphrontHeadsupActionListView();
|
||||
$action_list->setActions($actions);
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
|||
phutil_require_module('phabricator', 'infrastructure/javelin/api');
|
||||
phutil_require_module('phabricator', 'view/form/base');
|
||||
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('phutil', 'markup');
|
||||
|
|
|
@ -16,35 +16,61 @@
|
|||
* 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() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$task = new ManiphestTask();
|
||||
|
||||
$task->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
|
||||
if ($this->id) {
|
||||
$task = id(new ManiphestTask())->load($this->id);
|
||||
if (!$task) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
} else {
|
||||
$task = new ManiphestTask();
|
||||
$task->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
|
||||
$task->setAuthorPHID($user->getPHID());
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
$e_title = true;
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$task->setTitle($request->getStr('title'));
|
||||
$task->setAuthorPHID($user->getPHID());
|
||||
$task->setDescription($request->getStr('description'));
|
||||
|
||||
$changes = array();
|
||||
|
||||
$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_phid = reset($owner_tokenizer);
|
||||
|
||||
if (!strlen($task->getTitle())) {
|
||||
if (!strlen($new_title)) {
|
||||
$e_title = 'Required';
|
||||
$errors[] = 'Title is required.';
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
$changes = array();
|
||||
|
||||
$changes[ManiphestTransactionType::TYPE_STATUS] =
|
||||
ManiphestTaskStatus::STATUS_OPEN;
|
||||
|
@ -80,9 +106,11 @@ class ManiphestTaskCreateController extends ManiphestController {
|
|||
->setURI('/T'.$task->getID());
|
||||
}
|
||||
} else {
|
||||
$task->setCCPHIDs(array(
|
||||
$user->getPHID(),
|
||||
));
|
||||
if (!$task->getID()) {
|
||||
$task->setCCPHIDs(array(
|
||||
$user->getPHID(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$phids = array_merge(
|
||||
|
@ -119,6 +147,16 @@ class ManiphestTaskCreateController extends ManiphestController {
|
|||
$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
|
||||
->setUser($user)
|
||||
|
@ -155,11 +193,12 @@ class ManiphestTaskCreateController extends ManiphestController {
|
|||
->setValue($task->getDescription()))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue('Create Task'));
|
||||
->addCancelButton($cancel_uri)
|
||||
->setValue($button_name));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
||||
$panel->setHeader('Create New Task');
|
||||
$panel->setHeader($header_name);
|
||||
$panel->appendChild($form);
|
||||
|
||||
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', 'applications/maniphest/constants/priority');
|
||||
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_source('ManiphestTaskCreateController.php');
|
||||
phutil_require_source('ManiphestTaskEditController.php');
|
|
@ -49,6 +49,12 @@ class ManiphestTransactionEditor {
|
|||
case ManiphestTransactionType::TYPE_ATTACH:
|
||||
$old = $task->getAttached();
|
||||
break;
|
||||
case ManiphestTransactionType::TYPE_TITLE:
|
||||
$old = $task->getTitle();
|
||||
break;
|
||||
case ManiphestTransactionType::TYPE_DESCRIPTION:
|
||||
$old = $task->getDescription();
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Unknown action type.');
|
||||
}
|
||||
|
@ -84,6 +90,12 @@ class ManiphestTransactionEditor {
|
|||
case ManiphestTransactionType::TYPE_ATTACH:
|
||||
$task->setAttached($new);
|
||||
break;
|
||||
case ManiphestTransactionType::TYPE_TITLE:
|
||||
$task->setTitle($new);
|
||||
break;
|
||||
case ManiphestTransactionType::TYPE_DESCRIPTION:
|
||||
$task->setDescription($new);
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Unknown action type.');
|
||||
}
|
||||
|
|
|
@ -149,6 +149,16 @@ class ManiphestTransactionDetailView extends AphrontView {
|
|||
$new = $transaction->getNewValue();
|
||||
$old = $transaction->getOldValue();
|
||||
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:
|
||||
$verb = 'Commented On';
|
||||
$desc = 'added a comment';
|
||||
|
@ -279,4 +289,12 @@ class ManiphestTransactionDetailView extends AphrontView {
|
|||
return implode(', ', $links);
|
||||
}
|
||||
|
||||
private function renderString($string) {
|
||||
if ($this->forEmail) {
|
||||
return '"'.$string.'"';
|
||||
} else {
|
||||
return '"'.phutil_escape_html($string).'"';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue