Skip to content

Commit

Permalink
Fix updating of f/b information when date changes.
Browse files Browse the repository at this point in the history
Fixes updating freebusy information when changing date via either
the textbox or date picker on new events before saving (both were broken),
as well as via the date picker when editing existing events.

Bug: 12676
  • Loading branch information
mrubinsk committed Jan 8, 2014
1 parent 8eab226 commit 3426076
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions kronolith/js/kronolith.js
Expand Up @@ -47,6 +47,7 @@ KronolithCore = {
ucb: null,
resourceACCache: { choices: [], map: $H() },
paramsCache: null,
attendees: [],

/**
* The location that was open before the current location.
Expand Down Expand Up @@ -5330,7 +5331,7 @@ KronolithCore = {
}
RedBox.onDisplay = this.redBoxOnDisplay;
}.bind(this);

this.attendees = [];
this.updateCalendarDropDown('kronolithEventTarget');
this.toggleAllDay(false);
this.openTab($('kronolithEventForm').down('.tabset a.kronolithTabLink'));
Expand Down Expand Up @@ -5403,15 +5404,6 @@ KronolithCore = {
this.toggleRecurrence(true, 'None');
$('kronolithEventEditRecur').hide();
this.enableAlarm('Event', Kronolith.conf.default_alarm);
// Need to clear any existing handler for new events, as they are
// bound to the attendees of the last edited event. @TODO: figure
// out how to attach a similar event for new events.
if (this.attendeeStartDateHandler) {
$('kronolithEventStartDate').stopObserving('change', this.attendeeStartDateHandler);
}
if (this.resourceStartDateHandler) {
$('kronolithEventStartDate').stopObserving('change', this.resourceStartDateHandler);
}
this.redBoxLoading = true;
RedBox.showHtml($('kronolithEventDialog').show());
}
Expand Down Expand Up @@ -5667,21 +5659,12 @@ KronolithCore = {
}

/* Attendees */
if (this.attendeeStartDateHandler) {
$('kronolithEventStartDate').stopObserving('change', this.attendeeStartDateHandler);
}
if (!Object.isUndefined(ev.at)) {
HordeImple.AutoCompleter.kronolithEventAttendees.reset(ev.at.pluck('l'));
ev.at.each(this.addAttendee.bind(this));
if (this.fbLoading) {
$('kronolithFBLoading').show();
}
this.attendeeStartDateHandler = function() {
ev.at.each(function(attendee) {
this.insertFreeBusy(attendee.l);
}, this);
}.bind(this);
$('kronolithEventStartDate').observe('change', this.attendeeStartDateHandler);
}

/* Resources */
Expand Down Expand Up @@ -5754,6 +5737,13 @@ KronolithCore = {
}
},

attendeeStartDateHandler: function(start) {
this.attendees.each(function(attendee) {
this.insertFreeBusy(attendee, start);
}, this);

},

/**
* Adds an attendee row to the free/busy table.
*
Expand Down Expand Up @@ -5781,6 +5771,7 @@ KronolithCore = {
}

if (attendee.e) {
this.attendees.push(attendee.e);
this.fbLoading++;
HordeCore.doAction('getFreeBusy', {
email: attendee.e
Expand Down Expand Up @@ -5918,12 +5909,12 @@ KronolithCore = {
/**
* Updates rows with free/busy information in the attendees table.
*
* @todo Update when changing dates;
*
* @param string attendee An attendee display name as the free/busy
* identifier.
* @param date start An optinal start date for f/b info. If omitted,
* $('kronolithEventStartDate') is used.
*/
insertFreeBusy: function(attendee)
insertFreeBusy: function(attendee, start)
{
if (!$('kronolithEventDialog').visible() ||
!this.freeBusy.get(attendee)) {
Expand All @@ -5946,8 +5937,12 @@ KronolithCore = {
div.purge();
div.remove();
}
var start = Date.parseExact($F('kronolithEventStartDate'), Kronolith.conf.date_format),
end = start.clone().add(1).days(),
if (start) {
start = Date.parseExact(start, Kronolith.conf.date_format);
} else {
start = Date.parseExact($F('kronolithEventStartDate'), Kronolith.conf.date_format)
}
var end = start.clone().add(1).days(),
width = td.getWidth(),
fbs = this.parseDate(fb.s),
fbe = this.parseDate(fb.e);
Expand Down Expand Up @@ -6357,12 +6352,14 @@ KronolithCore = {
{
switch (field) {
case 'kronolithEventStartDate':
this.attendeeStartDateHandler();
case 'kronolithEventStartTime':
this.updateEndTime();
break;
case 'kronolithEventEndDate':
case 'kronolithEventEndTime':
this.updateStartTime();
this.attendeeStartDateHandler();
break;
}
},
Expand Down Expand Up @@ -6625,6 +6622,8 @@ KronolithCore = {
$(field).observe(Prototype.Browser.Gecko ? 'DOMMouseScroll' : 'mousewheel', this.scrollTimeField.bindAsEventListener(this, field));
}, this);

$('kronolithEventStartDate').observe('change', this.attendeeStartDateHandler.bind(this));

this.updateMinical(this.date);
},

Expand Down

0 comments on commit 3426076

Please sign in to comment.