1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-14 08:41:07 +01:00

Workboards - add task create + improve task placement wrt priority edits

Summary: Fixes T4553, T4407.

Test Plan: created tasks and they showed up in the proper column. edited task priority and they moved about sensically.

Reviewers: chad, epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4553, T4407

Differential Revision: https://secure.phabricator.com/D8420
This commit is contained in:
Bob Trahan 2014-03-05 18:40:28 -08:00
parent df7e795fc8
commit d08576ed4e
5 changed files with 177 additions and 29 deletions

View file

@ -401,7 +401,7 @@ return array(
'rsrc/js/application/policy/behavior-policy-control.js' => 'c01153ea', 'rsrc/js/application/policy/behavior-policy-control.js' => 'c01153ea',
'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '263aeb8c', 'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '263aeb8c',
'rsrc/js/application/ponder/behavior-votebox.js' => '327dbe61', 'rsrc/js/application/ponder/behavior-votebox.js' => '327dbe61',
'rsrc/js/application/projects/behavior-project-boards.js' => 'cbdc9b22', 'rsrc/js/application/projects/behavior-project-boards.js' => '04c59172',
'rsrc/js/application/projects/behavior-project-create.js' => '065227cc', 'rsrc/js/application/projects/behavior-project-create.js' => '065227cc',
'rsrc/js/application/releeph/releeph-preview-branch.js' => '9eb2cedb', 'rsrc/js/application/releeph/releeph-preview-branch.js' => '9eb2cedb',
'rsrc/js/application/releeph/releeph-request-state-change.js' => 'fe7fc914', 'rsrc/js/application/releeph/releeph-request-state-change.js' => 'fe7fc914',
@ -610,7 +610,7 @@ return array(
'javelin-behavior-policy-control' => 'c01153ea', 'javelin-behavior-policy-control' => 'c01153ea',
'javelin-behavior-policy-rule-editor' => '263aeb8c', 'javelin-behavior-policy-rule-editor' => '263aeb8c',
'javelin-behavior-ponder-votebox' => '327dbe61', 'javelin-behavior-ponder-votebox' => '327dbe61',
'javelin-behavior-project-boards' => 'cbdc9b22', 'javelin-behavior-project-boards' => '04c59172',
'javelin-behavior-project-create' => '065227cc', 'javelin-behavior-project-create' => '065227cc',
'javelin-behavior-refresh-csrf' => 'c4b31646', 'javelin-behavior-refresh-csrf' => 'c4b31646',
'javelin-behavior-releeph-preview-branch' => '9eb2cedb', 'javelin-behavior-releeph-preview-branch' => '9eb2cedb',
@ -839,6 +839,15 @@ return array(
3 => 'javelin-vector', 3 => 'javelin-vector',
4 => 'javelin-install', 4 => 'javelin-install',
), ),
'04c59172' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
2 => 'javelin-util',
3 => 'javelin-stratcom',
4 => 'javelin-workflow',
5 => 'phabricator-draggable-list',
),
'065227cc' => '065227cc' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
@ -1216,6 +1225,13 @@ return array(
2 => 'javelin-util', 2 => 'javelin-util',
3 => 'phabricator-shaped-request', 3 => 'phabricator-shaped-request',
), ),
'62e18640' =>
array(
0 => 'javelin-install',
1 => 'javelin-util',
2 => 'javelin-dom',
3 => 'javelin-typeahead-normalizer',
),
'6453c869' => '6453c869' =>
array( array(
0 => 'javelin-install', 0 => 'javelin-install',
@ -1249,13 +1265,6 @@ return array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
1 => 'javelin-dom', 1 => 'javelin-dom',
), ),
'62e18640' =>
array(
0 => 'javelin-install',
1 => 'javelin-util',
2 => 'javelin-dom',
3 => 'javelin-typeahead-normalizer',
),
'75903ee1' => '75903ee1' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
@ -1689,15 +1698,6 @@ return array(
2 => 'javelin-stratcom', 2 => 'javelin-stratcom',
3 => 'phabricator-phtize', 3 => 'phabricator-phtize',
), ),
'cbdc9b22' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
2 => 'javelin-util',
3 => 'javelin-stratcom',
4 => 'javelin-workflow',
5 => 'phabricator-draggable-list',
),
'cd9e7094' => 'cd9e7094' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',

View file

@ -12,7 +12,7 @@ final class ManiphestTaskEditController extends ManiphestController {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$response_type = $request->getStr('response_type', 'task'); $response_type = $request->getStr('responseType', 'task');
$can_edit_assign = $this->hasApplicationCapability( $can_edit_assign = $this->hasApplicationCapability(
ManiphestCapabilityEditAssign::CAPABILITY); ManiphestCapabilityEditAssign::CAPABILITY);
@ -242,8 +242,28 @@ final class ManiphestTaskEditController extends ManiphestController {
$changes[ManiphestTransaction::TYPE_CCS] = $request->getArr('cc'); $changes[ManiphestTransaction::TYPE_CCS] = $request->getArr('cc');
if ($can_edit_projects) { if ($can_edit_projects) {
$projects = $request->getArr('projects');
$changes[ManiphestTransaction::TYPE_PROJECTS] = $changes[ManiphestTransaction::TYPE_PROJECTS] =
$request->getArr('projects'); $projects;
$column_phid = $request->getStr('columnPHID');
// allow for putting a task in a project column at creation -only-
if (!$task->getID() && $column_phid && $projects) {
$column = id(new PhabricatorProjectColumnQuery())
->setViewer($user)
->withProjectPHIDs($projects)
->withPHIDs(array($column_phid))
->executeOne();
if ($column) {
$changes[ManiphestTransaction::TYPE_PROJECT_COLUMN] =
array(
'new' => array(
'projectPHID' => $column->getProjectPHID(),
'columnPHIDs' => array($column_phid)),
'old' => array(
'projectPHID' => $column->getProjectPHID(),
'columnPHIDs' => array()));
}
}
} }
if ($can_edit_policies) { if ($can_edit_policies) {
@ -267,7 +287,12 @@ final class ManiphestTaskEditController extends ManiphestController {
foreach ($changes as $type => $value) { foreach ($changes as $type => $value) {
$transaction = clone $template; $transaction = clone $template;
$transaction->setTransactionType($type); $transaction->setTransactionType($type);
$transaction->setNewValue($value); if ($type == ManiphestTransaction::TYPE_PROJECT_COLUMN) {
$transaction->setNewValue($value['new']);
$transaction->setOldValue($value['old']);
} else {
$transaction->setNewValue($value);
}
$transactions[] = $transaction; $transactions[] = $transaction;
} }
@ -351,15 +376,72 @@ final class ManiphestTaskEditController extends ManiphestController {
->setOwner($owner) ->setOwner($owner)
->setCanEdit(true) ->setCanEdit(true)
->getItem(); ->getItem();
$column_phid = $request->getStr('columnPHID');
$column = id(new PhabricatorProjectColumnQuery())
->setViewer($user)
->withPHIDs(array($column_phid))
->executeOne();
if ($column->isDefaultColumn()) {
$column_tasks = array();
$potential_col_tasks = id(new ManiphestTaskQuery())
->setViewer($user)
->withAllProjects(array($column->getProjectPHID()))
->withStatuses(ManiphestTaskStatus::getOpenStatusConstants())
->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY)
->execute();
$potential_col_tasks = mpull(
$potential_col_tasks,
null,
'getPHID');
$potential_task_phids = array_keys($potential_col_tasks);
if ($potential_task_phids) {
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_COLUMN;
$edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs($potential_task_phids)
->withEdgeTypes(array($edge_type));
$edges = $edge_query->execute();
foreach ($potential_col_tasks as $task_phid => $curr_task) {
$curr_column_phids = $edges[$task_phid][$edge_type];
$curr_column_phid = head_key($curr_column_phids);
if (!$curr_column_phid ||
$curr_column_phid == $column_phid) {
$column_tasks[] = $curr_task;
}
}
}
} else {
$column_task_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$column_phid,
PhabricatorEdgeConfig::TYPE_COLUMN_HAS_OBJECT);
$column_tasks = id(new ManiphestTaskQuery())
->setViewer($user)
->withPHIDs($column_task_phids)
->withStatuses(ManiphestTaskStatus::getOpenStatusConstants())
->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY)
->execute();
}
$column_task_phids = mpull($column_tasks, 'getPHID');
$task_phid = $task->getPHID();
$after_phid = null;
foreach ($column_task_phids as $phid) {
if ($phid == $task_phid) {
break;
}
$after_phid = $phid;
}
$data = array(
'insertAfterPHID' => $after_phid);
break; break;
case 'task': case 'task':
default: default:
$tasks = $this->renderSingleTask($task); $tasks = $this->renderSingleTask($task);
$data = array();
break; break;
} }
return id(new AphrontAjaxResponse())->setContent( return id(new AphrontAjaxResponse())->setContent(
array( array(
'tasks' => $tasks, 'tasks' => $tasks,
'data' => $data,
)); ));
} }
@ -486,7 +568,8 @@ final class ManiphestTaskEditController extends ManiphestController {
$form $form
->setUser($user) ->setUser($user)
->addHiddenInput('template', $template_id) ->addHiddenInput('template', $template_id)
->addHiddenInput('response_type', $response_type); ->addHiddenInput('responseType', $response_type)
->addHiddenInput('columnPHID', $request->getStr('columnPHID'));
if ($parent_task) { if ($parent_task) {
$form $form

View file

@ -94,7 +94,9 @@ final class PhabricatorProjectBoardController
'project-boards', 'project-boards',
array( array(
'boardID' => $board_id, 'boardID' => $board_id,
'projectPHID' => $project->getPHID(),
'moveURI' => $this->getApplicationURI('move/'.$project->getID().'/'), 'moveURI' => $this->getApplicationURI('move/'.$project->getID().'/'),
'createURI' => '/maniphest/task/create/',
)); ));
$this->handles = ManiphestTaskListView::loadTaskHandles($viewer, $tasks); $this->handles = ManiphestTaskListView::loadTaskHandles($viewer, $tasks);
@ -106,6 +108,13 @@ final class PhabricatorProjectBoardController
if (!$column->isDefaultColumn()) { if (!$column->isDefaultColumn()) {
$panel->setEditURI('edit/'.$column->getID().'/'); $panel->setEditURI('edit/'.$column->getID().'/');
} }
$panel->setHeaderAction(id(new PHUIIconView())
->setSpriteSheet(PHUIIconView::SPRITE_ACTIONS)
->setSpriteIcon('new-grey')
->setHref('/maniphest/task/create/')
->addSigil('column-add-task')
->setMetadata(
array('columnPHID' => $column->getPHID())));
$cards = id(new PHUIObjectItemListView()) $cards = id(new PHUIObjectItemListView())
->setUser($viewer) ->setUser($viewer)

View file

@ -5,9 +5,15 @@ final class PHUIWorkpanelView extends AphrontTagView {
private $cards = array(); private $cards = array();
private $header; private $header;
private $editURI; private $editURI;
private $headerAction;
private $footerAction; private $footerAction;
private $headerColor = PhabricatorActionHeaderView::HEADER_GREY; private $headerColor = PhabricatorActionHeaderView::HEADER_GREY;
public function setHeaderAction(PHUIIconView $header_action) {
$this->headerAction = $header_action;
return $this;
}
public function setCards(PHUIObjectItemListView $cards) { public function setCards(PHUIObjectItemListView $cards) {
$this->cards[] = $cards; $this->cards[] = $cards;
return $this; return $this;
@ -60,13 +66,15 @@ final class PHUIWorkpanelView extends AphrontTagView {
->setSpriteIcon('settings-grey') ->setSpriteIcon('settings-grey')
->setHref($this->editURI); ->setHref($this->editURI);
} }
$header = id(new PhabricatorActionHeaderView()) $header = id(new PhabricatorActionHeaderView())
->setHeaderTitle($this->header) ->setHeaderTitle($this->header)
->setHeaderColor($this->headerColor); ->setHeaderColor($this->headerColor);
if ($header_edit) { if ($header_edit) {
$header->addAction($header_edit); $header->addAction($header_edit);
} }
if ($this->headerAction) {
$header->addAction($this->headerAction);
}
$body = phutil_tag( $body = phutil_tag(
'div', 'div',

View file

@ -65,10 +65,31 @@ JX.behavior('project-boards', function(config) {
lists[ii].setGroup(lists); lists[ii].setGroup(lists);
} }
var onedit = function(card, r) { var onedit = function(card, column, r) {
var nodes = JX.$H(r.tasks).getFragment().firstChild;
var new_card = JX.$H(r.tasks); var new_card = JX.$H(r.tasks);
JX.DOM.replace(card, new_card); var items = finditems(column);
var insert_after = r.data.insertAfterPHID;
if (!insert_after) {
JX.DOM.prependContent(column, new_card);
if (card) {
JX.DOM.remove(card);
}
return;
}
var ii;
var item;
var item_phid;
for (ii = 0; ii< items.length; ii++) {
item = items[ii];
item_phid = JX.Stratcom.getData(item).objectPHID;
if (item_phid == insert_after) {
JX.DOM.replace(item, [item, new_card]);
if (card) {
JX.DOM.remove(card);
}
return;
}
}
}; };
JX.Stratcom.listen( JX.Stratcom.listen(
@ -77,9 +98,36 @@ JX.behavior('project-boards', function(config) {
function(e) { function(e) {
e.kill(); e.kill();
var card = e.getNode('project-card'); var card = e.getNode('project-card');
new JX.Workflow(e.getNode('tag:a').href, { 'response_type' : 'card' }) var column = e.getNode('project-column');
.setHandler(JX.bind(null, onedit, card)) var request_data = {
.start(); 'responseType' : 'card',
'columnPHID' : JX.Stratcom.getData(column).columnPHID };
new JX.Workflow(e.getNode('tag:a').href, request_data)
.setHandler(JX.bind(null, onedit, card, column))
.start();
}); });
JX.Stratcom.listen(
'click',
['column-add-task'],
function (e) {
e.kill();
var column_phid = e.getNodeData('column-add-task').columnPHID;
var request_data = {
'responseType' : 'card',
'columnPHID' : column_phid,
'projects' : config.projectPHID };
var cols = JX.DOM.scry(JX.$(config.boardID), 'ul', 'project-column');
var ii;
var column;
for (ii = 0; ii < cols.length; ii++) {
if (JX.Stratcom.getData(cols[ii]).columnPHID == column_phid) {
column = cols[ii];
break;
}
}
new JX.Workflow(config.createURI, request_data)
.setHandler(JX.bind(null, onedit, null, column))
.start();
});
}); });