diff --git a/resources/sql/autopatches/20150828.ponder.wiki.1.sql b/resources/sql/autopatches/20150828.ponder.wiki.1.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20150828.ponder.wiki.1.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_ponder.ponder_question + ADD answerWiki LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL; diff --git a/src/applications/ponder/controller/PonderQuestionEditController.php b/src/applications/ponder/controller/PonderQuestionEditController.php --- a/src/applications/ponder/controller/PonderQuestionEditController.php +++ b/src/applications/ponder/controller/PonderQuestionEditController.php @@ -32,6 +32,7 @@ $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 @@ 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 @@ ->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 @@ ->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 @@ ->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 @@ $crumbs, $form_box, $preview, + $answer_preview, ), array( 'title' => $title, diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php --- a/src/applications/ponder/controller/PonderQuestionViewController.php +++ b/src/applications/ponder/controller/PonderQuestionViewController.php @@ -98,10 +98,20 @@ $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, )) diff --git a/src/applications/ponder/editor/PonderQuestionEditor.php b/src/applications/ponder/editor/PonderQuestionEditor.php --- a/src/applications/ponder/editor/PonderQuestionEditor.php +++ b/src/applications/ponder/editor/PonderQuestionEditor.php @@ -74,6 +74,7 @@ $types[] = PonderQuestionTransaction::TYPE_CONTENT; $types[] = PonderQuestionTransaction::TYPE_ANSWERS; $types[] = PonderQuestionTransaction::TYPE_STATUS; + $types[] = PonderQuestionTransaction::TYPE_ANSWERWIKI; return $types; } @@ -91,6 +92,8 @@ return mpull($object->getAnswers(), 'getPHID'); case PonderQuestionTransaction::TYPE_STATUS: return $object->getStatus(); + case PonderQuestionTransaction::TYPE_ANSWERWIKI: + return $object->getAnswerWiki(); } } @@ -102,6 +105,7 @@ 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 @@ 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 @@ case PonderQuestionTransaction::TYPE_TITLE: case PonderQuestionTransaction::TYPE_CONTENT: case PonderQuestionTransaction::TYPE_STATUS: + case PonderQuestionTransaction::TYPE_ANSWERWIKI: return $v; } diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php --- a/src/applications/ponder/storage/PonderQuestion.php +++ b/src/applications/ponder/storage/PonderQuestion.php @@ -20,6 +20,7 @@ protected $authorPHID; protected $status; protected $content; + protected $answerWiki; protected $contentSource; protected $viewPolicy; protected $spacePHID; @@ -56,6 +57,7 @@ 'title' => 'text255', 'status' => 'text32', 'content' => 'text', + 'answerWiki' => 'text', 'answerCount' => 'uint32', 'mailKey' => 'bytes20', diff --git a/src/applications/ponder/storage/PonderQuestionTransaction.php b/src/applications/ponder/storage/PonderQuestionTransaction.php --- a/src/applications/ponder/storage/PonderQuestionTransaction.php +++ b/src/applications/ponder/storage/PonderQuestionTransaction.php @@ -7,6 +7,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ public function hasChangeDetails() { switch ($this->getTransactionType()) { case self::TYPE_CONTENT: + case self::TYPE_ANSWERWIKI: return true; } return parent::hasChangeDetails(); @@ -253,6 +262,11 @@ '%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);