Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14396743
D12776.id30712.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D12776.id30712.diff
View Options
diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
--- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
+++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
@@ -392,9 +392,14 @@
$phids = mpull($statuses, 'getUserPHID');
foreach ($statuses as $status) {
+ if ($status->getIsCancelled()) {
+ continue;
+ }
+
$event = new AphrontCalendarEventView();
$event->setEventID($status->getID());
$event->setEpochRange($status->getDateFrom(), $status->getDateTo());
+ $event->setIsAllDay($status->getIsAllDay());
$event->setName($status->getName());
$event->setURI('/'.$status->getMonogram());
diff --git a/src/applications/calendar/view/AphrontCalendarEventView.php b/src/applications/calendar/view/AphrontCalendarEventView.php
--- a/src/applications/calendar/view/AphrontCalendarEventView.php
+++ b/src/applications/calendar/view/AphrontCalendarEventView.php
@@ -10,6 +10,7 @@
private $eventID;
private $color;
private $uri;
+ private $isAllDay;
public function setURI($uri) {
$this->uri = $uri;
@@ -81,14 +82,16 @@
}
}
- public function getAllDay() {
- $time = (60 * 60 * 22);
- if (($this->getEpochEnd() - $this->getEpochStart()) >= $time) {
- return true;
- }
- return false;
+ public function setIsAllDay($is_all_day) {
+ $this->isAllDay = $is_all_day;
+ return $this;
}
+ public function getIsAllDay() {
+ return $this->isAllDay;
+ }
+
+
public function getMultiDay() {
$nextday = strtotime('12:00 AM Tomorrow', $this->getEpochStart());
if ($this->getEpochEnd() > $nextday) {
diff --git a/src/view/phui/calendar/PHUICalendarDayView.php b/src/view/phui/calendar/PHUICalendarDayView.php
--- a/src/view/phui/calendar/PHUICalendarDayView.php
+++ b/src/view/phui/calendar/PHUICalendarDayView.php
@@ -7,6 +7,9 @@
private $year;
private $browseURI;
private $events = array();
+ private $todayEvents = array();
+
+ private $allDayEvents = array();
public function addEvent(AphrontCalendarEventView $event) {
$this->events[] = $event;
@@ -34,43 +37,62 @@
$hourly_events = array();
$rows = array();
+ $all_day_events = $this->getAllDayEvents();
+
// sort events into buckets by their start time
// pretend no events overlap
foreach ($hours as $hour) {
- $events = array();
+ $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;
+ }
if ($event->getEpochStart() >= $hour_start
&& $event->getEpochStart() < $hour_end) {
- $events[] = $event;
+ $current_hour_events[] = $event;
+ $this->todayEvents[] = $event;
}
}
- $count_events = count($events);
- $n = 0;
- foreach ($events as $event) {
+ foreach ($current_hour_events as $event) {
$event_start = $event->getEpochStart();
$event_end = $event->getEpochEnd();
- $top = ((($event_start - $hour_start) / ($hour_end - $hour_start))
- * 100).'%';
- $height = ((($event_end - $event_start) / ($hour_end - $hour_start))
- * 100).'%';
+ $top = (($event_start - $hour_start) / ($hour_end - $hour_start))
+ * 100;
+ $top = max(0, $top);
+
+ $height = (($event_end - $event_start) / ($hour_end - $hour_start))
+ * 100;
+ $height = min(2400, $height);
$hourly_events[$event->getEventID()] = array(
'hour' => $hour,
'event' => $event,
'offset' => '0',
'width' => '100%',
- 'top' => $top,
- 'height' => $height,
+ 'top' => $top.'%',
+ 'height' => $height.'%',
);
-
- $n++;
}
}
- $clusters = $this->findClusters();
+ $clusters = $this->findTodayClusters();
foreach ($clusters as $cluster) {
$hourly_events = $this->updateEventsFromCluster(
$cluster,
@@ -138,26 +160,46 @@
$layout);
}
+ private function getAllDayEvents() {
+ $all_day_events = array();
+
+ foreach ($this->events as $event) {
+ if ($event->getIsAllDay()) {
+ $all_day_events[] = $event;
+ }
+ }
+
+ $all_day_events = array_values(msort($all_day_events, 'getEpochStart'));
+
+ return $all_day_events;
+ }
+
private function renderSidebar() {
$this->events = msort($this->events, 'getEpochStart');
$week_of_boxes = $this->getWeekOfBoxes();
$filled_boxes = array();
- foreach ($week_of_boxes as $weekly_box) {
- $start = $weekly_box['start'];
- $end = id(clone $start)->modify('+1 day');
+ foreach ($week_of_boxes as $day_box) {
+ $box_start = $day_box['start'];
+ $box_end = id(clone $box_start)->modify('+1 day');
+
+ $box_start = $box_start->format('U');
+ $box_end = $box_end->format('U');
$box_events = array();
foreach ($this->events as $event) {
- if ($event->getEpochStart() >= $start->format('U') &&
- $event->getEpochStart() < $end->format('U')) {
+ $event_start = $event->getEpochStart();
+ $event_end = $event->getEpochEnd();
+
+ if ($event_start < $box_end && $event_end > $box_start) {
$box_events[] = $event;
}
}
+
$filled_boxes[] = $this->renderSidebarBox(
$box_events,
- $weekly_box['title']);
+ $day_box['title']);
}
return $filled_boxes;
@@ -267,7 +309,6 @@
private function updateEventsFromCluster($cluster, $hourly_events) {
$cluster_size = count($cluster);
-
$n = 0;
foreach ($cluster as $cluster_member) {
$event_id = $cluster_member->getEventID();
@@ -375,8 +416,8 @@
return $date;
}
- private function findClusters() {
- $events = msort($this->events, 'getEpochStart');
+ private function findTodayClusters() {
+ $events = msort($this->todayEvents, 'getEpochStart');
$clusters = array();
foreach ($events as $event) {
diff --git a/src/view/phui/calendar/PHUICalendarListView.php b/src/view/phui/calendar/PHUICalendarListView.php
--- a/src/view/phui/calendar/PHUICalendarListView.php
+++ b/src/view/phui/calendar/PHUICalendarListView.php
@@ -37,7 +37,7 @@
foreach ($events as $event) {
$color = $event->getColor();
- if ($event->getAllDay()) {
+ if ($event->getIsAllDay()) {
$timelabel = pht('All Day');
} else {
$timelabel = phabricator_time(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 8:25 AM (17 h, 6 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6920938
Default Alt Text
D12776.id30712.diff (7 KB)
Attached To
Mode
D12776: Calendar day view and corresponding sidebar should correctly display all all-day events returned from query
Attached
Detach File
Event Timeline
Log In to Comment