1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-14 00:31:05 +01:00

Basic Answer Wiki for Ponder

Summary: Adds an additional field for questions, an answer wiki, should should usually be community editable.

Test Plan: New question, edit question, no wiki, lots of wiki.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14003
This commit is contained in:
Chad Little 2015-08-29 13:59:33 -07:00
parent 96e7f766ff
commit 2665970762
6 changed files with 57 additions and 1 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_ponder.ponder_question
ADD answerWiki LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL;

View file

@ -32,6 +32,7 @@ final class PonderQuestionEditController extends PonderController {
$v_title = $question->getTitle();
$v_content = $question->getContent();
$v_wiki = $question->getAnswerWiki();
$v_view = $question->getViewPolicy();
$v_space = $question->getSpacePHID();
$v_status = $question->getStatus();
@ -42,6 +43,7 @@ final class PonderQuestionEditController extends PonderController {
if ($request->isFormPost()) {
$v_title = $request->getStr('title');
$v_content = $request->getStr('content');
$v_wiki = $request->getStr('answerWiki');
$v_projects = $request->getArr('projects');
$v_view = $request->getStr('viewPolicy');
$v_space = $request->getStr('spacePHID');
@ -68,6 +70,10 @@ final class PonderQuestionEditController extends PonderController {
->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT)
->setNewValue($v_content);
$xactions[] = id(clone $template)
->setTransactionType(PonderQuestionTransaction::TYPE_ANSWERWIKI)
->setNewValue($v_wiki);
if (!$is_new) {
$xactions[] = id(clone $template)
->setTransactionType(PonderQuestionTransaction::TYPE_STATUS)
@ -119,7 +125,15 @@ final class PonderQuestionEditController extends PonderController {
->setName('content')
->setID('content')
->setValue($v_content)
->setLabel(pht('Description'))
->setLabel(pht('Question Details'))
->setUser($viewer))
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($viewer)
->setName('answerWiki')
->setID('answerWiki')
->setValue($v_wiki)
->setLabel(pht('Answer Summary'))
->setUser($viewer))
->appendControl(
id(new AphrontFormPolicyControl())
@ -157,6 +171,11 @@ final class PonderQuestionEditController extends PonderController {
->setControlID('content')
->setPreviewURI($this->getApplicationURI('preview/'));
$answer_preview = id(new PHUIRemarkupPreviewPanel())
->setHeader(pht('Answer Summary Preview'))
->setControlID('answerWiki')
->setPreviewURI($this->getApplicationURI('preview/'));
$crumbs = $this->buildApplicationCrumbs();
$id = $question->getID();
@ -179,6 +198,7 @@ final class PonderQuestionEditController extends PonderController {
$crumbs,
$form_box,
$preview,
$answer_preview,
),
array(
'title' => $title,

View file

@ -98,10 +98,20 @@ final class PonderQuestionViewController extends PonderController {
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
$crumbs->addTextCrumb('Q'.$id, '/Q'.$id);
$answer_wiki = null;
if ($question->getAnswerWiki()) {
$answer = phutil_tag_div('mlt mlb msr msl', $question->getAnswerWiki());
$answer_wiki = id(new PHUIObjectBoxView())
->setHeaderText(pht('Answer Summary'))
->setColor(PHUIObjectBoxView::COLOR_BLUE)
->appendChild($answer);
}
$ponder_view = id(new PHUITwoColumnView())
->setMainColumn(array(
$object_box,
$comment_view,
$answer_wiki,
$answers,
$answer_add_panel,
))

View file

@ -74,6 +74,7 @@ final class PonderQuestionEditor
$types[] = PonderQuestionTransaction::TYPE_CONTENT;
$types[] = PonderQuestionTransaction::TYPE_ANSWERS;
$types[] = PonderQuestionTransaction::TYPE_STATUS;
$types[] = PonderQuestionTransaction::TYPE_ANSWERWIKI;
return $types;
}
@ -91,6 +92,8 @@ final class PonderQuestionEditor
return mpull($object->getAnswers(), 'getPHID');
case PonderQuestionTransaction::TYPE_STATUS:
return $object->getStatus();
case PonderQuestionTransaction::TYPE_ANSWERWIKI:
return $object->getAnswerWiki();
}
}
@ -102,6 +105,7 @@ final class PonderQuestionEditor
case PonderQuestionTransaction::TYPE_TITLE:
case PonderQuestionTransaction::TYPE_CONTENT:
case PonderQuestionTransaction::TYPE_STATUS:
case PonderQuestionTransaction::TYPE_ANSWERWIKI:
return $xaction->getNewValue();
case PonderQuestionTransaction::TYPE_ANSWERS:
$raw_new_value = $xaction->getNewValue();
@ -136,6 +140,9 @@ final class PonderQuestionEditor
case PonderQuestionTransaction::TYPE_STATUS:
$object->setStatus($xaction->getNewValue());
break;
case PonderQuestionTransaction::TYPE_ANSWERWIKI:
$object->setAnswerWiki($xaction->getNewValue());
break;
case PonderQuestionTransaction::TYPE_ANSWERS:
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();
@ -167,6 +174,7 @@ final class PonderQuestionEditor
case PonderQuestionTransaction::TYPE_TITLE:
case PonderQuestionTransaction::TYPE_CONTENT:
case PonderQuestionTransaction::TYPE_STATUS:
case PonderQuestionTransaction::TYPE_ANSWERWIKI:
return $v;
}

View file

@ -20,6 +20,7 @@ final class PonderQuestion extends PonderDAO
protected $authorPHID;
protected $status;
protected $content;
protected $answerWiki;
protected $contentSource;
protected $viewPolicy;
protected $spacePHID;
@ -56,6 +57,7 @@ final class PonderQuestion extends PonderDAO
'title' => 'text255',
'status' => 'text32',
'content' => 'text',
'answerWiki' => 'text',
'answerCount' => 'uint32',
'mailKey' => 'bytes20',

View file

@ -7,6 +7,7 @@ final class PonderQuestionTransaction
const TYPE_CONTENT = 'ponder.question:content';
const TYPE_ANSWERS = 'ponder.question:answer';
const TYPE_STATUS = 'ponder.question:status';
const TYPE_ANSWERWIKI = 'ponder.question:wiki';
const MAILTAG_DETAILS = 'question:details';
const MAILTAG_COMMENT = 'question:comment';
@ -78,6 +79,10 @@ final class PonderQuestionTransaction
return pht(
'%s edited the question description.',
$this->renderHandleLink($author_phid));
case self::TYPE_ANSWERWIKI:
return pht(
'%s edited the question answer wiki.',
$this->renderHandleLink($author_phid));
case self::TYPE_ANSWERS:
$answer_handle = $this->getHandle($this->getNewAnswerPHID());
$question_handle = $this->getHandle($object_phid);
@ -120,6 +125,7 @@ final class PonderQuestionTransaction
case self::TYPE_TITLE:
case self::TYPE_CONTENT:
case self::TYPE_STATUS:
case self::TYPE_ANSWERWIKI:
$tags[] = self::MAILTAG_DETAILS;
break;
case self::TYPE_ANSWERS:
@ -139,6 +145,7 @@ final class PonderQuestionTransaction
switch ($this->getTransactionType()) {
case self::TYPE_TITLE:
case self::TYPE_CONTENT:
case self::TYPE_ANSWERWIKI:
return 'fa-pencil';
case self::TYPE_STATUS:
return PonderQuestionStatus::getQuestionStatusIcon($new);
@ -156,6 +163,7 @@ final class PonderQuestionTransaction
switch ($this->getTransactionType()) {
case self::TYPE_TITLE:
case self::TYPE_CONTENT:
case self::TYPE_ANSWERWIKI:
return PhabricatorTransactions::COLOR_BLUE;
case self::TYPE_ANSWERS:
return PhabricatorTransactions::COLOR_GREEN;
@ -167,6 +175,7 @@ final class PonderQuestionTransaction
public function hasChangeDetails() {
switch ($this->getTransactionType()) {
case self::TYPE_CONTENT:
case self::TYPE_ANSWERWIKI:
return true;
}
return parent::hasChangeDetails();
@ -253,6 +262,11 @@ final class PonderQuestionTransaction
'%s edited the description of %s',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
case self::TYPE_ANSWERWIKI:
return pht(
'%s edited the answer wiki for %s',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
case self::TYPE_ANSWERS:
$answer_handle = $this->getHandle($this->getNewAnswerPHID());
$question_handle = $this->getHandle($object_phid);