2014-05-16 04:17:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ManiphestTaskResultListView extends ManiphestView {
|
|
|
|
|
|
|
|
private $tasks;
|
|
|
|
private $savedQuery;
|
|
|
|
private $canEditPriority;
|
|
|
|
private $canBatchEdit;
|
|
|
|
private $showBatchControls;
|
|
|
|
|
|
|
|
public function setSavedQuery(PhabricatorSavedQuery $query) {
|
|
|
|
$this->savedQuery = $query;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTasks(array $tasks) {
|
|
|
|
$this->tasks = $tasks;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCanEditPriority($can_edit_priority) {
|
|
|
|
$this->canEditPriority = $can_edit_priority;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCanBatchEdit($can_batch_edit) {
|
|
|
|
$this->canBatchEdit = $can_batch_edit;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setShowBatchControls($show_batch_controls) {
|
|
|
|
$this->showBatchControls = $show_batch_controls;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
$viewer = $this->getUser();
|
|
|
|
$tasks = $this->tasks;
|
|
|
|
$query = $this->savedQuery;
|
|
|
|
|
|
|
|
// If we didn't match anything, just pick up the default empty state.
|
|
|
|
if (!$tasks) {
|
|
|
|
return id(new PHUIObjectItemListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
}
|
|
|
|
|
|
|
|
$group_parameter = nonempty($query->getParameter('group'), 'priority');
|
|
|
|
$order_parameter = nonempty($query->getParameter('order'), 'priority');
|
|
|
|
|
|
|
|
$handles = ManiphestTaskListView::loadTaskHandles($viewer, $tasks);
|
|
|
|
$groups = $this->groupTasks(
|
|
|
|
$tasks,
|
|
|
|
$group_parameter,
|
|
|
|
$handles);
|
|
|
|
|
|
|
|
$can_edit_priority = $this->canEditPriority;
|
|
|
|
|
|
|
|
$can_drag = ($order_parameter == 'priority') &&
|
|
|
|
($can_edit_priority) &&
|
|
|
|
($group_parameter == 'none' || $group_parameter == 'priority');
|
|
|
|
|
|
|
|
if (!$viewer->isLoggedIn()) {
|
2015-02-03 21:29:08 +01:00
|
|
|
// TODO: (T7131) Eventually, we conceivably need to make each task
|
2014-05-16 04:17:38 +02:00
|
|
|
// draggable individually, since the user may be able to edit some but
|
|
|
|
// not others.
|
|
|
|
$can_drag = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = array();
|
|
|
|
|
|
|
|
$lists = array();
|
|
|
|
foreach ($groups as $group => $list) {
|
|
|
|
$task_list = new ManiphestTaskListView();
|
|
|
|
$task_list->setShowBatchControls($this->showBatchControls);
|
|
|
|
if ($can_drag) {
|
|
|
|
$task_list->setShowSubpriorityControls(true);
|
|
|
|
}
|
|
|
|
$task_list->setUser($viewer);
|
|
|
|
$task_list->setTasks($list);
|
|
|
|
$task_list->setHandles($handles);
|
|
|
|
|
[Redesign] New PHUIObjectItemListView
Summary:
New, cleaner, ObjectItemLists. Lots of minor style tweaks, basic overview:
- Remove FootIcons
- Remove Stackable
- Remove Plain List
- Add StatusIcon
- Add setting ObjectList to an ObjectBox
- Minor retouches to Headers
Mostly, this should give us an idea of life with the new Object Lists. I'll take another application by application pass down the road. This mostly looks at implementation in Maniphest, Differential, Audit, Workboards. Checked a few other areas and dialogs while testing, and everything looks square.
Test Plan: Maniphest, Differential, Homepage, Audit, People, and other applications. Drag reorder, etc.
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12865
2015-05-15 22:28:59 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->addSigil('task-group')
|
|
|
|
->setMetadata(array('priority' => head($list)->getPriority()))
|
2015-11-02 20:54:38 +01:00
|
|
|
->setHeader(pht('%s (%s)', $group, phutil_count($list)));
|
[Redesign] New PHUIObjectItemListView
Summary:
New, cleaner, ObjectItemLists. Lots of minor style tweaks, basic overview:
- Remove FootIcons
- Remove Stackable
- Remove Plain List
- Add StatusIcon
- Add setting ObjectList to an ObjectBox
- Minor retouches to Headers
Mostly, this should give us an idea of life with the new Object Lists. I'll take another application by application pass down the road. This mostly looks at implementation in Maniphest, Differential, Audit, Workboards. Checked a few other areas and dialogs while testing, and everything looks square.
Test Plan: Maniphest, Differential, Homepage, Audit, People, and other applications. Drag reorder, etc.
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12865
2015-05-15 22:28:59 +02:00
|
|
|
|
|
|
|
$lists[] = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
2015-06-30 18:37:12 +02:00
|
|
|
->setObjectList($task_list);
|
[Redesign] New PHUIObjectItemListView
Summary:
New, cleaner, ObjectItemLists. Lots of minor style tweaks, basic overview:
- Remove FootIcons
- Remove Stackable
- Remove Plain List
- Add StatusIcon
- Add setting ObjectList to an ObjectBox
- Minor retouches to Headers
Mostly, this should give us an idea of life with the new Object Lists. I'll take another application by application pass down the road. This mostly looks at implementation in Maniphest, Differential, Audit, Workboards. Checked a few other areas and dialogs while testing, and everything looks square.
Test Plan: Maniphest, Differential, Homepage, Audit, People, and other applications. Drag reorder, etc.
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12865
2015-05-15 22:28:59 +02:00
|
|
|
|
2014-05-16 04:17:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($can_drag) {
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'maniphest-subpriority-editor',
|
|
|
|
array(
|
|
|
|
'uri' => '/maniphest/subpriority/',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
[Redesign] New PHUIObjectItemListView
Summary:
New, cleaner, ObjectItemLists. Lots of minor style tweaks, basic overview:
- Remove FootIcons
- Remove Stackable
- Remove Plain List
- Add StatusIcon
- Add setting ObjectList to an ObjectBox
- Minor retouches to Headers
Mostly, this should give us an idea of life with the new Object Lists. I'll take another application by application pass down the road. This mostly looks at implementation in Maniphest, Differential, Audit, Workboards. Checked a few other areas and dialogs while testing, and everything looks square.
Test Plan: Maniphest, Differential, Homepage, Audit, People, and other applications. Drag reorder, etc.
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12865
2015-05-15 22:28:59 +02:00
|
|
|
return array(
|
|
|
|
$lists,
|
|
|
|
$this->showBatchControls ? $this->renderBatchEditor($query) : null,
|
|
|
|
);
|
2014-05-16 04:17:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function groupTasks(array $tasks, $group, array $handles) {
|
|
|
|
assert_instances_of($tasks, 'ManiphestTask');
|
|
|
|
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
|
|
|
|
|
|
|
$groups = $this->getTaskGrouping($tasks, $group);
|
|
|
|
|
|
|
|
$results = array();
|
|
|
|
foreach ($groups as $label_key => $tasks) {
|
|
|
|
$label = $this->getTaskLabelName($group, $label_key, $handles);
|
|
|
|
$results[$label][] = $tasks;
|
|
|
|
}
|
|
|
|
foreach ($results as $label => $task_groups) {
|
|
|
|
$results[$label] = array_mergev($task_groups);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getTaskGrouping(array $tasks, $group) {
|
|
|
|
switch ($group) {
|
|
|
|
case 'priority':
|
|
|
|
return mgroup($tasks, 'getPriority');
|
|
|
|
case 'status':
|
|
|
|
return mgroup($tasks, 'getStatus');
|
|
|
|
case 'assigned':
|
|
|
|
return mgroup($tasks, 'getOwnerPHID');
|
|
|
|
case 'project':
|
|
|
|
return mgroup($tasks, 'getGroupByProjectPHID');
|
|
|
|
default:
|
|
|
|
return array(pht('Tasks') => $tasks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getTaskLabelName($group, $label_key, array $handles) {
|
|
|
|
switch ($group) {
|
|
|
|
case 'priority':
|
|
|
|
return ManiphestTaskPriority::getTaskPriorityName($label_key);
|
|
|
|
case 'status':
|
|
|
|
return ManiphestTaskStatus::getTaskStatusFullName($label_key);
|
|
|
|
case 'assigned':
|
|
|
|
if ($label_key) {
|
|
|
|
return $handles[$label_key]->getFullName();
|
|
|
|
} else {
|
|
|
|
return pht('(Not Assigned)');
|
|
|
|
}
|
|
|
|
case 'project':
|
|
|
|
if ($label_key) {
|
|
|
|
return $handles[$label_key]->getFullName();
|
|
|
|
} else {
|
2014-05-16 17:47:06 +02:00
|
|
|
// This may mean "No Projects", or it may mean the query has project
|
|
|
|
// constraints but the task is only in constrained projects (in this
|
|
|
|
// case, we don't show the group because it would always have all
|
|
|
|
// of the tasks). Since distinguishing between these two cases is
|
|
|
|
// messy and the UI is reasonably clear, label generically.
|
|
|
|
return pht('(Ungrouped)');
|
2014-05-16 04:17:38 +02:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
return pht('Tasks');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderBatchEditor(PhabricatorSavedQuery $saved_query) {
|
|
|
|
$user = $this->getUser();
|
|
|
|
|
|
|
|
if (!$this->canBatchEdit) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$user->isLoggedIn()) {
|
|
|
|
// Don't show the batch editor or excel export for logged-out users.
|
|
|
|
// Technically we //could// let them export, but ehh.
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'maniphest-batch-selector',
|
|
|
|
array(
|
|
|
|
'selectAll' => 'batch-select-all',
|
|
|
|
'selectNone' => 'batch-select-none',
|
|
|
|
'submit' => 'batch-select-submit',
|
|
|
|
'status' => 'batch-select-status-cell',
|
|
|
|
'idContainer' => 'batch-select-id-container',
|
|
|
|
'formID' => 'batch-select-form',
|
|
|
|
));
|
|
|
|
|
|
|
|
$select_all = javelin_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#',
|
|
|
|
'mustcapture' => true,
|
|
|
|
'class' => 'grey button',
|
|
|
|
'id' => 'batch-select-all',
|
|
|
|
),
|
|
|
|
pht('Select All'));
|
|
|
|
|
|
|
|
$select_none = javelin_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '#',
|
|
|
|
'mustcapture' => true,
|
|
|
|
'class' => 'grey button',
|
|
|
|
'id' => 'batch-select-none',
|
|
|
|
),
|
|
|
|
pht('Clear Selection'));
|
|
|
|
|
|
|
|
$submit = phutil_tag(
|
|
|
|
'button',
|
|
|
|
array(
|
|
|
|
'id' => 'batch-select-submit',
|
|
|
|
'disabled' => 'disabled',
|
|
|
|
'class' => 'disabled',
|
|
|
|
),
|
|
|
|
pht("Batch Edit Selected \xC2\xBB"));
|
|
|
|
|
|
|
|
$export = javelin_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/maniphest/export/'.$saved_query->getQueryKey().'/',
|
|
|
|
'class' => 'grey button',
|
|
|
|
),
|
|
|
|
pht('Export to Excel'));
|
|
|
|
|
|
|
|
$hidden = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'id' => 'batch-select-id-container',
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
|
|
|
|
$editor = hsprintf(
|
|
|
|
'<table class="maniphest-batch-editor-layout">'.
|
|
|
|
'<tr>'.
|
|
|
|
'<td>%s%s</td>'.
|
|
|
|
'<td>%s</td>'.
|
|
|
|
'<td id="batch-select-status-cell">%s</td>'.
|
|
|
|
'<td class="batch-select-submit-cell">%s%s</td>'.
|
|
|
|
'</tr>'.
|
[Redesign] New PHUIObjectItemListView
Summary:
New, cleaner, ObjectItemLists. Lots of minor style tweaks, basic overview:
- Remove FootIcons
- Remove Stackable
- Remove Plain List
- Add StatusIcon
- Add setting ObjectList to an ObjectBox
- Minor retouches to Headers
Mostly, this should give us an idea of life with the new Object Lists. I'll take another application by application pass down the road. This mostly looks at implementation in Maniphest, Differential, Audit, Workboards. Checked a few other areas and dialogs while testing, and everything looks square.
Test Plan: Maniphest, Differential, Homepage, Audit, People, and other applications. Drag reorder, etc.
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12865
2015-05-15 22:28:59 +02:00
|
|
|
'</table>',
|
2014-05-16 04:17:38 +02:00
|
|
|
$select_all,
|
|
|
|
$select_none,
|
|
|
|
$export,
|
|
|
|
'',
|
|
|
|
$submit,
|
|
|
|
$hidden);
|
|
|
|
|
|
|
|
$editor = phabricator_form(
|
|
|
|
$user,
|
|
|
|
array(
|
|
|
|
'method' => 'POST',
|
|
|
|
'action' => '/maniphest/batch/',
|
|
|
|
'id' => 'batch-select-form',
|
|
|
|
),
|
|
|
|
$editor);
|
|
|
|
|
[Redesign] New PHUIObjectItemListView
Summary:
New, cleaner, ObjectItemLists. Lots of minor style tweaks, basic overview:
- Remove FootIcons
- Remove Stackable
- Remove Plain List
- Add StatusIcon
- Add setting ObjectList to an ObjectBox
- Minor retouches to Headers
Mostly, this should give us an idea of life with the new Object Lists. I'll take another application by application pass down the road. This mostly looks at implementation in Maniphest, Differential, Audit, Workboards. Checked a few other areas and dialogs while testing, and everything looks square.
Test Plan: Maniphest, Differential, Homepage, Audit, People, and other applications. Drag reorder, etc.
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12865
2015-05-15 22:28:59 +02:00
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Batch Task Editor'))
|
|
|
|
->appendChild($editor);
|
|
|
|
|
[Redesign] Mobile/Phone design pass
Summary: Ref T8099, Quick descent pass at making header, object lists, tables, filter view, mobile friendly.
Test Plan:
Test home, differential diff, maniphest task, new task, search, and a few other views.
{F414034}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D12984
2015-05-23 02:52:51 +02:00
|
|
|
$content = phutil_tag_div('maniphest-batch-editor', $box);
|
|
|
|
|
|
|
|
return $content;
|
2014-05-16 04:17:38 +02:00
|
|
|
}
|
|
|
|
}
|