1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-14 16:51:08 +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_title = $question->getTitle();
$v_content = $question->getContent(); $v_content = $question->getContent();
$v_wiki = $question->getAnswerWiki();
$v_view = $question->getViewPolicy(); $v_view = $question->getViewPolicy();
$v_space = $question->getSpacePHID(); $v_space = $question->getSpacePHID();
$v_status = $question->getStatus(); $v_status = $question->getStatus();
@ -42,6 +43,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_wiki = $request->getStr('answerWiki');
$v_projects = $request->getArr('projects'); $v_projects = $request->getArr('projects');
$v_view = $request->getStr('viewPolicy'); $v_view = $request->getStr('viewPolicy');
$v_space = $request->getStr('spacePHID'); $v_space = $request->getStr('spacePHID');
@ -68,6 +70,10 @@ final class PonderQuestionEditController extends PonderController {
->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT) ->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT)
->setNewValue($v_content); ->setNewValue($v_content);
$xactions[] = id(clone $template)
->setTransactionType(PonderQuestionTransaction::TYPE_ANSWERWIKI)
->setNewValue($v_wiki);
if (!$is_new) { if (!$is_new) {
$xactions[] = id(clone $template) $xactions[] = id(clone $template)
->setTransactionType(PonderQuestionTransaction::TYPE_STATUS) ->setTransactionType(PonderQuestionTransaction::TYPE_STATUS)
@ -119,7 +125,15 @@ final class PonderQuestionEditController extends PonderController {
->setName('content') ->setName('content')
->setID('content') ->setID('content')
->setValue($v_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)) ->setUser($viewer))
->appendControl( ->appendControl(
id(new AphrontFormPolicyControl()) id(new AphrontFormPolicyControl())
@ -157,6 +171,11 @@ final class PonderQuestionEditController extends PonderController {
->setControlID('content') ->setControlID('content')
->setPreviewURI($this->getApplicationURI('preview/')); ->setPreviewURI($this->getApplicationURI('preview/'));
$answer_preview = id(new PHUIRemarkupPreviewPanel())
->setHeader(pht('Answer Summary Preview'))
->setControlID('answerWiki')
->setPreviewURI($this->getApplicationURI('preview/'));
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$id = $question->getID(); $id = $question->getID();
@ -179,6 +198,7 @@ final class PonderQuestionEditController extends PonderController {
$crumbs, $crumbs,
$form_box, $form_box,
$preview, $preview,
$answer_preview,
), ),
array( array(
'title' => $title, 'title' => $title,

View file

@ -98,10 +98,20 @@ final class PonderQuestionViewController extends PonderController {
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
$crumbs->addTextCrumb('Q'.$id, '/Q'.$id); $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()) $ponder_view = id(new PHUITwoColumnView())
->setMainColumn(array( ->setMainColumn(array(
$object_box, $object_box,
$comment_view, $comment_view,
$answer_wiki,
$answers, $answers,
$answer_add_panel, $answer_add_panel,
)) ))

View file

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

View file

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

View file

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