mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 12:30:56 +01:00
Clean up some Ponder language
Summary: Ref T9099. - Remove unused function - Fix celerity resource include - Add a note when an answer's been closed - Clean up architecture a little - Add a better notice when you've already answered. Test Plan: Test with and without answers, with answering, with being closed. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9099 Differential Revision: https://secure.phabricator.com/D13875
This commit is contained in:
parent
f18537ce0b
commit
9a7beadd22
4 changed files with 35 additions and 60 deletions
|
@ -41,7 +41,7 @@ final class PonderQuestionStatus extends PonderConstants {
|
||||||
self::STATUS_OPEN =>
|
self::STATUS_OPEN =>
|
||||||
pht('This question is open for answers.'),
|
pht('This question is open for answers.'),
|
||||||
self::STATUS_CLOSED_RESOLVED =>
|
self::STATUS_CLOSED_RESOLVED =>
|
||||||
pht('This question has been resolved.'),
|
pht('This question has been answered or resolved.'),
|
||||||
self::STATUS_CLOSED_OBSOLETE =>
|
self::STATUS_CLOSED_OBSOLETE =>
|
||||||
pht('This question is no longer valid or out of date.'),
|
pht('This question is no longer valid or out of date.'),
|
||||||
self::STATUS_CLOSED_DUPLICATE =>
|
self::STATUS_CLOSED_DUPLICATE =>
|
||||||
|
|
|
@ -18,21 +18,10 @@ final class PonderQuestionViewController extends PonderController {
|
||||||
|
|
||||||
$answers = $this->buildAnswers($question->getAnswers());
|
$answers = $this->buildAnswers($question->getAnswers());
|
||||||
|
|
||||||
$authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
|
$answer_add_panel = id(new PonderAddAnswerView())
|
||||||
if (isset($authors[$viewer->getPHID()])) {
|
->setQuestion($question)
|
||||||
$answer_add_panel = id(new PHUIInfoView())
|
->setUser($viewer)
|
||||||
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
|
->setActionURI('/ponder/answer/add/');
|
||||||
->appendChild(
|
|
||||||
pht(
|
|
||||||
'You have already answered this question. You can not answer '.
|
|
||||||
'twice, but you can edit your existing answer.'));
|
|
||||||
} else {
|
|
||||||
$answer_add_panel = new PonderAddAnswerView();
|
|
||||||
$answer_add_panel
|
|
||||||
->setQuestion($question)
|
|
||||||
->setUser($viewer)
|
|
||||||
->setActionURI('/ponder/answer/add/');
|
|
||||||
}
|
|
||||||
|
|
||||||
$header = new PHUIHeaderView();
|
$header = new PHUIHeaderView();
|
||||||
$header->setHeader($question->getTitle());
|
$header->setHeader($question->getTitle());
|
||||||
|
@ -245,49 +234,6 @@ final class PonderQuestionViewController extends PonderController {
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function wrapComments($n, $stuff) {
|
|
||||||
if ($n == 0) {
|
|
||||||
$text = pht('Add a Comment');
|
|
||||||
} else {
|
|
||||||
$text = pht('Show %s Comments', new PhutilNumber($n));
|
|
||||||
}
|
|
||||||
|
|
||||||
$show_id = celerity_generate_unique_node_id();
|
|
||||||
$hide_id = celerity_generate_unique_node_id();
|
|
||||||
|
|
||||||
Javelin::initBehavior('phabricator-reveal-content');
|
|
||||||
require_celerity_resource('ponder-view-css');
|
|
||||||
|
|
||||||
$show = phutil_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'id' => $show_id,
|
|
||||||
'class' => 'ponder-show-comments',
|
|
||||||
),
|
|
||||||
javelin_tag(
|
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => '#',
|
|
||||||
'sigil' => 'reveal-content',
|
|
||||||
'meta' => array(
|
|
||||||
'showIDs' => array($hide_id),
|
|
||||||
'hideIDs' => array($show_id),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
$text));
|
|
||||||
|
|
||||||
$hide = phutil_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'ponder-comments-view',
|
|
||||||
'id' => $hide_id,
|
|
||||||
'style' => 'display: none',
|
|
||||||
),
|
|
||||||
$stuff);
|
|
||||||
|
|
||||||
return array($show, $hide);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildSidebar(PonderQuestion $question) {
|
private function buildSidebar(PonderQuestion $question) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$status = $question->getStatus();
|
$status = $question->getStatus();
|
||||||
|
|
|
@ -18,6 +18,28 @@ final class PonderAddAnswerView extends AphrontView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
$question = $this->question;
|
$question = $this->question;
|
||||||
|
$viewer = $this->user;
|
||||||
|
|
||||||
|
$authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
|
||||||
|
if (isset($authors[$viewer->getPHID()])) {
|
||||||
|
return id(new PHUIInfoView())
|
||||||
|
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
|
||||||
|
->setTitle(pht('Already Answered'))
|
||||||
|
->appendChild(
|
||||||
|
pht(
|
||||||
|
'You have already answered this question. You can not answer '.
|
||||||
|
'twice, but you can edit your existing answer.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$info_panel = null;
|
||||||
|
if ($question->getStatus() != PonderQuestionStatus::STATUS_OPEN) {
|
||||||
|
$info_panel = id(new PHUIInfoView())
|
||||||
|
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
|
||||||
|
->appendChild(
|
||||||
|
pht(
|
||||||
|
'This question has been marked as closed,
|
||||||
|
but you can still leave a new answer.'));
|
||||||
|
}
|
||||||
|
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
->setHeader(pht('Add Answer'));
|
->setHeader(pht('Add Answer'));
|
||||||
|
@ -39,8 +61,14 @@ final class PonderAddAnswerView extends AphrontView {
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->setValue(pht('Add Answer')));
|
->setValue(pht('Add Answer')));
|
||||||
|
|
||||||
return id(new PHUIObjectBoxView())
|
$box = id(new PHUIObjectBoxView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->appendChild($form);
|
->appendChild($form);
|
||||||
|
|
||||||
|
if ($info_panel) {
|
||||||
|
$box->setInfoView($info_panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ final class PonderFooterView extends AphrontTagView {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTagContent() {
|
protected function getTagContent() {
|
||||||
|
require_celerity_resource('ponder-view-css');
|
||||||
Javelin::initBehavior('phabricator-reveal-content');
|
Javelin::initBehavior('phabricator-reveal-content');
|
||||||
|
|
||||||
$hide_action_id = celerity_generate_unique_node_id();
|
$hide_action_id = celerity_generate_unique_node_id();
|
||||||
|
|
Loading…
Reference in a new issue