From ea64046df2419e19313ae494ae1d7d92988ad4ee Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 8 Nov 2016 12:24:56 -0500 Subject: [PATCH] Fix links to newly added addressbook --- UI/Contacts/UIxContactFoldersView.h | 6 +-- UI/Contacts/UIxContactFoldersView.m | 37 +++++++++++++++++-- .../ContactsUI/UIxContactFoldersView.wox | 2 +- .../js/Contacts/AddressBook.service.js | 25 +++++++++++++ .../js/Contacts/AddressBooksController.js | 32 ++++++++++------ 5 files changed, 82 insertions(+), 20 deletions(-) diff --git a/UI/Contacts/UIxContactFoldersView.h b/UI/Contacts/UIxContactFoldersView.h index 6bb658417..4ecebf6d5 100644 --- a/UI/Contacts/UIxContactFoldersView.h +++ b/UI/Contacts/UIxContactFoldersView.h @@ -1,8 +1,6 @@ /* UIxContactFoldersView.h - this file is part of SOGo * - * Copyright (C) 2006-2009 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2006-2016 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 @@ -36,7 +34,7 @@ BOOL contextIsSetup; } -- (NSString *) contactFolders; +- (NSArray *) contactFolders; - (NSArray *) personalContactInfos; diff --git a/UI/Contacts/UIxContactFoldersView.m b/UI/Contacts/UIxContactFoldersView.m index 016097c9c..1fcb8e879 100644 --- a/UI/Contacts/UIxContactFoldersView.m +++ b/UI/Contacts/UIxContactFoldersView.m @@ -1,6 +1,6 @@ /* UIxContactFoldersView.m - this file is part of SOGo * - * Copyright (C) 2006-2014 Inverse inc. + * Copyright (C) 2006-2016 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 @@ -274,7 +274,7 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK; return [[SOGoSystemDefaults sharedSystemDefaults] enablePublicAccess]; } -- (NSString *) contactFolders +- (NSArray *) contactFolders { SOGoContactFolders *folderContainer; NSMutableDictionary *urls, *acls; @@ -347,7 +347,38 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK; [foldersAttrs addObject: folderAttrs]; } - return [foldersAttrs jsonRepresentation]; + return foldersAttrs; +} + +/** + * @api {get} /so/:username/Contacts/addressbooksList Get address books + * @apiVersion 1.0.0 + * @apiName GetAddressbooksList + * @apiGroup Contacts + * @apiExample {curl} Example usage: + * curl -i http://localhost/SOGo/so/sogo1/Contacts/addressbooksList + * + * @apiSuccess (Success 200) {Object[]} addressbooks List of address books + * @apiSuccess (Success 200) {String} addressbooks.id AddressBook ID + * @apiSuccess (Success 200) {String} addressbooks.name Human readable name + * @apiSuccess (Success 200) {String} addressbooks.owner User ID of owner + * @apiSuccess (Success 200) {Number} addressbooks.synchronize 1 if address book must be synchronized in EAS + * @apiSuccess (Success 200) {Number} addressbooks.listRequiresDot 1 if listing requires a search + * @apiSuccess (Success 200) {Number} addressbooks.isRemote 1 if address book is a global source + * @apiSuccess (Success 200) {Object[]} urls URLs to this address book + * @apiSuccess (Success 200) {String} [urls.cardDavURL] CardDAV URL + * @apiSuccess (Success 200) {String} [urls.publicCardDavURL] Public CardDAV URL + */ +- (WOResponse *) addressbooksListAction +{ + NSDictionary *data; + WOResponse *response; + + data = [NSDictionary dictionaryWithObject: [self contactFolders] + forKey: @"addressbooks"]; + response = [self responseWithStatus: 200 andJSONRepresentation: data]; + + return response; } // - (NSString *) currentContactFolderId diff --git a/UI/Templates/ContactsUI/UIxContactFoldersView.wox b/UI/Templates/ContactsUI/UIxContactFoldersView.wox index af3cf12a9..065c86a6e 100644 --- a/UI/Templates/ContactsUI/UIxContactFoldersView.wox +++ b/UI/Templates/ContactsUI/UIxContactFoldersView.wox @@ -11,7 +11,7 @@ const:userDefaultsKeys="SOGoContactsCategories" const:jsFiles="vendor/ckeditor/ckeditor.js, vendor/ckeditor/ck.js, Common.js, Preferences.services.js, Mailer.services.js, Contacts.js, Contacts.services.js, vendor/angular-file-upload.min.js, vendor/FileSaver.min.js">