1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +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) {
return new Aphront404Response();
}
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
$question->getPHID(),
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
$v_projects = array_reverse($v_projects);
} else {
$question = id(new PonderQuestion())
->setStatus(PonderQuestionStatus::STATUS_OPEN)
@ -32,6 +36,7 @@ final class PonderQuestionEditController extends PonderController {
->setVoteCount(0)
->setAnswerCount(0)
->setHeat(0.0);
$v_projects = array();
}
$v_title = $question->getTitle();
@ -42,6 +47,7 @@ final class PonderQuestionEditController extends PonderController {
if ($request->isFormPost()) {
$v_title = $request->getStr('title');
$v_content = $request->getStr('content');
$v_projects = $request->getArr('projects');
$len = phutil_utf8_strlen($v_title);
if ($len < 1) {
@ -64,6 +70,12 @@ final class PonderQuestionEditController extends PonderController {
->setTransactionType(PonderQuestionTransaction::TYPE_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())
->setActor($user)
->setContentSourceFromRequest($request)
@ -90,11 +102,25 @@ final class PonderQuestionEditController extends PonderController {
->setID('content')
->setValue($v_content)
->setLabel(pht('Description'))
->setUser($user))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($this->getApplicationURI())
->setValue(pht('Ask Away!')));
->setUser($user));
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())
->addCancelButton($this->getApplicationURI())
->setValue(pht('Ask Away!')));
$preview = id(new PHUIRemarkupPreviewPanel())
->setHeader(pht('Question Preview'))

View file

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

View file

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