From ef6c689e87624d74ebf1c0cb77fc69604440af79 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 27 Jul 2016 08:23:27 -0700 Subject: [PATCH] When a Calendar day has too many events, show a "More..." link Summary: Fixes T8361. Test Plan: {F1739073} Reviewers: chad Reviewed By: chad Maniphest Tasks: T8361 Differential Revision: https://secure.phabricator.com/D16337 --- .../phui/calendar/PHUICalendarListView.php | 37 ++++++++++++++++++- .../phui/calendar/PHUICalendarMonthView.php | 9 +++-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/view/phui/calendar/PHUICalendarListView.php b/src/view/phui/calendar/PHUICalendarListView.php index d84c0b0bc3..88bbde351a 100644 --- a/src/view/phui/calendar/PHUICalendarListView.php +++ b/src/view/phui/calendar/PHUICalendarListView.php @@ -5,6 +5,16 @@ final class PHUICalendarListView extends AphrontTagView { private $events = array(); private $blankState; private $view; + private $moreLink; + + public function setMoreLink($more_link) { + $this->moreLink = $more_link; + return $this; + } + + public function getMoreLink() { + return $this->moreLink; + } private function getView() { return $this->view; @@ -60,7 +70,7 @@ final class PHUICalendarListView extends AphrontTagView { $icon_icon = $event->getIcon(); $icon_color = $event->getIconColor(); - $dot = id(new PHUIIconView()) + $icon = id(new PHUIIconView()) ->setIcon($icon_icon, $icon_color) ->addClass('phui-calendar-list-item-icon'); @@ -108,7 +118,7 @@ final class PHUICalendarListView extends AphrontTagView { ), ), array( - $dot, + $icon, $time, $title, )); @@ -121,6 +131,29 @@ final class PHUICalendarListView extends AphrontTagView { $content); } + if ($this->moreLink) { + $singletons[] = phutil_tag( + 'li', + array( + 'class' => 'phui-calendar-list-item', + ), + phutil_tag( + 'a', + array( + 'href' => $this->moreLink, + 'class' => 'phui-calendar-list-more', + ), + array( + id(new PHUIIconView())->setIcon('fa-ellipsis-h grey'), + phutil_tag( + 'span', + array( + 'class' => 'phui-calendar-list-title', + ), + pht('View More...')), + ))); + } + if (empty($singletons)) { $singletons[] = phutil_tag( 'li', diff --git a/src/view/phui/calendar/PHUICalendarMonthView.php b/src/view/phui/calendar/PHUICalendarMonthView.php index d7efeac97f..0cc3d9b815 100644 --- a/src/view/phui/calendar/PHUICalendarMonthView.php +++ b/src/view/phui/calendar/PHUICalendarMonthView.php @@ -95,13 +95,13 @@ final class PHUICalendarMonthView extends AphrontView { ->setViewer($viewer) ->setView('month'); foreach ($all_day_events as $item) { - if ($counter <= $max_daily) { + if ($counter < $max_daily) { $list->addEvent($item); } $counter++; } foreach ($list_events as $item) { - if ($counter <= $max_daily) { + if ($counter < $max_daily) { $list->addEvent($item); } $counter++; @@ -112,8 +112,11 @@ final class PHUICalendarMonthView extends AphrontView { $day->format('m').'/'. $day->format('d').'/'; - $day_id = $day->format('Ymd'); + if ($counter > $max_daily) { + $list->setMoreLink($uri); + } + $day_id = $day->format('Ymd'); $classes = array(); if ($day->format('m') != $this->month) { -- 2.51.2