Skip to content

Commit

Permalink
(js) Fix autocompletion of LDAP-based groups
Browse files Browse the repository at this point in the history
Fixes #3673
  • Loading branch information
cgx committed May 19, 2016
1 parent fdc8291 commit cc28357
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -4,6 +4,7 @@
Bug fixes
- [web] fixed creation of chip on blur (sgTransformOnBlur directive)
- [web] fixed composition of new messages from Contacts module
- [web] fixed autocompletion of LDAP-based groups (#3673)

3.1.0 (2016-05-18)
------------------
Expand Down
13 changes: 7 additions & 6 deletions UI/WebServerResources/js/Contacts/AddressBookController.js
Expand Up @@ -171,31 +171,32 @@
var promises = [], recipients = [];

_.forEach(selectedCards, function(card) {
if (card.c_component == 'vcard' && card.c_mail.length) {
recipients.push(card.c_cn + ' <' + card.c_mail + '>');
}
else if (card.$isList()) {
if (card.$isList({expandable: true})) {
// If the list's members were already fetch, use them
if (angular.isDefined(card.refs) && card.refs.length) {
_.forEach(card.refs, function(ref) {
if (ref.email.length)
recipients.push(ref.c_cn + ' <' + ref.email + '>');
recipients.push(ref.$shortFormat());
});
}
else {
promises.push(vm.selectedFolder.$getCard(card.id).then(function(card) {
return card.$futureCardData.then(function(data) {
_.forEach(data.refs, function(ref) {
if (ref.email.length)
recipients.push(ref.c_cn + ' <' + ref.email + '>');
recipients.push(ref.$shortFormat());
});
});
}));
}
}
else if (card.c_mail.length) {
recipients.push(card.$shortFormat());
}
});

$q.all(promises).then(function() {
recipients = _.uniq(recipients);
if (recipients.length)
vm.newMessage($event, recipients);
});
Expand Down
9 changes: 7 additions & 2 deletions UI/WebServerResources/js/Contacts/Card.service.js
Expand Up @@ -285,6 +285,9 @@
else if (this.emails && this.emails.length) {
email = this.emails[0].value;
}
else if (this.c_mail && this.c_mail.length) {
email = this.c_mail[0];
}
else {
email = '';
}
Expand All @@ -311,8 +314,10 @@
return this.c_component == 'vcard';
};

Card.prototype.$isList = function() {
return this.c_component == 'vlist';
Card.prototype.$isList = function(options) {
// isGroup attribute means it's a group of a LDAP source (not expandable on the client-side)
var condition = (!options || !options.expandable || options.expandable && !this.isgroup);
return this.c_component == 'vlist' && condition;
};

Card.prototype.$addOrgUnit = function(orgUnit) {
Expand Down
2 changes: 1 addition & 1 deletion UI/WebServerResources/js/Mailer/MessageEditorController.js
Expand Up @@ -209,7 +209,7 @@

recipients = vm.message.editable[field];

if (contact.$isList()) {
if (contact.$isList({expandable: true})) {
// If the list's members were already fetch, use them
if (angular.isDefined(contact.refs) && contact.refs.length) {
_.forEach(contact.refs, function(ref) {
Expand Down

0 comments on commit cc28357

Please sign in to comment.