mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 15:22:41 +01:00
Add minimum and maximum priority select boxes to Maniphest Custom Query.
Summary: Added the boxes. NOTE: I am not sure how to deal with the user choosing a minimum higher than the maximum; it causes an empty result set, but if we can avoid allowing it, that'd be better, I think. Test Plan: See the boxes there, not filtering. Change them, see them filtering. Reviewers: epriestley CC: aran, Korvin Maniphest Tasks: T1565 Differential Revision: https://secure.phabricator.com/D3109
This commit is contained in:
parent
9092994e45
commit
54d1b95141
3 changed files with 118 additions and 12 deletions
|
@ -48,6 +48,9 @@ final class ManiphestTaskQuery {
|
|||
|
||||
private $priority = null;
|
||||
|
||||
private $minPriority = null;
|
||||
private $maxPriority = null;
|
||||
|
||||
private $groupBy = 'group-none';
|
||||
const GROUP_NONE = 'group-none';
|
||||
const GROUP_PRIORITY = 'group-priority';
|
||||
|
@ -119,6 +122,12 @@ final class ManiphestTaskQuery {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withPrioritiesBetween($min, $max) {
|
||||
$this->minPriority = $min;
|
||||
$this->maxPriority = $max;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withSubscribers(array $subscribers) {
|
||||
$this->subscriberPHIDs = $subscribers;
|
||||
return $this;
|
||||
|
@ -316,14 +325,20 @@ final class ManiphestTaskQuery {
|
|||
}
|
||||
|
||||
private function buildPriorityWhereClause($conn) {
|
||||
if ($this->priority === null) {
|
||||
return null;
|
||||
if ($this->priority !== null) {
|
||||
return qsprintf(
|
||||
$conn,
|
||||
'priority = %d',
|
||||
$this->priority);
|
||||
} elseif ($this->minPriority !== null && $this->maxPriority !== null) {
|
||||
return qsprintf(
|
||||
$conn,
|
||||
'priority >= %d AND priority <= %d',
|
||||
$this->minPriority,
|
||||
$this->maxPriority);
|
||||
}
|
||||
|
||||
return qsprintf(
|
||||
$conn,
|
||||
'priority = %d',
|
||||
$this->priority);
|
||||
return null;
|
||||
}
|
||||
|
||||
private function buildAuthorWhereClause($conn) {
|
||||
|
|
|
@ -28,6 +28,11 @@ final class ManiphestTaskPriority extends ManiphestConstants {
|
|||
const PRIORITY_LOW = 25;
|
||||
const PRIORITY_WISH = 0;
|
||||
|
||||
/**
|
||||
* Get the priorities and their full descriptions.
|
||||
*
|
||||
* @return map Priorities to descriptions.
|
||||
*/
|
||||
public static function getTaskPriorityMap() {
|
||||
return array(
|
||||
self::PRIORITY_UNBREAK_NOW => 'Unbreak Now!',
|
||||
|
@ -39,6 +44,11 @@ final class ManiphestTaskPriority extends ManiphestConstants {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the priorities and their related short (one-word) descriptions.
|
||||
*
|
||||
* @return map Priorities to brief descriptions.
|
||||
*/
|
||||
public static function getTaskBriefPriorityMap() {
|
||||
return array(
|
||||
self::PRIORITY_UNBREAK_NOW => 'Unbreak!',
|
||||
|
@ -50,7 +60,11 @@ final class ManiphestTaskPriority extends ManiphestConstants {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the priorities and some bits for bitwise fun.
|
||||
*
|
||||
* @return map Priorities to bits.
|
||||
*/
|
||||
public static function getLoadMap() {
|
||||
return array(
|
||||
self::PRIORITY_UNBREAK_NOW => 16,
|
||||
|
@ -62,6 +76,31 @@ final class ManiphestTaskPriority extends ManiphestConstants {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lowest defined priority.
|
||||
*
|
||||
* @return int The value of the lowest priority constant.
|
||||
*/
|
||||
public static function getLowestPriority() {
|
||||
return self::PRIORITY_WISH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the highest defined priority.
|
||||
*
|
||||
* @return int The value of the highest priority constant.
|
||||
*/
|
||||
public static function getHighestPriority() {
|
||||
return self::PRIORITY_UNBREAK_NOW;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the full name of the priority level provided.
|
||||
*
|
||||
* @param int A priority level.
|
||||
* @return string The priority name if the level is a valid one,
|
||||
* or `???` if it is not.
|
||||
*/
|
||||
public static function getTaskPriorityName($priority) {
|
||||
return idx(self::getTaskPriorityMap(), $priority, '???');
|
||||
}
|
||||
|
|
|
@ -49,12 +49,20 @@ final class ManiphestTaskListController extends ManiphestController {
|
|||
$search_text = $request->getStr('set_search');
|
||||
$search_text = nonempty($search_text, null);
|
||||
|
||||
$min_priority = $request->getInt('set_lpriority');
|
||||
$min_priority = nonempty($min_priority, null);
|
||||
|
||||
$max_priority = $request->getInt('set_hpriority');
|
||||
$max_priority = nonempty($max_priority, null);
|
||||
|
||||
$uri = $request->getRequestURI()
|
||||
->alter('users', $this->getArrToStrList('set_users'))
|
||||
->alter('projects', $this->getArrToStrList('set_projects'))
|
||||
->alter('xprojects', $this->getArrToStrList('set_xprojects'))
|
||||
->alter('owners', $this->getArrToStrList('set_owners'))
|
||||
->alter('authors', $this->getArrToStrList('set_authors'))
|
||||
->alter('lpriority', $min_priority)
|
||||
->alter('hpriority', $max_priority)
|
||||
->alter('tasks', $task_ids)
|
||||
->alter('search', $search_text);
|
||||
|
||||
|
@ -113,6 +121,9 @@ final class ManiphestTaskListController extends ManiphestController {
|
|||
$exclude_project_phids = $query->getParameter(
|
||||
'excludeProjectPHIDs',
|
||||
array());
|
||||
$low_priority = $query->getParameter('lowPriority');
|
||||
$high_priority = $query->getParameter('highPriority');
|
||||
|
||||
$page_size = $query->getParameter('limit');
|
||||
$page = $query->getParameter('offset');
|
||||
|
||||
|
@ -209,6 +220,32 @@ final class ManiphestTaskListController extends ManiphestController {
|
|||
->setName('set_xprojects')
|
||||
->setLabel('Exclude Projects')
|
||||
->setValue($tokens));
|
||||
|
||||
$priority = ManiphestTaskPriority::getLowestPriority();
|
||||
if ($low_priority) {
|
||||
$priority = $low_priority;
|
||||
}
|
||||
|
||||
$form->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel('From Priority')
|
||||
->setName('set_lpriority')
|
||||
->setValue($priority)
|
||||
->setOptions(array_reverse(
|
||||
ManiphestTaskPriority::getTaskPriorityMap(), true)));
|
||||
|
||||
$priority = ManiphestTaskPriority::getHighestPriority();
|
||||
if ($high_priority) {
|
||||
$priority = $high_priority;
|
||||
}
|
||||
|
||||
$form->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel('To Priority')
|
||||
->setName('set_hpriority')
|
||||
->setValue($priority)
|
||||
->setOptions(ManiphestTaskPriority::getTaskPriorityMap()));
|
||||
|
||||
}
|
||||
|
||||
$form
|
||||
|
@ -377,6 +414,13 @@ final class ManiphestTaskListController extends ManiphestController {
|
|||
$owner_phids = $search_query->getParameter('ownerPHIDs', array());
|
||||
$author_phids = $search_query->getParameter('authorPHIDs', array());
|
||||
|
||||
$low_priority = $search_query->getParameter('lowPriority');
|
||||
$low_priority = nonempty($low_priority,
|
||||
ManiphestTaskPriority::getLowestPriority());
|
||||
$high_priority = $search_query->getParameter('highPriority');
|
||||
$high_priority = nonempty($high_priority,
|
||||
ManiphestTaskPriority::getHighestPriority());
|
||||
|
||||
$query = new ManiphestTaskQuery();
|
||||
$query->withProjects($project_phids);
|
||||
$query->withTaskIDs($task_ids);
|
||||
|
@ -428,6 +472,9 @@ final class ManiphestTaskListController extends ManiphestController {
|
|||
case 'projectall':
|
||||
$any_project = true;
|
||||
break;
|
||||
case 'custom':
|
||||
$query->withPrioritiesBetween($low_priority, $high_priority);
|
||||
break;
|
||||
}
|
||||
|
||||
$query->withAnyProject($any_project);
|
||||
|
@ -639,8 +686,8 @@ final class ManiphestTaskListController extends ManiphestController {
|
|||
}
|
||||
|
||||
private function buildQueryFromRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$status = $this->getStatusValueFromRequest();
|
||||
$group = $this->getGroupValueFromRequest();
|
||||
|
@ -681,10 +728,13 @@ final class ManiphestTaskListController extends ManiphestController {
|
|||
$task_ids = $numeric_task_ids;
|
||||
}
|
||||
|
||||
$owner_phids = $request->getStrList('owners');
|
||||
$author_phids = $request->getStrList('authors');
|
||||
$owner_phids = $request->getStrList('owners');
|
||||
$author_phids = $request->getStrList('authors');
|
||||
|
||||
$search_string = $request->getStr('search');
|
||||
$search_string = $request->getStr('search');
|
||||
|
||||
$low_priority = $request->getInt('lpriority');
|
||||
$high_priority = $request->getInt('hpriority');
|
||||
|
||||
$page = $request->getInt('offset');
|
||||
$page_size = self::DEFAULT_PAGE_SIZE;
|
||||
|
@ -701,6 +751,8 @@ final class ManiphestTaskListController extends ManiphestController {
|
|||
'ownerPHIDs' => $owner_phids,
|
||||
'authorPHIDs' => $author_phids,
|
||||
'taskIDs' => $task_ids,
|
||||
'lowPriority' => $low_priority,
|
||||
'highPriority' => $high_priority,
|
||||
'group' => $group,
|
||||
'order' => $order,
|
||||
'offset' => $page,
|
||||
|
|
Loading…
Reference in a new issue