1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

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
This commit is contained in:
Erik Fercak 2013-10-25 10:16:39 -07:00 committed by epriestley
parent 6a169de967
commit 1fb2f39fc0
2 changed files with 56 additions and 3 deletions

View file

@ -49,9 +49,49 @@ final class ManiphestTaskEditController extends ManiphestController {
$task->setTitle($request->getStr('title')); $task->setTitle($request->getStr('title'));
if ($can_edit_projects) { if ($can_edit_projects) {
$default_projects = $request->getStr('projects'); $projects = $request->getStr('projects');
if ($default_projects) { if ($projects) {
$task->setProjectPHIDs(explode(';', $default_projects)); $tokens = explode(';', $projects);
$slug_map = id(new PhabricatorProjectQuery())
->setViewer($user)
->withPhrictionSlugs($tokens)
->execute();
$name_map = id(new PhabricatorProjectQuery())
->setViewer($user)
->withNames($tokens)
->execute();
$phid_map = id(new PhabricatorProjectQuery())
->setViewer($user)
->withPHIDs($tokens)
->execute();
$all_map = mpull($slug_map, null, 'getPhrictionSlug') +
mpull($name_map, null, 'getName') +
mpull($phid_map, null, 'getPHID');
$default_projects = array();
foreach ($tokens as $token) {
if (isset($all_map[$token])) {
$default_projects[] = $all_map[$token]->getPHID();
}
}
if ($default_projects) {
$task->setProjectPHIDs($default_projects);
}
}
}
if ($can_edit_priority) {
$priority = $request->getInt('priority');
if ($priority !== null) {
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
if (isset($priority_map[$priority])) {
$task->setPriority($priority);
}
} }
} }

View file

@ -7,6 +7,7 @@ final class PhabricatorProjectQuery
private $phids; private $phids;
private $memberPHIDs; private $memberPHIDs;
private $slugs; private $slugs;
private $names;
private $status = 'status-any'; private $status = 'status-any';
const STATUS_ANY = 'status-any'; const STATUS_ANY = 'status-any';
@ -43,6 +44,11 @@ final class PhabricatorProjectQuery
return $this; return $this;
} }
public function withNames(array $names) {
$this->names = $names;
return $this;
}
public function needMembers($need_members) { public function needMembers($need_members) {
$this->needMembers = $need_members; $this->needMembers = $need_members;
return $this; return $this;
@ -224,6 +230,13 @@ final class PhabricatorProjectQuery
$this->slugs); $this->slugs);
} }
if ($this->names) {
$where[] = qsprintf(
$conn_r,
'name IN (%Ls)',
$this->names);
}
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where); return $this->formatWhereClause($where);