Add Mark as Helpful to PonderAnswer

Summary: Ref T6920, this adds a basic controller for marking an answer as helpful and removes the negative voting. Any current positive vote is kept as helpful. New UI is needed here, but there is a separate task for redesigning Ponder overall.

Test Plan: Mark an answer as helpful, see count go up, remove helpful, see count go down. Test endpoint manually.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T6920

Differential Revision: https://secure.phabricator.com/D13834
This commit is contained in:
Chad Little
2015-08-10 09:09:07 -07:00
parent 0e7efceb51
commit 2752419160
8 changed files with 91 additions and 37 deletions

View File

@@ -291,6 +291,28 @@ final class PonderQuestionViewController extends PonderController {
->setObject($answer)
->setObjectURI($request->getRequestURI());
$user_marked = $answer->getUserVote();
$can_vote = $viewer->isLoggedIn();
if ($user_marked) {
$helpful_uri = "/answer/helpful/remove/{$id}/";
$helpful_icon = 'fa-times';
$helpful_text = pht('Remove Helpful');
} else {
$helpful_uri = "/answer/helpful/add/{$id}/";
$helpful_icon = 'fa-thumbs-up';
$helpful_text = pht('Mark as Helpful');
}
$view->addAction(
id(new PhabricatorActionView())
->setIcon($helpful_icon)
->setName($helpful_text)
->setHref($this->getApplicationURI($helpful_uri))
->setRenderAsForm(true)
->setDisabled(!$can_vote)
->setWorkflow($can_vote));
$view->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
@@ -322,6 +344,10 @@ final class PonderQuestionViewController extends PonderController {
pht('Created'),
phabricator_datetime($answer->getDateCreated(), $viewer));
$view->addProperty(
pht('Helpfuls'),
$answer->getVoteCount());
$view->invokeWillRenderEvent();
$view->addSectionHeader(pht('Answer'));