@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Enable prefilling of projects and priority fields in Maniphest task creation

Summary:
Projects and priority inputs can be prefilled similar to how title
and description fields work.

Prefilling of projects already worked but used PHIDs instead of
more user friendly name so I changed that too.

Test Plan:
Visit [[/maniphest/task/create/?projects=Maniphest;Easy&priority=100&assign=vrana&title=Hip-hip&description=hooray!|example]]
and see prefilled form fields.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7394

authored by

Erik Fercak and committed by
epriestley
1fb2f39f 6a169de9

+56 -3
+43 -3
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 49 49 $task->setTitle($request->getStr('title')); 50 50 51 51 if ($can_edit_projects) { 52 - $default_projects = $request->getStr('projects'); 53 - if ($default_projects) { 54 - $task->setProjectPHIDs(explode(';', $default_projects)); 52 + $projects = $request->getStr('projects'); 53 + if ($projects) { 54 + $tokens = explode(';', $projects); 55 + 56 + $slug_map = id(new PhabricatorProjectQuery()) 57 + ->setViewer($user) 58 + ->withPhrictionSlugs($tokens) 59 + ->execute(); 60 + 61 + $name_map = id(new PhabricatorProjectQuery()) 62 + ->setViewer($user) 63 + ->withNames($tokens) 64 + ->execute(); 65 + 66 + $phid_map = id(new PhabricatorProjectQuery()) 67 + ->setViewer($user) 68 + ->withPHIDs($tokens) 69 + ->execute(); 70 + 71 + $all_map = mpull($slug_map, null, 'getPhrictionSlug') + 72 + mpull($name_map, null, 'getName') + 73 + mpull($phid_map, null, 'getPHID'); 74 + 75 + $default_projects = array(); 76 + foreach ($tokens as $token) { 77 + if (isset($all_map[$token])) { 78 + $default_projects[] = $all_map[$token]->getPHID(); 79 + } 80 + } 81 + 82 + if ($default_projects) { 83 + $task->setProjectPHIDs($default_projects); 84 + } 85 + } 86 + } 87 + 88 + if ($can_edit_priority) { 89 + $priority = $request->getInt('priority'); 90 + if ($priority !== null) { 91 + $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); 92 + if (isset($priority_map[$priority])) { 93 + $task->setPriority($priority); 94 + } 55 95 } 56 96 } 57 97
+13
src/applications/project/query/PhabricatorProjectQuery.php
··· 7 7 private $phids; 8 8 private $memberPHIDs; 9 9 private $slugs; 10 + private $names; 10 11 11 12 private $status = 'status-any'; 12 13 const STATUS_ANY = 'status-any'; ··· 40 41 41 42 public function withPhrictionSlugs(array $slugs) { 42 43 $this->slugs = $slugs; 44 + return $this; 45 + } 46 + 47 + public function withNames(array $names) { 48 + $this->names = $names; 43 49 return $this; 44 50 } 45 51 ··· 222 228 $conn_r, 223 229 'phrictionSlug IN (%Ls)', 224 230 $this->slugs); 231 + } 232 + 233 + if ($this->names) { 234 + $where[] = qsprintf( 235 + $conn_r, 236 + 'name IN (%Ls)', 237 + $this->names); 225 238 } 226 239 227 240 $where[] = $this->buildPagingClause($conn_r);