Skip to content

Commit 73bd2e9

Browse files
committedMay 29, 2013
Conpherence calendar updates
Summary: Fixes T3253 by shifting the display to the "next 3 days". Also adds in the "create" functionality for calendar on desktop view only, ref T3251. As part of T3251, I plan to make this work on mobile too. Test Plan: added statuses and noted errors showed up. noted on success the widget pane refreshed. also made sure the regular old /calendar/status/create/ page still worked. Reviewers: epriestley Reviewed By: epriestley CC: chad, aran, Korvin Maniphest Tasks: T3251, T3253 Differential Revision: https://secure.phabricator.com/D6072
1 parent 545dbab commit 73bd2e9

File tree

9 files changed

+139
-38
lines changed

9 files changed

+139
-38
lines changed
 

‎src/__celerity_resource_map__.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@
945945
),
946946
'conpherence-widget-pane-css' =>
947947
array(
948-
'uri' => '/res/b218398a/rsrc/css/application/conpherence/widget-pane.css',
948+
'uri' => '/res/e06804b6/rsrc/css/application/conpherence/widget-pane.css',
949949
'type' => 'css',
950950
'requires' =>
951951
array(
@@ -1294,7 +1294,7 @@
12941294
),
12951295
'javelin-behavior-conpherence-menu' =>
12961296
array(
1297-
'uri' => '/res/478fc4f3/rsrc/js/application/conpherence/behavior-menu.js',
1297+
'uri' => '/res/87e901c2/rsrc/js/application/conpherence/behavior-menu.js',
12981298
'type' => 'js',
12991299
'requires' =>
13001300
array(
@@ -1325,7 +1325,7 @@
13251325
),
13261326
'javelin-behavior-conpherence-widget-pane' =>
13271327
array(
1328-
'uri' => '/res/232893cf/rsrc/js/application/conpherence/behavior-widget-pane.js',
1328+
'uri' => '/res/3b06849a/rsrc/js/application/conpherence/behavior-widget-pane.js',
13291329
'type' => 'js',
13301330
'requires' =>
13311331
array(

‎src/applications/calendar/controller/PhabricatorCalendarEditStatusController.php

+43-7
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ public function processRequest() {
8686
'Y'),
8787
$redirect => true,
8888
));
89-
return id(new AphrontRedirectResponse())
90-
->setURI($uri);
89+
if ($request->isAjax()) {
90+
$response = id(new AphrontAjaxResponse())
91+
->setContent(array('redirect_uri' => $uri));
92+
} else {
93+
$response = id(new AphrontRedirectResponse())
94+
->setURI($uri);
95+
}
96+
return $response;
9197
}
9298
}
9399

@@ -109,23 +115,53 @@ public function processRequest() {
109115
->setName('description')
110116
->setValue($status->getDescription());
111117

112-
$form = id(new AphrontFormView())
113-
->setUser($user)
114-
->setFlexible(true)
118+
if ($request->isAjax()) {
119+
$dialog = id(new AphrontDialogView())
120+
->setUser($user)
121+
->setTitle($page_title)
122+
->setWidth(AphrontDialogView::WIDTH_FORM);
123+
if ($this->isCreate()) {
124+
$dialog->setSubmitURI($this->getApplicationURI('status/create/'));
125+
} else {
126+
$dialog->setSubmitURI(
127+
$this->getApplicationURI('status/edit/'.$status->getID().'/'));
128+
}
129+
$form = new AphrontFormLayoutView();
130+
if ($error_view) {
131+
$form->appendChild($error_view);
132+
}
133+
} else {
134+
$form = id(new AphrontFormView())
135+
->setUser($user)
136+
->setFlexible(true);
137+
}
138+
139+
$form
115140
->appendChild($status_select)
116141
->appendChild($start_time)
117142
->appendChild($end_time)
118143
->appendChild($description);
119144

120-
$submit = id(new AphrontFormSubmitControl())
121-
->setValue($submit_label);
145+
if ($request->isAjax()) {
146+
$dialog->addSubmitButton($submit_label);
147+
$submit = $dialog;
148+
} else {
149+
$submit = id(new AphrontFormSubmitControl())
150+
->setValue($submit_label);
151+
}
122152
if ($this->isCreate()) {
123153
$submit->addCancelButton($this->getApplicationURI());
124154
} else {
125155
$submit->addCancelButton(
126156
$this->getApplicationURI('status/delete/'.$status->getID().'/'),
127157
pht('Delete Status'));
128158
}
159+
160+
if ($request->isAjax()) {
161+
$dialog->appendChild($form);
162+
return id(new AphrontDialogResponse())
163+
->setDialog($dialog);
164+
}
129165
$form->appendChild($submit);
130166

131167
$nav = $this->buildSideNavView($status);

‎src/applications/conpherence/constants/ConpherenceUpdateActions.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ final class ConpherenceUpdateActions extends ConpherenceConstants {
77
const ADD_PERSON = 'add_person';
88
const REMOVE_PERSON = 'remove_person';
99
const NOTIFICATIONS = 'notifications';
10+
const ADD_STATUS = 'add_status';
1011
}

‎src/applications/conpherence/controller/ConpherenceWidgetController.php

+14-13
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ private function renderWidgetPaneContent() {
6565
$conpherence = $this->getConpherence();
6666

6767
$widgets = array();
68+
$new_icon = id(new PHUIIconView())
69+
->setSpriteSheet(PHUIIconView::SPRITE_ACTIONS)
70+
->setSpriteIcon('new-grey')
71+
->setHref($this->getWidgetURI())
72+
->addSigil('conpherence-widget-adder');
6873
$widgets[] = phutil_tag(
6974
'div',
7075
array(
@@ -75,6 +80,7 @@ private function renderWidgetPaneContent() {
7580
->setHeaderTitle(pht('Participants'))
7681
->setHeaderHref('#')
7782
->setDropdown(true)
83+
->addAction($new_icon)
7884
->addHeaderSigil('widgets-selector'));
7985
$user = $this->getRequest()->getUser();
8086
// now the widget bodies
@@ -193,11 +199,11 @@ private function renderCalendarWidgetPaneContent() {
193199
$content = array();
194200
$layout = id(new AphrontMultiColumnView())
195201
->setFluidLayout(true);
196-
$timestamps = $this->getCalendarWidgetWeekTimestamps();
202+
$timestamps = $this->getCalendarWidgetTimestamps();
197203
$today = $timestamps['today'];
198-
$weekstamps = $timestamps['weekstamps'];
204+
$epoch_stamps = $timestamps['epoch_stamps'];
199205
$one_day = 24 * 60 * 60;
200-
foreach ($weekstamps as $time => $day) {
206+
foreach ($epoch_stamps as $time => $day) {
201207
// build a header for the new day
202208
if ($day->format('w') == $today->format('w')) {
203209
$active_class = 'today';
@@ -227,7 +233,6 @@ private function renderCalendarWidgetPaneContent() {
227233

228234
$week_day_number = $day->format('w');
229235

230-
231236
$day->setTime(0, 0, 0);
232237
$epoch_start = $day->format('U');
233238
$next_day = clone $day;
@@ -371,24 +376,20 @@ private function renderCalendarWidgetPaneContent() {
371376
);
372377
}
373378

374-
private function getCalendarWidgetWeekTimestamps() {
379+
private function getCalendarWidgetTimestamps() {
375380
$user = $this->getRequest()->getUser();
376381
$timezone = new DateTimeZone($user->getTimezoneIdentifier());
377382

378-
$today = id(new DateTime('now', $timezone));
379-
$monday = clone $today;
380-
$monday
381-
->modify('+1 day')
382-
->modify('last monday');
383+
$today = id(new DateTime('today', $timezone));
383384
$timestamps = array();
384-
for ($day = 0; $day < 7; $day++) {
385-
$timestamp = clone $monday;
385+
for ($day = 0; $day < 3; $day++) {
386+
$timestamp = clone $today;
386387
$timestamps[] = $timestamp->modify(sprintf('+%d days', $day));
387388
}
388389

389390
return array(
390391
'today' => $today,
391-
'weekstamps' => $timestamps
392+
'epoch_stamps' => $timestamps
392393
);
393394
}
394395

‎src/applications/conpherence/query/ConpherenceThreadQuery.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,21 @@ 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 one week window
221-
$start_of_week = phabricator_format_local_time(
222-
strtotime('last monday', strtotime('tomorrow')),
220+
// for a rolling three day window
221+
$start_epoch = phabricator_format_local_time(
222+
strtotime('today', strtotime('tomorrow')),
223223
$this->getViewer(),
224224
'U');
225-
$end_of_week = phabricator_format_local_time(
226-
strtotime('last monday +1 week', strtotime('tomorrow')),
225+
$end_epoch = phabricator_format_local_time(
226+
strtotime('+3 days', strtotime('tomorrow')),
227227
$this->getViewer(),
228228
'U');
229229
$statuses = id(new PhabricatorUserStatus())
230230
->loadAllWhere(
231231
'userPHID in (%Ls) AND dateTo >= %d AND dateFrom <= %d',
232232
$participant_phids,
233-
$start_of_week,
234-
$end_of_week);
233+
$start_epoch,
234+
$end_epoch);
235235
$statuses = mgroup($statuses, 'getUserPHID');
236236

237237
// attached files

‎src/applications/conpherence/view/ConpherenceLayoutView.php

+6
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,28 @@ public function render() {
8282
'conpherence-message-pane' => array(
8383
'name' => pht('Thread'),
8484
'deviceOnly' => true,
85+
'hasCreate' => false
8586
),
8687
'widgets-people' => array(
8788
'name' => pht('Participants'),
8889
'deviceOnly' => false,
90+
'hasCreate' => false
8991
),
9092
'widgets-files' => array(
9193
'name' => pht('Files'),
9294
'deviceOnly' => false,
95+
'hasCreate' => false
9396
),
9497
'widgets-calendar' => array(
9598
'name' => pht('Calendar'),
9699
'deviceOnly' => false,
100+
'hasCreate' => true,
101+
'createHref' => '/calendar/status/create/'
97102
),
98103
'widgets-settings' => array(
99104
'name' => pht('Settings'),
100105
'deviceOnly' => false,
106+
'hasCreate' => false
101107
),
102108
)));
103109

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@
145145
/* calendar widget */
146146

147147
.conpherence-widget-pane #widgets-calendar .aphront-multi-column-view {
148-
margin: 2px 0px 0px 0px;
149148
width: 240px;
150149
}
151150
.device .conpherence-widget-pane #widgets-calendar .aphront-multi-column-view {
151+
margin: 2px 0px 0px 0px;
152152
width: 100%;
153153
}
154154
.conpherence-widget-pane #widgets-calendar .aphront-multi-column-view

‎webroot/rsrc/js/application/conpherence/behavior-menu.js

+25-7
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,7 @@ JX.behavior('conpherence-menu', function(config) {
138138
}
139139

140140
if (_thread.visible !== null || !config.hasWidgets) {
141-
markWidgetLoading(true);
142-
var widget_uri = config.baseURI + 'widget/' + data.threadID + '/';
143-
new JX.Workflow(widget_uri, {})
144-
.setHandler(JX.bind(null, onWidgetResponse, data.threadID))
145-
.start();
141+
reloadWidget(data);
146142
} else {
147143
JX.Stratcom.invoke(
148144
'conpherence-update-widgets',
@@ -191,7 +187,29 @@ JX.behavior('conpherence-menu', function(config) {
191187
JX.DOM.alterClass(widgets_root, 'loading', loading);
192188
}
193189

194-
function onWidgetResponse(thread_id, response) {
190+
function reloadWidget(data) {
191+
markWidgetLoading(true);
192+
if (!data.widget) {
193+
data.widget = getDefaultWidget();
194+
}
195+
var widget_uri = config.baseURI + 'widget/' + data.threadID + '/';
196+
new JX.Workflow(widget_uri, {})
197+
.setHandler(JX.bind(null, onWidgetResponse, data.threadID, data.widget))
198+
.start();
199+
}
200+
JX.Stratcom.listen(
201+
'conpherence-reload-widget',
202+
null,
203+
function (e) {
204+
var data = e.getData();
205+
if (data.threadID != _thread.selected) {
206+
return;
207+
}
208+
reloadWidget(data);
209+
}
210+
);
211+
212+
function onWidgetResponse(thread_id, widget, response) {
195213
// we got impatient and this is no longer the right answer :/
196214
if (_thread.selected != thread_id) {
197215
return;
@@ -204,7 +222,7 @@ JX.behavior('conpherence-menu', function(config) {
204222
'conpherence-update-widgets',
205223
null,
206224
{
207-
widget : getDefaultWidget(),
225+
widget : widget,
208226
buildSelectors : true,
209227
toggleWidget : true,
210228
threadID : _thread.selected

‎webroot/rsrc/js/application/conpherence/behavior-widget-pane.js

+39
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ JX.behavior('conpherence-widget-pane', function(config) {
169169
var root = JX.DOM.find(document, 'div', 'conpherence-layout');
170170
var widget_pane = JX.DOM.find(root, 'div', 'conpherence-widget-pane');
171171
var widget_header = JX.DOM.find(widget_pane, 'a', 'widgets-selector');
172+
var adder = JX.DOM.find(widget_pane, 'a', 'conpherence-widget-adder');
172173
JX.DOM.setContent(
173174
widget_header,
174175
widget_data.name);
175176
JX.DOM.appendContent(
176177
widget_header,
177178
JX.$N('span', { className : 'caret' }));
179+
if (widget_data.hasCreate) {
180+
JX.DOM.show(adder);
181+
} else {
182+
JX.DOM.hide(adder);
183+
}
178184
}
179185

180186
for (var widget in config.widgetRegistry) {
@@ -215,6 +221,39 @@ JX.behavior('conpherence-widget-pane', function(config) {
215221
}
216222
});
217223

224+
/**
225+
* Generified adding new stuff to widgets technology!
226+
*/
227+
JX.Stratcom.listen(
228+
['click'],
229+
'conpherence-widget-adder',
230+
function (e) {
231+
e.kill();
232+
var widgets = config.widgetRegistry;
233+
var active_widget = null;
234+
var href = null;
235+
for (var widget in widgets) {
236+
if (widgets[widget].name == _selectedWidgetName) {
237+
href = widgets[widget].createHref;
238+
active_widget = widget;
239+
break;
240+
}
241+
}
242+
new JX.Workflow(href, {})
243+
.setHandler(function () {
244+
JX.Stratcom.invoke(
245+
'conpherence-reload-widget',
246+
null,
247+
{
248+
threadID : _loadedWidgetsID,
249+
widget : active_widget
250+
}
251+
);
252+
})
253+
.start();
254+
}
255+
);
256+
218257
/* people widget */
219258
JX.Stratcom.listen(
220259
['submit', 'didSyntheticSubmit'],

0 commit comments

Comments
 (0)
Failed to load comments.