1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 00:10:57 +01:00

When viewing a Calendar import, show all the events it imported

Summary: Ref T10747. Show which events a source imported, and link to the full list as a query result.

Test Plan: {F1870049}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10747

Differential Revision: https://secure.phabricator.com/D16703
This commit is contained in:
epriestley 2016-10-13 08:51:27 -07:00
parent 6e2a86470b
commit c2411e3dcc
2 changed files with 53 additions and 0 deletions

View file

@ -30,10 +30,13 @@ final class PhabricatorCalendarImportViewController
$curtain = $this->buildCurtain($import);
$details = $this->buildPropertySection($import);
$imported_events = $this->buildImportedEvents($import);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setMainColumn(
array(
$imported_events,
$timeline,
))
->setCurtain($curtain)
@ -130,4 +133,46 @@ final class PhabricatorCalendarImportViewController
return $properties;
}
private function buildImportedEvents(
PhabricatorCalendarImport $import) {
$viewer = $this->getViewer();
$engine = id(new PhabricatorCalendarEventSearchEngine())
->setViewer($viewer);
$saved = $engine->newSavedQuery()
->setParameter('importSourcePHIDs', array($import->getPHID()));
$pager = $engine->newPagerForSavedQuery($saved);
$pager->setPageSize(25);
$query = $engine->buildQueryFromSavedQuery($saved);
$results = $engine->executeQuery($query, $pager);
$view = $engine->renderResults($results, $saved);
$list = $view->getObjectList();
$list->setNoDataString(pht('No imported events.'));
$all_uri = $this->getApplicationURI();
$all_uri = (string)id(new PhutilURI($all_uri))
->setQueryParam('importSourcePHID', $import->getPHID())
->setQueryParam('display', 'list');
$all_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('View All'))
->setIcon('fa-search')
->setHref($all_uri);
$header = id(new PHUIHeaderView())
->setHeader(pht('Imported Events'))
->addActionLink($all_button);
return id(new PHUIObjectBoxView())
->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setObjectList($list);
}
}

View file

@ -51,6 +51,10 @@ final class PhabricatorCalendarEventSearchEngine
->setKey('isCancelled')
->setOptions($this->getCancelledOptions())
->setDefault('active'),
id(new PhabricatorPHIDsSearchField())
->setLabel(pht('Import Sources'))
->setKey('importSourcePHIDs')
->setAliases(array('importSourcePHID')),
id(new PhabricatorSearchSelectField())
->setLabel(pht('Display Options'))
->setKey('display')
@ -114,6 +118,10 @@ final class PhabricatorCalendarEventSearchEngine
break;
}
if ($map['importSourcePHIDs']) {
$query->withImportSourcePHIDs($map['importSourcePHIDs']);
}
// Generate ghosts (and ignore stub events) if we aren't querying for
// specific events or exporting.
if (!empty($map['export'])) {