diff --git a/UI/Contacts/GNUmakefile b/UI/Contacts/GNUmakefile index 1a378c4f1..9e72fff80 100644 --- a/UI/Contacts/GNUmakefile +++ b/UI/Contacts/GNUmakefile @@ -23,7 +23,8 @@ ContactsUI_OBJC_FILES = \ UIxContactsListActions.m \ UIxContactFoldersView.m \ UIxContactFolderActions.m \ - UIxContactFolderLinksTemplate.m + UIxContactFolderLinksTemplate.m \ + UIxContactFolderProperties.m ContactsUI_RESOURCE_FILES += \ product.plist \ diff --git a/UI/Contacts/UIxContactFolderProperties.h b/UI/Contacts/UIxContactFolderProperties.h new file mode 100644 index 000000000..882c77cde --- /dev/null +++ b/UI/Contacts/UIxContactFolderProperties.h @@ -0,0 +1,32 @@ +/* UIxContactFolderProperties.m - this file is part of SOGo + * + * Copyright (C) 2015 Inverse inc. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import + +@class NSString; + +@class SOGoContactGCSFolder; + +@interface UIxContactFolderProperties : UIxComponent +{ + SOGoContactGCSFolder *addressbook; +} + +@end diff --git a/UI/Contacts/UIxContactFolderProperties.m b/UI/Contacts/UIxContactFolderProperties.m new file mode 100644 index 000000000..102446485 --- /dev/null +++ b/UI/Contacts/UIxContactFolderProperties.m @@ -0,0 +1,84 @@ +/* UIxContactFolderProperties.m - this file is part of SOGo + * + * Copyright (C) 2015 Inverse inc. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import +#import +#import + +#import + +#import +#import +#import +#import + +#import + +#import "UIxContactFolderProperties.h" + +@implementation UIxContactFolderProperties + +- (id) init +{ + if ((self = [super init])) + { + addressbook = [self clientObject]; + } + + return self; +} + +- (void) dealloc +{ + [super dealloc]; +} + +/** + * @api {post} /so/:username/Contacts/:addressbookId/save Save addressbook + * @apiDescription Save an addressbook's properties. + * @apiVersion 1.0.0 + * @apiName PostSaveProperties + * @apiGroup AddressBook + * + * @apiParam {String} name Human readable name + * @apiParam {Number} synchronize 1 if we enable EAS synchronization for this addressbook + */ +- (WOResponse *) savePropertiesAction +{ + WORequest *request; + NSDictionary *params; + id o, values; + + request = [context request]; + params = [[request contentAsString] objectFromJSONString]; + + o = [params objectForKey: @"name"]; + if ([o isKindOfClass: [NSString class]]) + [addressbook renameTo: o]; + + o = [params objectForKey: @"synchronize"]; + if ([o isKindOfClass: [NSNumber class]]) + [addressbook setSynchronize: [o boolValue]]; + + return [self responseWith204]; +} + +@end diff --git a/UI/Contacts/UIxContactFoldersView.m b/UI/Contacts/UIxContactFoldersView.m index 356deb538..111af01b6 100644 --- a/UI/Contacts/UIxContactFoldersView.m +++ b/UI/Contacts/UIxContactFoldersView.m @@ -296,7 +296,7 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK; NSDictionary *folderAttrs; id currentFolder; - BOOL objectCreator, objectEditor, objectEraser; + BOOL objectCreator, objectEditor, objectEraser, synchronize; int max, i; userLogin = [[context activeUser] login]; @@ -333,11 +333,20 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK; [NSNumber numberWithBool: objectEditor], @"objectEditor", [NSNumber numberWithBool: objectEraser], @"objectEraser", nil]; + if ([currentFolder isKindOfClass: SOGoGCSFolderK]) + synchronize = [currentFolder synchronize]; + else + synchronize = NO; + + if ([[currentFolder nameInContainer] isEqualToString: @"personal"]) + synchronize = YES; + // NOTE: keep urls as the last key/value here, to avoid chopping the dictionary // if it is not a GCS folder folderAttrs = [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat: @"%@", [currentFolder nameInContainer]], @"id", [currentFolder displayName], @"name", + [NSNumber numberWithBool: synchronize], @"synchronize", owner, @"owner", [NSNumber numberWithBool: [currentFolder isKindOfClass: SOGoGCSFolderK]], @"isEditable", [NSNumber numberWithBool: [currentFolder isKindOfClass: SOGoContactSourceFolderK] diff --git a/UI/Contacts/product.plist b/UI/Contacts/product.plist index d78e3749e..158e24815 100644 --- a/UI/Contacts/product.plist +++ b/UI/Contacts/product.plist @@ -136,6 +136,15 @@ protectedBy = "View"; pageName = "UIxContactFolderLinksTemplate"; }; + properties = { + protectedBy = "Access Contents Information"; + pageName = "UIxContactFolderProperties"; + }; + save = { + protectedBy = "Access Contents Information"; + pageName = "UIxContactFolderProperties"; + actionName = "saveProperties"; + }; }; }; @@ -157,11 +166,6 @@ pageName = "UIxContactEditor"; actionName = "new"; }; - save = { - protectedBy = "Change Permissions"; - actionClass = "UIxFolderActions"; - actionName = "renameFolder"; - }; mailer-contacts = { protectedBy = ""; pageName = "UIxContactFoldersView"; diff --git a/UI/Templates/ContactsUI/UIxContactFolderProperties.wox b/UI/Templates/ContactsUI/UIxContactFolderProperties.wox new file mode 100644 index 000000000..a43293f60 --- /dev/null +++ b/UI/Templates/ContactsUI/UIxContactFolderProperties.wox @@ -0,0 +1,42 @@ + + + + + + +
+ + + + + + + close + +
+
+ + + + + + + +
+ + +
+ +
+
diff --git a/UI/Templates/ContactsUI/UIxContactFoldersView.wox b/UI/Templates/ContactsUI/UIxContactFoldersView.wox index d585e4c2e..6b68b5022 100644 --- a/UI/Templates/ContactsUI/UIxContactFoldersView.wox +++ b/UI/Templates/ContactsUI/UIxContactFoldersView.wox @@ -94,6 +94,12 @@ + + + + + + @@ -148,6 +154,12 @@ + + + + + + diff --git a/UI/WebServerResources/js/Contacts/AddressBooksController.js b/UI/WebServerResources/js/Contacts/AddressBooksController.js index c0de570c4..7163efbab 100644 --- a/UI/WebServerResources/js/Contacts/AddressBooksController.js +++ b/UI/WebServerResources/js/Contacts/AddressBooksController.js @@ -21,6 +21,7 @@ vm.importCards = importCards; vm.exportCards = exportCards; vm.showLinks = showLinks; + vm.showProperties = showProperties; vm.share = share; vm.subscribeToFolder = subscribeToFolder; @@ -222,6 +223,44 @@ } } + function showProperties(addressbook) { + $mdDialog.show({ + templateUrl: addressbook.id + '/properties', + controller: PropertiesDialogController, + controllerAs: 'properties', + clickOutsideToClose: true, + escapeToClose: true, + locals: { + srcAddressBook: addressbook + } + }).catch(function() { + // Do nothing + }); + + /** + * @ngInject + */ + PropertiesDialogController.$inject = ['$scope', '$mdDialog', 'srcAddressBook']; + function PropertiesDialogController($scope, $mdDialog, srcAddressBook) { + var vm = this; + + vm.addressbook = new AddressBook(srcAddressBook.$omit()); + vm.saveProperties = saveProperties; + vm.close = close; + + function saveProperties() { + vm.addressbook.$save(); + // Refresh list instance + srcAddressBook.init(vm.addressbook.$omit()); + $mdDialog.hide(); + } + + function close() { + $mdDialog.cancel(); + } + } + } + function share(addressbook) { // Fetch list of ACL users addressbook.$acl.$users().then(function() {