Skip to content

Commit 11961cd

Browse files
committed
Conpherence - tweak calendar widget
Summary: this does a few things. Fixes T3253. Including the Sunday -> Saturday list view part. Cleans up the display when there are no events, getting rid of this spacer thing. Also fixes Calendar CSS for device-tablet where we had a 2px gap on the calendar from the header. Test Plan: played with calendar widget a bunch Reviewers: epriestley, chad Reviewed By: chad CC: aran, Korvin Maniphest Tasks: T3253 Differential Revision: https://secure.phabricator.com/D6102
1 parent f4bd214 commit 11961cd

File tree

3 files changed

+115
-113
lines changed

3 files changed

+115
-113
lines changed

src/applications/conpherence/controller/ConpherenceWidgetController.php

Lines changed: 92 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -204,33 +204,42 @@ private function renderCalendarWidgetPaneContent() {
204204
$today = $timestamps['today'];
205205
$epoch_stamps = $timestamps['epoch_stamps'];
206206
$one_day = 24 * 60 * 60;
207-
foreach ($epoch_stamps as $time => $day) {
207+
$is_today = false;
208+
$calendar_columns = 0;
209+
$list_days = 0;
210+
foreach ($epoch_stamps as $day) {
208211
// build a header for the new day
209-
if ($day->format('w') == $today->format('w')) {
210-
$active_class = 'today';
212+
if ($day->format('Ymd') == $today->format('Ymd')) {
213+
$active_class = 'today';
214+
$is_today = true;
211215
} else {
212-
$active_class = '';
216+
$active_class = '';
217+
$is_today = false;
213218
}
214219

215-
$content[] = phutil_tag(
216-
'div',
217-
array(
218-
'class' => 'day-header '.$active_class
219-
),
220-
array(
221-
phutil_tag(
222-
'div',
223-
array(
224-
'class' => 'day-name'
225-
),
226-
$day->format('l')),
227-
phutil_tag(
228-
'div',
229-
array(
230-
'class' => 'day-date'
231-
),
232-
$day->format('m/d/y'))
233-
));
220+
$should_draw_list = $list_days < 7;
221+
$list_days++;
222+
223+
if ($should_draw_list) {
224+
$content[] = phutil_tag(
225+
'div',
226+
array(
227+
'class' => 'day-header '.$active_class
228+
),
229+
array(
230+
phutil_tag(
231+
'div',
232+
array(
233+
'class' => 'day-name'
234+
),
235+
$day->format('l')),
236+
phutil_tag(
237+
'div',
238+
array(
239+
'class' => 'day-date'
240+
),
241+
$day->format('m/d/y'))));
242+
}
234243

235244
$week_day_number = $day->format('w');
236245

@@ -251,81 +260,73 @@ private function renderCalendarWidgetPaneContent() {
251260

252261
if ($status->getDateFrom() < $epoch_end &&
253262
$status->getDateTo() > $epoch_start) {
254-
if (!$first_status_of_the_day) {
263+
$statuses_of_the_day[$status->getUserPHID()] = $status;
264+
if ($should_draw_list) {
265+
$top_border = '';
266+
if (!$first_status_of_the_day) {
267+
$top_border = ' top-border';
268+
}
269+
$timespan = $status->getDateTo() - $status->getDateFrom();
270+
if ($timespan > $one_day) {
271+
$time_str = 'm/d';
272+
} else {
273+
$time_str = 'h:i A';
274+
}
275+
$epoch_range =
276+
phabricator_format_local_time(
277+
$status->getDateFrom(),
278+
$user,
279+
$time_str) .
280+
' - ' .
281+
phabricator_format_local_time(
282+
$status->getDateTo(),
283+
$user,
284+
$time_str);
285+
286+
$secondary_info = pht('%s, %s',
287+
$handles[$status->getUserPHID()]->getName(), $epoch_range);
288+
255289
$content[] = phutil_tag(
256290
'div',
257291
array(
258-
'class' => 'divider'
292+
'class' => 'user-status '.$status->getTextStatus().$top_border,
259293
),
260-
'');
261-
}
262-
$statuses_of_the_day[$status->getUserPHID()] = $status;
263-
$timespan = $status->getDateTo() - $status->getDateFrom();
264-
if ($timespan > $one_day) {
265-
$time_str = 'm/d';
266-
} else {
267-
$time_str = 'h:i A';
294+
array(
295+
phutil_tag(
296+
'div',
297+
array(
298+
'class' => 'icon',
299+
),
300+
''),
301+
phutil_tag(
302+
'div',
303+
array(
304+
'class' => 'description'
305+
),
306+
array(
307+
$status->getTerseSummary($user),
308+
phutil_tag(
309+
'div',
310+
array(
311+
'class' => 'participant'
312+
),
313+
$secondary_info)))));
268314
}
269-
$epoch_range = phabricator_format_local_time(
270-
$status->getDateFrom(),
271-
$user,
272-
$time_str) . ' - ' . phabricator_format_local_time(
273-
$status->getDateTo(),
274-
$user,
275-
$time_str);
276-
277-
$secondary_info = pht('%s, %s',
278-
$handles[$status->getUserPHID()]->getName(), $epoch_range);
279-
280-
$content[] = phutil_tag(
281-
'div',
282-
array(
283-
'class' => 'pm user-status '.$status->getTextStatus(),
284-
),
285-
array(
286-
phutil_tag(
287-
'div',
288-
array(
289-
'class' => 'icon',
290-
),
291-
''),
292-
phutil_tag(
293-
'div',
294-
array(
295-
'class' => 'description'
296-
),
297-
array(
298-
$status->getTerseSummary($user),
299-
phutil_tag(
300-
'div',
301-
array(
302-
'class' => 'participant'
303-
),
304-
$secondary_info)))
305-
));
306315
$first_status_of_the_day = false;
307-
} else {
308-
$content[] = phutil_tag(
309-
'div',
310-
array('class' => 'no-events pmt pml'),
311-
pht('No Events Scheduled.'));
312316
}
313317
}
314318

315319
// we didn't get a status on this day so add a spacer
316-
if ($first_status_of_the_day) {
320+
if ($first_status_of_the_day && $should_draw_list) {
317321
$content[] = phutil_tag(
318322
'div',
319-
array(
320-
'class' => 'spacer'
321-
),
322-
'');
323+
array('class' => 'no-events pm'),
324+
pht('No Events Scheduled.'));
323325
}
324-
if ($week_day_number > 0 && $week_day_number < 6) {
325-
if ($week_day_number == $today->format('w')) {
326+
if ($is_today || ($calendar_columns && $calendar_columns < 3)) {
327+
$active_class = '';
328+
if ($day->format('Ymd') == $today->format('Ymd')) {
326329
$active_class = '-active';
327-
} else {
328-
$active_class = '';
329330
}
330331
$inner_layout = array();
331332
foreach ($participants as $phid => $participant) {
@@ -366,7 +367,8 @@ private function renderCalendarWidgetPaneContent() {
366367
),
367368
$day->format('j')),
368369
$inner_layout
369-
)));
370+
)));
371+
$calendar_columns++;
370372
}
371373
}
372374

@@ -381,15 +383,14 @@ private function getCalendarWidgetTimestamps() {
381383
$user = $this->getRequest()->getUser();
382384
$timezone = new DateTimeZone($user->getTimezoneIdentifier());
383385

384-
$today = id(new DateTime('today', $timezone));
386+
$first_day = new DateTime('last sunday', $timezone);
385387
$timestamps = array();
386-
for ($day = 0; $day < 3; $day++) {
387-
$timestamp = clone $today;
388+
for ($day = 0; $day < 8; $day++) {
389+
$timestamp = clone $first_day;
388390
$timestamps[] = $timestamp->modify(sprintf('+%d days', $day));
389391
}
390-
391392
return array(
392-
'today' => $today,
393+
'today' => new DateTime('today', $timezone),
393394
'epoch_stamps' => $timestamps
394395
);
395396
}
@@ -399,4 +400,4 @@ private function getWidgetURI() {
399400
return $this->getApplicationURI('update/'.$conpherence->getID().'/');
400401
}
401402

402-
}
403+
}

src/applications/conpherence/query/ConpherenceThreadQuery.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,15 @@ private function loadWidgetData(array $conpherences) {
217217
$file_phids = array_mergev($file_phids);
218218

219219
// statuses of everyone currently in the conpherence
220-
// for a rolling three day window
220+
// we show sunday -> saturday in a list *AND* a window
221+
// of today -> +2 days. If its saturday we need
222+
// +2 days.
221223
$start_epoch = phabricator_format_local_time(
222-
strtotime('today', strtotime('tomorrow')),
224+
strtotime('last sunday', strtotime('tomorrow')),
223225
$this->getViewer(),
224226
'U');
225227
$end_epoch = phabricator_format_local_time(
226-
strtotime('+3 days', strtotime('tomorrow')),
228+
strtotime('last sunday +8 days', strtotime('tomorrow')),
227229
$this->getViewer(),
228230
'U');
229231
$statuses = id(new PhabricatorUserStatus())

webroot/rsrc/css/application/conpherence/widget-pane.css

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,12 @@
140140
.conpherence-widget-pane #widgets-calendar .aphront-multi-column-view {
141141
width: 240px;
142142
}
143-
.device .conpherence-widget-pane #widgets-calendar .aphront-multi-column-view {
144-
margin: 2px 0px 0px 0px;
143+
.device-phone .conpherence-widget-pane #widgets-calendar
144+
.aphront-multi-column-view {
145+
display: none;
146+
}
147+
.device-tablet .conpherence-widget-pane #widgets-calendar
148+
.aphront-multi-column-view {
145149
width: 100%;
146150
}
147151
.conpherence-widget-pane #widgets-calendar .aphront-multi-column-view
@@ -150,6 +154,11 @@
150154
border-right: 1px solid #bfbfbf;
151155
text-align: center;
152156
}
157+
.device-phone .conpherence-widget-pane #widgets-calendar
158+
.aphront-multi-column-view .aphront-multi-column-column {
159+
border-right: 0;
160+
}
161+
153162
.device-phone .conpherence-widget-pane #widgets-calendar
154163
.aphront-multi-column-fluid .aphront-multi-column-5-up
155164
.aphront-multi-column-column-outer {
@@ -248,22 +257,13 @@
248257
font-size: 11px;
249258
}
250259

251-
.conpherence-widget-pane #widgets-calendar .divider {
252-
float: left;
253-
clear: both;
254-
width: 220px;
255-
margin: 0px 0px 0px 10px;
256-
border: 1px dashed #bfbfbf;
257-
}
258-
.conpherence-widget-pane #widgets-calendar .divider {
259-
width: 96%;
260-
margin: 0px 0px 0px 2%;
260+
.conpherence-widget-pane #widgets-calendar .top-border {
261+
border-top: 1px solid #E7E7E7;
261262
}
262-
.conpherence-widget-pane #widgets-calendar .spacer {
263-
float: left;
264-
clear: both;
265-
height: 10px;
266-
width: 100%;
263+
264+
.conpherence-widget-pane #widgets-calendar .user-status {
265+
padding: 10px 0px 10px 0px;
266+
margin: 0px 0px 0px 10px;
267267
}
268268

269269
.conpherence-widget-pane #widgets-calendar .user-status .icon {
@@ -284,9 +284,8 @@
284284

285285
.conpherence-widget-pane #widgets-calendar .user-status .description {
286286
width: 195px;
287-
float: left;
288287
text-overflow: ellipsis;
289-
margin: 0 0 10px 10px;
288+
margin: 0 0 0px 20px;
290289
}
291290

292291
.conpherence-widget-pane #widgets-calendar .user-status .participant {

0 commit comments

Comments
 (0)