(js) Decompose contacts list in attendees editor
This commit is contained in:
parent
6464e35704
commit
d08c490992
|
@ -31,12 +31,13 @@
|
||||||
* @desc The factory we'll use to register with Angular
|
* @desc The factory we'll use to register with Angular
|
||||||
* @returns the Component constructor
|
* @returns the Component constructor
|
||||||
*/
|
*/
|
||||||
Component.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Preferences', 'Gravatar', 'Resource', function($q, $timeout, $log, Settings, Preferences, Gravatar, Resource) {
|
Component.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Preferences', 'Card', 'Gravatar', 'Resource', function($q, $timeout, $log, Settings, Preferences, Card, Gravatar, Resource) {
|
||||||
angular.extend(Component, {
|
angular.extend(Component, {
|
||||||
$q: $q,
|
$q: $q,
|
||||||
$timeout: $timeout,
|
$timeout: $timeout,
|
||||||
$log: $log,
|
$log: $log,
|
||||||
$Preferences: Preferences,
|
$Preferences: Preferences,
|
||||||
|
$Card: Card,
|
||||||
$gravatar: Gravatar,
|
$gravatar: Gravatar,
|
||||||
$$resource: new Resource(Settings.baseURL(), Settings.activeUser()),
|
$$resource: new Resource(Settings.baseURL(), Settings.activeUser()),
|
||||||
timeFormat: "%H:%M",
|
timeFormat: "%H:%M",
|
||||||
|
@ -794,24 +795,53 @@
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
Component.prototype.addAttendee = function(card) {
|
Component.prototype.addAttendee = function(card) {
|
||||||
var attendee, url, params;
|
var _this = this, attendee, list, url, params;
|
||||||
if (card) {
|
if (card) {
|
||||||
attendee = {
|
if (card.$isList() && card.isGroup !== 1) {
|
||||||
name: card.c_cn,
|
// Decompose list members
|
||||||
email: card.$preferredEmail(),
|
list = Component.$Card.$find(card.container, card.c_name);
|
||||||
role: 'req-participant',
|
list.$id().then(function(listId) {
|
||||||
status: 'needs-action',
|
_.forEach(list.refs, function(ref) {
|
||||||
uid: card.c_uid
|
attendee = {
|
||||||
};
|
name: ref.c_cn,
|
||||||
if (!_.find(this.attendees, function(o) {
|
email: ref.$preferredEmail(),
|
||||||
return o.email == attendee.email;
|
role: 'req-participant',
|
||||||
})) {
|
status: 'needs-action',
|
||||||
attendee.image = Component.$gravatar(attendee.email, 32);
|
uid: ref.c_uid
|
||||||
if (this.attendees)
|
};
|
||||||
this.attendees.push(attendee);
|
if (!_.find(_this.attendees, function(o) {
|
||||||
else
|
return o.email == attendee.email;
|
||||||
this.attendees = [attendee];
|
})) {
|
||||||
this.updateFreeBusyAttendee(attendee);
|
// Contact is not already an attendee, add it
|
||||||
|
attendee.image = Component.$gravatar(attendee.email, 32);
|
||||||
|
if (_this.attendees)
|
||||||
|
_this.attendees.push(attendee);
|
||||||
|
else
|
||||||
|
_this.attendees = [attendee];
|
||||||
|
_this.updateFreeBusyAttendee(attendee);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Single contact
|
||||||
|
attendee = {
|
||||||
|
name: card.c_cn,
|
||||||
|
email: card.$preferredEmail(),
|
||||||
|
role: 'req-participant',
|
||||||
|
status: 'needs-action',
|
||||||
|
uid: card.c_uid
|
||||||
|
};
|
||||||
|
if (!_.find(this.attendees, function(o) {
|
||||||
|
return o.email == attendee.email;
|
||||||
|
})) {
|
||||||
|
attendee.image = Component.$gravatar(attendee.email, 32);
|
||||||
|
if (this.attendees)
|
||||||
|
this.attendees.push(attendee);
|
||||||
|
else
|
||||||
|
this.attendees = [attendee];
|
||||||
|
this.updateFreeBusyAttendee(attendee);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue