2015-05-06 04:06:13 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* JavaScript for SOGoContacts */
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('SOGo.Common', []);
|
|
|
|
|
|
|
|
angular.module('SOGo.ContactsUI', ['ngSanitize', 'ui.router', 'vs-repeat', 'SOGo.Common'])
|
|
|
|
|
|
|
|
.constant('sgSettings', {
|
|
|
|
baseURL: ApplicationBaseURL,
|
|
|
|
activeUser: {
|
|
|
|
login: UserLogin,
|
|
|
|
identification: UserIdentification,
|
|
|
|
language: UserLanguage,
|
|
|
|
folderURL: UserFolderURL,
|
|
|
|
isSuperUser: IsSuperUser
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
.config(configure);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
|
|
|
configure.$inject = ['$stateProvider', '$urlRouterProvider'];
|
|
|
|
function configure($stateProvider, $urlRouterProvider) {
|
|
|
|
$stateProvider
|
|
|
|
.state('app', {
|
|
|
|
url: '/addressbooks',
|
|
|
|
abstract: true,
|
|
|
|
views: {
|
|
|
|
addressbooks: {
|
|
|
|
templateUrl: 'UIxContactFoldersView', // UI/Templates/Contacts/UIxContactFoldersView.wox
|
2015-05-28 19:48:45 +02:00
|
|
|
controller: 'AddressBooksController',
|
|
|
|
controllerAs: 'app'
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
resolve: {
|
2015-05-06 18:12:27 +02:00
|
|
|
stateAddressbooks: stateAddressbooks
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.addressbook', {
|
|
|
|
url: '/:addressbookId',
|
|
|
|
views: {
|
|
|
|
addressbook: {
|
|
|
|
templateUrl: 'addressbook',
|
2015-05-28 19:48:45 +02:00
|
|
|
controller: 'AddressBookController',
|
|
|
|
controllerAs: 'addressbook'
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
resolve: {
|
2015-05-06 18:12:27 +02:00
|
|
|
stateAddressbook: stateAddressbook
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.addressbook.new', {
|
|
|
|
url: '/{contactType:(?:card|list)}/new',
|
|
|
|
views: {
|
|
|
|
card: {
|
|
|
|
templateUrl: 'UIxContactEditorTemplate', // UI/Templates/Contacts/UIxContactEditorTemplate.wox
|
2015-05-28 19:48:45 +02:00
|
|
|
controller: 'CardController',
|
|
|
|
controllerAs: 'editor'
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
resolve: {
|
2015-05-06 18:12:27 +02:00
|
|
|
stateCard: stateNewCard
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.addressbook.card', {
|
|
|
|
url: '/:cardId',
|
|
|
|
abstract: true,
|
|
|
|
views: {
|
|
|
|
card: {
|
|
|
|
template: '<ui-view/>'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
resolve: {
|
2015-05-06 18:12:27 +02:00
|
|
|
stateCard: stateCard
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.addressbook.card.view', {
|
|
|
|
url: '/view',
|
|
|
|
views: {
|
|
|
|
'card@app.addressbook': {
|
|
|
|
templateUrl: 'UIxContactViewTemplate', // UI/Templates/Contacts/UIxContactViewTemplate.wox
|
2015-05-28 19:48:45 +02:00
|
|
|
controller: 'CardController',
|
|
|
|
controllerAs: 'editor'
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.addressbook.card.editor', {
|
|
|
|
url: '/edit',
|
|
|
|
views: {
|
|
|
|
'card@app.addressbook': {
|
|
|
|
templateUrl: 'UIxContactEditorTemplate', // UI/Templates/Contacts/UIxContactEditorTemplate.wox
|
2015-05-28 19:48:45 +02:00
|
|
|
controller: 'CardController',
|
|
|
|
controllerAs: 'editor'
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// if none of the above states are matched, use this as the fallback
|
|
|
|
$urlRouterProvider.otherwise('/addressbooks/personal');
|
|
|
|
}
|
|
|
|
|
2015-05-06 18:12:27 +02:00
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
|
|
|
stateAddressbooks.$inject = ['AddressBook'];
|
|
|
|
function stateAddressbooks(AddressBook) {
|
|
|
|
return AddressBook.$findAll(window.contactFolders);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
|
|
|
stateAddressbook.$inject = ['$stateParams', 'AddressBook'];
|
|
|
|
function stateAddressbook($stateParams, AddressBook) {
|
|
|
|
return AddressBook.$find($stateParams.addressbookId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
|
|
|
stateNewCard.$inject = ['$stateParams', 'stateAddressbook', 'Card'];
|
|
|
|
function stateNewCard($stateParams, stateAddressbook, Card) {
|
|
|
|
var tag = 'v' + $stateParams.contactType,
|
|
|
|
card = new Card({ pid: $stateParams.addressbookId, tag: tag });
|
|
|
|
return card;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
|
|
|
stateCard.$inject = ['$stateParams', 'stateAddressbook'];
|
|
|
|
function stateCard($stateParams, stateAddressbook) {
|
|
|
|
return stateAddressbook.$getCard($stateParams.cardId);
|
|
|
|
}
|
|
|
|
|
2015-05-06 04:06:13 +02:00
|
|
|
})();
|