From ba8803af9681a345cbfa4e83c04eb915803ba314 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 28 Jul 2013 18:47:43 -0700 Subject: [PATCH] Hide Ponder comments and "add comment" form behind a disclosure link Summary: Ref T3373. This is probably about as good as I can get without actual design, but it seems mostly improved over what we had going on before? Test Plan: {F52087} Reviewers: btrahan, chad Reviewed By: chad CC: aran Maniphest Tasks: T3373 Differential Revision: https://secure.phabricator.com/D6613 --- src/__celerity_resource_map__.php | 2 +- .../PonderQuestionViewController.php | 71 ++++++++++++++++--- .../ponder/view/PonderAddAnswerView.php | 21 ------ .../rsrc/css/application/ponder/comments.css | 8 +++ 4 files changed, 71 insertions(+), 31 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 707ad5a948..5d0672e260 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -3893,7 +3893,7 @@ celerity_register_resource_map(array( ), 'ponder-comment-table-css' => array( - 'uri' => '/res/15cb54fb/rsrc/css/application/ponder/comments.css', + 'uri' => '/res/2527ba37/rsrc/css/application/ponder/comments.css', 'type' => 'css', 'requires' => array( diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php index d71026b299..033ab2550f 100644 --- a/src/applications/ponder/controller/PonderQuestionViewController.php +++ b/src/applications/ponder/controller/PonderQuestionViewController.php @@ -29,9 +29,12 @@ final class PonderQuestionViewController extends PonderController { $authors = mpull($question->getAnswers(), null, 'getAuthorPHID'); if (isset($authors[$user->getPHID()])) { - // TODO: Make this pretty - $answer_add_panel = pht( - 'You have already answered this question.'); + $answer_add_panel = id(new AphrontErrorView()) + ->setSeverity(AphrontErrorView::SEVERITY_NODATA) + ->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 @@ -190,10 +193,12 @@ final class PonderQuestionViewController extends PonderController { ->setAction($this->getApplicationURI("/question/comment/{$id}/")) ->setSubmitButtonName(pht('Comment')); - return array( - $timeline, - $add_comment, - ); + return $this->wrapComments( + count($xactions), + array( + $timeline, + $add_comment, + )); } private function buildAnswers(array $answers) { @@ -238,18 +243,24 @@ final class PonderQuestionViewController extends PonderController { $out[] = $this->buildAnswerActions($answer); $out[] = $this->buildAnswerProperties($answer); - $out[] = id(new PhabricatorApplicationTransactionView()) + $details = array(); + + $details[] = id(new PhabricatorApplicationTransactionView()) ->setUser($viewer) ->setObjectPHID($answer->getPHID()) ->setTransactions($xactions) ->setMarkupEngine($engine); - $out[] = id(new PhabricatorApplicationTransactionCommentView()) + $details[] = id(new PhabricatorApplicationTransactionCommentView()) ->setUser($viewer) ->setObjectPHID($answer->getPHID()) ->setShowPreview(false) ->setAction($this->getApplicationURI("/answer/comment/{$id}/")) ->setSubmitButtonName(pht('Comment')); + + $out[] = $this->wrapComments( + count($xactions), + $details); } $out[] = phutil_tag('br'); @@ -317,4 +328,46 @@ final class PonderQuestionViewController extends PonderController { 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-comment-table-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( + 'id' => $hide_id, + 'style' => 'display: none', + ), + $stuff); + + return array($show, $hide); + } + } diff --git a/src/applications/ponder/view/PonderAddAnswerView.php b/src/applications/ponder/view/PonderAddAnswerView.php index 95b2905635..04307bb72a 100644 --- a/src/applications/ponder/view/PonderAddAnswerView.php +++ b/src/applications/ponder/view/PonderAddAnswerView.php @@ -44,32 +44,11 @@ final class PonderAddAnswerView extends AphrontView { pht('Submit') : pht('Make it so'))); - $loading = pht('Loading answer preview...'); - $preview = hsprintf( - '
'. - '
'. - ''. - '%s'. - ''. - '
'. - '
', - $loading); - - Javelin::initBehavior( - 'ponder-feedback-preview', - array( - 'uri' => '/ponder/answer/preview/', - 'content' => 'answer-content', - 'preview' => 'answer-preview', - 'question_id' => $question->getID() - )); - return id(new AphrontNullView()) ->appendChild( array( $header, $form, - $preview, )) ->render(); } diff --git a/webroot/rsrc/css/application/ponder/comments.css b/webroot/rsrc/css/application/ponder/comments.css index 19abb5b044..67e4cd2d82 100644 --- a/webroot/rsrc/css/application/ponder/comments.css +++ b/webroot/rsrc/css/application/ponder/comments.css @@ -2,6 +2,14 @@ * @provides ponder-comment-table-css */ +.ponder-show-comments { + text-align: center; + padding: 8px 0; + font-weight: bold; + background: #f9f9f9; + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + border-bottom: 1px solid #b7b7b7; +} .ponder-comments { width: 480px;