1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Add project tags to PonderQuestion

Summary: T2628, adding project tags to ponder questions

Test Plan: Create ponder question, add project tag, save, project tag should show in question properties on question view.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D9447
This commit is contained in:
lkassianik 2014-06-10 11:18:03 -07:00 committed by epriestley
parent 6df8c4a426
commit 0bdf18fdd2
3 changed files with 35 additions and 6 deletions

View file

@ -25,6 +25,10 @@ final class PonderQuestionEditController extends PonderController {
if (!$question) { if (!$question) {
return new Aphront404Response(); return new Aphront404Response();
} }
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
$question->getPHID(),
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
$v_projects = array_reverse($v_projects);
} else { } else {
$question = id(new PonderQuestion()) $question = id(new PonderQuestion())
->setStatus(PonderQuestionStatus::STATUS_OPEN) ->setStatus(PonderQuestionStatus::STATUS_OPEN)
@ -32,6 +36,7 @@ final class PonderQuestionEditController extends PonderController {
->setVoteCount(0) ->setVoteCount(0)
->setAnswerCount(0) ->setAnswerCount(0)
->setHeat(0.0); ->setHeat(0.0);
$v_projects = array();
} }
$v_title = $question->getTitle(); $v_title = $question->getTitle();
@ -42,6 +47,7 @@ final class PonderQuestionEditController extends PonderController {
if ($request->isFormPost()) { if ($request->isFormPost()) {
$v_title = $request->getStr('title'); $v_title = $request->getStr('title');
$v_content = $request->getStr('content'); $v_content = $request->getStr('content');
$v_projects = $request->getArr('projects');
$len = phutil_utf8_strlen($v_title); $len = phutil_utf8_strlen($v_title);
if ($len < 1) { if ($len < 1) {
@ -64,6 +70,12 @@ final class PonderQuestionEditController extends PonderController {
->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT) ->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT)
->setNewValue($v_content); ->setNewValue($v_content);
$proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT;
$xactions[] = id(new PonderQuestionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue('edge:type', $proj_edge_type)
->setNewValue(array('=' => array_fuse($v_projects)));
$editor = id(new PonderQuestionEditor()) $editor = id(new PonderQuestionEditor())
->setActor($user) ->setActor($user)
->setContentSourceFromRequest($request) ->setContentSourceFromRequest($request)
@ -90,8 +102,22 @@ final class PonderQuestionEditController extends PonderController {
->setID('content') ->setID('content')
->setValue($v_content) ->setValue($v_content)
->setLabel(pht('Description')) ->setLabel(pht('Description'))
->setUser($user)) ->setUser($user));
->appendChild(
if ($v_projects) {
$project_handles = $this->loadViewerHandles($v_projects);
} else {
$project_handles = array();
}
$form->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Projects'))
->setName('projects')
->setValue($project_handles)
->setDatasource('/typeahead/common/projects/'));
$form ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->addCancelButton($this->getApplicationURI()) ->addCancelButton($this->getApplicationURI())
->setValue(pht('Ask Away!'))); ->setValue(pht('Ask Away!')));

View file

@ -141,6 +141,8 @@ final class PonderQuestionEditor
$object->setAnswerCount($count); $object->setAnswerCount($count);
break; break;
case PhabricatorTransactions::TYPE_EDGE:
return;
} }
} }

View file

@ -7,7 +7,8 @@ final class PonderQuestion extends PonderDAO
PhabricatorSubscribableInterface, PhabricatorSubscribableInterface,
PhabricatorFlaggableInterface, PhabricatorFlaggableInterface,
PhabricatorPolicyInterface, PhabricatorPolicyInterface,
PhabricatorTokenReceiverInterface { PhabricatorTokenReceiverInterface,
PhabricatorProjectInterface {
const MARKUP_FIELD_CONTENT = 'markup:content'; const MARKUP_FIELD_CONTENT = 'markup:content';