From 3ceb3d340b2f3ea2918485ebb3fbb528d6bbf393 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 1 Aug 2011 13:51:27 -0700 Subject: [PATCH] Use active project filter as default field value when creating new tasks Summary: See T389. If you're looking at tasks in project X, default new tasks into project X. Test Plan: - Created a new task without associated projects. - Created a new task from a filter view with 1 and 2 projects; defaults were filled in. - Submitted task with invalid title, projects were correctly preserved. Reviewed By: skrul Reviewers: skrul, hunterbridges, jungejason, tuomaspelkonen, aran CC: aran, skrul, epriestley Differential Revision: 757 --- .../controller/taskedit/ManiphestTaskEditController.php | 5 +++++ .../controller/tasklist/ManiphestTaskListController.php | 9 ++++++++- .../maniphest/controller/tasklist/__init__.php | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php b/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php index b4996f0a06..9e35a4a307 100644 --- a/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php @@ -47,6 +47,11 @@ class ManiphestTaskEditController extends ManiphestController { // These allow task creation with defaults. if (!$request->isFormPost()) { $task->setTitle($request->getStr('title')); + + $default_projects = $request->getStr('projects'); + if ($default_projects) { + $task->setProjectPHIDs(explode(';', $default_projects)); + } } $file_phids = $request->getArr('files', array()); diff --git a/src/applications/maniphest/controller/tasklist/ManiphestTaskListController.php b/src/applications/maniphest/controller/tasklist/ManiphestTaskListController.php index 7303c65dd2..23f048fcb5 100644 --- a/src/applications/maniphest/controller/tasklist/ManiphestTaskListController.php +++ b/src/applications/maniphest/controller/tasklist/ManiphestTaskListController.php @@ -176,12 +176,19 @@ class ManiphestTaskListController extends ManiphestController { id(new AphrontFormSubmitControl()) ->setValue('Filter Tasks')); + $create_uri = new PhutilURI('/maniphest/task/create/'); + if ($project_phids) { + // If we have project filters selected, use them as defaults for task + // creation. + $create_uri->setQueryParam('projects', implode(';', $project_phids)); + } + $filter = new AphrontListFilterView(); $filter->addButton( phutil_render_tag( 'a', array( - 'href' => '/maniphest/task/create/', + 'href' => (string)$create_uri, 'class' => 'green button', ), 'Create New Task')); diff --git a/src/applications/maniphest/controller/tasklist/__init__.php b/src/applications/maniphest/controller/tasklist/__init__.php index 28c7ec5a4c..87bd5495f9 100644 --- a/src/applications/maniphest/controller/tasklist/__init__.php +++ b/src/applications/maniphest/controller/tasklist/__init__.php @@ -23,6 +23,7 @@ phutil_require_module('phabricator', 'view/layout/listfilter'); phutil_require_module('phabricator', 'view/layout/sidenav'); phutil_require_module('phutil', 'markup'); +phutil_require_module('phutil', 'parser/uri'); phutil_require_module('phutil', 'utils');