Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13958466
D12742.id30616.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D12742.id30616.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
@@ -70,7 +70,7 @@
if ($saved->getParameter('display') == 'month') {
$next->modify('+1 month');
} else if ($saved->getParameter('display') == 'day') {
- $next->modify('+1 day');
+ $next->modify('+6 day');
}
$display_start = $start_day->format('U');
@@ -447,7 +447,7 @@
} else {
$value = AphrontFormDateControlValue::newFromEpoch(
$viewer,
- PhabricatorTime::getNow());
+ PhabricatorTime::getTodayMidnightDateTime($viewer)->format('U'));
$value->setEnabled(false);
}
diff --git a/src/infrastructure/time/PhabricatorTime.php b/src/infrastructure/time/PhabricatorTime.php
--- a/src/infrastructure/time/PhabricatorTime.php
+++ b/src/infrastructure/time/PhabricatorTime.php
@@ -58,4 +58,15 @@
return $timestamp;
}
+ public static function getTodayMidnightDateTime($viewer) {
+ $timezone = new DateTimeZone($viewer->getTimezoneIdentifier());
+ $today = new DateTime('@'.time());
+ $today->setTimeZone($timezone);
+ $year = $today->format('Y');
+ $month = $today->format('m');
+ $day = $today->format('d');
+ $today = new DateTime("{$year}-{$month}-{$day}", $timezone);
+ return $today;
+ }
+
}
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
@@ -117,12 +117,164 @@
));
$header = $this->renderDayViewHeader();
+ $sidebar = $this->renderSidebar();
- $day_box = (new PHUIObjectBoxView())
+ $table_box = id(new PHUIObjectBoxView())
->setHeader($header)
->appendChild($table);
- return $day_box;
+ $column1 = phutil_tag(
+ 'div',
+ array(
+ 'class' => 'pm',
+ ),
+ $sidebar);
+
+ $column2 = phutil_tag(
+ 'div',
+ array(
+ 'class' => 'pm',
+ ),
+ $table_box);
+
+ $layout = id(new AphrontMultiColumnView())
+ ->addColumn($column1, 'third')
+ ->addColumn($column2, 'thirds')
+ ->setFluidLayout(true)
+ ->setGutter(AphrontMultiColumnView::GUTTER_MEDIUM);
+
+ $wrap = phutil_tag(
+ 'div',
+ array(
+ 'class' => 'ml',
+ ),
+ $layout);
+
+ return phutil_tag(
+ 'div',
+ array(),
+ array(
+ $wrap,
+ ));
+ }
+
+ private function renderSidebar() {
+ $this->events = msort($this->events, 'getEpochStart');
+ $week_of_boxes = $this->getWeekOfBoxes();
+ $filled_boxes = array();
+
+ foreach ($week_of_boxes as $box) {
+ $start = $box['start'];
+ $end = id(clone $start)->modify('+1 day');
+
+ $box = $box['box'];
+ $box_events = array();
+
+ foreach ($this->events as $event) {
+ if ($event->getEpochStart() >= $start->format('U') &&
+ $event->getEpochStart() < $end->format('U')) {
+ $box_events[] = $event;
+ }
+ }
+ $filled_boxes[] = $this->renderSidebarBox($box_events, $box);
+ }
+
+ return $filled_boxes;
+ }
+
+ private function renderSidebarBox($events, $box) {
+ $user = $this->user;
+ $rows = array();
+
+ foreach ($events as $key => $event) {
+ $uri = $event->getURI();
+ $name = $event->getName();
+ $time = id(AphrontFormDateControlValue::newFromEpoch(
+ $user,
+ $event->getEpochStart()))
+ ->getValueTime();
+
+ $name = phutil_tag(
+ 'a',
+ array(
+ 'href' => $uri,
+ ),
+ array(
+ $name,
+ ));
+
+ $name = phutil_tag(
+ 'td',
+ array(
+ 'class' => 'calendar-day-sidebar-column-name',
+ ),
+ array(
+ $name,
+ ));
+
+ $time = phutil_tag(
+ 'td',
+ array(
+ 'class' => 'calendar-day-sidebar-column-time',
+ ),
+ array(
+ $time,
+ ));
+
+ $rows[] = phutil_tag(
+ 'tr',
+ array(
+ 'class' => 'calendar-day-sidebar-row',
+ ),
+ array(
+ $name,
+ $time,
+ ));
+ }
+
+ $table = phutil_tag(
+ 'table',
+ array(
+ 'class' => 'calendar-day-sidebar-today-table',
+ ),
+ array(
+ '',
+ $rows,
+ ));
+
+ $box->appendChild($table);
+ return $box;
+ }
+
+ private function getWeekOfBoxes() {
+ $sidebar_day_boxes = array();
+
+ $display_start_day = $this->getDateTime();
+ $display_end_day = id(clone $display_start_day)->modify('+6 day');
+
+ $box_start_time = clone $display_start_day;
+
+ $today_time = PhabricatorTime::getTodayMidnightDateTime($this->user);
+ $tomorrow_time = clone $today_time;
+ $tomorrow_time->modify('+1 day');
+
+ while ($box_start_time <= $display_end_day) {
+ if ($box_start_time->format('U') == $today_time->format('U')) {
+ $title = 'Today';
+ } else if ($box_start_time->format('U') == $tomorrow_time->format('U')) {
+ $title = 'Tomorrow';
+ } else {
+ $title = $box_start_time->format('l');
+ }
+
+ $sidebar_day_boxes[] = array(
+ 'box' => id(new PHUIObjectBoxView())->setHeaderText($title),
+ 'start' => clone $box_start_time,
+ );
+
+ $box_start_time->modify('+1 day');
+ }
+ return $sidebar_day_boxes;
}
private function renderDayViewHeader() {
@@ -290,7 +442,6 @@
$events = msort($this->events, 'getEpochStart');
$clusters = array();
-
foreach ($events as $event) {
$destination_cluster_key = null;
$event_start = $event->getEpochStart();
diff --git a/webroot/rsrc/css/phui/calendar/phui-calendar-day.css b/webroot/rsrc/css/phui/calendar/phui-calendar-day.css
--- a/webroot/rsrc/css/phui/calendar/phui-calendar-day.css
+++ b/webroot/rsrc/css/phui/calendar/phui-calendar-day.css
@@ -7,6 +7,29 @@
width: 100%;
}
+.calendar-day-sidebar-today-table {
+ width: 100%;
+ margin: 8px 0;
+}
+
+.calendar-day-sidebar-column-name {
+ text-align: left;
+ color: {$bluetext};
+ width: 60%;
+ padding: 4px 16px;
+}
+
+.calendar-day-sidebar-column-name a {
+ color: {$bluetext};
+}
+
+.calendar-day-sidebar-column-time {
+ color: {$bluetext};
+ text-align: right;
+ width: 40%;
+ padding: 4px 16px;
+}
+
.phui-calendar-day-hour {
width: 60px;
color: {$lightgreytext};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 15 2024, 2:56 PM (4 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713223
Default Alt Text
D12742.id30616.diff (6 KB)
Attached To
Mode
D12742: First stab at Calendar day view sidebar
Attached
Detach File
Event Timeline
Log In to Comment