Differential D21847 Diff 52071 src/applications/slowvote/controller/PhabricatorSlowvotePollController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/slowvote/controller/PhabricatorSlowvotePollController.php
Show All 29 Lines | if ($request->isAjax()) { | ||||
return id(new AphrontAjaxResponse()) | return id(new AphrontAjaxResponse()) | ||||
->setContent( | ->setContent( | ||||
array( | array( | ||||
'pollID' => $poll->getID(), | 'pollID' => $poll->getID(), | ||||
'contentHTML' => $poll_view->render(), | 'contentHTML' => $poll_view->render(), | ||||
)); | )); | ||||
} | } | ||||
$header_icon = $poll->getIsClosed() ? 'fa-ban' : 'fa-square-o'; | $status = $poll->getStatusObject(); | ||||
$header_name = $poll->getIsClosed() ? pht('Closed') : pht('Open'); | |||||
$header_color = $poll->getIsClosed() ? 'indigo' : 'bluegrey'; | $header_icon = $status->getHeaderTagIcon(); | ||||
$header_color = $status->getHeaderTagColor(); | |||||
$header_name = $status->getName(); | |||||
$header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
->setHeader($poll->getQuestion()) | ->setHeader($poll->getQuestion()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setStatus($header_icon, $header_color, $header_name) | ->setStatus($header_icon, $header_color, $header_name) | ||||
->setPolicyObject($poll) | ->setPolicyObject($poll) | ||||
->setHeaderIcon('fa-bar-chart'); | ->setHeaderIcon('fa-bar-chart'); | ||||
$curtain = $this->buildCurtain($poll); | $curtain = $this->buildCurtain($poll); | ||||
$subheader = $this->buildSubheaderView($poll); | $subheader = $this->buildSubheaderView($poll); | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumbs->addTextCrumb('V'.$poll->getID()); | $crumbs->addTextCrumb($poll->getMonogram()); | ||||
$crumbs->setBorder(true); | $crumbs->setBorder(true); | ||||
$timeline = $this->buildTransactionTimeline( | $timeline = $this->buildTransactionTimeline( | ||||
$poll, | $poll, | ||||
new PhabricatorSlowvoteTransactionQuery()); | new PhabricatorSlowvoteTransactionQuery()); | ||||
$add_comment = $this->buildCommentForm($poll); | $add_comment = $this->buildCommentForm($poll); | ||||
$poll_content = array( | $poll_content = array( | ||||
$poll_view, | $poll_view, | ||||
$timeline, | $timeline, | ||||
$add_comment, | $add_comment, | ||||
); | ); | ||||
$view = id(new PHUITwoColumnView()) | $view = id(new PHUITwoColumnView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->setSubheader($subheader) | ->setSubheader($subheader) | ||||
->setCurtain($curtain) | ->setCurtain($curtain) | ||||
->setMainColumn($poll_content); | ->setMainColumn($poll_content); | ||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle('V'.$poll->getID().' '.$poll->getQuestion()) | ->setTitle( | ||||
pht( | |||||
'%s %s', | |||||
$poll->getMonogram(), | |||||
$poll->getQuestion())) | |||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->setPageObjectPHIDs(array($poll->getPHID())) | ->setPageObjectPHIDs(array($poll->getPHID())) | ||||
->appendChild($view); | ->appendChild($view); | ||||
} | } | ||||
private function buildCurtain(PhabricatorSlowvotePoll $poll) { | private function buildCurtain(PhabricatorSlowvotePoll $poll) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$can_edit = PhabricatorPolicyFilter::hasCapability( | $can_edit = PhabricatorPolicyFilter::hasCapability( | ||||
$viewer, | $viewer, | ||||
$poll, | $poll, | ||||
PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
$curtain = $this->newCurtainView($poll); | $curtain = $this->newCurtainView($poll); | ||||
$is_closed = $poll->getIsClosed(); | $is_closed = $poll->isClosed(); | ||||
$close_poll_text = $is_closed ? pht('Reopen Poll') : pht('Close Poll'); | $close_poll_text = $is_closed ? pht('Reopen Poll') : pht('Close Poll'); | ||||
$close_poll_icon = $is_closed ? 'fa-check' : 'fa-ban'; | $close_poll_icon = $is_closed ? 'fa-check' : 'fa-ban'; | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setName(pht('Edit Poll')) | ->setName(pht('Edit Poll')) | ||||
->setIcon('fa-pencil') | ->setIcon('fa-pencil') | ||||
->setHref($this->getApplicationURI('edit/'.$poll->getID().'/')) | ->setHref($this->getApplicationURI('edit/'.$poll->getID().'/')) | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |