diff --git a/UI/Contacts/English.lproj/Localizable.strings b/UI/Contacts/English.lproj/Localizable.strings index e1a671c7e..4c49f587a 100644 --- a/UI/Contacts/English.lproj/Localizable.strings +++ b/UI/Contacts/English.lproj/Localizable.strings @@ -132,6 +132,8 @@ "New Addressbook..." = "New Addressbook..."; "Subscribe to an Addressbook..." = "Subscribe to an Addressbook..."; "Remove the selected Addressbook" = "Remove the selected Addressbook"; +"Subscribe to a shared folder" = "Subscribe to a shared folder"; +"Search User" = "Search User"; "Name of the Address Book" = "Name of the Address Book"; "Are you sure you want to delete the selected address book?" @@ -147,8 +149,6 @@ "You cannot delete the card of \"%{0}\"." = "You cannot delete the card of \"%{0}\"."; - - "You cannot subscribe to a folder that you own!" = "You cannot subscribe to a folder that you own."; "Unable to subscribe to that folder!" diff --git a/UI/Templates/ContactsUI/UIxContactsUserFolders.wox b/UI/Templates/ContactsUI/UIxContactsUserFolders.wox index ea76b92ce..b8b2e31d7 100644 --- a/UI/Templates/ContactsUI/UIxContactsUserFolders.wox +++ b/UI/Templates/ContactsUI/UIxContactsUserFolders.wox @@ -8,31 +8,67 @@ xmlns:uix="OGo:uix"> -

+

- + + ng-model="subscribe.searchText" + ng-model-options="subscribe.searchTextOptions" + ng-change="subscribe.onChange()"/> - + + +
+ +
+ +
+
+
+
+
{{user.cn}} {{user.userClass}}
+
{{user.c_email}}
+
+ +
+
+ +
+ warning + +
+
+ +

{{folder.displayName}}

+ +
+
+
+ + - + ng-repeat="user in subscribe.users"> +
{{user.$shortFormat()}} - +
+ ng-show="user == subscribe.selectedUser"> warning @@ -44,7 +80,7 @@

{{folder.displayName}}

+ ng-click="subscribe.selectFolder(folder)">
diff --git a/UI/WebServerResources/js/Common/sgSubscribe.directive.js b/UI/WebServerResources/js/Common/sgSubscribe.directive.js index a6dd7229e..e87821f4a 100644 --- a/UI/WebServerResources/js/Common/sgSubscribe.directive.js +++ b/UI/WebServerResources/js/Common/sgSubscribe.directive.js @@ -6,7 +6,7 @@ /* * sgSubscribe - Common subscription widget - * @restrict class or attribute + * @restrict attribute * @param {string} sgSubscribe - the folder type * @param {function} sgSubscribeOnSelect - the function to call when subscribing to a folder. * One variable is available: folderData. @@ -26,7 +26,7 @@ replace: false, bindToController: true, controller: sgSubscribeDialogController, - controllerAs: 'vm', + controllerAs: '$sgSubscribeDialogController', link: link }; } @@ -51,7 +51,7 @@ onFolderSelect: vm.onFolderSelect }, controller: sgSubscribeController, - controllerAs: 'vm' + controllerAs: 'subscribe' }); }; } @@ -62,7 +62,9 @@ sgSubscribeController.$inject = ['folderType', 'onFolderSelect', 'User']; function sgSubscribeController(folderType, onFolderSelect, User) { var vm = this; + vm.selectedUser = null; + vm.users = User.$users; vm.searchTextOptions = { updateOn: 'default blur', @@ -73,16 +75,28 @@ }; vm.onChange = function() { - User.$filter(vm.searchText).then(function(matches) { - vm.users = matches; + User.$filter(vm.searchText).then(function() { + if (vm.selectedUser) { + // If selected user is no longer part of the matching users, unselect it + if (_.isUndefined(_.find(User.$users, function(user) { + return user.uid == vm.selectedUser.uid; + }))) { + vm.selectedUser = null; + } + } }); }; vm.selectUser = function(i) { - // Fetch folders of specific type for selected user - vm.users[i].$folders(folderType).then(function() { - vm.selectedUser = vm.users[i]; - }); + if (vm.selectedUser == vm.users[i]) { + vm.selectedUser = null; + } + else { + // Fetch folders of specific type for selected user + vm.users[i].$folders(folderType).then(function() { + vm.selectedUser = vm.users[i]; + }); + } }; // Callback upon subscription to a folder