diff --git a/ChangeLog b/ChangeLog index 91f43d6b3..8b878d416 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,7 +8,7 @@ (availabilitySession): new class, used by the above, for triggering availability searchs in the available freebusys. Listeners should implement the "onRequestComplete" method. - (freeBusyRequest): new class design to asynchronosly fetch a user + (freeBusyRequest): new class designed to asynchronosly fetch a user freebusy between specific dates. Makes use of an internal cache and may trigger ajax requests covering more that the specified range in order to take advantage of that cache. Listeners should @@ -18,6 +18,7 @@ (initializeTimeSlotWidgets): new method that initializes the new widgets that controls the time range behaviour in the freebusy searches. + (editorConflictHander): new class that handles time conflicts. * UI/Scheduler/UIxCalListingActions.m (-findPossibleSlotAction): removed action method and submethods since the slot resolution is diff --git a/UI/Scheduler/BrazilianPortuguese.lproj/Localizable.strings b/UI/Scheduler/BrazilianPortuguese.lproj/Localizable.strings index 2d60c83a8..588b37031 100644 --- a/UI/Scheduler/BrazilianPortuguese.lproj/Localizable.strings +++ b/UI/Scheduler/BrazilianPortuguese.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "A data que você informou ocorre antes da data ini "During specified hours" = "During specified hours"; "and" = "and"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Título"; "Start" = "Início"; diff --git a/UI/Scheduler/Czech.lproj/Localizable.strings b/UI/Scheduler/Czech.lproj/Localizable.strings index 872c2095a..4ec2c82db 100644 --- a/UI/Scheduler/Czech.lproj/Localizable.strings +++ b/UI/Scheduler/Czech.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "Zadané datum konce je před začátkem události. "During specified hours" = "During specified hours"; "and" = "and"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Název"; "Start" = "Začátek"; diff --git a/UI/Scheduler/Dutch.lproj/Localizable.strings b/UI/Scheduler/Dutch.lproj/Localizable.strings index 5885022c5..20e994f6e 100644 --- a/UI/Scheduler/Dutch.lproj/Localizable.strings +++ b/UI/Scheduler/Dutch.lproj/Localizable.strings @@ -487,6 +487,9 @@ validate_endbeforestart = "Het begin vindt plaats vóór het einde."; "During specified hours" = "Tijdens gespecificeerde uren"; "and" = "en"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Titel"; "Start" = "Begin"; diff --git a/UI/Scheduler/English.lproj/Localizable.strings b/UI/Scheduler/English.lproj/Localizable.strings index 8ea87c1d2..ebafba714 100644 --- a/UI/Scheduler/English.lproj/Localizable.strings +++ b/UI/Scheduler/English.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "The end date that you entered occurs before the st "During specified hours" = "During specified hours"; "and" = "and"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Title"; "Start" = "Start"; diff --git a/UI/Scheduler/French.lproj/Localizable.strings b/UI/Scheduler/French.lproj/Localizable.strings index 6c0126010..b75b0cce0 100644 --- a/UI/Scheduler/French.lproj/Localizable.strings +++ b/UI/Scheduler/French.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "La date de fin est avant la date de début."; "During specified hours" = "Pendant les heures spécifiées"; "and" = "et"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "Il y a un conflit avec l'horaire d'un ou plusieurs participants.\nVoulez-vous conserver les paramètres actuel malgré tout?"; + /* apt list */ "Title" = "Titre"; "Start" = "Début"; diff --git a/UI/Scheduler/German.lproj/Localizable.strings b/UI/Scheduler/German.lproj/Localizable.strings index 25fe6922b..3707d52fc 100644 --- a/UI/Scheduler/German.lproj/Localizable.strings +++ b/UI/Scheduler/German.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "Ihr Beginn ist nach dem Ende"; "During specified hours" = "During specified hours"; "and" = "and"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Titel"; "Start" = "Beginn"; diff --git a/UI/Scheduler/Hungarian.lproj/Localizable.strings b/UI/Scheduler/Hungarian.lproj/Localizable.strings index 54b6bb0ea..87235bd97 100644 --- a/UI/Scheduler/Hungarian.lproj/Localizable.strings +++ b/UI/Scheduler/Hungarian.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "A megadott befejező dátum korábbi, mint a kezd "During specified hours" = "During specified hours"; "and" = "and"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Cím"; "Start" = "Kezdés"; diff --git a/UI/Scheduler/Italian.lproj/Localizable.strings b/UI/Scheduler/Italian.lproj/Localizable.strings index fdb41e70b..7394edc0e 100644 --- a/UI/Scheduler/Italian.lproj/Localizable.strings +++ b/UI/Scheduler/Italian.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "La data finale specificata è precedente alla data "During specified hours" = "During specified hours"; "and" = "and"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Titolo"; "Start" = "Inizio"; diff --git a/UI/Scheduler/Russian.lproj/Localizable.strings b/UI/Scheduler/Russian.lproj/Localizable.strings index 560f71432..bd18894df 100644 --- a/UI/Scheduler/Russian.lproj/Localizable.strings +++ b/UI/Scheduler/Russian.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "The end date that you entered occurs before the st "During specified hours" = "During specified hours"; "and" = "and"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Title"; "Start" = "Start"; diff --git a/UI/Scheduler/Spanish.lproj/Localizable.strings b/UI/Scheduler/Spanish.lproj/Localizable.strings index 96648c696..4d4935cfe 100644 --- a/UI/Scheduler/Spanish.lproj/Localizable.strings +++ b/UI/Scheduler/Spanish.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "Su fecha/hora de comienzo es posterio a la de fina "During specified hours" = "During specified hours"; "and" = "and"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Título"; "Start" = "Inicio"; diff --git a/UI/Scheduler/Swedish.lproj/Localizable.strings b/UI/Scheduler/Swedish.lproj/Localizable.strings index ed486abd4..16f6f8354 100644 --- a/UI/Scheduler/Swedish.lproj/Localizable.strings +++ b/UI/Scheduler/Swedish.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "Angivet slutdatumet inträffar före angivet start "During specified hours" = "During specified hours"; "and" = "and"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Titel"; "Start" = "Start"; diff --git a/UI/Scheduler/Welsh.lproj/Localizable.strings b/UI/Scheduler/Welsh.lproj/Localizable.strings index 3ddf44e87..8cd6a6cf7 100644 --- a/UI/Scheduler/Welsh.lproj/Localizable.strings +++ b/UI/Scheduler/Welsh.lproj/Localizable.strings @@ -488,6 +488,9 @@ validate_endbeforestart = "Mae'r dyddiad gorffen sydd wedi'i roi yn digwydd c "During specified hours" = "During specified hours"; "and" = "and"; +"A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?" += "A time conflict exists with one or more attendees.\nWould you like to keep the current settings anyway?"; + /* apt list */ "Title" = "Teitl"; "Start" = "Dechrau"; diff --git a/UI/WebServerResources/UIxAttendeesEditor.js b/UI/WebServerResources/UIxAttendeesEditor.js index b2ccc3049..f8be34370 100644 --- a/UI/WebServerResources/UIxAttendeesEditor.js +++ b/UI/WebServerResources/UIxAttendeesEditor.js @@ -591,7 +591,6 @@ availabilitySession.prototype = { }, _step: function aS__step() { - // log("currentStart: " + this.mCurrentStart); this.mCurrentEntries = null; var max = this.mUids.length; if (max > 0) { @@ -626,7 +625,6 @@ availabilitySession.prototype = { this.mActiveRequests--; this._mergeEntries(entries); if (this.mActiveRequests == 0) { - // log("requests done"); var foundDate = this._findDate(); if (foundDate) { var foundEndDate = foundDate.clone(); @@ -644,7 +642,6 @@ availabilitySession.prototype = { if (this.mWorkDaysOnly) { this._adjustCurrentStart(); } - // log("found no date, new start: " + this.mCurrentStart); this._step(); } } @@ -877,7 +874,7 @@ _freeBusyCacheEntry.prototype = { if (adjustedSd.getTime() < this.startDate.getTime()) { var start = adjustedSd.clone(); start.addDays(-7); - var end = start.clone(); + var end = this.startDate.beginOfDay(); end.addDays(-1); fetchDates.push({ start: start, end: end }); } @@ -997,6 +994,66 @@ freeBusyRequest.prototype = { } }; +function editorConflictHandler(uids, startDate, endDate, listener) { + this.mUids = uids; + this.mRemaining = uids.length; + this.mCurrentUid = 0; + + this.mStartDate = startDate; + this.mEndDate = endDate; + + this.mListener = listener; +} + +editorConflictHandler.prototype = { + mUids: null, + mCurrentUid: 0, + + mStartDate: null, + mEndDate: null, + + mQuOffset: 0, + mQuOffsetMax: 0, + + mCurrentEntries: null, + + mListener: null, + + start: function eCH_start() { + this.mQuOffset = (this.mStartDate.getHours() * 4 + + Math.floor(this.mStartDate.getMinutes() / 15)); + this.mQuOffsetMax = (this.mEndDate.deltaDays(this.mStartDate) * 96 + + this.mEndDate.getHours() * 4 + + Math.ceil(this.mEndDate.getMinutes() / 15)); + this._step(); + }, + + _step: function eCH__step() { + if (this.mCurrentUid < this.mUids.length) { + var fbRequest = new freeBusyRequest(this.mStartDate, + this.mEndDate, + this.mUids[this.mCurrentUid], + this); + fbRequest.start(); + } + else { + this.mListener.onRequestComplete(this, true); + } + }, + + onRequestComplete: function eCH_onRequestComplete(fbRequest, success, + entries) { + var periodEntries = entries.slice(this.mQuOffset, this.mQuOffsetMax); + if (periodEntries.indexOf("1") > -1) { + this.mListener.onRequestComplete(this, false); + } + else { + this.mCurrentUid++; + this._step(); + } + } +}; + function displayFreeBusyForNode(input) { var rowIndex = input.parentNode.parentNode.sectionRowIndex; var row = $("freeBusyData").tBodies[0].rows[rowIndex]; @@ -1206,17 +1263,48 @@ function updateSlotDisplayCallback(http) { window.timeWidgets['start']['date'].setValueAsDate(start); window.timeWidgets['start']['hour'].value = cleanInt(data[0]['startHour']); window.timeWidgets['start']['minute'].value = cleanInt(data[0]['startMinute']); - + cb(); } function onEditorOkClick(event) { preventDefault(event); + var uids = []; + var inputs = $("freeBusy").getElementsByTagName("input"); + for (var i = 0; i < inputs.length - 1; i++) { + var input = inputs[i]; + if (input.uid) { + uids.push(input.uid); + } + } + + var startDate = $("startTime_date").valueAsDate(); + startDate.setHours(parseInt($("startTime_time_hour").value)); + startDate.setMinutes(parseInt($("startTime_time_minute").value)); + var endDate = $("endTime_date").valueAsDate(); + endDate.setHours(parseInt($("endTime_time_hour").value)); + endDate.setMinutes(parseInt($("endTime_time_minute").value)); + + var listener = { + onRequestComplete: function eCH_l_onRequestComplete(handlers, code) { + var label = ("A time conflict exists with one or more attendees.\n" + + "Would you like to keep the current settings anyway?"); + if (code || window.confirm(getLabel(label))) { + _confirmEditorOkClick(); + } + } + }; + + var conflictHandler = new editorConflictHandler(uids, startDate, + endDate, listener); + conflictHandler.start(); +} + +function _confirmEditorOkClick() { var attendees = window.opener.attendees; var newAttendees = new Hash(); - var table = $("freeBusy"); - var inputs = table.getElementsByTagName("input"); + var inputs = $("freeBusy").getElementsByTagName("input"); for (var i = 0; i < inputs.length - 1; i++) { var row = $(inputs[i]).up("tr"); var name = extractEmailName(inputs[i].value); @@ -1294,16 +1382,14 @@ function onTimeWidgetChange() { } function onTimeDateWidgetChange() { - var table = $("freeBusyHeader"); - var rows = table.select("tr"); + var rows = $("freeBusyHeader").select("tr"); for (var i = 0; i < rows.length; i++) { for (var j = rows[i].cells.length - 1; j > -1; j--) { rows[i].deleteCell(j); } } - table = $("freeBusyData"); - rows = table.select("tr"); + rows = $("freeBusyData").select("tr"); for (var i = 0; i < rows.length; i++) { for (var j = rows[i].cells.length - 1; j > -1; j--) { rows[i].deleteCell(j);