Changeset View
Changeset View
Standalone View
Standalone View
src/applications/pholio/query/PholioMockSearchEngine.php
<?php | <?php | ||||
final class PholioMockSearchEngine | final class PholioMockSearchEngine | ||||
extends PhabricatorApplicationSearchEngine { | extends PhabricatorApplicationSearchEngine { | ||||
public function getApplicationClassName() { | public function getApplicationClassName() { | ||||
return 'PhabricatorApplicationPholio'; | return 'PhabricatorApplicationPholio'; | ||||
} | } | ||||
public function buildSavedQueryFromRequest(AphrontRequest $request) { | public function buildSavedQueryFromRequest(AphrontRequest $request) { | ||||
$saved = new PhabricatorSavedQuery(); | $saved = new PhabricatorSavedQuery(); | ||||
$saved->setParameter( | $saved->setParameter( | ||||
'authorPHIDs', | 'authorPHIDs', | ||||
$this->readUsersFromRequest($request, 'authors')); | $this->readUsersFromRequest($request, 'authors')); | ||||
$saved->setParameter( | |||||
'statuses', | |||||
$request->getStrList('status')); | |||||
return $saved; | return $saved; | ||||
} | } | ||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | ||||
$query = id(new PholioMockQuery()) | $query = id(new PholioMockQuery()) | ||||
->needCoverFiles(true) | ->needCoverFiles(true) | ||||
->needImages(true) | ->needImages(true) | ||||
->needTokenCounts(true) | ->needTokenCounts(true) | ||||
->withAuthorPHIDs($saved->getParameter('authorPHIDs', array())); | ->withAuthorPHIDs($saved->getParameter('authorPHIDs', array())) | ||||
->withStatuses($saved->getParameter('statuses', array())); | |||||
return $query; | return $query; | ||||
} | } | ||||
public function buildSearchForm( | public function buildSearchForm( | ||||
AphrontFormView $form, | AphrontFormView $form, | ||||
PhabricatorSavedQuery $saved_query) { | PhabricatorSavedQuery $saved_query) { | ||||
$phids = $saved_query->getParameter('authorPHIDs', array()); | $phids = $saved_query->getParameter('authorPHIDs', array()); | ||||
$author_handles = id(new PhabricatorHandleQuery()) | $author_handles = id(new PhabricatorHandleQuery()) | ||||
->setViewer($this->requireViewer()) | ->setViewer($this->requireViewer()) | ||||
->withPHIDs($phids) | ->withPHIDs($phids) | ||||
->execute(); | ->execute(); | ||||
$statuses = array( | |||||
''=>pht('Any Status'), | |||||
'closed'=>pht('Closed'), | |||||
'open'=>pht('Open')); | |||||
$status = $saved_query->getParameter('statuses', array()); | |||||
$status = head($status); | |||||
$form | $form | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormTokenizerControl()) | id(new AphrontFormTokenizerControl()) | ||||
->setDatasource('/typeahead/common/users/') | ->setDatasource('/typeahead/common/users/') | ||||
->setName('authors') | ->setName('authors') | ||||
->setLabel(pht('Authors')) | ->setLabel(pht('Authors')) | ||||
->setValue($author_handles)); | ->setValue($author_handles)) | ||||
->appendChild( | |||||
id(new AphrontFormSelectControl()) | |||||
->setLabel(pht('Status')) | |||||
->setName('status') | |||||
->setOptions($statuses) | |||||
->setValue($status)); | |||||
} | } | ||||
protected function getURI($path) { | protected function getURI($path) { | ||||
return '/pholio/'.$path; | return '/pholio/'.$path; | ||||
} | } | ||||
public function getBuiltinQueryNames() { | public function getBuiltinQueryNames() { | ||||
$names = array( | $names = array( | ||||
'open' => pht('Open Mocks'), | |||||
'all' => pht('All Mocks'), | 'all' => pht('All Mocks'), | ||||
); | ); | ||||
if ($this->requireViewer()->isLoggedIn()) { | if ($this->requireViewer()->isLoggedIn()) { | ||||
$names['authored'] = pht('Authored'); | $names['authored'] = pht('Authored'); | ||||
} | } | ||||
return $names; | return $names; | ||||
} | } | ||||
public function buildSavedQueryFromBuiltin($query_key) { | public function buildSavedQueryFromBuiltin($query_key) { | ||||
$query = $this->newSavedQuery(); | $query = $this->newSavedQuery(); | ||||
$query->setQueryKey($query_key); | $query->setQueryKey($query_key); | ||||
switch ($query_key) { | switch ($query_key) { | ||||
case 'open': | |||||
return $query->setParameter( | |||||
'statuses', | |||||
array('open')); | |||||
case 'all': | case 'all': | ||||
return $query; | return $query; | ||||
case 'authored': | case 'authored': | ||||
return $query->setParameter( | return $query->setParameter( | ||||
'authorPHIDs', | 'authorPHIDs', | ||||
array($this->requireViewer()->getPHID())); | array($this->requireViewer()->getPHID())); | ||||
} | } | ||||
Show All 11 Lines | protected function renderResultList( | ||||
PhabricatorSavedQuery $query, | PhabricatorSavedQuery $query, | ||||
array $handles) { | array $handles) { | ||||
assert_instances_of($mocks, 'PholioMock'); | assert_instances_of($mocks, 'PholioMock'); | ||||
$viewer = $this->requireViewer(); | $viewer = $this->requireViewer(); | ||||
$board = new PHUIPinboardView(); | $board = new PHUIPinboardView(); | ||||
foreach ($mocks as $mock) { | foreach ($mocks as $mock) { | ||||
$header = 'M'.$mock->getID().' '.$mock->getName(); | |||||
if ($mock->isClosed()) { | |||||
epriestley: As above. | |||||
$header = pht('%s (Closed)', $header); | |||||
Not Done Inline ActionsI'm worried if this gets cut off in long titles? Don't recall the CSS offhand. chad: I'm worried if this gets cut off in long titles? Don't recall the CSS offhand. | |||||
Not Done Inline Actions(We're doing the same thing in Macro right now, the pinboards just don't have a "disabled" style yet.) epriestley: (We're doing the same thing in Macro right now, the pinboards just don't have a "disabled"… | |||||
} | |||||
$item = id(new PHUIPinboardItemView()) | $item = id(new PHUIPinboardItemView()) | ||||
->setHeader('M'.$mock->getID().' '.$mock->getName()) | ->setHeader($header) | ||||
->setURI('/M'.$mock->getID()) | ->setURI('/M'.$mock->getID()) | ||||
->setImageURI($mock->getCoverFile()->getThumb280x210URI()) | ->setImageURI($mock->getCoverFile()->getThumb280x210URI()) | ||||
->setImageSize(280, 210) | ->setImageSize(280, 210) | ||||
->addIconCount('fa-picture-o', count($mock->getImages())) | ->addIconCount('fa-picture-o', count($mock->getImages())) | ||||
->addIconCount('fa-trophy', $mock->getTokenCount()); | ->addIconCount('fa-trophy', $mock->getTokenCount()); | ||||
if ($mock->getAuthorPHID()) { | if ($mock->getAuthorPHID()) { | ||||
$author_handle = $handles[$mock->getAuthorPHID()]; | $author_handle = $handles[$mock->getAuthorPHID()]; | ||||
Show All 12 Lines |
As above.