Fix links to newly added addressbook
parent
8e33794400
commit
ea64046df2
|
@ -1,8 +1,6 @@
|
|||
/* UIxContactFoldersView.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2006-2009 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
* 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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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">
|
||||
<script type="text/javascript">
|
||||
var contactFolders = <var:string value="contactFolders" const:escapeHTML="NO" />;
|
||||
var contactFolders = <var:string value="contactFolders.jsonRepresentation" const:escapeHTML="NO" />;
|
||||
</script>
|
||||
|
||||
<main class="view"
|
||||
|
|
|
@ -199,6 +199,31 @@
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @memberof AddressBook
|
||||
* @desc Reload the list of known addressbooks.
|
||||
*/
|
||||
AddressBook.$reloadAll = function() {
|
||||
var _this = this;
|
||||
|
||||
return AddressBook.$$resource.fetch('addressbooksList').then(function(data) {
|
||||
_.forEach(data.addressbooks, function(addressbookData) {
|
||||
var group, addressbook;
|
||||
|
||||
if (addressbookData.isRemote)
|
||||
group = _this.$remotes;
|
||||
else if (addressbookData.owner != AddressBook.activeUser.login)
|
||||
group = _this.$subscriptions;
|
||||
else
|
||||
group = _this.$addressbooks;
|
||||
|
||||
addressbook = _.find(group, function(o) { return o.id == addressbookData.id; });
|
||||
if (addressbook)
|
||||
addressbook.init(addressbookData);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @function init
|
||||
* @memberof AddressBook.prototype
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
AddressBooksController.$inject = ['$state', '$scope', '$rootScope', '$stateParams', '$timeout', '$window', '$mdDialog', '$mdToast', '$mdMedia', '$mdSidenav', 'FileUploader', 'sgConstant', 'sgHotkeys', 'sgFocus', 'Card', 'AddressBook', 'Dialog', 'sgSettings', 'User', 'stateAddressbooks'];
|
||||
function AddressBooksController($state, $scope, $rootScope, $stateParams, $timeout, $window, $mdDialog, $mdToast, $mdMedia, $mdSidenav, FileUploader, sgConstant, sgHotkeys, focus, Card, AddressBook, Dialog, Settings, User, stateAddressbooks) {
|
||||
AddressBooksController.$inject = ['$q', '$state', '$scope', '$rootScope', '$stateParams', '$timeout', '$window', '$mdDialog', '$mdToast', '$mdMedia', '$mdSidenav', 'FileUploader', 'sgConstant', 'sgHotkeys', 'sgFocus', 'Card', 'AddressBook', 'Dialog', 'sgSettings', 'User', 'stateAddressbooks'];
|
||||
function AddressBooksController($q, $state, $scope, $rootScope, $stateParams, $timeout, $window, $mdDialog, $mdToast, $mdMedia, $mdSidenav, FileUploader, sgConstant, sgHotkeys, focus, Card, AddressBook, Dialog, Settings, User, stateAddressbooks) {
|
||||
var vm = this, hotkeys = [];
|
||||
|
||||
vm.activeUser = Settings.activeUser;
|
||||
|
@ -234,16 +234,24 @@
|
|||
}
|
||||
|
||||
function showLinks(addressbook) {
|
||||
$mdDialog.show({
|
||||
parent: angular.element(document.body),
|
||||
clickOutsideToClose: true,
|
||||
escapeToClose: true,
|
||||
templateUrl: addressbook.id + '/links',
|
||||
controller: LinksDialogController,
|
||||
controllerAs: 'links',
|
||||
locals: {
|
||||
addressbook: addressbook
|
||||
}
|
||||
var promise;
|
||||
if (addressbook.urls)
|
||||
promise = $q.when();
|
||||
else
|
||||
// Refresh list of addressbooks to fetch links associated to addressbook
|
||||
promise = AddressBook.$reloadAll();
|
||||
promise.then(function() {
|
||||
$mdDialog.show({
|
||||
parent: angular.element(document.body),
|
||||
clickOutsideToClose: true,
|
||||
escapeToClose: true,
|
||||
templateUrl: addressbook.id + '/links',
|
||||
controller: LinksDialogController,
|
||||
controllerAs: 'links',
|
||||
locals: {
|
||||
addressbook: addressbook
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue