@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

First stab at day view

Summary: Ref T4393, First stab at day view.

Test Plan: Open Calendar Advanced Search, select "Day View (beta)", see rough day view of selected day.

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T4393

Differential Revision: https://secure.phabricator.com/D12685

+262 -4
+2 -2
resources/celerity/map.php
··· 119 119 'rsrc/css/layout/phabricator-hovercard-view.css' => '44394670', 120 120 'rsrc/css/layout/phabricator-side-menu-view.css' => 'c1db9e9c', 121 121 'rsrc/css/layout/phabricator-source-code-view.css' => '2ceee894', 122 - 'rsrc/css/phui/calendar/phui-calendar-day.css' => 'de035c8a', 122 + 'rsrc/css/phui/calendar/phui-calendar-day.css' => 'a00b748d', 123 123 'rsrc/css/phui/calendar/phui-calendar-list.css' => 'c1d0ca59', 124 124 'rsrc/css/phui/calendar/phui-calendar-month.css' => 'a92e47d2', 125 125 'rsrc/css/phui/calendar/phui-calendar.css' => '8675968e', ··· 780 780 'phui-box-css' => '7b3a2eed', 781 781 'phui-button-css' => 'de610129', 782 782 'phui-calendar-css' => '8675968e', 783 - 'phui-calendar-day-css' => 'de035c8a', 783 + 'phui-calendar-day-css' => 'a00b748d', 784 784 'phui-calendar-list-css' => 'c1d0ca59', 785 785 'phui-calendar-month-css' => 'a92e47d2', 786 786 'phui-crumbs-view-css' => '594d719e',
+4 -2
src/__phutil_library_map__.php
··· 102 102 'AphrontApplicationConfiguration' => 'aphront/configuration/AphrontApplicationConfiguration.php', 103 103 'AphrontBarView' => 'view/widget/bars/AphrontBarView.php', 104 104 'AphrontCSRFException' => 'aphront/exception/AphrontCSRFException.php', 105 + 'AphrontCalendarDayEventView' => 'applications/calendar/view/AphrontCalendarDayEventView.php', 105 106 'AphrontCalendarEventView' => 'applications/calendar/view/AphrontCalendarEventView.php', 106 107 'AphrontController' => 'aphront/AphrontController.php', 107 108 'AphrontCursorPagerView' => 'view/control/AphrontCursorPagerView.php', ··· 1159 1160 'PHUIButtonBarView' => 'view/phui/PHUIButtonBarView.php', 1160 1161 'PHUIButtonExample' => 'applications/uiexample/examples/PHUIButtonExample.php', 1161 1162 'PHUIButtonView' => 'view/phui/PHUIButtonView.php', 1163 + 'PHUICalendarDayView' => 'view/phui/calendar/PHUICalendarDayView.php', 1162 1164 'PHUICalendarListView' => 'view/phui/calendar/PHUICalendarListView.php', 1163 1165 'PHUICalendarMonthView' => 'view/phui/calendar/PHUICalendarMonthView.php', 1164 1166 'PHUICalendarWidgetView' => 'view/phui/calendar/PHUICalendarWidgetView.php', ··· 1498 1500 'PhabricatorCalendarEventEditController' => 'applications/calendar/controller/PhabricatorCalendarEventEditController.php', 1499 1501 'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php', 1500 1502 'PhabricatorCalendarEventEmailCommand' => 'applications/calendar/command/PhabricatorCalendarEventEmailCommand.php', 1501 - 'PhabricatorCalendarEventInvalidEpochException' => 'applications/calendar/exception/PhabricatorCalendarEventInvalidEpochException.php', 1502 1503 'PhabricatorCalendarEventInvitee' => 'applications/calendar/storage/PhabricatorCalendarEventInvitee.php', 1503 1504 'PhabricatorCalendarEventInviteeQuery' => 'applications/calendar/query/PhabricatorCalendarEventInviteeQuery.php', 1504 1505 'PhabricatorCalendarEventJoinController' => 'applications/calendar/controller/PhabricatorCalendarEventJoinController.php', ··· 3349 3350 'AphrontAjaxResponse' => 'AphrontResponse', 3350 3351 'AphrontBarView' => 'AphrontView', 3351 3352 'AphrontCSRFException' => 'AphrontException', 3353 + 'AphrontCalendarDayEventView' => 'AphrontView', 3352 3354 'AphrontCalendarEventView' => 'AphrontView', 3353 3355 'AphrontController' => 'Phobject', 3354 3356 'AphrontCursorPagerView' => 'AphrontView', ··· 4483 4485 'PHUIButtonBarView' => 'AphrontTagView', 4484 4486 'PHUIButtonExample' => 'PhabricatorUIExample', 4485 4487 'PHUIButtonView' => 'AphrontTagView', 4488 + 'PHUICalendarDayView' => 'AphrontView', 4486 4489 'PHUICalendarListView' => 'AphrontTagView', 4487 4490 'PHUICalendarMonthView' => 'AphrontView', 4488 4491 'PHUICalendarWidgetView' => 'AphrontTagView', ··· 4848 4851 'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController', 4849 4852 'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor', 4850 4853 'PhabricatorCalendarEventEmailCommand' => 'MetaMTAEmailTransactionCommand', 4851 - 'PhabricatorCalendarEventInvalidEpochException' => 'Exception', 4852 4854 'PhabricatorCalendarEventInvitee' => array( 4853 4855 'PhabricatorCalendarDAO', 4854 4856 'PhabricatorPolicyInterface',
+54
src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
··· 5 5 6 6 private $calendarYear; 7 7 private $calendarMonth; 8 + private $calendarDay; 8 9 9 10 public function getResultTypeDescription() { 10 11 return pht('Calendar Events'); ··· 144 145 ); 145 146 $display_options = array( 146 147 'month' => pht('Month View'), 148 + 'day' => pht('Day View (beta)'), 147 149 'list' => pht('List View'), 148 150 ); 149 151 ··· 249 251 250 252 if ($query->getParameter('display') == 'month') { 251 253 return $this->buildCalendarView($events, $query, $handles); 254 + } else if ($query->getParameter('display') == 'day') { 255 + return $this->buildCalendarDayView($events, $query, $handles); 252 256 } 253 257 254 258 assert_instances_of($events, 'PhabricatorCalendarEvent'); ··· 349 353 return $month_view; 350 354 } 351 355 356 + private function buildCalendarDayView( 357 + array $statuses, 358 + PhabricatorSavedQuery $query, 359 + array $handles) { 360 + $viewer = $this->requireViewer(); 361 + list($start_month, $start_year, $start_day) = 362 + $this->getDisplayMonthAndYearAndDay($query); 363 + 364 + $day_view = new PHUICalendarDayView( 365 + $start_month, 366 + $start_year, 367 + $start_day); 368 + 369 + $day_view->setUser($viewer); 370 + 371 + $phids = mpull($statuses, 'getUserPHID'); 372 + 373 + foreach ($statuses as $status) { 374 + $event = new AphrontCalendarDayEventView(); 375 + $event->setEpochRange($status->getDateFrom(), $status->getDateTo()); 376 + 377 + $event->setName($status->getName()); 378 + $day_view->addEvent($event); 379 + } 380 + 381 + return $day_view; 382 + } 383 + 352 384 private function getDisplayMonthAndYear( 353 385 PhabricatorSavedQuery $query) { 354 386 $viewer = $this->requireViewer(); ··· 370 402 } 371 403 372 404 return array($start_month, $start_year); 405 + } 406 + 407 + private function getDisplayMonthAndYearAndDay( 408 + PhabricatorSavedQuery $query) { 409 + $viewer = $this->requireViewer(); 410 + if ($this->calendarYear && $this->calendarMonth && $this->calendarDay) { 411 + $start_year = $this->calendarYear; 412 + $start_month = $this->calendarMonth; 413 + $start_day = $this->calendarDay; 414 + } else { 415 + $epoch = $query->getParameter('rangeStart'); 416 + if (!$epoch) { 417 + $epoch = $query->getParameter('rangeEnd'); 418 + if (!$epoch) { 419 + $epoch = time(); 420 + } 421 + } 422 + $start_year = phabricator_format_local_time($epoch, $viewer, 'Y'); 423 + $start_month = phabricator_format_local_time($epoch, $viewer, 'm'); 424 + $start_day = phabricator_format_local_time($epoch, $viewer, 'd'); 425 + } 426 + return array($start_year, $start_month, $start_day); 373 427 } 374 428 375 429 public function getPageSize(PhabricatorSavedQuery $saved) {
+39
src/applications/calendar/view/AphrontCalendarDayEventView.php
··· 1 + <?php 2 + 3 + final class AphrontCalendarDayEventView extends AphrontView { 4 + 5 + private $event; 6 + private $epochStart; 7 + private $epochEnd; 8 + private $name; 9 + 10 + public function setName($name) { 11 + $this->name = $name; 12 + return $this; 13 + } 14 + 15 + public function getName() { 16 + return $this->name; 17 + } 18 + 19 + public function setEpochRange($start, $end) { 20 + $this->epochStart = $start; 21 + $this->epochEnd = $end; 22 + return $this; 23 + } 24 + 25 + public function getEpochStart() { 26 + return $this->epochStart; 27 + } 28 + 29 + public function getEpochEnd() { 30 + return $this->epochEnd; 31 + } 32 + 33 + public function render() { 34 + $box = new PHUIObjectBoxView(); 35 + $box->setHeaderText($this->name); 36 + return $box; 37 + 38 + } 39 + }
+131
src/view/phui/calendar/PHUICalendarDayView.php
··· 1 + <?php 2 + 3 + final class PHUICalendarDayView extends AphrontView { 4 + 5 + private $day; 6 + private $month; 7 + private $year; 8 + private $events = array(); 9 + 10 + public function addEvent(AphrontCalendarDayEventView $event) { 11 + $this->events[] = $event; 12 + return $this; 13 + } 14 + 15 + public function __construct($year, $month, $day = null) { 16 + $this->day = $day; 17 + $this->month = $month; 18 + $this->year = $year; 19 + } 20 + 21 + public function render() { 22 + require_celerity_resource('phui-calendar-day-css'); 23 + 24 + $day_box = new PHUIObjectBoxView(); 25 + $day_of_week = $this->getDayOfWeek(); 26 + $header_text = $this->getDateTime()->format('F j, Y'); 27 + $header_text = $day_of_week.', '.$header_text; 28 + $day_box->setHeaderText($header_text); 29 + $hours = $this->getHoursOfDay(); 30 + $rows = array(); 31 + 32 + foreach ($hours as $hour) { 33 + // time slot 34 + $cell_time = phutil_tag( 35 + 'td', 36 + array('class' => 'phui-calendar-day-hour'), 37 + $hour->format('g:i A')); 38 + 39 + $event_boxes = array(); 40 + foreach ($this->events as $event) { 41 + if ($event->getEpochStart() >= $hour->format('U') 42 + && $event->getEpochStart() < $hour->modify('+1 hour')->format('U')) { 43 + $event_boxes[] = $this->drawEvent($event); 44 + } 45 + } 46 + 47 + // events starting in time slot 48 + $cell_event = phutil_tag( 49 + 'td', 50 + array(), 51 + $event_boxes); 52 + 53 + 54 + $row = phutil_tag( 55 + 'tr', 56 + array(), 57 + array($cell_time, $cell_event)); 58 + 59 + $rows[] = $row; 60 + } 61 + 62 + $table = phutil_tag( 63 + 'table', 64 + array('class' => 'phui-calendar-day-view'), 65 + array( 66 + '', 67 + $rows, 68 + )); 69 + 70 + $day_box->appendChild($table); 71 + return $day_box; 72 + 73 + } 74 + 75 + private function drawEvent(AphrontCalendarDayEventView $event) { 76 + $name = phutil_tag( 77 + 'div', 78 + array(), 79 + $event->getName()); 80 + 81 + $div = phutil_tag( 82 + 'div', 83 + array('class' => 'phui-calendar-day-event'), 84 + $name); 85 + 86 + return $div; 87 + } 88 + 89 + private function getDayOfWeek() { 90 + $date = $this->getDateTime(); 91 + $day_of_week = $date->format('l'); 92 + return $day_of_week; 93 + } 94 + 95 + // returns DateTime of each hour in the day 96 + private function getHoursOfDay() { 97 + $included_datetimes = array(); 98 + 99 + $day_datetime = $this->getDateTime(); 100 + $day_epoch = $day_datetime->format('U'); 101 + 102 + $day_datetime->modify('+1 day'); 103 + $next_day_epoch = $day_datetime->format('U'); 104 + 105 + $included_time = $day_epoch; 106 + $included_datetime = $this->getDateTime(); 107 + 108 + while ($included_time < $next_day_epoch) { 109 + $included_datetimes[] = clone $included_datetime; 110 + 111 + $included_datetime->modify('+1 hour'); 112 + $included_time = $included_datetime->format('U'); 113 + } 114 + 115 + return $included_datetimes; 116 + } 117 + 118 + private function getDateTime() { 119 + $user = $this->user; 120 + 121 + $timezone = new DateTimeZone($user->getTimezoneIdentifier()); 122 + 123 + $day = $this->day; 124 + $month = $this->month; 125 + $year = $this->year; 126 + 127 + $date = new DateTime("{$year}-{$month}-{$day} ", $timezone); 128 + 129 + return $date; 130 + } 131 + }
+32
webroot/rsrc/css/phui/calendar/phui-calendar-day.css
··· 1 1 /** 2 2 * @provides phui-calendar-day-css 3 3 */ 4 + 5 + .phui-calendar-day-view { 6 + overflow: scroll; 7 + width: 100%; 8 + } 9 + 10 + .phui-calendar-day-hour { 11 + width: 60px; 12 + font-size: 10px; 13 + } 14 + 15 + .phui-calendar-day-view tr { 16 + width: 100%; 17 + height: 60px; 18 + border: 1px solid {$lightgreyborder}; 19 + } 20 + 21 + .phui-calendar-day-view td { 22 + position: relative; 23 + } 24 + 25 + .phui-calendar-day-view td div.phui-calendar-day-event { 26 + width: 100%; 27 + background-color: {$darkgreybackground}; 28 + position: absolute; 29 + top: 0; 30 + bottom: 0; 31 + } 32 + 33 + .phui-calendar-day-view td div.phui-calendar-day-event div { 34 + padding: 4px; 35 + }