parent
5d1ac9db5d
commit
74acab0738
|
@ -136,7 +136,7 @@
|
||||||
* @param {Object} card - an Card object instance to be added to the attendees list
|
* @param {Object} card - an Card object instance to be added to the attendees list
|
||||||
*/
|
*/
|
||||||
Attendees.prototype.add = function(card, options) {
|
Attendees.prototype.add = function(card, options) {
|
||||||
var _this = this, attendee, list, url, params;
|
var _this = this, attendee, list, url, params, promise = Attendees.$q.when();
|
||||||
if (card) {
|
if (card) {
|
||||||
if (!this.component.attendees || (options && options.organizerCalendar)) {
|
if (!this.component.attendees || (options && options.organizerCalendar)) {
|
||||||
// No attendee yet; initialize the organizer
|
// No attendee yet; initialize the organizer
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
if (card.$isList({expandable: true})) {
|
if (card.$isList({expandable: true})) {
|
||||||
// Decompose list members
|
// Decompose list members
|
||||||
list = Attendees.$Card.$find(card.container, card.c_name);
|
list = Attendees.$Card.$find(card.container, card.c_name);
|
||||||
list.$id().then(function(listId) {
|
promise = list.$id().then(function(listId) {
|
||||||
_.forEach(list.refs, function(ref) {
|
_.forEach(list.refs, function(ref) {
|
||||||
attendee = {
|
attendee = {
|
||||||
name: ref.c_cn,
|
name: ref.c_cn,
|
||||||
|
@ -189,7 +189,7 @@
|
||||||
})) {
|
})) {
|
||||||
if (card.$isList() && Attendees.$Preferences.defaults.SOGoLDAPGroupExpansionEnabled) {
|
if (card.$isList() && Attendees.$Preferences.defaults.SOGoLDAPGroupExpansionEnabled) {
|
||||||
// LDAP list -- preload members
|
// LDAP list -- preload members
|
||||||
card.$members().then(function(members) {
|
promise = card.$members().then(function(members) {
|
||||||
attendee.members = members;
|
attendee.members = members;
|
||||||
attendee.isExpandableGroup = true;
|
attendee.isExpandableGroup = true;
|
||||||
});
|
});
|
||||||
|
@ -205,6 +205,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -483,7 +483,7 @@
|
||||||
|
|
||||||
return new Date(parseInt(date[0]), parseInt(date[1]) - 1, parseInt(date[2]),
|
return new Date(parseInt(date[0]), parseInt(date[1]) - 1, parseInt(date[2]),
|
||||||
parseInt(time[0]), parseInt(time[1]), 0, 0);
|
parseInt(time[0]), parseInt(time[1]), 0, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function init
|
* @function init
|
||||||
|
|
|
@ -205,8 +205,8 @@
|
||||||
/**
|
/**
|
||||||
* @ngInject
|
* @ngInject
|
||||||
*/
|
*/
|
||||||
ComponentEditorController.$inject = ['$rootScope', '$scope', '$log', '$timeout', '$window', '$element', '$mdDialog', '$mdToast', 'sgFocus', 'User', 'CalendarSettings', 'Calendar', 'Component', 'Attendees', 'AddressBook', 'Card', 'Preferences', 'stateComponent'];
|
ComponentEditorController.$inject = ['$rootScope', '$scope', '$q', '$log', '$timeout', '$window', '$element', '$mdDialog', '$mdToast', 'sgFocus', 'User', 'CalendarSettings', 'Calendar', 'Component', 'Attendees', 'AddressBook', 'Card', 'Preferences', 'stateComponent'];
|
||||||
function ComponentEditorController($rootScope, $scope, $log, $timeout, $window, $element, $mdDialog, $mdToast, focus, User, CalendarSettings, Calendar, Component, Attendees, AddressBook, Card, Preferences, stateComponent) {
|
function ComponentEditorController($rootScope, $scope, $q, $log, $timeout, $window, $element, $mdDialog, $mdToast, focus, User, CalendarSettings, Calendar, Component, Attendees, AddressBook, Card, Preferences, stateComponent) {
|
||||||
var vm = this, component, oldStartDate, oldEndDate, oldDueDate, dayStartTime, dayEndTime;
|
var vm = this, component, oldStartDate, oldEndDate, oldDueDate, dayStartTime, dayEndTime;
|
||||||
|
|
||||||
this.$onInit = function () {
|
this.$onInit = function () {
|
||||||
|
@ -291,7 +291,8 @@
|
||||||
this.addAttendee = function (card, partial) {
|
this.addAttendee = function (card, partial) {
|
||||||
var initOrganizer = (!this.component.attendees || this.component.attendees.length === 0),
|
var initOrganizer = (!this.component.attendees || this.component.attendees.length === 0),
|
||||||
destinationCalendar = Calendar.$get(this.component.destinationCalendar),
|
destinationCalendar = Calendar.$get(this.component.destinationCalendar),
|
||||||
options = initOrganizer? { organizerCalendar: destinationCalendar } : {};
|
options = initOrganizer? { organizerCalendar: destinationCalendar } : {},
|
||||||
|
promises = [];
|
||||||
var emailRE = /([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i,
|
var emailRE = /([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i,
|
||||||
i, address;
|
i, address;
|
||||||
if (partial) options.partial = partial;
|
if (partial) options.partial = partial;
|
||||||
|
@ -316,7 +317,7 @@
|
||||||
|
|
||||||
function addCard(newCard) {
|
function addCard(newCard) {
|
||||||
if (!vm.component.$attendees.hasAttendee(newCard))
|
if (!vm.component.$attendees.hasAttendee(newCard))
|
||||||
vm.component.$attendees.add(newCard, options);
|
return vm.component.$attendees.add(newCard, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (angular.isString(card)) {
|
if (angular.isString(card)) {
|
||||||
|
@ -332,23 +333,26 @@
|
||||||
card.charCodeAt(i) == 44 || // ,
|
card.charCodeAt(i) == 44 || // ,
|
||||||
card.charCodeAt(i) == 59) && // ;
|
card.charCodeAt(i) == 59) && // ;
|
||||||
emailRE.test(address)) {
|
emailRE.test(address)) {
|
||||||
createCard(address).then(addCard);
|
promises.push(createCard(address).then(addCard));
|
||||||
address = '';
|
address = '';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
address += card.charAt(i);
|
address += card.charAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (address && emailRE.test(address))
|
if (address && emailRE.test(address)) {
|
||||||
createCard(address).then(addCard);
|
promises.push(createCard(address).then(addCard));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (angular.isDefined(card)) {
|
else if (angular.isDefined(card)) {
|
||||||
if (!this.component.$attendees.hasAttendee(card))
|
if (!this.component.$attendees.hasAttendee(card))
|
||||||
this.component.$attendees.add(card, options);
|
promises.push(this.component.$attendees.add(card, options));
|
||||||
this.showAttendeesEditor |= initOrganizer;
|
this.showAttendeesEditor |= initOrganizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
$timeout(scrollToStart);
|
$timeout(scrollToStart);
|
||||||
|
|
||||||
|
return $q.all(promises);
|
||||||
};
|
};
|
||||||
|
|
||||||
function scrollToStart() {
|
function scrollToStart() {
|
||||||
|
@ -466,20 +470,22 @@
|
||||||
this.adjustStartTime();
|
this.adjustStartTime();
|
||||||
this.adjustEndTime();
|
this.adjustEndTime();
|
||||||
this.changeAlarmRelation(form);
|
this.changeAlarmRelation(form);
|
||||||
if (form.$valid) {
|
this.addAttendee(this.searchText).then(function () {
|
||||||
this.component.$save(options)
|
if (form.$valid) {
|
||||||
.then(function(data) {
|
vm.component.$save(options)
|
||||||
$rootScope.$emit('calendars:list');
|
.then(function(data) {
|
||||||
Preferences.getAlarms();
|
$rootScope.$emit('calendars:list');
|
||||||
$mdDialog.hide();
|
Preferences.getAlarms();
|
||||||
}, function(response) {
|
$mdDialog.hide();
|
||||||
if (response.status == CalendarSettings.ConflictHTTPErrorCode &&
|
}, function(response) {
|
||||||
_.isObject(response.data.message))
|
if (response.status == CalendarSettings.ConflictHTTPErrorCode &&
|
||||||
vm.attendeeConflictError = response.data.message;
|
_.isObject(response.data.message))
|
||||||
else
|
vm.attendeeConflictError = response.data.message;
|
||||||
vm.edit(form);
|
else
|
||||||
});
|
vm.edit(form);
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.reset = function (form) {
|
this.reset = function (form) {
|
||||||
|
|
Loading…
Reference in New Issue