From 218856e8b8073390c1740acb905c6d71bed58630 Mon Sep 17 00:00:00 2001 From: hunterbridges Date: Tue, 26 Jul 2011 12:39:36 -0500 Subject: [PATCH] Modified create workflow to support rapid templated task creation, made Task Edit repopulate user input array fields on error Reviewers: epriestley Test Plan: Create a new task in Maniphest, then click "Create Another Task Like This" Differential Revision: 734 --- .../ManiphestTaskDetailController.php | 14 ++++++++ .../taskedit/ManiphestTaskEditController.php | 34 ++++++++++++++++--- .../css/application/maniphest/task-detail.css | 6 +++- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php index f350929f2b..a4b1b64146 100644 --- a/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php @@ -163,6 +163,19 @@ class ManiphestTaskDetailController extends ManiphestController { implode("\n", $table). ''; + $create_new_button = ''; + if ($request->getStr('workflow') == 'create') { + $create_new_button = + '
'. + phutil_render_tag( + 'a', + array( + 'href' => '/maniphest/task/create/?template='.$task->getID(), + 'class' => 'green button', + ), + 'Create New Task'). + '
'; + } $actions = array(); @@ -196,6 +209,7 @@ class ManiphestTaskDetailController extends ManiphestController { '
'. $action_list->render(). '
'. + $create_new_button. '

'. ''. phutil_escape_html('T'.$task->getID()). diff --git a/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php b/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php index 5d4aaf5357..b4996f0a06 100644 --- a/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php @@ -78,6 +78,8 @@ class ManiphestTaskEditController extends ManiphestController { $new_desc = $request->getStr('description'); $new_status = $request->getStr('status'); + $workflow = ''; + if ($task->getID()) { if ($new_title != $task->getTitle()) { $changes[ManiphestTransactionType::TYPE_TITLE] = $new_title; @@ -93,6 +95,8 @@ class ManiphestTaskEditController extends ManiphestController { $task->setDescription($new_desc); $changes[ManiphestTransactionType::TYPE_STATUS] = ManiphestTaskStatus::STATUS_OPEN; + + $workflow = 'create'; } $owner_tokenizer = $request->getArr('assigned_to'); @@ -103,9 +107,12 @@ class ManiphestTaskEditController extends ManiphestController { $errors[] = 'Title is required.'; } - if (!$errors) { - - + if ($errors) { + $task->setPriority($request->getInt('priority')); + $task->setOwnerPHID($owner_phid); + $task->setCCPHIDs($request->getArr('cc')); + $task->setProjectPHIDs($request->getArr('projects')); + } else { if ($request->getInt('priority') != $task->getPriority()) { $changes[ManiphestTransactionType::TYPE_PRIORITY] = $request->getInt('priority'); @@ -155,8 +162,14 @@ class ManiphestTaskEditController extends ManiphestController { $editor->applyTransactions($task, $transactions); } + $redirect_uri = '/T'.$task->getID(); + + if ($workflow) { + $redirect_uri .= '?workflow='.$workflow; + } + return id(new AphrontRedirectResponse()) - ->setURI('/T'.$task->getID()); + ->setURI($redirect_uri); } } else { if (!$task->getID()) { @@ -166,10 +179,23 @@ class ManiphestTaskEditController extends ManiphestController { } } + $template_task = null; + $template_id = $request->getStr('template'); + if ($template_id && !$request->isFormPost()) { + $template_task = id(new ManiphestTask())->load($template_id); + } + + if (!$task->getID() && $template_task) { + $task->setCCPHIDs($template_task->getCCPHIDs()); + $task->setProjectPHIDs($template_task->getProjectPHIDs()); + $task->setOwnerPHID($template_task->getOwnerPHID()); + } + $phids = array_merge( array($task->getOwnerPHID()), $task->getCCPHIDs(), $task->getProjectPHIDs()); + $phids = array_filter($phids); $phids = array_unique($phids); diff --git a/webroot/rsrc/css/application/maniphest/task-detail.css b/webroot/rsrc/css/application/maniphest/task-detail.css index 602840d9e6..a932e54b4d 100644 --- a/webroot/rsrc/css/application/maniphest/task-detail.css +++ b/webroot/rsrc/css/application/maniphest/task-detail.css @@ -16,7 +16,6 @@ margin-bottom: 8px; } - .maniphest-task-properties { font-size: 12px; width: 100%; @@ -42,3 +41,8 @@ .maniphest-task-detail-core { margin-right: 265px; } + +.maniphest-task-detail-core .create-button-container { + float:right; + margin-top:-0.5em; +}