From cc283575535d3acf8f03343a7d8128c3b5a46eb5 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 19 May 2016 16:34:42 -0400 Subject: [PATCH] (js) Fix autocompletion of LDAP-based groups Fixes #3673 --- NEWS | 1 + .../js/Contacts/AddressBookController.js | 13 +++++++------ UI/WebServerResources/js/Contacts/Card.service.js | 9 +++++++-- .../js/Mailer/MessageEditorController.js | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index b63badee7..bdd954356 100644 --- a/NEWS +++ b/NEWS @@ -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) ------------------ diff --git a/UI/WebServerResources/js/Contacts/AddressBookController.js b/UI/WebServerResources/js/Contacts/AddressBookController.js index aa51a4595..f67110421 100644 --- a/UI/WebServerResources/js/Contacts/AddressBookController.js +++ b/UI/WebServerResources/js/Contacts/AddressBookController.js @@ -171,15 +171,12 @@ 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 { @@ -187,15 +184,19 @@ 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); }); diff --git a/UI/WebServerResources/js/Contacts/Card.service.js b/UI/WebServerResources/js/Contacts/Card.service.js index b3b5b951d..cdfcbd665 100644 --- a/UI/WebServerResources/js/Contacts/Card.service.js +++ b/UI/WebServerResources/js/Contacts/Card.service.js @@ -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 = ''; } @@ -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) { diff --git a/UI/WebServerResources/js/Mailer/MessageEditorController.js b/UI/WebServerResources/js/Mailer/MessageEditorController.js index 71021aefb..69a8227d5 100644 --- a/UI/WebServerResources/js/Mailer/MessageEditorController.js +++ b/UI/WebServerResources/js/Mailer/MessageEditorController.js @@ -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) {