Workboards - add transactions for column changes
Summary: adds ManiphestTransaction::TYPE_PROJECT_COLUMN and makes it work. Had to clean up the Javascript ever so slightly as it was sending up the string "null" when it should just omit the data in these cases. Ref T4422. NOTE: this is overall a bit buggy - e.g. move a task Foo from column A to top of column B; refresh; task Foo is at bottom of column B and should be at top of column B - but I plan on additional diff or three to clean this up. Test Plan: dragged tasks around columns. clicked on those tasks and saw some nice transactions. Reviewers: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T4422 Differential Revision: https://secure.phabricator.com/D8366
This commit is contained in:
@@ -49,12 +49,15 @@ final class PhabricatorProjectMoveController
|
||||
->execute();
|
||||
|
||||
$columns = mpull($columns, null, 'getPHID');
|
||||
if (empty($columns[$column_phid])) {
|
||||
$column = idx($columns, $column_phid);
|
||||
if (!$column) {
|
||||
// User is trying to drop this object into a nonexistent column, just kick
|
||||
// them out.
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$xactions = array();
|
||||
|
||||
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_COLUMN;
|
||||
|
||||
$query = id(new PhabricatorEdgeQuery())
|
||||
@@ -66,11 +69,14 @@ final class PhabricatorProjectMoveController
|
||||
|
||||
$edge_phids = $query->getDestinationPHIDs();
|
||||
|
||||
$this->rewriteEdges(
|
||||
$object->getPHID(),
|
||||
$edge_type,
|
||||
$column_phid,
|
||||
$edge_phids);
|
||||
$xactions[] = id(new ManiphestTransaction())
|
||||
->setTransactionType(ManiphestTransaction::TYPE_PROJECT_COLUMN)
|
||||
->setNewValue(array(
|
||||
'columnPHIDs' => array($column->getPHID()),
|
||||
'projectPHID' => $column->getProjectPHID()))
|
||||
->setOldValue(array(
|
||||
'columnPHIDs' => $edge_phids,
|
||||
'projectPHID' => $column->getProjectPHID()));
|
||||
|
||||
if ($after_phid) {
|
||||
$after_task = id(new ManiphestTaskQuery())
|
||||
@@ -84,60 +90,22 @@ final class PhabricatorProjectMoveController
|
||||
$after_pri = $after_task->getPriority();
|
||||
$after_sub = $after_task->getSubpriority();
|
||||
|
||||
$xactions = array(id(new ManiphestTransaction())
|
||||
$xactions[] = id(new ManiphestTransaction())
|
||||
->setTransactionType(ManiphestTransaction::TYPE_SUBPRIORITY)
|
||||
->setNewValue(array(
|
||||
'newPriority' => $after_pri,
|
||||
'newSubpriorityBase' => $after_sub)));
|
||||
$editor = id(new ManiphestTransactionEditor())
|
||||
->setActor($viewer)
|
||||
->setContinueOnMissingFields(true)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$editor->applyTransactions($object, $xactions);
|
||||
'newSubpriorityBase' => $after_sub));
|
||||
}
|
||||
|
||||
$editor = id(new ManiphestTransactionEditor())
|
||||
->setActor($viewer)
|
||||
->setContinueOnMissingFields(true)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$editor->applyTransactions($object, $xactions);
|
||||
|
||||
return id(new AphrontAjaxResponse())->setContent(array());
|
||||
}
|
||||
|
||||
private function rewriteEdges($src, $edge_type, $dst, array $edges) {
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
// NOTE: Normally, we expect only one edge to exist, but this works in a
|
||||
// general way so it will repair any stray edges.
|
||||
|
||||
$remove = array();
|
||||
$edge_missing = true;
|
||||
foreach ($edges as $phid) {
|
||||
if ($phid == $dst) {
|
||||
$edge_missing = false;
|
||||
} else {
|
||||
$remove[] = $phid;
|
||||
}
|
||||
}
|
||||
|
||||
$add = array();
|
||||
if ($edge_missing) {
|
||||
$add[] = $dst;
|
||||
}
|
||||
|
||||
if (!$add && !$remove) {
|
||||
return;
|
||||
}
|
||||
|
||||
$editor = id(new PhabricatorEdgeEditor())
|
||||
->setActor($viewer)
|
||||
->setSuppressEvents(true);
|
||||
|
||||
foreach ($add as $phid) {
|
||||
$editor->addEdge($src, $edge_type, $phid);
|
||||
}
|
||||
foreach ($remove as $phid) {
|
||||
$editor->removeEdge($src, $edge_type, $phid);
|
||||
}
|
||||
|
||||
$editor->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user