2015-05-06 04:06:13 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* JavaScript for SOGoContacts */
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
2015-08-27 17:01:23 +02:00
|
|
|
angular.module('SOGo.ContactsUI', ['ngSanitize', 'ui.router', 'angularFileUpload', 'ck', 'SOGo.Common', 'SOGo.PreferencesUI', 'SOGo.MailerUI'])
|
2015-08-03 17:53:54 +02:00
|
|
|
.config(configure)
|
|
|
|
.run(runBlock);
|
2015-05-06 04:06:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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) {
|
2015-07-20 21:32:57 +02:00
|
|
|
return AddressBook.$find($stateParams.addressbookId).$futureAddressBookData;
|
2015-05-06 18:12:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
|
|
|
stateNewCard.$inject = ['$stateParams', 'stateAddressbook', 'Card'];
|
|
|
|
function stateNewCard($stateParams, stateAddressbook, Card) {
|
|
|
|
var tag = 'v' + $stateParams.contactType,
|
2015-07-27 18:47:40 +02:00
|
|
|
card = new Card({ pid: $stateParams.addressbookId, c_component: tag });
|
2015-07-15 21:15:17 +02:00
|
|
|
stateAddressbook.selectedCard = true;
|
2015-05-06 18:12:27 +02:00
|
|
|
return card;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
|
|
|
stateCard.$inject = ['$stateParams', 'stateAddressbook'];
|
|
|
|
function stateCard($stateParams, stateAddressbook) {
|
2015-07-15 19:44:17 +02:00
|
|
|
stateAddressbook.selectedCard = $stateParams.cardId;
|
2015-05-06 18:12:27 +02:00
|
|
|
return stateAddressbook.$getCard($stateParams.cardId);
|
|
|
|
}
|
|
|
|
|
2015-08-03 17:53:54 +02:00
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
|
|
|
runBlock.$inject = ['$rootScope'];
|
|
|
|
function runBlock($rootScope) {
|
|
|
|
$rootScope.$on('$routeChangeError', function(event, current, previous, rejection) {
|
|
|
|
console.error(event, current, previous, rejection);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-05-06 04:06:13 +02:00
|
|
|
})();
|