From 87bf532c4146f7bd8c51a73712290f370993616d Mon Sep 17 00:00:00 2001 From: lkassianik Date: Thu, 14 May 2015 12:35:34 -0700 Subject: [PATCH] Calendar tooltips should always show start and end time of events. Summary: Closes T8191, Calendar tooltips should always show start and end time of events. Test Plan: Open month view, hover over, All day events, multi-day all day events, multi-day non-all-day events, and regular events. Tooltips should be "All day", "All day, - ", "-", and "-", respectively. Reviewers: epriestley, #blessed_reviewers, chad Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T8191 Differential Revision: https://secure.phabricator.com/D12846 --- resources/celerity/map.php | 4 +-- .../control/AphrontFormDateControlValue.php | 7 ++++ .../phui/calendar/PHUICalendarListView.php | 34 ++++++++++++++++--- .../css/phui/calendar/phui-calendar-month.css | 4 --- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 36b773434a..2c92f74300 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -122,7 +122,7 @@ return array( 'rsrc/css/layout/phabricator-source-code-view.css' => '2ceee894', 'rsrc/css/phui/calendar/phui-calendar-day.css' => '38891735', 'rsrc/css/phui/calendar/phui-calendar-list.css' => 'c1d0ca59', - 'rsrc/css/phui/calendar/phui-calendar-month.css' => '75e6a2ee', + 'rsrc/css/phui/calendar/phui-calendar-month.css' => 'e7ee38c6', 'rsrc/css/phui/calendar/phui-calendar.css' => '8675968e', 'rsrc/css/phui/phui-action-header-view.css' => '89c497e7', 'rsrc/css/phui/phui-action-list.css' => '4f4d09f2', @@ -763,7 +763,7 @@ return array( 'phui-calendar-css' => '8675968e', 'phui-calendar-day-css' => '38891735', 'phui-calendar-list-css' => 'c1d0ca59', - 'phui-calendar-month-css' => '75e6a2ee', + 'phui-calendar-month-css' => 'e7ee38c6', 'phui-crumbs-view-css' => '594d719e', 'phui-document-view-css' => '94d5dcd8', 'phui-feed-story-css' => 'c9f3a0b5', diff --git a/src/view/form/control/AphrontFormDateControlValue.php b/src/view/form/control/AphrontFormDateControlValue.php index 58a7b754b1..3fb6a07fb4 100644 --- a/src/view/form/control/AphrontFormDateControlValue.php +++ b/src/view/form/control/AphrontFormDateControlValue.php @@ -157,6 +157,13 @@ final class AphrontFormDateControlValue extends Phobject { ); } + public function getValueAsFormat($format) { + return phabricator_format_local_time( + $this->getEpoch(), + $this->viewer, + $format); + } + private function formatTime($epoch, $format) { return phabricator_format_local_time( $epoch, diff --git a/src/view/phui/calendar/PHUICalendarListView.php b/src/view/phui/calendar/PHUICalendarListView.php index fc40d87745..c2d33b8469 100644 --- a/src/view/phui/calendar/PHUICalendarListView.php +++ b/src/view/phui/calendar/PHUICalendarListView.php @@ -105,12 +105,36 @@ final class PHUICalendarListView extends AphrontTagView { Javelin::initBehavior('phabricator-tooltips'); - if ($event->getMultiDay()) { - $tip = pht('%s, Until: %s', $event->getName(), - phabricator_date($event->getEpochEnd(), $this->getUser())); + $start = id(AphrontFormDateControlValue::newFromEpoch( + $this->getUser(), + $event->getEpochStart())); + $end = id(AphrontFormDateControlValue::newFromEpoch( + $this->getUser(), + $event->getEpochEnd())); + + if ($event->getIsAllDay()) { + if ($start->getValueDay() == $end->getValueDay()) { + $tip = pht('All day'); + } else { + $tip = pht( + 'All day, %s - %s', + $start->getValueAsFormat('M j, Y'), + $end->getValueAsFormat('M j, Y')); + } } else { - $tip = pht('%s, Until: %s', $event->getName(), - phabricator_time($event->getEpochEnd(), $this->getUser())); + if ($start->getValueDay() == $end->getValueDay() && + $start->getValueMonth() == $end->getValueMonth() && + $start->getValueYear() == $end->getValueYear()) { + $tip = pht( + '%s - %s', + $start->getValueAsFormat('g:i A'), + $end->getValueAsFormat('g:i A')); + } else { + $tip = pht( + '%s - %s', + $start->getValueAsFormat('M j, Y, g:i A'), + $end->getValueAsFormat('M j, Y, g:i A')); + } } $description = $event->getDescription(); diff --git a/webroot/rsrc/css/phui/calendar/phui-calendar-month.css b/webroot/rsrc/css/phui/calendar/phui-calendar-month.css index 3f53e89b25..284937f1a9 100644 --- a/webroot/rsrc/css/phui/calendar/phui-calendar-month.css +++ b/webroot/rsrc/css/phui/calendar/phui-calendar-month.css @@ -88,10 +88,6 @@ table.phui-calendar-view td.phui-calendar-date-number-container { text-align: right; } -.phui-calendar-not-work-day { - background-color: {$lightgreybackground}; -} - .phui-calendar-today-slot { display: block; width: 100%;