Skip to content

Commit

Permalink
Basic Answer Wiki for Ponder
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Chad Little committed Aug 29, 2015
1 parent 96e7f76 commit 2665970
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 1 deletion.
2 changes: 2 additions & 0 deletions resources/sql/autopatches/20150828.ponder.wiki.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_ponder.ponder_question
ADD answerWiki LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function handleRequest(AphrontRequest $request) {

$v_title = $question->getTitle();
$v_content = $question->getContent();
$v_wiki = $question->getAnswerWiki();
$v_view = $question->getViewPolicy();
$v_space = $question->getSpacePHID();
$v_status = $question->getStatus();
Expand All @@ -42,6 +43,7 @@ public function handleRequest(AphrontRequest $request) {
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');
Expand All @@ -68,6 +70,10 @@ public function handleRequest(AphrontRequest $request) {
->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)
Expand Down Expand Up @@ -119,7 +125,15 @@ public function handleRequest(AphrontRequest $request) {
->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())
Expand Down Expand Up @@ -157,6 +171,11 @@ public function handleRequest(AphrontRequest $request) {
->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();
Expand All @@ -179,6 +198,7 @@ public function handleRequest(AphrontRequest $request) {
$crumbs,
$form_box,
$preview,
$answer_preview,
),
array(
'title' => $title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,20 @@ public function handleRequest(AphrontRequest $request) {
$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,
))
Expand Down
8 changes: 8 additions & 0 deletions src/applications/ponder/editor/PonderQuestionEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function getTransactionTypes() {
$types[] = PonderQuestionTransaction::TYPE_CONTENT;
$types[] = PonderQuestionTransaction::TYPE_ANSWERS;
$types[] = PonderQuestionTransaction::TYPE_STATUS;
$types[] = PonderQuestionTransaction::TYPE_ANSWERWIKI;

return $types;
}
Expand All @@ -91,6 +92,8 @@ protected function getCustomTransactionOldValue(
return mpull($object->getAnswers(), 'getPHID');
case PonderQuestionTransaction::TYPE_STATUS:
return $object->getStatus();
case PonderQuestionTransaction::TYPE_ANSWERWIKI:
return $object->getAnswerWiki();
}
}

Expand All @@ -102,6 +105,7 @@ protected function getCustomTransactionNewValue(
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();
Expand Down Expand Up @@ -136,6 +140,9 @@ protected function applyCustomInternalTransaction(
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();
Expand Down Expand Up @@ -167,6 +174,7 @@ protected function mergeTransactions(
case PonderQuestionTransaction::TYPE_TITLE:
case PonderQuestionTransaction::TYPE_CONTENT:
case PonderQuestionTransaction::TYPE_STATUS:
case PonderQuestionTransaction::TYPE_ANSWERWIKI:
return $v;
}

Expand Down
2 changes: 2 additions & 0 deletions src/applications/ponder/storage/PonderQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ final class PonderQuestion extends PonderDAO
protected $authorPHID;
protected $status;
protected $content;
protected $answerWiki;
protected $contentSource;
protected $viewPolicy;
protected $spacePHID;
Expand Down Expand Up @@ -56,6 +57,7 @@ protected function getConfiguration() {
'title' => 'text255',
'status' => 'text32',
'content' => 'text',
'answerWiki' => 'text',
'answerCount' => 'uint32',
'mailKey' => 'bytes20',

Expand Down
14 changes: 14 additions & 0 deletions src/applications/ponder/storage/PonderQuestionTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -78,6 +79,10 @@ public function getTitle() {
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);
Expand Down Expand Up @@ -120,6 +125,7 @@ public function getMailTags() {
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:
Expand All @@ -139,6 +145,7 @@ public function getIcon() {
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);
Expand All @@ -156,6 +163,7 @@ public function getColor() {
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;
Expand All @@ -167,6 +175,7 @@ public function getColor() {
public function hasChangeDetails() {
switch ($this->getTransactionType()) {
case self::TYPE_CONTENT:
case self::TYPE_ANSWERWIKI:
return true;
}
return parent::hasChangeDetails();
Expand Down Expand Up @@ -253,6 +262,11 @@ public function getTitleForFeed() {
'%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);
Expand Down

0 comments on commit 2665970

Please sign in to comment.