Improve JavaScript coding style
To comitted code now passes the Airbnb pattern using jscs
This commit is contained in:
parent
17ee62f4de
commit
3e2173db7a
|
@ -112,12 +112,12 @@
|
|||
|
||||
<!-- dropdown menu for new card split button -->
|
||||
<ul id="newListDrop" class="f-dropdown">
|
||||
<li><a class="tiny" data-ui-sref="addressbook.new({addressbook_id: addressbook.id, contact_type: 'list'})"><var:string label:value="New List"/></a></li>
|
||||
<li><a class="tiny" data-ui-sref="addressbook.new({addressbookId: addressbook.id, contactType: 'list'})"><var:string label:value="New List"/></a></li>
|
||||
</ul>
|
||||
|
||||
<div id="addressbooksList" class="folders-list">
|
||||
<div class="newItemsToolbar">
|
||||
<a class="button tiny radius split" data-ui-sref="addressbook.new({addressbook_id: addressbook.id, contact_type: 'card'})"><var:string label:value="New Card"/><span data-dropdown-toggle="#newListDrop"></span></a><br/>
|
||||
<a class="button tiny radius split" data-ui-sref="addressbook.new({addressbookId: addressbook.id, contactType: 'card'})"><var:string label:value="New Card"/><span data-dropdown-toggle="#newListDrop"></span></a><br/>
|
||||
</div>
|
||||
<ul id="contactFolders">
|
||||
<li data-ng-repeat="folder in addressbooks"
|
||||
|
@ -125,7 +125,7 @@
|
|||
data-ng-dblclick="edit($index)">
|
||||
<i class="icon" data-ng-class="{'icon-earth': folder.isRemote, 'icon-address-book': folder.isEditable}"><!-- icon --></i>
|
||||
<form data-ng-submit="save($index)">
|
||||
<a data-ui-sref="addressbook({addressbook_id: folder.id})"
|
||||
<a data-ui-sref="addressbook({addressbookId: folder.id})"
|
||||
data-ng-click="select($index)"
|
||||
data-ng-show="editMode!=folder.id"
|
||||
data-ng-cloak="ng-cloak">{{folder.name}}</a>
|
||||
|
@ -180,7 +180,7 @@
|
|||
<li data-ng-repeat="card in addressbook.cards"
|
||||
data-ng-class="{_selected: addressbook.card.id == card.id}">
|
||||
<!-- <input type="checkbox" class="card-picture left"/> -->
|
||||
<a data-ui-sref="addressbook.card({addressbook_id: addressbook.id, card_id: card.id})">
|
||||
<a data-ui-sref="addressbook.card({addressbookId: addressbook.id, cardId: card.id})">
|
||||
<span class="card-picture" data-ng-switch="card.tag">
|
||||
<i data-ng-switch-when="vcard" class="icon-ion-ios7-person"><!-- card --></i>
|
||||
<i data-ng-switch-when="vlist" class="icon-ion-ios7-people"><!-- list --></i>
|
||||
|
@ -208,7 +208,7 @@
|
|||
</div>
|
||||
<div class="buttonsToolbar">
|
||||
<span data-ng-show="addressbook.isEditable">
|
||||
<a class="button tiny radius" data-ui-sref="addressbook.editor({addressbook_id: addressbook.id, card_id: addressbook.card.id})"><i class="icon-pencil"><!-- edit --></i></a>
|
||||
<a class="button tiny radius" data-ui-sref="addressbook.editor({addressbookId: addressbook.id, cardId: addressbook.card.id})"><i class="icon-pencil"><!-- edit --></i></a>
|
||||
<span class="button tiny radius alert" data-ng-click="confirmDelete(addressbook.card)"><i class="icon-trash"><!-- delete --></i></span>
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
<ion-content class="has-header">
|
||||
<ion-list>
|
||||
<ion-item ng-repeat="addressbook in addressbooks" option-buttons="buttons"
|
||||
ui-sref="app.addressbook({addressbook_id: addressbook.id})"
|
||||
ui-sref="app.addressbook({addressbookId: addressbook.id})"
|
||||
class="item-icon-left item-icon-right">
|
||||
<i class="icon" ng-class="{'ion-earth': addressbook.isRemote}"><!-- public addressbook --></i>
|
||||
{{addressbook.name}}
|
||||
|
@ -71,7 +71,7 @@
|
|||
<script type="text/ng-template" id="addressbook.html">
|
||||
<ion-view title="{{addressbook.name}}">
|
||||
<ion-nav-buttons side="right">
|
||||
<a class="button button-clear button-positive button-icon icon ion-ios7-plus-empty" ui-sref="app.newCard({ addressbook_id: addressbook.id, contact_type: 'card' })"><!-- new --></a>
|
||||
<a class="button button-clear button-positive button-icon icon ion-ios7-plus-empty" ui-sref="app.newCard({ addressbookId: addressbook.id, contactType: 'card' })"><!-- new --></a>
|
||||
</ion-nav-buttons>
|
||||
<ion-content class="has-header">
|
||||
<ion-list>
|
||||
|
@ -86,7 +86,7 @@
|
|||
<ion-list>
|
||||
<ion-item class="item-icon-right" option-buttons="buttons"
|
||||
data-ng-repeat="card in addressbook.cards"
|
||||
data-ui-sref="app.card({addressbook_id: addressbook.id, card_id: card.c_name})">
|
||||
data-ui-sref="app.card({addressbookId: addressbook.id, cardId: card.c_name})">
|
||||
{{card.c_cn || card.c_mail}}
|
||||
<i class="icon ion-ios7-arrow-right"><!-- right arrow icon --></i>
|
||||
</ion-item>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
|
@ -35,7 +37,8 @@
|
|||
}];
|
||||
|
||||
/* Factory registration in Angular module */
|
||||
angular.module('SOGo.ContactsUI').factory('sgAddressBook', AddressBook.$factory);
|
||||
angular.module('SOGo.ContactsUI')
|
||||
.factory('sgAddressBook', AddressBook.$factory)
|
||||
|
||||
/**
|
||||
* @memberof AddressBook
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
Card.$tel_types = ['work', 'home', 'cell', 'fax', 'pager'];
|
||||
Card.$email_types = ['work', 'home', 'pref'];
|
||||
Card.$url_types = ['work', 'home', 'pref'];
|
||||
Card.$address_types = ['work', 'home'];
|
||||
Card.$TEL_TYPES = ['work', 'home', 'cell', 'fax', 'pager'];
|
||||
Card.$EMAIL_TYPES = ['work', 'home', 'pref'];
|
||||
Card.$URL_TYPES = ['work', 'home', 'pref'];
|
||||
Card.$ADDRESS_TYPES = ['work', 'home'];
|
||||
|
||||
/* The factory we'll use to register with Angular */
|
||||
Card.$factory = ['$timeout', 'sgSettings', 'sgResource', function($timeout, Settings, Resource) {
|
||||
|
@ -39,11 +39,18 @@
|
|||
return Card; // return constructor
|
||||
}];
|
||||
|
||||
/* Factory registration in Angular module */
|
||||
/**
|
||||
* @module SOGo.ContactsUI
|
||||
* @desc Factory registration of Card in Angular module
|
||||
*/
|
||||
angular.module('SOGo.ContactsUI')
|
||||
.factory('sgCard', Card.$factory)
|
||||
|
||||
// Directive to format a postal address
|
||||
/**
|
||||
* @name sgAddress
|
||||
* @memberof ContactsUI
|
||||
* @desc Directive to format a postal address
|
||||
*/
|
||||
.directive('sgAddress', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
|
||||
$stateProvider
|
||||
.state('addressbook', {
|
||||
url: '/:addressbook_id',
|
||||
url: '/:addressbookId',
|
||||
views: {
|
||||
addressbooks: {
|
||||
templateUrl: 'addressbooks.html',
|
||||
|
@ -27,12 +27,12 @@
|
|||
return AddressBook.$all(contactFolders);
|
||||
}],
|
||||
stateAddressbook: ['$stateParams', 'sgAddressBook', function($stateParams, AddressBook) {
|
||||
return AddressBook.$find($stateParams.addressbook_id);
|
||||
return AddressBook.$find($stateParams.addressbookId);
|
||||
}]
|
||||
}
|
||||
})
|
||||
.state('addressbook.card', {
|
||||
url: '/:card_id',
|
||||
url: '/:cardId',
|
||||
views: {
|
||||
card: {
|
||||
templateUrl: 'card.html',
|
||||
|
@ -41,12 +41,12 @@
|
|||
},
|
||||
resolve: {
|
||||
stateCard: ['$stateParams', 'stateAddressbook', function($stateParams, stateAddressbook) {
|
||||
return stateAddressbook.$getCard($stateParams.card_id);
|
||||
return stateAddressbook.$getCard($stateParams.cardId);
|
||||
}]
|
||||
}
|
||||
})
|
||||
.state('addressbook.new', {
|
||||
url: '/:contact_type/new',
|
||||
url: '/:contactType/new',
|
||||
views: {
|
||||
card: {
|
||||
templateUrl: 'cardEditor.html',
|
||||
|
@ -55,14 +55,14 @@
|
|||
},
|
||||
resolve: {
|
||||
stateCard: ['$stateParams', 'stateAddressbook', 'sgCard', function($stateParams, stateAddressbook, Card) {
|
||||
var tag = 'v' + $stateParams.contact_type;
|
||||
stateAddressbook.card = new Card({ pid: $stateParams.addressbook_id, tag: tag });
|
||||
var tag = 'v' + $stateParams.contactType;
|
||||
stateAddressbook.card = new Card({ pid: $stateParams.addressbookId, tag: tag });
|
||||
return stateAddressbook.card;
|
||||
}]
|
||||
}
|
||||
})
|
||||
.state('addressbook.editor', {
|
||||
url: '/:card_id/edit',
|
||||
url: '/:cardId/edit',
|
||||
views: {
|
||||
card: {
|
||||
templateUrl: 'cardEditor.html',
|
||||
|
@ -71,7 +71,7 @@
|
|||
},
|
||||
resolve: {
|
||||
stateCard: ['$stateParams', 'stateAddressbook', function($stateParams, stateAddressbook) {
|
||||
return stateAddressbook.$getCard($stateParams.card_id);
|
||||
return stateAddressbook.$getCard($stateParams.cardId);
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
@ -100,19 +100,20 @@
|
|||
}])
|
||||
|
||||
.controller('AddressBookCtrl', ['$state', '$scope', '$rootScope', '$stateParams', '$timeout', '$modal', 'sgFocus', 'sgCard', 'sgAddressBook', 'sgDialog', 'stateAddressbooks', 'stateAddressbook', function($state, $scope, $rootScope, $stateParams, $timeout, $modal, focus, Card, AddressBook, Dialog, stateAddressbooks, stateAddressbook) {
|
||||
var addressbookEntry;
|
||||
var currentAddressbook;
|
||||
|
||||
// $scope objects
|
||||
$scope.search = { status: null, filter: null, last_filter: null };
|
||||
|
||||
$rootScope.addressbooks = stateAddressbooks;
|
||||
// Resolve objects
|
||||
$scope.addressbooks = stateAddressbooks;
|
||||
$rootScope.addressbook = stateAddressbook;
|
||||
|
||||
// $scope objects
|
||||
$scope.search = { status: null, filter: null, lastFilter: null };
|
||||
|
||||
// Adjust search status depending on addressbook type
|
||||
var o = _.find($rootScope.addressbooks, function(o) {
|
||||
return o.id == $stateParams.addressbook_id;
|
||||
currentAddressbook = _.find($scope.addressbooks, function(o) {
|
||||
return o.id == $stateParams.addressbookId;
|
||||
});
|
||||
$scope.search.status = (o && o.isRemote)? 'remote-addressbook' : '';
|
||||
$scope.search.status = (currentAddressbook && currentAddressbook.isRemote)? 'remote-addressbook' : '';
|
||||
|
||||
// $scope functions
|
||||
$scope.select = function(rowIndex) {
|
||||
|
@ -138,14 +139,14 @@
|
|||
$scope.edit = function(i) {
|
||||
if (!$rootScope.addressbook.isRemote) {
|
||||
if (angular.isUndefined(i)) {
|
||||
i = _.indexOf(_.pluck($rootScope.addressbooks, 'id'), $rootScope.addressbook.id);
|
||||
i = _.indexOf(_.pluck($scope.addressbooks, 'id'), $rootScope.addressbook.id);
|
||||
}
|
||||
$scope.editMode = $rootScope.addressbook.id;
|
||||
focus('addressBookName_' + i);
|
||||
}
|
||||
};
|
||||
$scope.save = function(i) {
|
||||
var name = $rootScope.addressbooks[i].name;
|
||||
var name = $scope.addressbooks[i].name;
|
||||
if (name && name.length > 0) {
|
||||
$scope.addressbook.$rename(name)
|
||||
.then(function(data) {
|
||||
|
@ -184,7 +185,7 @@
|
|||
});
|
||||
};
|
||||
$scope.doSearch = function(keyEvent) {
|
||||
if ($scope.search.filter != $scope.search.last_filter) {
|
||||
if ($scope.search.filter != $scope.search.lastFilter) {
|
||||
if ($scope.search.filter.length > 2) {
|
||||
$rootScope.addressbook.$filter($scope.search.filter).then(function(data) {
|
||||
if (data.length == 0)
|
||||
|
@ -194,10 +195,10 @@
|
|||
});
|
||||
}
|
||||
else if ($scope.search.filter.length == 0) {
|
||||
$rootScope.addressbook = AddressBook.$find($stateParams.addressbook_id);
|
||||
$rootScope.addressbook = AddressBook.$find($stateParams.addressbookId);
|
||||
// Extend resulting model instance with parameters from addressbooks listing
|
||||
var o = _.find($rootScope.addressbooks, function(o) {
|
||||
return o.id == $stateParams.addressbook_id;
|
||||
var o = _.find($scope.addressbooks, function(o) {
|
||||
return o.id == $stateParams.addressbookId;
|
||||
});
|
||||
$scope.search.status = (o.isRemote)? 'remote-addressbook' : '';
|
||||
}
|
||||
|
@ -206,32 +207,32 @@
|
|||
$rootScope.addressbook.cards = [];
|
||||
}
|
||||
}
|
||||
$scope.search.last_filter = $scope.search.filter;
|
||||
$scope.search.lastFilter = $scope.search.filter;
|
||||
};
|
||||
}])
|
||||
|
||||
.controller('CardCtrl', ['$scope', '$rootScope', 'sgAddressBook', 'sgCard', 'sgDialog', 'sgFocus', '$state', '$stateParams', function($scope, $rootScope, AddressBook, Card, Dialog, focus, $state, $stateParams) {
|
||||
$scope.allEmailTypes = Card.$email_types;
|
||||
$scope.allTelTypes = Card.$tel_types;
|
||||
$scope.allUrlTypes = Card.$url_types;
|
||||
$scope.allAddressTypes = Card.$address_types;
|
||||
$scope.allEmailTypes = Card.$EMAIL_TYPES;
|
||||
$scope.allTelTypes = Card.$TEL_TYPES;
|
||||
$scope.allUrlTypes = Card.$URL_TYPES;
|
||||
$scope.allAddressTypes = Card.$ADDRESS_TYPES;
|
||||
|
||||
$rootScope.master_card = angular.copy($rootScope.addressbook.card);
|
||||
$rootScope.masterCard = angular.copy($rootScope.addressbook.card);
|
||||
|
||||
$scope.addOrgUnit = function() {
|
||||
var i = $rootScope.addressbook.card.$addOrgUnit('');
|
||||
focus('orgUnit_' + i);
|
||||
};
|
||||
$scope.addCategory = function() {
|
||||
var i = $rootScope.addressbook.card.$addCategory($scope.new_category);
|
||||
var i = $rootScope.addressbook.card.$addCategory('');
|
||||
focus('category_' + i);
|
||||
};
|
||||
$scope.addEmail = function() {
|
||||
var i = $rootScope.addressbook.card.$addEmail($scope.new_email_type);
|
||||
var i = $rootScope.addressbook.card.$addEmail('');
|
||||
focus('email_' + i);
|
||||
};
|
||||
$scope.addPhone = function() {
|
||||
var i = $rootScope.addressbook.card.$addPhone($scope.new_phone_type);
|
||||
var i = $rootScope.addressbook.card.$addPhone('');
|
||||
focus('phone_' + i);
|
||||
};
|
||||
$scope.addUrl = function() {
|
||||
|
@ -267,19 +268,19 @@
|
|||
};
|
||||
$scope.cancel = function() {
|
||||
$scope.reset();
|
||||
delete $rootScope.master_card;
|
||||
delete $rootScope.masterCard;
|
||||
if ($scope.addressbook.card.id) {
|
||||
// Cancelling the edition of an existing card
|
||||
$state.go('addressbook.card', { card_id: $scope.addressbook.card.id });
|
||||
$state.go('addressbook.card', { cardId: $scope.addressbook.card.id });
|
||||
}
|
||||
else {
|
||||
// Cancelling the creation of a card
|
||||
delete $rootScope.addressbook.card;
|
||||
$state.go('addressbook', { addressbook_id: $scope.addressbook.id });
|
||||
$state.go('addressbook', { addressbookId: $scope.addressbook.id });
|
||||
}
|
||||
};
|
||||
$scope.reset = function() {
|
||||
$rootScope.addressbook.card = angular.copy($rootScope.master_card);
|
||||
$rootScope.addressbook.card = angular.copy($rootScope.masterCard);
|
||||
};
|
||||
$scope.confirmDelete = function(card) {
|
||||
Dialog.confirm(l('Warning'),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* JavaScript for SOGoContacts (mobile) */
|
||||
|
||||
(function() {
|
||||
|
@ -9,7 +9,7 @@
|
|||
angular.module('SOGo.ContactsUI', ['ionic', 'SOGo.Common', 'SOGo.UIMobile'])
|
||||
|
||||
.constant('sgSettings', {
|
||||
'baseURL': ApplicationBaseURL
|
||||
baseURL: ApplicationBaseURL
|
||||
})
|
||||
|
||||
.run(function($ionicPlatform) {
|
||||
|
@ -29,31 +29,31 @@
|
|||
.config(function($stateProvider, $urlRouterProvider) {
|
||||
$stateProvider
|
||||
.state('app', {
|
||||
url: "/app",
|
||||
url: '/app',
|
||||
abstract: true,
|
||||
templateUrl: "menu.html",
|
||||
templateUrl: 'menu.html',
|
||||
controller: 'AppCtrl'
|
||||
})
|
||||
|
||||
.state('app.addressbooks', {
|
||||
url: "/addressbooks",
|
||||
url: '/addressbooks',
|
||||
views: {
|
||||
'menuContent': {
|
||||
templateUrl: "addressbooks.html",
|
||||
menuContent: {
|
||||
templateUrl: 'addressbooks.html',
|
||||
controller: 'AddressBooksCtrl'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
.state('app.addressbook', {
|
||||
url: "/addressbook/:addressbook_id",
|
||||
url: '/addressbook/:addressbookId',
|
||||
views: {
|
||||
'menuContent': {
|
||||
templateUrl: "addressbook.html",
|
||||
menuContent: {
|
||||
templateUrl: 'addressbook.html',
|
||||
controller: 'AddressBookCtrl',
|
||||
resolve: {
|
||||
stateAddressbook: function($stateParams, sgAddressBook) {
|
||||
return sgAddressBook.$find($stateParams.addressbook_id);
|
||||
return sgAddressBook.$find($stateParams.addressbookId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,38 +61,42 @@
|
|||
})
|
||||
|
||||
.state('app.newCard', {
|
||||
url: "/addressbook/:addressbook_id/:contact_type/new",
|
||||
url: '/addressbook/:addressbookId/:contactType/new',
|
||||
views: {
|
||||
'menuContent': {
|
||||
templateUrl: "card.html",
|
||||
menuContent: {
|
||||
templateUrl: 'card.html',
|
||||
controller: 'CardCtrl',
|
||||
resolve: {
|
||||
stateCard: function($rootScope, $stateParams, sgAddressBook, sgCard) {
|
||||
var tag = 'v' + $stateParams.contact_type;
|
||||
stateCard: ['$rootScope', '$stateParams', 'sgAddressBook', 'sgCard', function($rootScope, $stateParams, sgAddressBook, Card) {
|
||||
var tag = 'v' + $stateParams.contactType;
|
||||
if (!$rootScope.addressbook) {
|
||||
$rootScope.addressbook = sgAddressBook.$find($stateParams.addressbook_id);
|
||||
$rootScope.addressbook = sgAddressBook.$find($stateParams.addressbookId);
|
||||
}
|
||||
return new sgCard({ 'pid': $stateParams.addressbook_id,
|
||||
'tag': tag,
|
||||
'isNew': true });
|
||||
return new Card(
|
||||
{
|
||||
pid: $stateParams.addressbookId,
|
||||
tag: tag,
|
||||
isNew: true
|
||||
}
|
||||
);
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
.state('app.card', {
|
||||
url: "/addressbook/:addressbook_id/:card_id",
|
||||
url: '/addressbook/:addressbookId/:cardId',
|
||||
views: {
|
||||
'menuContent': {
|
||||
templateUrl: "card.html",
|
||||
menuContent: {
|
||||
templateUrl: 'card.html',
|
||||
controller: 'CardCtrl',
|
||||
resolve: {
|
||||
stateCard: function($rootScope, $stateParams, sgAddressBook) {
|
||||
if (!$rootScope.addressbook) {
|
||||
$rootScope.addressbook = sgAddressBook.$find($stateParams.addressbook_id);
|
||||
$rootScope.addressbook = sgAddressBook.$find($stateParams.addressbookId);
|
||||
}
|
||||
return $rootScope.addressbook.$getCard($stateParams.card_id);
|
||||
return $rootScope.addressbook.$getCard($stateParams.cardId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,9 +127,13 @@
|
|||
l('Name of new addressbook'))
|
||||
.then(function(res) {
|
||||
if (res && res.length > 0) {
|
||||
var addressbook = new AddressBook({ 'name': res,
|
||||
'isEditable': true,
|
||||
'isRemote': false });
|
||||
var addressbook = new AddressBook(
|
||||
{
|
||||
name: res,
|
||||
isEditable: true,
|
||||
isRemote: false
|
||||
}
|
||||
);
|
||||
AddressBook.$add(addressbook);
|
||||
}
|
||||
});
|
||||
|
@ -160,7 +168,7 @@
|
|||
l(data.error));
|
||||
});
|
||||
return true;
|
||||
},
|
||||
}
|
||||
// cancel: function() {
|
||||
// },
|
||||
});
|
||||
|
@ -171,9 +179,9 @@
|
|||
.controller('AddressBookCtrl', ['$scope', '$rootScope', '$stateParams', '$state', 'sgAddressBook', 'sgCard', 'stateAddressbook', function($scope, $rootScope, $stateParams, $state, AddressBook, Card, stateAddressbook) {
|
||||
$rootScope.addressbook = stateAddressbook;
|
||||
|
||||
$scope.search = { 'status': null, 'filter': null, 'last_filter': null };
|
||||
$scope.search = { status: null, filter: null, lastFilter: null };
|
||||
$scope.doSearch = function(keyEvent) {
|
||||
if ($scope.search.last_filter != $scope.search.filter) {
|
||||
if ($scope.search.lastFilter != $scope.search.filter) {
|
||||
if ($scope.search.filter.length > 2) {
|
||||
$rootScope.addressbook.$filter($scope.search.filter).then(function(data) {
|
||||
if (data.length == 0)
|
||||
|
@ -191,7 +199,7 @@
|
|||
$rootScope.addressbook.cards = [];
|
||||
}
|
||||
}
|
||||
$scope.search.last_filter = $scope.search.filter;
|
||||
$scope.search.lastFilter = $scope.search.filter;
|
||||
};
|
||||
}])
|
||||
|
||||
|
@ -199,14 +207,14 @@
|
|||
$rootScope.addressbook.card = stateCard;
|
||||
|
||||
$scope.UserFolderURL = UserFolderURL;
|
||||
$scope.allEmailTypes = Card.$email_types;
|
||||
$scope.allTelTypes = Card.$tel_types;
|
||||
$scope.allUrlTypes = Card.$url_types;
|
||||
$scope.allAddressTypes = Card.$address_types;
|
||||
$scope.allEmailTypes = Card.$EMAIL_TYPES;
|
||||
$scope.allTelTypes = Card.$TEL_TYPES;
|
||||
$scope.allUrlTypes = Card.$URL_TYPES;
|
||||
$scope.allAddressTypes = Card.$ADDRESS_TYPES;
|
||||
|
||||
$scope.edit = function() {
|
||||
// Copy card to be able to cancel changes later
|
||||
$scope.master_card = angular.copy($rootScope.addressbook.card);
|
||||
$scope.masterCard = angular.copy($rootScope.addressbook.card);
|
||||
// Build modal editor
|
||||
$ionicModal.fromTemplateUrl('cardEditor.html', {
|
||||
scope: $scope,
|
||||
|
@ -225,11 +233,11 @@
|
|||
if ($rootScope.addressbook.card.isNew) {
|
||||
$scope.$cardEditorModal.hide().then(function() {
|
||||
// Go back to addressbook
|
||||
$state.go('app.addressbook', { addressbook_id: $rootScope.addressbook.id });
|
||||
$state.go('app.addressbook', { addressbookId: $rootScope.addressbook.id });
|
||||
});
|
||||
}
|
||||
else {
|
||||
$rootScope.addressbook.card = angular.copy($scope.master_card);
|
||||
$rootScope.addressbook.card = angular.copy($scope.masterCard);
|
||||
$scope.$cardEditorModal.hide()
|
||||
}
|
||||
};
|
||||
|
@ -238,15 +246,15 @@
|
|||
focus('orgUnit_' + i);
|
||||
};
|
||||
$scope.addCategory = function() {
|
||||
var i = $rootScope.addressbook.card.$addCategory($scope.new_category);
|
||||
var i = $rootScope.addressbook.card.$addCategory('');
|
||||
focus('category_' + i);
|
||||
};
|
||||
$scope.addEmail = function() {
|
||||
var i = $rootScope.addressbook.card.$addEmail($scope.new_email_type);
|
||||
var i = $rootScope.addressbook.card.$addEmail('');
|
||||
focus('email_' + i);
|
||||
};
|
||||
$scope.addPhone = function() {
|
||||
var i = $rootScope.addressbook.card.$addPhone($scope.new_phone_type);
|
||||
var i = $rootScope.addressbook.card.$addPhone('');
|
||||
focus('phone_' + i);
|
||||
};
|
||||
$scope.addUrl = function() {
|
||||
|
@ -265,12 +273,13 @@
|
|||
if (form.$valid) {
|
||||
$rootScope.addressbook.card.$save()
|
||||
.then(function(data) {
|
||||
var i, card;
|
||||
delete $rootScope.addressbook.card.isNew;
|
||||
var i = _.indexOf(_.pluck($rootScope.addressbook.cards, 'id'), $rootScope.addressbook.card.id);
|
||||
i = _.indexOf(_.pluck($rootScope.addressbook.cards, 'id'), $rootScope.addressbook.card.id);
|
||||
if (i < 0) {
|
||||
// New card
|
||||
// Reload contacts list and show addressbook in which the card has been created
|
||||
var card = angular.copy($rootScope.addressbook.card);
|
||||
card = angular.copy($rootScope.addressbook.card);
|
||||
$rootScope.addressbook = AddressBook.$find(data.pid);
|
||||
$rootScope.addressbook.card = card;
|
||||
}
|
||||
|
@ -300,7 +309,7 @@
|
|||
// Delete modal editor
|
||||
$scope.$cardEditorModal.remove();
|
||||
// Go back to addressbook
|
||||
$state.go('app.addressbook', { addressbook_id: $rootScope.addressbook.id });
|
||||
$state.go('app.addressbook', { addressbookId: $rootScope.addressbook.id });
|
||||
}, function(data, status) {
|
||||
Dialog.alert(l('Warning'), l('An error occured while deleting the card "%{0}".',
|
||||
card.$fullname()));
|
||||
|
|
Loading…
Reference in a new issue