From 15a1f083016010eeb622bf966cc64fe2b779ec1e Mon Sep 17 00:00:00 2001 From: lkassianik Date: Tue, 24 Jun 2014 10:13:18 -0700 Subject: [PATCH] Adding project tags to slowvote polls Summary: T2628, project tags in slowvote polls Test Plan: Open poll, edit, add project tags, save. Poll should show tagged projects and a relevant transaction. (transaction doesn't currently show up) Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9708 --- .../PhabricatorSlowvoteEditController.php | 30 ++++++++++++++++++- .../editor/PhabricatorSlowvoteEditor.php | 2 ++ .../storage/PhabricatorSlowvotePoll.php | 3 +- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php index 9b41276874..a5353f174b 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php @@ -36,6 +36,15 @@ final class PhabricatorSlowvoteEditController $is_new = true; } + if ($is_new) { + $v_projects = array(); + } else { + $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs( + $poll->getPHID(), + PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + $v_projects = array_reverse($v_projects); + } + $e_question = true; $e_response = true; $errors = array(); @@ -52,6 +61,7 @@ final class PhabricatorSlowvoteEditController $v_responses = (int)$request->getInt('responses'); $v_shuffle = (int)$request->getBool('shuffle'); $v_view_policy = $request->getStr('viewPolicy'); + $v_projects = $request->getArr('projects'); if ($is_new) { $poll->setMethod($request->getInt('method')); @@ -98,6 +108,12 @@ final class PhabricatorSlowvoteEditController ->setNewValue($v_view_policy); if (empty($errors)) { + $proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT; + $xactions[] = id(new PhabricatorSlowvoteTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $proj_edge_type) + ->setNewValue(array('=' => array_fuse($v_projects))); + $editor = id(new PhabricatorSlowvoteEditor()) ->setActor($user) ->setContinueOnNoEffect(true) @@ -132,6 +148,12 @@ final class PhabricatorSlowvoteEditController pht('Resolve issues and build consensus through '. 'protracted deliberation.')); + if ($v_projects) { + $project_handles = $this->loadViewerHandles($v_projects); + } else { + $project_handles = array(); + } + $form = id(new AphrontFormView()) ->setUser($user) ->appendChild($instructions) @@ -146,7 +168,13 @@ final class PhabricatorSlowvoteEditController id(new PhabricatorRemarkupControl()) ->setLabel(pht('Description')) ->setName('description') - ->setValue($v_description)); + ->setValue($v_description)) + ->appendChild( + id(new AphrontFormTokenizerControl()) + ->setLabel(pht('Projects')) + ->setName('projects') + ->setValue($project_handles) + ->setDatasource('/typeahead/common/projects/')); if ($is_new) { for ($ii = 0; $ii < 10; $ii++) { diff --git a/src/applications/slowvote/editor/PhabricatorSlowvoteEditor.php b/src/applications/slowvote/editor/PhabricatorSlowvoteEditor.php index 9d85cfe949..bef46d517a 100644 --- a/src/applications/slowvote/editor/PhabricatorSlowvoteEditor.php +++ b/src/applications/slowvote/editor/PhabricatorSlowvoteEditor.php @@ -94,6 +94,8 @@ final class PhabricatorSlowvoteEditor case PhabricatorSlowvoteTransaction::TYPE_CLOSE: $object->setIsClosed((int)$xaction->getNewValue()); break; + case PhabricatorTransactions::TYPE_EDGE: + return; } } diff --git a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php index ee01088246..9de418f937 100644 --- a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php +++ b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php @@ -8,7 +8,8 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO PhabricatorPolicyInterface, PhabricatorSubscribableInterface, PhabricatorFlaggableInterface, - PhabricatorTokenReceiverInterface { + PhabricatorTokenReceiverInterface, + PhabricatorProjectInterface { const RESPONSES_VISIBLE = 0; const RESPONSES_VOTERS = 1;