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
This commit is contained in:
epriestley
2013-07-28 18:47:43 -07:00
parent 644f377915
commit ba8803af96
4 changed files with 71 additions and 31 deletions

View File

@@ -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);
}
}