Changeset View
Changeset View
Standalone View
Standalone View
src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php
Show All 20 Lines | protected function buildQueryFromParameters(array $map) { | ||||
if ($map['voted']) { | if ($map['voted']) { | ||||
$query->withVotesByViewer(true); | $query->withVotesByViewer(true); | ||||
} | } | ||||
if ($map['authorPHIDs']) { | if ($map['authorPHIDs']) { | ||||
$query->withAuthorPHIDs($map['authorPHIDs']); | $query->withAuthorPHIDs($map['authorPHIDs']); | ||||
} | } | ||||
$statuses = $map['statuses']; | if ($map['statuses']) { | ||||
if (count($statuses) == 1) { | $query->withStatuses($map['statuses']); | ||||
$status = head($statuses); | |||||
if ($status == 'open') { | |||||
$query->withIsClosed(false); | |||||
} else { | |||||
$query->withIsClosed(true); | |||||
} | |||||
} | } | ||||
return $query; | return $query; | ||||
} | } | ||||
protected function buildCustomSearchFields() { | protected function buildCustomSearchFields() { | ||||
$status_options = SlowvotePollStatus::getAll(); | |||||
$status_options = mpull($status_options, 'getName'); | |||||
return array( | return array( | ||||
id(new PhabricatorUsersSearchField()) | id(new PhabricatorUsersSearchField()) | ||||
->setKey('authorPHIDs') | ->setKey('authorPHIDs') | ||||
->setAliases(array('authors')) | ->setAliases(array('authors')) | ||||
->setLabel(pht('Authors')), | ->setLabel(pht('Authors')), | ||||
id(new PhabricatorSearchCheckboxesField()) | id(new PhabricatorSearchCheckboxesField()) | ||||
->setKey('voted') | ->setKey('voted') | ||||
->setLabel(pht('Voted')) | ->setLabel(pht('Voted')) | ||||
// TODO: This should probably become a list of "voterPHIDs", so hide | // TODO: This should probably become a list of "voterPHIDs", so hide | ||||
// the field from Conduit to avoid a backward compatibility break when | // the field from Conduit to avoid a backward compatibility break when | ||||
// this changes. | // this changes. | ||||
->setEnableForConduit(false) | ->setEnableForConduit(false) | ||||
->setOptions(array( | ->setOptions(array( | ||||
'voted' => pht("Show only polls I've voted in."), | 'voted' => pht("Show only polls I've voted in."), | ||||
)), | )), | ||||
id(new PhabricatorSearchCheckboxesField()) | id(new PhabricatorSearchCheckboxesField()) | ||||
->setKey('statuses') | ->setKey('statuses') | ||||
->setLabel(pht('Statuses')) | ->setLabel(pht('Statuses')) | ||||
->setOptions( | ->setOptions($status_options), | ||||
array( | |||||
'open' => pht('Open'), | |||||
'closed' => pht('Closed'), | |||||
)), | |||||
); | ); | ||||
} | } | ||||
protected function getURI($path) { | protected function getURI($path) { | ||||
return '/vote/'.$path; | return '/vote/'.$path; | ||||
} | } | ||||
protected function getBuiltinQueryNames() { | protected function getBuiltinQueryNames() { | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | foreach ($polls as $poll) { | ||||
$author = $handles[$poll->getAuthorPHID()]->renderLink(); | $author = $handles[$poll->getAuthorPHID()]->renderLink(); | ||||
} else { | } else { | ||||
$author = null; | $author = null; | ||||
} | } | ||||
$item = id(new PHUIObjectItemView()) | $item = id(new PHUIObjectItemView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setObject($poll) | ->setObject($poll) | ||||
->setObjectName('V'.$poll->getID()) | ->setObjectName($poll->getMonogram()) | ||||
->setHeader($poll->getQuestion()) | ->setHeader($poll->getQuestion()) | ||||
->setHref('/V'.$poll->getID()) | ->setHref($poll->getURI()) | ||||
->addIcon('none', $date_created); | ->addIcon('none', $date_created); | ||||
if ($poll->isClosed()) { | if ($poll->isClosed()) { | ||||
$item->setStatusIcon('fa-ban grey'); | $item->setStatusIcon('fa-ban grey'); | ||||
$item->setDisabled(true); | $item->setDisabled(true); | ||||
} else { | } else { | ||||
$item->setStatusIcon('fa-bar-chart'); | $item->setStatusIcon('fa-bar-chart'); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |