diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 5d0672e260..2c07ace96f 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -3432,7 +3432,7 @@ celerity_register_resource_map(array( ), 'phabricator-property-list-view-css' => array( - 'uri' => '/res/a04cc81d/rsrc/css/layout/phabricator-property-list-view.css', + 'uri' => '/res/1b2f0fa9/rsrc/css/layout/phabricator-property-list-view.css', 'type' => 'css', 'requires' => array( @@ -3920,7 +3920,7 @@ celerity_register_resource_map(array( ), 'ponder-vote-css' => array( - 'uri' => '/res/26945177/rsrc/css/application/ponder/vote.css', + 'uri' => '/res/28b71b13/rsrc/css/application/ponder/vote.css', 'type' => 'css', 'requires' => array( @@ -4191,7 +4191,7 @@ celerity_register_resource_map(array( ), array( 'packages' => array( - 'bbc1cd98' => + '4bd2b460' => array( 'name' => 'core.pkg.css', 'symbols' => @@ -4239,7 +4239,7 @@ celerity_register_resource_map(array( 40 => 'phabricator-property-list-view-css', 41 => 'phabricator-tag-view-css', ), - 'uri' => '/res/pkg/bbc1cd98/core.pkg.css', + 'uri' => '/res/pkg/4bd2b460/core.pkg.css', 'type' => 'css', ), '75ccea43' => @@ -4430,16 +4430,16 @@ celerity_register_resource_map(array( ), 'reverse' => array( - 'aphront-dialog-view-css' => 'bbc1cd98', - 'aphront-error-view-css' => 'bbc1cd98', - 'aphront-form-view-css' => 'bbc1cd98', - 'aphront-list-filter-view-css' => 'bbc1cd98', - 'aphront-pager-view-css' => 'bbc1cd98', - 'aphront-panel-view-css' => 'bbc1cd98', - 'aphront-table-view-css' => 'bbc1cd98', - 'aphront-tokenizer-control-css' => 'bbc1cd98', - 'aphront-tooltip-css' => 'bbc1cd98', - 'aphront-typeahead-control-css' => 'bbc1cd98', + 'aphront-dialog-view-css' => '4bd2b460', + 'aphront-error-view-css' => '4bd2b460', + 'aphront-form-view-css' => '4bd2b460', + 'aphront-list-filter-view-css' => '4bd2b460', + 'aphront-pager-view-css' => '4bd2b460', + 'aphront-panel-view-css' => '4bd2b460', + 'aphront-table-view-css' => '4bd2b460', + 'aphront-tokenizer-control-css' => '4bd2b460', + 'aphront-tooltip-css' => '4bd2b460', + 'aphront-typeahead-control-css' => '4bd2b460', 'differential-changeset-view-css' => 'dd27a69b', 'differential-core-view-css' => 'dd27a69b', 'differential-inline-comment-editor' => '48040be9', @@ -4453,7 +4453,7 @@ celerity_register_resource_map(array( 'differential-table-of-contents-css' => 'dd27a69b', 'diffusion-commit-view-css' => 'c8ce2d88', 'diffusion-icons-css' => 'c8ce2d88', - 'global-drag-and-drop-css' => 'bbc1cd98', + 'global-drag-and-drop-css' => '4bd2b460', 'inline-comment-summary-css' => 'dd27a69b', 'javelin-aphlict' => '75ccea43', 'javelin-behavior' => 'a9f14d76', @@ -4526,55 +4526,55 @@ celerity_register_resource_map(array( 'javelin-util' => 'a9f14d76', 'javelin-vector' => 'a9f14d76', 'javelin-workflow' => 'a9f14d76', - 'lightbox-attachment-css' => 'bbc1cd98', + 'lightbox-attachment-css' => '4bd2b460', 'maniphest-task-summary-css' => '06bacb9a', 'maniphest-transaction-detail-css' => '06bacb9a', - 'phabricator-action-list-view-css' => 'bbc1cd98', - 'phabricator-application-launch-view-css' => 'bbc1cd98', + 'phabricator-action-list-view-css' => '4bd2b460', + 'phabricator-application-launch-view-css' => '4bd2b460', 'phabricator-busy' => '75ccea43', 'phabricator-content-source-view-css' => 'dd27a69b', - 'phabricator-core-css' => 'bbc1cd98', - 'phabricator-crumbs-view-css' => 'bbc1cd98', + 'phabricator-core-css' => '4bd2b460', + 'phabricator-crumbs-view-css' => '4bd2b460', 'phabricator-drag-and-drop-file-upload' => '48040be9', 'phabricator-dropdown-menu' => '75ccea43', 'phabricator-file-upload' => '75ccea43', - 'phabricator-filetree-view-css' => 'bbc1cd98', - 'phabricator-flag-css' => 'bbc1cd98', - 'phabricator-form-view-css' => 'bbc1cd98', - 'phabricator-header-view-css' => 'bbc1cd98', + 'phabricator-filetree-view-css' => '4bd2b460', + 'phabricator-flag-css' => '4bd2b460', + 'phabricator-form-view-css' => '4bd2b460', + 'phabricator-header-view-css' => '4bd2b460', 'phabricator-hovercard' => '75ccea43', - 'phabricator-jump-nav' => 'bbc1cd98', + 'phabricator-jump-nav' => '4bd2b460', 'phabricator-keyboard-shortcut' => '75ccea43', 'phabricator-keyboard-shortcut-manager' => '75ccea43', - 'phabricator-main-menu-view' => 'bbc1cd98', + 'phabricator-main-menu-view' => '4bd2b460', 'phabricator-menu-item' => '75ccea43', - 'phabricator-nav-view-css' => 'bbc1cd98', + 'phabricator-nav-view-css' => '4bd2b460', 'phabricator-notification' => '75ccea43', - 'phabricator-notification-css' => 'bbc1cd98', - 'phabricator-notification-menu-css' => 'bbc1cd98', - 'phabricator-object-item-list-view-css' => 'bbc1cd98', + 'phabricator-notification-css' => '4bd2b460', + 'phabricator-notification-menu-css' => '4bd2b460', + 'phabricator-object-item-list-view-css' => '4bd2b460', 'phabricator-object-selector-css' => 'dd27a69b', 'phabricator-phtize' => '75ccea43', 'phabricator-prefab' => '75ccea43', 'phabricator-project-tag-css' => '06bacb9a', - 'phabricator-property-list-view-css' => 'bbc1cd98', - 'phabricator-remarkup-css' => 'bbc1cd98', + 'phabricator-property-list-view-css' => '4bd2b460', + 'phabricator-remarkup-css' => '4bd2b460', 'phabricator-shaped-request' => '48040be9', - 'phabricator-side-menu-view-css' => 'bbc1cd98', - 'phabricator-standard-page-view' => 'bbc1cd98', - 'phabricator-tag-view-css' => 'bbc1cd98', + 'phabricator-side-menu-view-css' => '4bd2b460', + 'phabricator-standard-page-view' => '4bd2b460', + 'phabricator-tag-view-css' => '4bd2b460', 'phabricator-textareautils' => '75ccea43', 'phabricator-tooltip' => '75ccea43', - 'phabricator-transaction-view-css' => 'bbc1cd98', - 'phabricator-zindex-css' => 'bbc1cd98', - 'phui-button-css' => 'bbc1cd98', - 'phui-form-css' => 'bbc1cd98', - 'phui-icon-view-css' => 'bbc1cd98', - 'phui-spacing-css' => 'bbc1cd98', - 'sprite-apps-large-css' => 'bbc1cd98', - 'sprite-gradient-css' => 'bbc1cd98', - 'sprite-icons-css' => 'bbc1cd98', - 'sprite-menu-css' => 'bbc1cd98', - 'syntax-highlighting-css' => 'bbc1cd98', + 'phabricator-transaction-view-css' => '4bd2b460', + 'phabricator-zindex-css' => '4bd2b460', + 'phui-button-css' => '4bd2b460', + 'phui-form-css' => '4bd2b460', + 'phui-icon-view-css' => '4bd2b460', + 'phui-spacing-css' => '4bd2b460', + 'sprite-apps-large-css' => '4bd2b460', + 'sprite-gradient-css' => '4bd2b460', + 'sprite-icons-css' => '4bd2b460', + 'sprite-menu-css' => '4bd2b460', + 'syntax-highlighting-css' => '4bd2b460', ), )); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 997736938b..0aae96c71e 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1868,13 +1868,11 @@ phutil_register_library_map(array( 'PhrictionSearchEngine' => 'applications/phriction/query/PhrictionSearchEngine.php', 'PhrictionSearchIndexer' => 'applications/phriction/search/PhrictionSearchIndexer.php', 'PonderAddAnswerView' => 'applications/ponder/view/PonderAddAnswerView.php', - 'PonderAddCommentView' => 'applications/ponder/view/PonderAddCommentView.php', 'PonderAnswer' => 'applications/ponder/storage/PonderAnswer.php', 'PonderAnswerCommentController' => 'applications/ponder/controller/PonderAnswerCommentController.php', 'PonderAnswerEditController' => 'applications/ponder/controller/PonderAnswerEditController.php', 'PonderAnswerEditor' => 'applications/ponder/editor/PonderAnswerEditor.php', 'PonderAnswerHistoryController' => 'applications/ponder/controller/PonderAnswerHistoryController.php', - 'PonderAnswerListView' => 'applications/ponder/view/PonderAnswerListView.php', 'PonderAnswerQuery' => 'applications/ponder/query/PonderAnswerQuery.php', 'PonderAnswerSaveController' => 'applications/ponder/controller/PonderAnswerSaveController.php', 'PonderAnswerTransaction' => 'applications/ponder/storage/PonderAnswerTransaction.php', @@ -1884,7 +1882,6 @@ phutil_register_library_map(array( 'PonderAnsweredMail' => 'applications/ponder/mail/PonderAnsweredMail.php', 'PonderComment' => 'applications/ponder/storage/PonderComment.php', 'PonderCommentEditor' => 'applications/ponder/editor/PonderCommentEditor.php', - 'PonderCommentListView' => 'applications/ponder/view/PonderCommentListView.php', 'PonderCommentMail' => 'applications/ponder/mail/PonderCommentMail.php', 'PonderCommentQuery' => 'applications/ponder/query/PonderCommentQuery.php', 'PonderConstants' => 'applications/ponder/constants/PonderConstants.php', @@ -1898,7 +1895,6 @@ phutil_register_library_map(array( 'PonderPostBodyView' => 'applications/ponder/view/PonderPostBodyView.php', 'PonderQuestion' => 'applications/ponder/storage/PonderQuestion.php', 'PonderQuestionCommentController' => 'applications/ponder/controller/PonderQuestionCommentController.php', - 'PonderQuestionDetailView' => 'applications/ponder/view/PonderQuestionDetailView.php', 'PonderQuestionEditController' => 'applications/ponder/controller/PonderQuestionEditController.php', 'PonderQuestionEditor' => 'applications/ponder/editor/PonderQuestionEditor.php', 'PonderQuestionHistoryController' => 'applications/ponder/controller/PonderQuestionHistoryController.php', @@ -3986,7 +3982,6 @@ phutil_register_library_map(array( 'PhrictionSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhrictionSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PonderAddAnswerView' => 'AphrontView', - 'PonderAddCommentView' => 'AphrontView', 'PonderAnswer' => array( 0 => 'PonderDAO', @@ -4000,7 +3995,6 @@ phutil_register_library_map(array( 'PonderAnswerEditController' => 'PonderController', 'PonderAnswerEditor' => 'PhabricatorApplicationTransactionEditor', 'PonderAnswerHistoryController' => 'PonderController', - 'PonderAnswerListView' => 'AphrontView', 'PonderAnswerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PonderAnswerSaveController' => 'PonderController', 'PonderAnswerTransaction' => 'PhabricatorApplicationTransaction', @@ -4014,7 +4008,6 @@ phutil_register_library_map(array( 1 => 'PhabricatorMarkupInterface', ), 'PonderCommentEditor' => 'PhabricatorEditor', - 'PonderCommentListView' => 'AphrontView', 'PonderCommentMail' => 'PonderMail', 'PonderCommentQuery' => 'PhabricatorQuery', 'PonderController' => 'PhabricatorController', @@ -4035,7 +4028,6 @@ phutil_register_library_map(array( 5 => 'PhabricatorTokenReceiverInterface', ), 'PonderQuestionCommentController' => 'PonderController', - 'PonderQuestionDetailView' => 'AphrontView', 'PonderQuestionEditController' => 'PonderController', 'PonderQuestionEditor' => 'PhabricatorApplicationTransactionEditor', 'PonderQuestionHistoryController' => 'PonderController', diff --git a/src/applications/ponder/application/PhabricatorApplicationPonder.php b/src/applications/ponder/application/PhabricatorApplicationPonder.php index c9b9fdd4ce..5e6fb5ebdf 100644 --- a/src/applications/ponder/application/PhabricatorApplicationPonder.php +++ b/src/applications/ponder/application/PhabricatorApplicationPonder.php @@ -60,8 +60,7 @@ final class PhabricatorApplicationPonder extends PhabricatorApplication { 'question/preview/' => 'PonderQuestionPreviewController', 'question/(?Popen|close)/(?P[1-9]\d*)/' => 'PonderQuestionStatusController', - '(?Pquestion)/vote/' => 'PonderVoteSaveController', - '(?Panswer)/vote/' => 'PonderVoteSaveController' + 'vote/' => 'PonderVoteSaveController', ), ); } diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php index 033ab2550f..216eeb145d 100644 --- a/src/applications/ponder/controller/PonderQuestionViewController.php +++ b/src/applications/ponder/controller/PonderQuestionViewController.php @@ -17,6 +17,7 @@ final class PonderQuestionViewController extends PonderController { ->setViewer($user) ->withIDs(array($this->questionID)) ->needAnswers(true) + ->needViewerVotes(true) ->executeOne(); if (!$question) { return new Aphront404Response(); @@ -149,11 +150,20 @@ final class PonderQuestionViewController extends PonderController { $view->invokeWillRenderEvent(); + $votable = id(new PonderVotableView()) + ->setPHID($question->getPHID()) + ->setURI($this->getApplicationURI('vote/')) + ->setCount($question->getVoteCount()) + ->setVote($question->getUserVote()); + $view->addTextContent( - PhabricatorMarkupEngine::renderOneObject( - $question, - $question->getMarkupField(), - $viewer)); + array( + $votable, + PhabricatorMarkupEngine::renderOneObject( + $question, + $question->getMarkupField(), + $viewer), + )); return $view; @@ -314,16 +324,25 @@ final class PonderQuestionViewController extends PonderController { $view->invokeWillRenderEvent(); + $votable = id(new PonderVotableView()) + ->setPHID($answer->getPHID()) + ->setURI($this->getApplicationURI('vote/')) + ->setCount($answer->getVoteCount()) + ->setVote($answer->getUserVote()); + $view->addTextContent( - phutil_tag( - 'div', - array( - 'class' => 'phabricator-remarkup', - ), - PhabricatorMarkupEngine::renderOneObject( - $answer, - $answer->getMarkupField(), - $viewer))); + array( + $votable, + phutil_tag( + 'div', + array( + 'class' => 'phabricator-remarkup', + ), + PhabricatorMarkupEngine::renderOneObject( + $answer, + $answer->getMarkupField(), + $viewer)), + )); return $view; } diff --git a/src/applications/ponder/controller/PonderVoteSaveController.php b/src/applications/ponder/controller/PonderVoteSaveController.php index 2d1e39d9dd..8b5dd39505 100644 --- a/src/applications/ponder/controller/PonderVoteSaveController.php +++ b/src/applications/ponder/controller/PonderVoteSaveController.php @@ -2,17 +2,11 @@ final class PonderVoteSaveController extends PonderController { - private $kind; - - public function willProcessRequest(array $data) { - $this->kind = $data['kind']; - } - public function processRequest() { $request = $this->getRequest(); - $user = $request->getUser(); - $newvote = $request->getInt("vote"); - $phid = $request->getStr("phid"); + $viewer = $request->getUser(); + $phid = $request->getStr('phid'); + $newvote = $request->getInt('vote'); if (1 < $newvote || $newvote < -1) { return new Aphront400Response(); @@ -20,28 +14,20 @@ final class PonderVoteSaveController extends PonderController { $target = null; - if ($this->kind == "question") { - $target = id(new PonderQuestionQuery()) - ->setViewer($user) - ->withPHIDs(array($phid)) - ->executeOne(); - } else if ($this->kind == "answer") { - $target = id(new PonderAnswerQuery()) - ->setViewer($user) - ->withPHIDs(array($phid)) - ->executeOne(); - } - - if (!$target) { + $object = id(new PhabricatorObjectQuery()) + ->setViewer($viewer) + ->withPHIDs(array($phid)) + ->executeOne(); + if (!$object) { return new Aphront404Response(); } $editor = id(new PonderVoteEditor()) - ->setVotable($target) - ->setActor($user) + ->setVotable($object) + ->setActor($viewer) ->setVote($newvote) ->saveVote(); - return id(new AphrontAjaxResponse())->setContent("."); + return id(new AphrontAjaxResponse())->setContent(array()); } } diff --git a/src/applications/ponder/query/PonderAnswerQuery.php b/src/applications/ponder/query/PonderAnswerQuery.php index 4254682100..66e532c6b6 100644 --- a/src/applications/ponder/query/PonderAnswerQuery.php +++ b/src/applications/ponder/query/PonderAnswerQuery.php @@ -8,6 +8,9 @@ final class PonderAnswerQuery private $authorPHIDs; private $questionIDs; + private $needViewerVotes; + + public function withIDs(array $ids) { $this->ids = $ids; return $this; @@ -28,6 +31,11 @@ final class PonderAnswerQuery return $this; } + public function needViewerVotes($need_viewer_votes) { + $this->needViewerVotes = $need_viewer_votes; + return $this; + } + private function buildWhereClause($conn_r) { $where = array(); @@ -78,11 +86,36 @@ final class PonderAnswerQuery ->withIDs(mpull($answers, 'getQuestionID')) ->execute(); - foreach ($answers as $answer) { + foreach ($answers as $key => $answer) { $question = idx($questions, $answer->getQuestionID()); + if (!$question) { + unset($answers[$key]); + continue; + } $answer->attachQuestion($question); } + if ($this->needViewerVotes) { + $viewer_phid = $this->getViewer()->getPHID(); + + $etype = PhabricatorEdgeConfig::TYPE_ANSWER_HAS_VOTING_USER; + $edges = id(new PhabricatorEdgeQuery()) + ->withSourcePHIDs(mpull($answers, 'getPHID')) + ->withDestinationPHIDs(array($viewer_phid)) + ->withEdgeTypes(array($etype)) + ->needEdgeData(true) + ->execute(); + foreach ($answers as $answer) { + $user_edge = idx( + $edges[$answer->getPHID()][$etype], + $viewer_phid, + array()); + + $answer->attachUserVote($viewer_phid, idx($user_edge, 'data', 0)); + } + } + + return $answers; } diff --git a/src/applications/ponder/query/PonderQuestionQuery.php b/src/applications/ponder/query/PonderQuestionQuery.php index 211e3a6329..3aae8cbb65 100644 --- a/src/applications/ponder/query/PonderQuestionQuery.php +++ b/src/applications/ponder/query/PonderQuestionQuery.php @@ -18,6 +18,7 @@ final class PonderQuestionQuery const STATUS_CLOSED = 'status-closed'; private $needAnswers; + private $needViewerVotes; public function withIDs(array $ids) { $this->ids = $ids; @@ -49,6 +50,11 @@ final class PonderQuestionQuery return $this; } + public function needViewerVotes($need_viewer_votes) { + $this->needViewerVotes = $need_viewer_votes; + return $this; + } + public function setOrder($order) { $this->order = $order; return $this; @@ -133,10 +139,15 @@ final class PonderQuestionQuery public function willFilterPage(array $questions) { if ($this->needAnswers) { - $answers = id(new PonderAnswerQuery()) + $aquery = id(new PonderAnswerQuery()) ->setViewer($this->getViewer()) - ->withQuestionIDs(mpull($questions, 'getID')) - ->execute(); + ->withQuestionIDs(mpull($questions, 'getID')); + + if ($this->needViewerVotes) { + $aquery->needViewerVotes($this->needViewerVotes); + } + + $answers = $aquery->execute(); $answers = mgroup($answers, 'getQuestionID'); foreach ($questions as $question) { @@ -144,6 +155,26 @@ final class PonderQuestionQuery } } + if ($this->needViewerVotes) { + $viewer_phid = $this->getViewer()->getPHID(); + + $etype = PhabricatorEdgeConfig::TYPE_QUESTION_HAS_VOTING_USER; + $edges = id(new PhabricatorEdgeQuery()) + ->withSourcePHIDs(mpull($questions, 'getPHID')) + ->withDestinationPHIDs(array($viewer_phid)) + ->withEdgeTypes(array($etype)) + ->needEdgeData(true) + ->execute(); + foreach ($questions as $question) { + $user_edge = idx( + $edges[$question->getPHID()][$etype], + $viewer_phid, + array()); + + $question->attachUserVote($viewer_phid, idx($user_edge, 'data', 0)); + } + } + return $questions; } diff --git a/src/applications/ponder/storage/PonderAnswer.php b/src/applications/ponder/storage/PonderAnswer.php index cfddc46b5d..e9d6234345 100644 --- a/src/applications/ponder/storage/PonderAnswer.php +++ b/src/applications/ponder/storage/PonderAnswer.php @@ -21,6 +21,8 @@ final class PonderAnswer extends PonderDAO private $question = self::ATTACHABLE; private $comments; + private $userVotes = array(); + // TODO: Get rid of this method. public function setQuestion($question) { return $this->attachQuestion($question); @@ -43,6 +45,11 @@ final class PonderAnswer extends PonderDAO return $this; } + public function attachUserVote($user_phid, $vote) { + $this->vote = $vote; + return $this; + } + public function getUserVote() { return $this->vote; } diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php index 3f98ee870f..cadf347566 100644 --- a/src/applications/ponder/storage/PonderQuestion.php +++ b/src/applications/ponder/storage/PonderQuestion.php @@ -101,6 +101,11 @@ final class PonderQuestion extends PonderDAO return $this; } + public function attachUserVote($user_phid, $vote) { + $this->vote = $vote; + return $this; + } + public function getUserVote() { return $this->vote; } diff --git a/src/applications/ponder/view/PonderAddCommentView.php b/src/applications/ponder/view/PonderAddCommentView.php deleted file mode 100644 index 11f87cc2be..0000000000 --- a/src/applications/ponder/view/PonderAddCommentView.php +++ /dev/null @@ -1,56 +0,0 @@ -target = $target; - return $this; - } - - public function setQuestionID($id) { - $this->questionID = $id; - return $this; - } - - public function setActionURI($uri) { - $this->actionURI = $uri; - return $this; - } - - public function render() { - require_celerity_resource('ponder-comment-table-css'); - - $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); - - $questionID = $this->questionID; - $target = $this->target; - - $form = new AphrontFormView(); - $form - ->setUser($this->user) - ->setAction($this->actionURI) - ->setNoShading(true) - ->setWorkflow(true) - ->addHiddenInput('target', $target) - ->addHiddenInput('question_id', $questionID) - ->appendChild( - id(new AphrontFormTextAreaControl()) - ->setName('content')) - ->appendChild( - id(new AphrontFormSubmitControl()) - ->setValue($is_serious ? - pht('Submit') : - pht('Editorialize'))); - - $view = id(new AphrontMoreView()) - ->setSome('') - ->setMore($form->render()) - ->setExpandText(pht('Add Comment')); - - return $view->render(); - } -} diff --git a/src/applications/ponder/view/PonderAnswerListView.php b/src/applications/ponder/view/PonderAnswerListView.php deleted file mode 100644 index 26ceb95556..0000000000 --- a/src/applications/ponder/view/PonderAnswerListView.php +++ /dev/null @@ -1,80 +0,0 @@ -question = $question; - return $this; - } - - public function setHandles(array $handles) { - assert_instances_of($handles, 'PhabricatorObjectHandle'); - $this->handles = $handles; - return $this; - } - - public function setAnswers(array $answers) { - assert_instances_of($answers, 'PonderAnswer'); - - $this->answers = array(); - - // group by descreasing score, randomizing - // order within groups - $by_score = mgroup($answers, 'getVoteCount'); - $scores = array_keys($by_score); - rsort($scores); - - foreach ($scores as $score) { - $group = $by_score[$score]; - shuffle($group); - foreach ($group as $cur_answer) { - $this->answers[] = $cur_answer; - } - } - - return $this; - } - - public function render() { - require_celerity_resource('ponder-post-css'); - - $question = $this->question; - $user = $this->user; - $handles = $this->handles; - - $panel = id(new AphrontPanelView()) - ->setNoBackground() - ->setHeader(pht("Responses")); - - foreach ($this->answers as $cur_answer) { - $view = new PonderPostBodyView(); - $view - ->setQuestion($question) - ->setTarget($cur_answer) - ->setAction(PonderLiterals::LITERAL_ANSWERED) - ->setHandles($handles) - ->setUser($user); - - $commentview = new PonderCommentListView(); - $commentview - ->setUser($user) - ->setHandles($handles) - ->setComments($cur_answer->getComments()) - ->setTarget($cur_answer->getPHID()) - ->setQuestionID($question->getID()) - ->setActionURI(new PhutilURI('/ponder/comment/add/')); - - $panel->appendChild($view); - $panel->appendChild($commentview); - $panel->appendChild( - hsprintf('
')); - - } - - return $panel->render(); - } -} diff --git a/src/applications/ponder/view/PonderCommentListView.php b/src/applications/ponder/view/PonderCommentListView.php deleted file mode 100644 index 4e1e991aec..0000000000 --- a/src/applications/ponder/view/PonderCommentListView.php +++ /dev/null @@ -1,90 +0,0 @@ -handles = $handles; - return $this; - } - - public function setComments(array $comments) { - assert_instances_of($comments, 'PonderComment'); - $this->comments = $comments; - return $this; - } - - public function setQuestionID($id) { - $this->questionID = $id; - return $this; - } - - public function setActionURI($uri) { - $this->actionURI = $uri; - return $this; - } - - public function setTarget($target) { - $this->target = $target; - return $this; - } - - public function render() { - require_celerity_resource('phabricator-remarkup-css'); - require_celerity_resource('ponder-comment-table-css'); - - $user = $this->user; - $handles = $this->handles; - $comments = $this->comments; - - $comment_markup = array(); - - foreach ($comments as $comment) { - $handle = $handles[$comment->getAuthorPHID()]; - $body = PhabricatorMarkupEngine::renderOneObject( - $comment, - $comment->getMarkupField(), - $this->user); - - $comment_anchor = ''; - $comment_markup[] = hsprintf( - ''. - ''. - ''. - '
'. - '%s -%s %s'. - '
'. - ''. - '', - $comment->getID(), - $body, - $handle->renderLink(), - phabricator_datetime($comment->getDateCreated(), $user)); - } - - $addview = id(new PonderAddCommentView) - ->setTarget($this->target) - ->setUser($user) - ->setQuestionID($this->questionID) - ->setActionURI($this->actionURI); - - $comment_markup[] = hsprintf( - ' %s', - $addview->render()); - - $comment_markup = phutil_tag( - 'table', - array( - 'class' => 'ponder-comments', - ), - $comment_markup); - - return $comment_markup; - } - -} diff --git a/src/applications/ponder/view/PonderPostBodyView.php b/src/applications/ponder/view/PonderPostBodyView.php index 1f02c5e8ff..2d5c2be484 100644 --- a/src/applications/ponder/view/PonderPostBodyView.php +++ b/src/applications/ponder/view/PonderPostBodyView.php @@ -97,24 +97,7 @@ final class PonderPostBodyView extends AphrontView { ), $content)); - $outerview = $xaction_view; - if (!$this->preview) { - $outerview = - id(new PonderVotableView()) - ->setPHID($target->getPHID()) - ->setCount($target->getVoteCount()) - ->setVote($target->getUserVote()); - - if ($this->target instanceof PonderAnswer) { - $outerview->setURI('/ponder/answer/vote/'); - } else { - $outerview->setURI('/ponder/question/vote/'); - } - - $outerview->appendChild($xaction_view); - } - - return $outerview->render(); + return $xaction_view; } } diff --git a/src/applications/ponder/view/PonderQuestionDetailView.php b/src/applications/ponder/view/PonderQuestionDetailView.php deleted file mode 100644 index 8577321c76..0000000000 --- a/src/applications/ponder/view/PonderQuestionDetailView.php +++ /dev/null @@ -1,50 +0,0 @@ -question = $question; - return $this; - } - - public function setHandles($handles) { - $this->handles = $handles; - return $this; - } - - public function render() { - - $question = $this->question; - $handles = $this->handles; - $user = $this->user; - - $panel = id(new AphrontPanelView()) - ->setNoBackground(true); - - $contentview = new PonderPostBodyView(); - $contentview - ->setTarget($question) - ->setQuestion($question) - ->setUser($user) - ->setHandles($handles) - ->setAction(PonderLiterals::LITERAL_ASKED); - - $commentview = new PonderCommentListView(); - $commentview - ->setUser($user) - ->setHandles($handles) - ->setComments($question->getComments()) - ->setTarget($question->getPHID()) - ->setQuestionID($question->getID()) - ->setActionURI(new PhutilURI('/ponder/comment/add/')); - - $panel->appendChild($contentview); - $panel->appendChild($commentview); - - return $panel->render(); - } - -} diff --git a/webroot/rsrc/css/application/ponder/vote.css b/webroot/rsrc/css/application/ponder/vote.css index 60dd9d1249..04357a2c70 100644 --- a/webroot/rsrc/css/application/ponder/vote.css +++ b/webroot/rsrc/css/application/ponder/vote.css @@ -2,60 +2,42 @@ * @provides ponder-vote-css */ +.ponder-votable { + float: right; + margin: 4px 0 4px 24px; +} + .ponder-votebox { + border-radius: 4px; + background: #f3f3f3; + border: 1px solid #d7d7d7; + box-shadow: 1px 1px rgba(0, 0, 0, 0.05); text-align: center; + width: 24px; } .ponder-votebox a { font-size: 20px; - line-height: 20px; + line-height: 24px; display: block; text-decoration: none; - color: #a1a5a9; + color: #aaaaaa; font-weight: normal; } -.ponder-votebox a:hover { - color: #606060; -} - .ponder-votebox a.ponder-vote-active { - color: #3b5998; + color: {$blue}; } -.ponder-votebox a.ponder-vote-active:hover { - color: #a1bbe5; +.ponder-votebox a:hover { + color: #ffffff; + background: {$blue}; } .ponder-vote-count { - color: #888888; + color: #333333; font-size: 14px; - line-height: 14px; + line-height: 20px; font-weight: bold; } - -.ponder-votebox { - float: left; - width: 32px; - height: 60px; - margin-top: 56px; - margin-left: 10px; -} - -.device-phone .ponder-votebox { - margin: 0; -} - -.device-phone .ponder-votebox-content { - margin-left: 35px; -} - -.ponder-votable .phabricator-transaction-view { - margin: 0; - padding: 0; -} - -.ponder-votable .phabricator-transaction-detail { - min-height : 90px; -} diff --git a/webroot/rsrc/css/layout/phabricator-property-list-view.css b/webroot/rsrc/css/layout/phabricator-property-list-view.css index b2c948aa28..f6b3448cac 100644 --- a/webroot/rsrc/css/layout/phabricator-property-list-view.css +++ b/webroot/rsrc/css/layout/phabricator-property-list-view.css @@ -91,6 +91,7 @@ padding: 12px 18px; background: #fdfdfd; border-bottom: 1px solid #dbdbdb; + overflow: hidden; } .phabricator-property-list-image-content {