mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-28 07:28:20 +01:00
Workboards - on edit, remove a task if no longer associated with workboard
Summary: Fixes T6179. This makes the interaction where users remove a task from a workboard much more pleasant. Test Plan: Loaded up workboard for "A Project". Edited tasks and if / when I removed "A Project" they disappeared on save. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6179 Differential Revision: https://secure.phabricator.com/D11259
This commit is contained in:
parent
c2b4ed1f7e
commit
ae0a214574
2 changed files with 21 additions and 1 deletions
|
@ -383,6 +383,17 @@ final class ManiphestTaskEditController extends ManiphestController {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// re-load projects for accuracy as they are not re-loaded via
|
||||||
|
// the editor
|
||||||
|
$project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||||
|
$task->getPHID(),
|
||||||
|
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||||
|
$task->attachProjectPHIDs($project_phids);
|
||||||
|
$remove_from_board = false;
|
||||||
|
if (!in_array($column->getProjectPHID(), $project_phids)) {
|
||||||
|
$remove_from_board = true;
|
||||||
|
}
|
||||||
|
|
||||||
$positions = id(new PhabricatorProjectColumnPositionQuery())
|
$positions = id(new PhabricatorProjectColumnPositionQuery())
|
||||||
->setViewer($user)
|
->setViewer($user)
|
||||||
->withColumns(array($column))
|
->withColumns(array($column))
|
||||||
|
@ -397,7 +408,7 @@ final class ManiphestTaskEditController extends ManiphestController {
|
||||||
if ($order == PhabricatorProjectColumn::ORDER_NATURAL) {
|
if ($order == PhabricatorProjectColumn::ORDER_NATURAL) {
|
||||||
// TODO: This is a little bit awkward, because PHP and JS use
|
// TODO: This is a little bit awkward, because PHP and JS use
|
||||||
// slightly different sort order parameters to achieve the same
|
// slightly different sort order parameters to achieve the same
|
||||||
// effect. It would be unify this a bit at some point.
|
// effect. It would be good to unify this a bit at some point.
|
||||||
$sort_map = array();
|
$sort_map = array();
|
||||||
foreach ($positions as $position) {
|
foreach ($positions as $position) {
|
||||||
$sort_map[$position->getObjectPHID()] = array(
|
$sort_map[$position->getObjectPHID()] = array(
|
||||||
|
@ -414,6 +425,7 @@ final class ManiphestTaskEditController extends ManiphestController {
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'sortMap' => $sort_map,
|
'sortMap' => $sort_map,
|
||||||
|
'removeFromBoard' => $remove_from_board,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'task':
|
case 'task':
|
||||||
|
|
|
@ -204,6 +204,7 @@ JX.behavior('project-boards', function(config) {
|
||||||
var new_data = JX.Stratcom.getData(new_card);
|
var new_data = JX.Stratcom.getData(new_card);
|
||||||
var items = finditems(column);
|
var items = finditems(column);
|
||||||
var edited = false;
|
var edited = false;
|
||||||
|
var remove_index = null;
|
||||||
|
|
||||||
for (var ii = 0; ii < items.length; ii++) {
|
for (var ii = 0; ii < items.length; ii++) {
|
||||||
var item = items[ii];
|
var item = items[ii];
|
||||||
|
@ -212,6 +213,9 @@ JX.behavior('project-boards', function(config) {
|
||||||
var phid = data.objectPHID;
|
var phid = data.objectPHID;
|
||||||
|
|
||||||
if (phid == new_data.objectPHID) {
|
if (phid == new_data.objectPHID) {
|
||||||
|
if (r.data.removeFromBoard) {
|
||||||
|
remove_index = ii;
|
||||||
|
}
|
||||||
items[ii] = new_card;
|
items[ii] = new_card;
|
||||||
data = new_data;
|
data = new_data;
|
||||||
edited = true;
|
edited = true;
|
||||||
|
@ -226,6 +230,10 @@ JX.behavior('project-boards', function(config) {
|
||||||
new_data.sort = r.data.sortMap[new_data.objectPHID] || new_data.sort;
|
new_data.sort = r.data.sortMap[new_data.objectPHID] || new_data.sort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (remove_index !== null) {
|
||||||
|
items.splice(remove_index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
items.sort(colsort);
|
items.sort(colsort);
|
||||||
|
|
||||||
JX.DOM.setContent(column, items);
|
JX.DOM.setContent(column, items);
|
||||||
|
|
Loading…
Add table
Reference in a new issue