1
1
'use strict' ;
2
2
3
- const _ = require ( 'lodash' ) ;
4
-
5
3
require ( '../../contact.service.js' ) ;
6
4
7
5
angular . module ( 'linagora.esn.contact' )
@@ -11,7 +9,8 @@ function contactActionMoveController(
11
9
asyncAction ,
12
10
contactAddressbookDisplayService ,
13
11
contactAddressbookService ,
14
- contactService
12
+ contactService ,
13
+ contactAddressbookHelper
15
14
) {
16
15
var self = this ;
17
16
var NOTIFICATION_MESSAGES = {
@@ -25,12 +24,12 @@ function contactActionMoveController(
25
24
26
25
function listPossbileDestinations ( ) {
27
26
contactAddressbookService . listAddressbooksUserCanCreateContact ( )
28
- . then ( _excludeCurrentAddressbook )
29
27
. then ( contactAddressbookDisplayService . convertShellsToDisplayShells )
30
- . then ( function ( availableAddressbookDisplayShells ) {
31
- self . availableAddressbookDisplayShells = availableAddressbookDisplayShells ;
32
- self . selectedAddressbook = self . availableAddressbookDisplayShells [ 0 ] . shell ;
28
+ . then ( displayShells => {
29
+ const uniqueShells = contactAddressbookHelper . getUniqueAdressBookShells ( displayShells ) ;
33
30
31
+ self . availableAddressbookDisplayShells = _excludeCurrentAddressbookShell ( uniqueShells ) ;
32
+ self . selectedAddressbook = self . availableAddressbookDisplayShells [ 0 ] . shell ;
34
33
} ) ;
35
34
}
36
35
@@ -40,12 +39,10 @@ function contactActionMoveController(
40
39
} ) ;
41
40
}
42
41
43
- function _excludeCurrentAddressbook ( addressbooks ) {
44
- _ . remove ( addressbooks , function ( addressbook ) {
45
- return self . contact . addressbook . bookName === addressbook . bookName ;
46
- } ) ;
42
+ function _excludeCurrentAddressbookShell ( addressbookShells ) {
43
+ const { addressbook : { href } } = self . contact ;
47
44
48
- return addressbooks ;
45
+ return addressbookShells . filter ( ( { shell : { href : addressbookHref } } ) => addressbookHref !== href ) ;
49
46
}
50
47
}
51
48
0 commit comments