mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 01:48:23 +01:00
Fix batch editor for edits which both add and remove projects
Summary: Aggregate multiple add/remove transactions so we don't restore removed projects for a (remove + add) batch edit. (Possibly we should do this in the TransactionEditor as well / instead, but it's fairly easy here and this is the only possible case currently.) Test Plan: Performed a remove + add batch edit without issues. Reviewers: btrahan Reviewed By: btrahan CC: cpiro, aran, epriestley Maniphest Tasks: T985 Differential Revision: https://secure.phabricator.com/D1967
This commit is contained in:
parent
238b403509
commit
81be1cf27b
1 changed files with 28 additions and 4 deletions
|
@ -143,6 +143,8 @@ final class ManiphestBatchEditController extends ManiphestController {
|
|||
|
||||
// TODO: Set content source to "batch edit".
|
||||
|
||||
$project_xaction = null;
|
||||
|
||||
$xactions = array();
|
||||
foreach ($actions as $action) {
|
||||
$value = $action['value'];
|
||||
|
@ -152,7 +154,20 @@ final class ManiphestBatchEditController extends ManiphestController {
|
|||
|
||||
$is_remove = ($action['action'] == 'remove_project');
|
||||
|
||||
$current = array_fill_keys($task->getProjectPHIDs(), true);
|
||||
// We want to roll up all of the add and remove actions into a single
|
||||
// transaction so we don't restore removed projects or remove added
|
||||
// projects in subsequent transactions. If we've already made some
|
||||
// modification to a task's projects, use that as the starting point.
|
||||
// Otherwise, start with the value on the task.
|
||||
|
||||
if ($project_xaction) {
|
||||
$xaction = $project_xaction;
|
||||
$current = $xaction->getNewValue();
|
||||
} else {
|
||||
$current = $task->getProjectPHIDs();
|
||||
}
|
||||
|
||||
$current = array_fill_keys($current, true);
|
||||
$value = array_fill_keys($value, true);
|
||||
|
||||
$new = $current;
|
||||
|
@ -178,11 +193,20 @@ final class ManiphestBatchEditController extends ManiphestController {
|
|||
break;
|
||||
}
|
||||
|
||||
// If this is the first project-related transaction, create a new
|
||||
// transaction object and populate it with appropriate defaults.
|
||||
|
||||
if (!$project_xaction) {
|
||||
$xaction = clone $template;
|
||||
$xaction->setTransactionType(
|
||||
ManiphestTransactionType::TYPE_PROJECTS);
|
||||
|
||||
$xactions[] = $xaction;
|
||||
$project_xaction = $xaction;
|
||||
}
|
||||
|
||||
$new = array_keys($new);
|
||||
$xaction = clone $template;
|
||||
$xaction->setTransactionType(ManiphestTransactionType::TYPE_PROJECTS);
|
||||
$xaction->setNewValue($new);
|
||||
$xactions[] = $xaction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue