diff --git a/src/applications/ponder/constants/PonderQuestionStatus.php b/src/applications/ponder/constants/PonderQuestionStatus.php --- a/src/applications/ponder/constants/PonderQuestionStatus.php +++ b/src/applications/ponder/constants/PonderQuestionStatus.php @@ -41,7 +41,7 @@ self::STATUS_OPEN => pht('This question is open for answers.'), self::STATUS_CLOSED_RESOLVED => - pht('This question has been resolved.'), + pht('This question has been answered or resolved.'), self::STATUS_CLOSED_OBSOLETE => pht('This question is no longer valid or out of date.'), self::STATUS_CLOSED_DUPLICATE => 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 @@ -18,21 +18,10 @@ $answers = $this->buildAnswers($question->getAnswers()); - $authors = mpull($question->getAnswers(), null, 'getAuthorPHID'); - if (isset($authors[$viewer->getPHID()])) { - $answer_add_panel = id(new PHUIInfoView()) - ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) - ->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/'); - } + $answer_add_panel = id(new PonderAddAnswerView()) + ->setQuestion($question) + ->setUser($viewer) + ->setActionURI('/ponder/answer/add/'); $header = new PHUIHeaderView(); $header->setHeader($question->getTitle()); @@ -245,49 +234,6 @@ 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) { $viewer = $this->getViewer(); $status = $question->getStatus(); diff --git a/src/applications/ponder/view/PonderAddAnswerView.php b/src/applications/ponder/view/PonderAddAnswerView.php --- a/src/applications/ponder/view/PonderAddAnswerView.php +++ b/src/applications/ponder/view/PonderAddAnswerView.php @@ -18,6 +18,28 @@ public function render() { $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()) ->setHeader(pht('Add Answer')); @@ -39,8 +61,14 @@ id(new AphrontFormSubmitControl()) ->setValue(pht('Add Answer'))); - return id(new PHUIObjectBoxView()) + $box = id(new PHUIObjectBoxView()) ->setHeader($header) ->appendChild($form); + + if ($info_panel) { + $box->setInfoView($info_panel); + } + + return $box; } } diff --git a/src/applications/ponder/view/PonderFooterView.php b/src/applications/ponder/view/PonderFooterView.php --- a/src/applications/ponder/view/PonderFooterView.php +++ b/src/applications/ponder/view/PonderFooterView.php @@ -28,6 +28,7 @@ } protected function getTagContent() { + require_celerity_resource('ponder-view-css'); Javelin::initBehavior('phabricator-reveal-content'); $hide_action_id = celerity_generate_unique_node_id();