From bb7285ab463b58894a5df58d0f5388ae565d06f3 Mon Sep 17 00:00:00 2001 From: vrana Date: Mon, 21 May 2012 11:59:12 -0700 Subject: [PATCH] Don't mix different users on the same line in Calendar Summary: The current state is very confusing: {F11734, size=full} Test Plan: Display calendar for user with two different events in the same week. Reviewers: epriestley, btrahan Reviewed By: epriestley CC: aran, Koolvin Differential Revision: https://secure.phabricator.com/D2522 --- src/__celerity_resource_map__.php | 2 +- .../PhabricatorCalendarBrowseController.php | 1 + .../view/event/AphrontCalendarEventView.php | 10 ++++++ .../view/month/AphrontCalendarMonthView.php | 32 +++++++++++++------ webroot/rsrc/css/aphront/calendar-view.css | 8 ++++- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 6e49c8b602..45f0cb5211 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -389,7 +389,7 @@ celerity_register_resource_map(array( ), 'aphront-calendar-view-css' => array( - 'uri' => '/res/4fd79240/rsrc/css/aphront/calendar-view.css', + 'uri' => '/res/b200376d/rsrc/css/aphront/calendar-view.css', 'type' => 'css', 'requires' => array( diff --git a/src/applications/calendar/controller/browse/PhabricatorCalendarBrowseController.php b/src/applications/calendar/controller/browse/PhabricatorCalendarBrowseController.php index 6a1a5de855..493ab6b7c3 100644 --- a/src/applications/calendar/controller/browse/PhabricatorCalendarBrowseController.php +++ b/src/applications/calendar/controller/browse/PhabricatorCalendarBrowseController.php @@ -51,6 +51,7 @@ final class PhabricatorCalendarBrowseController $name_text = $handles[$status->getUserPHID()]->getName(); $status_text = $status->getTextStatus(); + $event->setUserPHID($status->getUserPHID()); $event->setName("{$name_text} ({$status_text})"); $event->setDescription($status->getStatusDescription($user)); $month_view->addEvent($event); diff --git a/src/applications/calendar/view/event/AphrontCalendarEventView.php b/src/applications/calendar/view/event/AphrontCalendarEventView.php index 96edc741fa..dd079ac7db 100644 --- a/src/applications/calendar/view/event/AphrontCalendarEventView.php +++ b/src/applications/calendar/view/event/AphrontCalendarEventView.php @@ -18,11 +18,21 @@ final class AphrontCalendarEventView extends AphrontView { + private $userPHID; private $name; private $epochStart; private $epochEnd; private $description; + public function setUserPHID($user_phid) { + $this->userPHID = $user_phid; + return $this; + } + + public function getUserPHID() { + return $this->userPHID; + } + public function setName($name) { $this->name = $name; return $this; diff --git a/src/applications/calendar/view/month/AphrontCalendarMonthView.php b/src/applications/calendar/view/month/AphrontCalendarMonthView.php index fc217c422b..7134757bc5 100644 --- a/src/applications/calendar/view/month/AphrontCalendarMonthView.php +++ b/src/applications/calendar/view/month/AphrontCalendarMonthView.php @@ -69,6 +69,8 @@ final class AphrontCalendarMonthView extends AphrontView { $markup[] = $empty_box; } + $show_events = array(); + foreach ($days as $day) { $holiday = idx($this->holidays, $day->format('Y-m-d')); $class = 'aphront-calendar-day'; @@ -80,18 +82,27 @@ final class AphrontCalendarMonthView extends AphrontView { $day->setTime(0, 0, 0); $epoch_start = $day->format('U'); - $day->setTime(23, 59, 59); + $day->setTime(24, 0, 0); $epoch_end = $day->format('U'); - $show_events = array(); + if ($weekday == 0) { + $show_events = array(); + } else { + $show_events = array_fill_keys( + array_keys($show_events), + '
'. + ' '. + '
'); + } + foreach ($events as $event) { - if ($event->getEpochStart() > $epoch_end) { + if ($event->getEpochStart() >= $epoch_end) { // This list is sorted, so we can stop looking. break; } - if ($event->getEpochStart() <= $epoch_end && - $event->getEpochEnd() >= $epoch_start) { - $show_events[] = $this->renderEvent( + if ($event->getEpochStart() < $epoch_end && + $event->getEpochEnd() > $epoch_start) { + $show_events[$event->getUserPHID()] = $this->renderEvent( $event, $day, $epoch_start, @@ -101,18 +112,19 @@ final class AphrontCalendarMonthView extends AphrontView { $holiday_markup = null; if ($holiday) { + $name = phutil_escape_html($holiday->getName()); $holiday_markup = - '
'. - phutil_escape_html($holiday->getName()). + '
'. + $name. '
'; } $markup[] = '
'. - $holiday_markup. '
'. $day->format('j'). '
'. + $holiday_markup. implode("\n", $show_events). '
'; } @@ -213,7 +225,7 @@ final class AphrontCalendarMonthView extends AphrontView { if ($event_end > $epoch_end) { $classes[] = 'aphront-calendar-event-continues-after'; - $when[] = 'Ends '.phabricator_datetime($event_start, $user); + $when[] = 'Ends '.phabricator_datetime($event_end, $user); } else { $when[] = 'Ends at '.phabricator_time($event_end, $user); } diff --git a/webroot/rsrc/css/aphront/calendar-view.css b/webroot/rsrc/css/aphront/calendar-view.css index db381bb46b..e1b1a5962d 100644 --- a/webroot/rsrc/css/aphront/calendar-view.css +++ b/webroot/rsrc/css/aphront/calendar-view.css @@ -36,9 +36,10 @@ table.aphront-calendar-view td div.aphront-calendar-day { } .aphront-calendar-holiday { - float: left; color: #666666; padding: .5em; + max-height: 1em; + overflow: hidden; } .aphront-calendar-date-number { @@ -83,6 +84,11 @@ table.aphront-calendar-view td div.aphront-calendar-day { overflow: hidden; } +.aphront-calendar-event-empty { + border-color: transparent; + background: transparent; +} + .aphront-calendar-event-text { overflow: hidden; white-space: nowrap;