From 68df3cebc83468bcf8c0ebf7b77a54a19909c9ce Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 23 Aug 2017 13:11:21 -0700 Subject: [PATCH] Allow task parents and subtasks to be edited via Conduit API Summary: See PHI39. This adds support for editing parents and subtasks of a task via Conduit. It might be nice to tie this into the `PhabricatorObjectRelationship` stuff eventually, but I think we'd effectively end up in the same place anyway in terms of what the API looks like. Test Plan: {F5116163} Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D18456 --- .../maniphest/editor/ManiphestEditEngine.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php index 9f5e647ca9..b4ca86a442 100644 --- a/src/applications/maniphest/editor/ManiphestEditEngine.php +++ b/src/applications/maniphest/editor/ManiphestEditEngine.php @@ -251,6 +251,56 @@ EODOCS id(new PHUIRemarkupPreviewPanel()) ->setHeader(pht('Description Preview'))); + $parent_type = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST; + $subtask_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST; + + $src_phid = $object->getPHID(); + if ($src_phid) { + $edge_query = id(new PhabricatorEdgeQuery()) + ->withSourcePHIDs(array($src_phid)) + ->withEdgeTypes( + array( + $parent_type, + $subtask_type, + )); + $edge_query->execute(); + + $parent_phids = $edge_query->getDestinationPHIDs( + array($src_phid), + array($parent_type)); + + $subtask_phids = $edge_query->getDestinationPHIDs( + array($src_phid), + array($subtask_type)); + } else { + $parent_phids = array(); + $subtask_phids = array(); + } + + $fields[] = id(new PhabricatorHandlesEditField()) + ->setKey('parents') + ->setLabel(pht('Parents')) + ->setDescription(pht('Parent tasks.')) + ->setConduitDescription(pht('Change the parents of this task.')) + ->setConduitTypeDescription(pht('List of parent task PHIDs.')) + ->setUseEdgeTransactions(true) + ->setIsConduitOnly(true) + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $parent_type) + ->setValue($parent_phids); + + $fields[] = id(new PhabricatorHandlesEditField()) + ->setKey('subtasks') + ->setLabel(pht('Subtasks')) + ->setDescription(pht('Subtasks.')) + ->setConduitDescription(pht('Change the subtasks of this task.')) + ->setConduitTypeDescription(pht('List of subtask PHIDs.')) + ->setUseEdgeTransactions(true) + ->setIsConduitOnly(true) + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $subtask_type) + ->setValue($parent_phids); + return $fields; }