Skip to content

Commit 2665970

Browse files
author
Chad Little
committed
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
1 parent 96e7f76 commit 2665970

File tree

6 files changed

+57
-1
lines changed

6 files changed

+57
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE {$NAMESPACE}_ponder.ponder_question
2+
ADD answerWiki LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL;

src/applications/ponder/controller/PonderQuestionEditController.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function handleRequest(AphrontRequest $request) {
3232

3333
$v_title = $question->getTitle();
3434
$v_content = $question->getContent();
35+
$v_wiki = $question->getAnswerWiki();
3536
$v_view = $question->getViewPolicy();
3637
$v_space = $question->getSpacePHID();
3738
$v_status = $question->getStatus();
@@ -42,6 +43,7 @@ public function handleRequest(AphrontRequest $request) {
4243
if ($request->isFormPost()) {
4344
$v_title = $request->getStr('title');
4445
$v_content = $request->getStr('content');
46+
$v_wiki = $request->getStr('answerWiki');
4547
$v_projects = $request->getArr('projects');
4648
$v_view = $request->getStr('viewPolicy');
4749
$v_space = $request->getStr('spacePHID');
@@ -68,6 +70,10 @@ public function handleRequest(AphrontRequest $request) {
6870
->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT)
6971
->setNewValue($v_content);
7072

73+
$xactions[] = id(clone $template)
74+
->setTransactionType(PonderQuestionTransaction::TYPE_ANSWERWIKI)
75+
->setNewValue($v_wiki);
76+
7177
if (!$is_new) {
7278
$xactions[] = id(clone $template)
7379
->setTransactionType(PonderQuestionTransaction::TYPE_STATUS)
@@ -119,7 +125,15 @@ public function handleRequest(AphrontRequest $request) {
119125
->setName('content')
120126
->setID('content')
121127
->setValue($v_content)
122-
->setLabel(pht('Description'))
128+
->setLabel(pht('Question Details'))
129+
->setUser($viewer))
130+
->appendChild(
131+
id(new PhabricatorRemarkupControl())
132+
->setUser($viewer)
133+
->setName('answerWiki')
134+
->setID('answerWiki')
135+
->setValue($v_wiki)
136+
->setLabel(pht('Answer Summary'))
123137
->setUser($viewer))
124138
->appendControl(
125139
id(new AphrontFormPolicyControl())
@@ -157,6 +171,11 @@ public function handleRequest(AphrontRequest $request) {
157171
->setControlID('content')
158172
->setPreviewURI($this->getApplicationURI('preview/'));
159173

174+
$answer_preview = id(new PHUIRemarkupPreviewPanel())
175+
->setHeader(pht('Answer Summary Preview'))
176+
->setControlID('answerWiki')
177+
->setPreviewURI($this->getApplicationURI('preview/'));
178+
160179
$crumbs = $this->buildApplicationCrumbs();
161180

162181
$id = $question->getID();
@@ -179,6 +198,7 @@ public function handleRequest(AphrontRequest $request) {
179198
$crumbs,
180199
$form_box,
181200
$preview,
201+
$answer_preview,
182202
),
183203
array(
184204
'title' => $title,

src/applications/ponder/controller/PonderQuestionViewController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,20 @@ public function handleRequest(AphrontRequest $request) {
9898
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
9999
$crumbs->addTextCrumb('Q'.$id, '/Q'.$id);
100100

101+
$answer_wiki = null;
102+
if ($question->getAnswerWiki()) {
103+
$answer = phutil_tag_div('mlt mlb msr msl', $question->getAnswerWiki());
104+
$answer_wiki = id(new PHUIObjectBoxView())
105+
->setHeaderText(pht('Answer Summary'))
106+
->setColor(PHUIObjectBoxView::COLOR_BLUE)
107+
->appendChild($answer);
108+
}
109+
101110
$ponder_view = id(new PHUITwoColumnView())
102111
->setMainColumn(array(
103112
$object_box,
104113
$comment_view,
114+
$answer_wiki,
105115
$answers,
106116
$answer_add_panel,
107117
))

src/applications/ponder/editor/PonderQuestionEditor.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function getTransactionTypes() {
7474
$types[] = PonderQuestionTransaction::TYPE_CONTENT;
7575
$types[] = PonderQuestionTransaction::TYPE_ANSWERS;
7676
$types[] = PonderQuestionTransaction::TYPE_STATUS;
77+
$types[] = PonderQuestionTransaction::TYPE_ANSWERWIKI;
7778

7879
return $types;
7980
}
@@ -91,6 +92,8 @@ protected function getCustomTransactionOldValue(
9192
return mpull($object->getAnswers(), 'getPHID');
9293
case PonderQuestionTransaction::TYPE_STATUS:
9394
return $object->getStatus();
95+
case PonderQuestionTransaction::TYPE_ANSWERWIKI:
96+
return $object->getAnswerWiki();
9497
}
9598
}
9699

@@ -102,6 +105,7 @@ protected function getCustomTransactionNewValue(
102105
case PonderQuestionTransaction::TYPE_TITLE:
103106
case PonderQuestionTransaction::TYPE_CONTENT:
104107
case PonderQuestionTransaction::TYPE_STATUS:
108+
case PonderQuestionTransaction::TYPE_ANSWERWIKI:
105109
return $xaction->getNewValue();
106110
case PonderQuestionTransaction::TYPE_ANSWERS:
107111
$raw_new_value = $xaction->getNewValue();
@@ -136,6 +140,9 @@ protected function applyCustomInternalTransaction(
136140
case PonderQuestionTransaction::TYPE_STATUS:
137141
$object->setStatus($xaction->getNewValue());
138142
break;
143+
case PonderQuestionTransaction::TYPE_ANSWERWIKI:
144+
$object->setAnswerWiki($xaction->getNewValue());
145+
break;
139146
case PonderQuestionTransaction::TYPE_ANSWERS:
140147
$old = $xaction->getOldValue();
141148
$new = $xaction->getNewValue();
@@ -167,6 +174,7 @@ protected function mergeTransactions(
167174
case PonderQuestionTransaction::TYPE_TITLE:
168175
case PonderQuestionTransaction::TYPE_CONTENT:
169176
case PonderQuestionTransaction::TYPE_STATUS:
177+
case PonderQuestionTransaction::TYPE_ANSWERWIKI:
170178
return $v;
171179
}
172180

src/applications/ponder/storage/PonderQuestion.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ final class PonderQuestion extends PonderDAO
2020
protected $authorPHID;
2121
protected $status;
2222
protected $content;
23+
protected $answerWiki;
2324
protected $contentSource;
2425
protected $viewPolicy;
2526
protected $spacePHID;
@@ -56,6 +57,7 @@ protected function getConfiguration() {
5657
'title' => 'text255',
5758
'status' => 'text32',
5859
'content' => 'text',
60+
'answerWiki' => 'text',
5961
'answerCount' => 'uint32',
6062
'mailKey' => 'bytes20',
6163

src/applications/ponder/storage/PonderQuestionTransaction.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ final class PonderQuestionTransaction
77
const TYPE_CONTENT = 'ponder.question:content';
88
const TYPE_ANSWERS = 'ponder.question:answer';
99
const TYPE_STATUS = 'ponder.question:status';
10+
const TYPE_ANSWERWIKI = 'ponder.question:wiki';
1011

1112
const MAILTAG_DETAILS = 'question:details';
1213
const MAILTAG_COMMENT = 'question:comment';
@@ -78,6 +79,10 @@ public function getTitle() {
7879
return pht(
7980
'%s edited the question description.',
8081
$this->renderHandleLink($author_phid));
82+
case self::TYPE_ANSWERWIKI:
83+
return pht(
84+
'%s edited the question answer wiki.',
85+
$this->renderHandleLink($author_phid));
8186
case self::TYPE_ANSWERS:
8287
$answer_handle = $this->getHandle($this->getNewAnswerPHID());
8388
$question_handle = $this->getHandle($object_phid);
@@ -120,6 +125,7 @@ public function getMailTags() {
120125
case self::TYPE_TITLE:
121126
case self::TYPE_CONTENT:
122127
case self::TYPE_STATUS:
128+
case self::TYPE_ANSWERWIKI:
123129
$tags[] = self::MAILTAG_DETAILS;
124130
break;
125131
case self::TYPE_ANSWERS:
@@ -139,6 +145,7 @@ public function getIcon() {
139145
switch ($this->getTransactionType()) {
140146
case self::TYPE_TITLE:
141147
case self::TYPE_CONTENT:
148+
case self::TYPE_ANSWERWIKI:
142149
return 'fa-pencil';
143150
case self::TYPE_STATUS:
144151
return PonderQuestionStatus::getQuestionStatusIcon($new);
@@ -156,6 +163,7 @@ public function getColor() {
156163
switch ($this->getTransactionType()) {
157164
case self::TYPE_TITLE:
158165
case self::TYPE_CONTENT:
166+
case self::TYPE_ANSWERWIKI:
159167
return PhabricatorTransactions::COLOR_BLUE;
160168
case self::TYPE_ANSWERS:
161169
return PhabricatorTransactions::COLOR_GREEN;
@@ -167,6 +175,7 @@ public function getColor() {
167175
public function hasChangeDetails() {
168176
switch ($this->getTransactionType()) {
169177
case self::TYPE_CONTENT:
178+
case self::TYPE_ANSWERWIKI:
170179
return true;
171180
}
172181
return parent::hasChangeDetails();
@@ -253,6 +262,11 @@ public function getTitleForFeed() {
253262
'%s edited the description of %s',
254263
$this->renderHandleLink($author_phid),
255264
$this->renderHandleLink($object_phid));
265+
case self::TYPE_ANSWERWIKI:
266+
return pht(
267+
'%s edited the answer wiki for %s',
268+
$this->renderHandleLink($author_phid),
269+
$this->renderHandleLink($object_phid));
256270
case self::TYPE_ANSWERS:
257271
$answer_handle = $this->getHandle($this->getNewAnswerPHID());
258272
$question_handle = $this->getHandle($object_phid);

0 commit comments

Comments
 (0)