From eab74a9d7cd79e1c723472f27d8b2ef31b4928c6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 27 Jul 2016 09:07:29 -0700 Subject: [PATCH] Provide better headers and crumbs for Calendar result views Summary: Ref T11326. This isn't perfect, but should be a little easier to use and less weird/confusing. Generally, provide a "Query > Month > Day" crumb on day views, and a "Wed, July 3" header. Generally, provide a "Query > Month" crumb on month views, and a "July 2019" header. Also try to fix a bit of padding/spacing on the day view. Test Plan: {F1739128} Reviewers: chad Reviewed By: chad Maniphest Tasks: T11326 Differential Revision: https://secure.phabricator.com/D16338 --- resources/celerity/map.php | 8 +-- .../PhabricatorCalendarEventSearchEngine.php | 49 +++++++++++++++++-- ...PhabricatorApplicationSearchController.php | 23 +++++++-- ...PhabricatorApplicationSearchResultView.php | 24 +++++++++ .../control/AphrontFormDateControlValue.php | 21 -------- .../phui/calendar/PHUICalendarMonthView.php | 3 +- .../css/phui/calendar/phui-calendar-day.css | 1 - .../css/phui/calendar/phui-calendar-list.css | 18 +++++++ 8 files changed, 112 insertions(+), 35 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 3acfc7fd19..b9eac87871 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -115,8 +115,8 @@ return array( 'rsrc/css/layout/phabricator-filetree-view.css' => 'fccf9f82', 'rsrc/css/layout/phabricator-side-menu-view.css' => 'dd849797', 'rsrc/css/layout/phabricator-source-code-view.css' => 'cbeef983', - 'rsrc/css/phui/calendar/phui-calendar-day.css' => 'f15bb6d6', - 'rsrc/css/phui/calendar/phui-calendar-list.css' => '5d89cd71', + 'rsrc/css/phui/calendar/phui-calendar-day.css' => '572b1893', + 'rsrc/css/phui/calendar/phui-calendar-list.css' => 'fcc9fb41', 'rsrc/css/phui/calendar/phui-calendar-month.css' => '8e10e92c', 'rsrc/css/phui/calendar/phui-calendar.css' => 'daadaf39', 'rsrc/css/phui/phui-action-list.css' => 'c5eba19d', @@ -828,8 +828,8 @@ return array( 'phui-box-css' => '5c8387cf', 'phui-button-css' => '4a5fbe3d', 'phui-calendar-css' => 'daadaf39', - 'phui-calendar-day-css' => 'f15bb6d6', - 'phui-calendar-list-css' => '5d89cd71', + 'phui-calendar-day-css' => '572b1893', + 'phui-calendar-list-css' => 'fcc9fb41', 'phui-calendar-month-css' => '8e10e92c', 'phui-chart-css' => '6bf6f78e', 'phui-crumbs-view-css' => 'b4fa5755', diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php index d82e78d5b3..f093130bb4 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php @@ -362,7 +362,18 @@ final class PhabricatorCalendarEventSearchEngine $month_view->setBrowseURI( $this->getURI('query/'.$query->getQueryKey().'/')); + $from = $this->getQueryDateFrom($query)->getDateTime(); + + $crumbs = array(); + $crumbs[] = id(new PHUICrumbView()) + ->setName($from->format('F Y')); + + $header = id(new PHUIHeaderView()) + ->setHeader($from->format('F Y')); + return id(new PhabricatorApplicationSearchResultView()) + ->setCrumbs($crumbs) + ->setHeader($header) ->setContent($month_view) ->setCollapsed(true); } @@ -380,8 +391,8 @@ final class PhabricatorCalendarEventSearchEngine $query->getParameter('display')); $day_view = id(new PHUICalendarDayView( - $this->getQueryDateFrom($query)->getEpoch(), - $this->getQueryDateTo($query)->getEpoch(), + $this->getQueryDateFrom($query), + $this->getQueryDateTo($query), $start_year, $start_month, $start_day)) @@ -417,10 +428,26 @@ final class PhabricatorCalendarEventSearchEngine $day_view->addEvent($event_view); } - $day_view->setBrowseURI( - $this->getURI('query/'.$query->getQueryKey().'/')); + $browse_uri = $this->getURI('query/'.$query->getQueryKey().'/'); + $day_view->setBrowseURI($browse_uri); + + $from = $this->getQueryDateFrom($query)->getDateTime(); + $month_uri = $browse_uri.$from->format('Y/m/'); + + $crumbs = array( + id(new PHUICrumbView()) + ->setName($from->format('F Y')) + ->setHref($month_uri), + id(new PHUICrumbView()) + ->setName($from->format('D jS')), + ); + + $header = id(new PHUIHeaderView()) + ->setHeader($from->format('D, F jS')); return id(new PhabricatorApplicationSearchResultView()) + ->setCrumbs($crumbs) + ->setHeader($header) ->setContent($day_view) ->setCollapsed(true); } @@ -466,6 +493,20 @@ final class PhabricatorCalendarEventSearchEngine } private function getQueryDateFrom(PhabricatorSavedQuery $saved) { + if ($this->calendarYear && $this->calendarMonth) { + $viewer = $this->requireViewer(); + + $start_year = $this->calendarYear; + $start_month = $this->calendarMonth; + $start_day = $this->calendarDay ? $this->calendarDay : 1; + + return AphrontFormDateControlValue::newFromDictionary( + $viewer, + array( + 'd' => "{$start_year}-{$start_month}-{$start_day}", + )); + } + return $this->getQueryDate($saved, 'rangeStart'); } diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php index 688a7db527..b9ed90e80e 100644 --- a/src/applications/search/controller/PhabricatorApplicationSearchController.php +++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php @@ -210,7 +210,7 @@ final class PhabricatorApplicationSearchController } $body[] = $box; - + $more_crumbs = null; if ($run_query) { $exec_errors = array(); @@ -272,6 +272,13 @@ final class PhabricatorApplicationSearchController $box->setCollapsed(true); } + $result_header = $list->getHeader(); + if ($result_header) { + $box->setHeader($result_header); + } + + $more_crumbs = $list->getCrumbs(); + if ($pager->willShowPagingControls()) { $pager_box = id(new PHUIBoxView()) ->addPadding(PHUI::PADDING_MEDIUM) @@ -301,8 +308,18 @@ final class PhabricatorApplicationSearchController } $crumbs = $parent - ->buildApplicationCrumbs() - ->addTextCrumb($title); + ->buildApplicationCrumbs(); + + if ($more_crumbs) { + $query_uri = $engine->getQueryResultsPageURI($saved_query->getQueryKey()); + $crumbs->addTextCrumb($title, $query_uri); + + foreach ($more_crumbs as $crumb) { + $crumbs->addCrumb($crumb); + } + } else { + $crumbs->addTextCrumb($title); + } return $this->newPage() ->setApplicationMenu($this->buildApplicationMenu()) diff --git a/src/applications/search/view/PhabricatorApplicationSearchResultView.php b/src/applications/search/view/PhabricatorApplicationSearchResultView.php index 45a396898b..5bcfdcf675 100644 --- a/src/applications/search/view/PhabricatorApplicationSearchResultView.php +++ b/src/applications/search/view/PhabricatorApplicationSearchResultView.php @@ -14,6 +14,8 @@ final class PhabricatorApplicationSearchResultView extends Phobject { private $actions = array(); private $collapsed = null; private $noDataString; + private $crumbs = array(); + private $header; public function setObjectList(PHUIObjectItemListView $list) { $this->objectList = $list; @@ -82,4 +84,26 @@ final class PhabricatorApplicationSearchResultView extends Phobject { return $this; } + public function setCrumbs(array $crumbs) { + assert_instances_of($crumbs, 'PHUICrumbView'); + + $this->crumbs = $crumbs; + return $this; + } + + public function getCrumbs() { + return $this->crumbs; + } + + public function setHeader(PHUIHeaderView $header) { + $this->header = $header; + return $this; + } + + public function getHeader() { + return $this->header; + } + + + } diff --git a/src/view/form/control/AphrontFormDateControlValue.php b/src/view/form/control/AphrontFormDateControlValue.php index aeb35cdb15..f9dc14b238 100644 --- a/src/view/form/control/AphrontFormDateControlValue.php +++ b/src/view/form/control/AphrontFormDateControlValue.php @@ -59,27 +59,6 @@ final class AphrontFormDateControlValue extends Phobject { return $this->viewer; } - public static function newFromParts( - PhabricatorUser $viewer, - $year, - $month, - $day, - $time = null, - $enabled = true) { - - $value = new AphrontFormDateControlValue(); - $value->viewer = $viewer; - list($value->valueDate, $value->valueTime) = - $value->getFormattedDateFromParts( - $year, - $month, - $day, - coalesce($time, '12:00 AM')); - $value->valueEnabled = $enabled; - - return $value; - } - public static function newFromRequest(AphrontRequest $request, $key) { $value = new AphrontFormDateControlValue(); $value->viewer = $request->getViewer(); diff --git a/src/view/phui/calendar/PHUICalendarMonthView.php b/src/view/phui/calendar/PHUICalendarMonthView.php index 0cc3d9b815..61fd8b1e99 100644 --- a/src/view/phui/calendar/PHUICalendarMonthView.php +++ b/src/view/phui/calendar/PHUICalendarMonthView.php @@ -445,8 +445,7 @@ final class PHUICalendarMonthView extends AphrontView { } - $header = id(new PHUIHeaderView()) - ->setHeader($date->format('F Y')); + $header = id(new PHUIHeaderView()); if ($button_bar) { $header->setButtonBar($button_bar); diff --git a/webroot/rsrc/css/phui/calendar/phui-calendar-day.css b/webroot/rsrc/css/phui/calendar/phui-calendar-day.css index acb577675a..1c97c42265 100644 --- a/webroot/rsrc/css/phui/calendar/phui-calendar-day.css +++ b/webroot/rsrc/css/phui/calendar/phui-calendar-day.css @@ -92,7 +92,6 @@ div.phui-calendar-day-event.all-day { background-color: {$bluebackground}; color: {$greytext}; text-decoration: none; - text-decoration: none; } .day-view-all-day { diff --git a/webroot/rsrc/css/phui/calendar/phui-calendar-list.css b/webroot/rsrc/css/phui/calendar/phui-calendar-list.css index 9cf5e3bcd8..d5a4a89dc9 100644 --- a/webroot/rsrc/css/phui/calendar/phui-calendar-list.css +++ b/webroot/rsrc/css/phui/calendar/phui-calendar-list.css @@ -66,4 +66,22 @@ .phui-calendar-list-item-empty { color: {$lightgreytext}; + padding: 0 12px; + font-style: italic; +} + +.phui-calendar-list-item.all-day { + background: {$bluebackground}; +} + +.calendar-day-view-sidebar .phui-calendar-list { + padding: 12px 0; +} + +.calendar-day-view-sidebar .phui-calendar-list-item { + padding: 0 12px; +} + +.calendar-day-view-sidebar .phui-calendar-list-item a { + position: relative; }