1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Calendar day view should start at 8am at the latest and hour of first event at the earliest.

Summary: Closes T8114, Calendar day view should start at 8am at the latest and hour of first event at the earliest.

Test Plan: Open day view on day with all day event and event at 5am, all day events should all be stacked at the top of the day view table, and day should start at 5am.

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T8114

Differential Revision: https://secure.phabricator.com/D12779
This commit is contained in:
lkassianik 2015-05-08 16:19:51 -07:00
parent f309960a2d
commit ddb62d1ec3
3 changed files with 94 additions and 24 deletions

View file

@ -120,7 +120,7 @@ return array(
'rsrc/css/layout/phabricator-hovercard-view.css' => '44394670',
'rsrc/css/layout/phabricator-side-menu-view.css' => 'c1db9e9c',
'rsrc/css/layout/phabricator-source-code-view.css' => '2ceee894',
'rsrc/css/phui/calendar/phui-calendar-day.css' => '75b8cc4a',
'rsrc/css/phui/calendar/phui-calendar-day.css' => '49037167',
'rsrc/css/phui/calendar/phui-calendar-list.css' => 'c1d0ca59',
'rsrc/css/phui/calendar/phui-calendar-month.css' => 'a92e47d2',
'rsrc/css/phui/calendar/phui-calendar.css' => '8675968e',
@ -777,7 +777,7 @@ return array(
'phui-box-css' => '7b3a2eed',
'phui-button-css' => 'de610129',
'phui-calendar-css' => '8675968e',
'phui-calendar-day-css' => '75b8cc4a',
'phui-calendar-day-css' => '49037167',
'phui-calendar-list-css' => 'c1d0ca59',
'phui-calendar-month-css' => 'a92e47d2',
'phui-crumbs-view-css' => '594d719e',

View file

@ -35,30 +35,32 @@ final class PHUICalendarDayView extends AphrontView {
$hours = $this->getHoursOfDay();
$hourly_events = array();
$rows = array();
$first_event_hour = null;
$all_day_events = $this->getAllDayEvents();
$today_all_day_events = array();
$day_start = $this->getDateTime();
$day_end = id(clone $day_start)->modify('+1 day');
$day_start = $day_start->format('U');
$day_end = $day_end->format('U');
foreach ($all_day_events as $all_day_event) {
$all_day_start = $all_day_event->getEpochStart();
$all_day_end = $all_day_event->getEpochEnd();
if ($all_day_start < $day_end && $all_day_end > $day_start) {
$today_all_day_events[] = $all_day_event;
}
}
// sort events into buckets by their start time
// pretend no events overlap
foreach ($hours as $hour) {
$current_hour_events = array();
$hour_start = $hour->format('U');
$hour_end = id(clone $hour)->modify('+1 hour')->format('U');
if ($hour == $this->getDateTime()) {
foreach ($all_day_events as $all_day_event) {
$all_day_start = $all_day_event->getEpochStart();
$all_day_end = $all_day_event->getEpochEnd();
$day_end = id(clone $hour)->modify('+1 day')->format('U') - 1;
if ($all_day_start < $day_end && $all_day_end > $hour_start) {
$current_hour_events[] = $all_day_event;
$this->todayEvents[] = $all_day_event;
}
}
}
foreach ($this->events as $event) {
if ($event->getIsAllDay()) {
continue;
@ -81,6 +83,10 @@ final class PHUICalendarDayView extends AphrontView {
* 100;
$height = min(2400, $height);
if ($first_event_hour === null) {
$first_event_hour = $hour;
}
$hourly_events[$event->getEventID()] = array(
'hour' => $hour,
'event' => $event,
@ -99,8 +105,17 @@ final class PHUICalendarDayView extends AphrontView {
$hourly_events);
}
// actually construct table
$rows = array();
foreach ($hours as $hour) {
$early_hours = array(8);
if ($first_event_hour) {
$early_hours[] = $first_event_hour->format('G');
}
if ($hour->format('G') < min($early_hours)) {
continue;
}
$drawn_hourly_events = array();
$cell_time = phutil_tag(
'td',
@ -109,6 +124,7 @@ final class PHUICalendarDayView extends AphrontView {
foreach ($hourly_events as $hourly_event) {
if ($hourly_event['hour'] == $hour) {
$drawn_hourly_events[] = $this->drawEvent(
$hourly_event['event'],
$hourly_event['offset'],
@ -133,16 +149,20 @@ final class PHUICalendarDayView extends AphrontView {
$table = phutil_tag(
'table',
array('class' => 'phui-calendar-day-view'),
array(
'',
$rows,
));
$rows);
$all_day_event_box = new PHUIBoxView();
foreach ($today_all_day_events as $all_day_event) {
$all_day_event_box->appendChild(
$this->drawAllDayEvent($all_day_event));
}
$header = $this->renderDayViewHeader();
$sidebar = $this->renderSidebar();
$table_box = id(new PHUIObjectBoxView())
->setHeader($header)
->appendChild($all_day_event_box)
->appendChild($table)
->setFlush(true);
@ -170,7 +190,6 @@ final class PHUICalendarDayView extends AphrontView {
}
$all_day_events = array_values(msort($all_day_events, 'getEpochStart'));
return $all_day_events;
}
@ -325,6 +344,35 @@ final class PHUICalendarDayView extends AphrontView {
return $hourly_events;
}
private function drawAllDayEvent(AphrontCalendarEventView $event) {
$name = phutil_tag(
'a',
array(
'class' => 'all-day',
'href' => $event->getURI(),
),
$event->getName());
$all_day_label = phutil_tag(
'span',
array(
'class' => 'phui-calendar-all-day-label',
),
pht('All Day'));
$div = phutil_tag(
'div',
array(
'class' => 'phui-calendar-day-event',
),
array(
$all_day_label,
$name,
));
return $div;
}
private function drawEvent(
AphrontCalendarEventView $event,
$offset,

View file

@ -48,3 +48,25 @@
text-decoration: none;
color: {$greytext};
}
.all-day {
border: 1px solid {$blueborder};
height: 12px;
margin: 0;
display: block;
padding: 8px;
background-color: {$bluebackground};
text-decoration: none;
color: {$greytext};
}
.phui-calendar-day-event + .phui-calendar-day-event .all-day {
border-top-style: none;
border-top-width: 0;
}
.phui-calendar-all-day-label {
color: {$greytext};
float: right;
margin: 8px 8px 0 0;
}