@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 Calendar day view sidebar

Summary: Ref T4393, First stab at Calendar day view sidebar

Test Plan: Open Calendar day view, sidebar should show today and the next 6 days, empty or not.

Reviewers: epriestley, #blessed_reviewers, chad

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T4393

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

+183 -7
+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' => '75b8cc4a', 122 + 'rsrc/css/phui/calendar/phui-calendar-day.css' => 'c2eb34ce', 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', ··· 773 773 'phui-box-css' => '7b3a2eed', 774 774 'phui-button-css' => 'de610129', 775 775 'phui-calendar-css' => '8675968e', 776 - 'phui-calendar-day-css' => '75b8cc4a', 776 + 'phui-calendar-day-css' => 'c2eb34ce', 777 777 'phui-calendar-list-css' => 'c1d0ca59', 778 778 'phui-calendar-month-css' => 'a92e47d2', 779 779 'phui-crumbs-view-css' => '594d719e',
+2 -2
src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
··· 70 70 if ($saved->getParameter('display') == 'month') { 71 71 $next->modify('+1 month'); 72 72 } else if ($saved->getParameter('display') == 'day') { 73 - $next->modify('+1 day'); 73 + $next->modify('+6 day'); 74 74 } 75 75 76 76 $display_start = $start_day->format('U'); ··· 447 447 } else { 448 448 $value = AphrontFormDateControlValue::newFromEpoch( 449 449 $viewer, 450 - PhabricatorTime::getNow()); 450 + PhabricatorTime::getTodayMidnightDateTime($viewer)->format('U')); 451 451 $value->setEnabled(false); 452 452 } 453 453
+11
src/infrastructure/time/PhabricatorTime.php
··· 58 58 return $timestamp; 59 59 } 60 60 61 + public static function getTodayMidnightDateTime($viewer) { 62 + $timezone = new DateTimeZone($viewer->getTimezoneIdentifier()); 63 + $today = new DateTime('@'.time()); 64 + $today->setTimeZone($timezone); 65 + $year = $today->format('Y'); 66 + $month = $today->format('m'); 67 + $day = $today->format('d'); 68 + $today = new DateTime("{$year}-{$month}-{$day}", $timezone); 69 + return $today; 70 + } 71 + 61 72 }
+145 -3
src/view/phui/calendar/PHUICalendarDayView.php
··· 117 117 )); 118 118 119 119 $header = $this->renderDayViewHeader(); 120 + $sidebar = $this->renderSidebar(); 120 121 121 - $day_box = (new PHUIObjectBoxView()) 122 + $table_box = id(new PHUIObjectBoxView()) 122 123 ->setHeader($header) 123 124 ->appendChild($table); 124 125 125 - return $day_box; 126 + $column1 = phutil_tag( 127 + 'div', 128 + array( 129 + 'class' => 'pm', 130 + ), 131 + $sidebar); 132 + 133 + $column2 = phutil_tag( 134 + 'div', 135 + array( 136 + 'class' => 'pm', 137 + ), 138 + $table_box); 139 + 140 + $layout = id(new AphrontMultiColumnView()) 141 + ->addColumn($column1, 'third') 142 + ->addColumn($column2, 'thirds') 143 + ->setFluidLayout(true) 144 + ->setGutter(AphrontMultiColumnView::GUTTER_MEDIUM); 145 + 146 + $wrap = phutil_tag( 147 + 'div', 148 + array( 149 + 'class' => 'ml', 150 + ), 151 + $layout); 152 + 153 + return phutil_tag( 154 + 'div', 155 + array(), 156 + array( 157 + $wrap, 158 + )); 159 + } 160 + 161 + private function renderSidebar() { 162 + $this->events = msort($this->events, 'getEpochStart'); 163 + $week_of_boxes = $this->getWeekOfBoxes(); 164 + $filled_boxes = array(); 165 + 166 + foreach ($week_of_boxes as $box) { 167 + $start = $box['start']; 168 + $end = id(clone $start)->modify('+1 day'); 169 + 170 + $box = $box['box']; 171 + $box_events = array(); 172 + 173 + foreach ($this->events as $event) { 174 + if ($event->getEpochStart() >= $start->format('U') && 175 + $event->getEpochStart() < $end->format('U')) { 176 + $box_events[] = $event; 177 + } 178 + } 179 + $filled_boxes[] = $this->renderSidebarBox($box_events, $box); 180 + } 181 + 182 + return $filled_boxes; 183 + } 184 + 185 + private function renderSidebarBox($events, $box) { 186 + $user = $this->user; 187 + $rows = array(); 188 + 189 + foreach ($events as $key => $event) { 190 + $uri = $event->getURI(); 191 + $name = $event->getName(); 192 + $time = id(AphrontFormDateControlValue::newFromEpoch( 193 + $user, 194 + $event->getEpochStart())) 195 + ->getValueTime(); 196 + 197 + $name = phutil_tag( 198 + 'a', 199 + array( 200 + 'href' => $uri, 201 + ), 202 + $name); 203 + 204 + $name = phutil_tag( 205 + 'td', 206 + array( 207 + 'class' => 'calendar-day-sidebar-column-name', 208 + ), 209 + $name); 210 + 211 + $time = phutil_tag( 212 + 'td', 213 + array( 214 + 'class' => 'calendar-day-sidebar-column-time', 215 + ), 216 + $time); 217 + 218 + $rows[] = phutil_tag( 219 + 'tr', 220 + array( 221 + 'class' => 'calendar-day-sidebar-row', 222 + ), 223 + array( 224 + $name, 225 + $time, 226 + )); 227 + } 228 + 229 + $table = phutil_tag( 230 + 'table', 231 + array( 232 + 'class' => 'calendar-day-sidebar-today-table', 233 + ), 234 + $rows); 235 + 236 + $box->appendChild($table); 237 + return $box; 238 + } 239 + 240 + private function getWeekOfBoxes() { 241 + $sidebar_day_boxes = array(); 242 + 243 + $display_start_day = $this->getDateTime(); 244 + $display_end_day = id(clone $display_start_day)->modify('+6 day'); 245 + 246 + $box_start_time = clone $display_start_day; 247 + 248 + $today_time = PhabricatorTime::getTodayMidnightDateTime($this->user); 249 + $tomorrow_time = clone $today_time; 250 + $tomorrow_time->modify('+1 day'); 251 + 252 + while ($box_start_time <= $display_end_day) { 253 + if ($box_start_time == $today_time) { 254 + $title = pht('Today'); 255 + } else if ($box_start_time == $tomorrow_time) { 256 + $title = pht('Tomorrow'); 257 + } else { 258 + $title = $box_start_time->format('l'); 259 + } 260 + 261 + $sidebar_day_boxes[] = array( 262 + 'box' => id(new PHUIObjectBoxView())->setHeaderText($title), 263 + 'start' => clone $box_start_time, 264 + ); 265 + 266 + $box_start_time->modify('+1 day'); 267 + } 268 + return $sidebar_day_boxes; 126 269 } 127 270 128 271 private function renderDayViewHeader() { ··· 289 432 private function findClusters() { 290 433 $events = msort($this->events, 'getEpochStart'); 291 434 $clusters = array(); 292 - 293 435 294 436 foreach ($events as $event) { 295 437 $destination_cluster_key = null;
+23
webroot/rsrc/css/phui/calendar/phui-calendar-day.css
··· 7 7 width: 100%; 8 8 } 9 9 10 + .calendar-day-sidebar-today-table { 11 + width: 100%; 12 + margin: 8px 0; 13 + } 14 + 15 + .calendar-day-sidebar-column-name { 16 + text-align: left; 17 + color: {$bluetext}; 18 + width: 60%; 19 + padding: 4px 16px; 20 + } 21 + 22 + .calendar-day-sidebar-column-name a { 23 + color: {$bluetext}; 24 + } 25 + 26 + .calendar-day-sidebar-column-time { 27 + color: {$bluetext}; 28 + text-align: right; 29 + width: 40%; 30 + padding: 4px 16px; 31 + } 32 + 10 33 .phui-calendar-day-hour { 11 34 width: 60px; 12 35 color: {$lightgreytext};