mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-16 10:48:50 +00:00
(js) Fix possible errors (help from jsjint)
This commit is contained in:
@@ -83,9 +83,9 @@
|
||||
|
||||
list = addressbook.isSubscription? this.$subscriptions : this.$addressbooks;
|
||||
sibling = _.find(list, function(o) {
|
||||
return (addressbook.id == 'personal'
|
||||
|| (o.id != 'personal'
|
||||
&& o.name.localeCompare(addressbook.name) === 1));
|
||||
return (addressbook.id == 'personal' ||
|
||||
(o.id != 'personal' &&
|
||||
o.name.localeCompare(addressbook.name) === 1));
|
||||
});
|
||||
i = sibling ? _.indexOf(_.pluck(list, 'id'), sibling.id) : 1;
|
||||
list.splice(i, 0, addressbook);
|
||||
@@ -140,9 +140,9 @@
|
||||
var _this = this;
|
||||
return AddressBook.$$resource.userResource(uid).fetch(path, 'subscribe').then(function(addressbookData) {
|
||||
var addressbook = new AddressBook(addressbookData);
|
||||
if (!_.find(_this.$subscriptions, function(o) {
|
||||
if (_.isUndefined(_.find(_this.$subscriptions, function(o) {
|
||||
return o.id == addressbookData.id;
|
||||
})) {
|
||||
}))) {
|
||||
// Not already subscribed
|
||||
AddressBook.$add(addressbook);
|
||||
}
|
||||
@@ -196,7 +196,7 @@
|
||||
|
||||
count = 0;
|
||||
if (this.cards) {
|
||||
count = (_.filter(this.cards, function(card) { return card.selected })).length;
|
||||
count = (_.filter(this.cards, function(card) { return card.selected; })).length;
|
||||
}
|
||||
return count;
|
||||
};
|
||||
@@ -214,23 +214,22 @@
|
||||
.then(function(response) {
|
||||
var index, card,
|
||||
results = response.cards,
|
||||
cards = _this.cards;
|
||||
cards = _this.cards,
|
||||
compareIds = function(data) {
|
||||
return this.id == data.id;
|
||||
};
|
||||
|
||||
// Remove cards that no longer exist
|
||||
for (index = cards.length - 1; index >= 0; index--) {
|
||||
card = cards[index];
|
||||
if (!_.find(results, function(data) {
|
||||
return card.id == data.id;
|
||||
})) {
|
||||
if (_.isUndefined(_.find(results, compareIds, card))) {
|
||||
cards.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Add new cards
|
||||
_.each(results, function(data, index) {
|
||||
if (!_.find(cards, function(card) {
|
||||
return card.id == data.id;
|
||||
})) {
|
||||
if (_.isUndefined(_.find(cards, compareIds, data))) {
|
||||
var card = new AddressBook.$Card(data);
|
||||
cards.splice(index, 0, card);
|
||||
}
|
||||
@@ -272,7 +271,10 @@
|
||||
return this.$id().then(function(addressbookId) {
|
||||
return AddressBook.$$resource.fetch(addressbookId, 'view', _this.$query);
|
||||
}).then(function(response) {
|
||||
var results, cards, card, index;
|
||||
var results, cards, card, index,
|
||||
compareIds = function(data) {
|
||||
return this.id == data.id;
|
||||
};
|
||||
if (options && options.dry) {
|
||||
// Don't keep a copy of the resulting cards.
|
||||
// This is usefull when doing autocompletion.
|
||||
@@ -283,10 +285,8 @@
|
||||
}
|
||||
if (excludedCards) {
|
||||
// Remove excluded cards from results
|
||||
results = _.filter(response.cards, function(data) {
|
||||
return !_.find(excludedCards, function(card) {
|
||||
return card.id == data.id;
|
||||
});
|
||||
results = _.filter(response.cards, function(card) {
|
||||
return _.isUndefined(_.find(excludedCards, compareIds, card));
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -295,17 +295,13 @@
|
||||
// Remove cards that no longer match the search query
|
||||
for (index = cards.length - 1; index >= 0; index--) {
|
||||
card = cards[index];
|
||||
if (!_.find(results, function(data) {
|
||||
return card.id == data.id;
|
||||
})) {
|
||||
if (_.isUndefined(_.find(results, compareIds, card))) {
|
||||
cards.splice(index, 1);
|
||||
}
|
||||
}
|
||||
// Add new cards matching the search query
|
||||
_.each(results, function(data, index) {
|
||||
if (!_.find(cards, function(card) {
|
||||
return card.id == data.id;
|
||||
})) {
|
||||
if (_.isUndefined(_.find(cards, compareIds, data))) {
|
||||
var card = new AddressBook.$Card(data, search);
|
||||
cards.splice(index, 0, card);
|
||||
}
|
||||
@@ -314,9 +310,7 @@
|
||||
_.each(results, function(data, index) {
|
||||
var oldIndex, removedCards;
|
||||
if (cards[index].id != data.id) {
|
||||
oldIndex = _.findIndex(cards, function(card) {
|
||||
return card.id == data.id;
|
||||
});
|
||||
oldIndex = _.findIndex(cards, compareIds, data);
|
||||
removedCards = cards.splice(oldIndex, 1);
|
||||
cards.splice(index, 0, removedCards[0]);
|
||||
}
|
||||
@@ -379,7 +373,7 @@
|
||||
*/
|
||||
AddressBook.prototype.$deleteCards = function(cards) {
|
||||
|
||||
var uids = _.map(cards, function(card) { return card.id });
|
||||
var uids = _.map(cards, function(card) { return card.id; });
|
||||
var _this = this;
|
||||
|
||||
return AddressBook.$$resource.post(this.id, 'batchDelete', {uids: uids}).then(function() {
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
scope.create = function(type) {
|
||||
$mdDialog.hide();
|
||||
$state.go('app.addressbook.new', { addressbookId: addressbookId, contactType: type });
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +78,9 @@
|
||||
l('Are you sure you want to delete the selected contacts?'))
|
||||
.then(function() {
|
||||
// User confirmed the deletion
|
||||
var selectedCards = _.filter(vm.selectedFolder.cards, function(card) { return card.selected });
|
||||
var selectedCards = _.filter(vm.selectedFolder.cards, function(card) { return card.selected; });
|
||||
vm.selectedFolder.$deleteCards(selectedCards);
|
||||
delete vm.selectedFolder.selectedCard;
|
||||
}, function(data, status) {
|
||||
// Delete failed
|
||||
});
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
function LinksDialogController(scope, $mdDialog) {
|
||||
scope.close = function() {
|
||||
$mdDialog.hide();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
vm.selectedUser = null;
|
||||
}
|
||||
}, function(data, status) {
|
||||
Dialog.alert(l('Warning'), l('An error occured please try again.'))
|
||||
Dialog.alert(l('Warning'), l('An error occured please try again.'));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
* @desc Factory registration of Card in Angular module.
|
||||
*/
|
||||
angular.module('SOGo.ContactsUI')
|
||||
.factory('Card', Card.$factory)
|
||||
.factory('Card', Card.$factory);
|
||||
|
||||
/**
|
||||
* @memberof Card
|
||||
@@ -171,7 +171,7 @@
|
||||
|
||||
Card.prototype.$fullname = function() {
|
||||
var fn = this.fn || '', names;
|
||||
if (fn.length == 0) {
|
||||
if (fn.length === 0) {
|
||||
names = [];
|
||||
if (this.givenname && this.givenname.length > 0)
|
||||
names.push(this.givenname);
|
||||
@@ -185,7 +185,7 @@
|
||||
fn = this.org;
|
||||
}
|
||||
else if (this.emails && this.emails.length > 0) {
|
||||
fn = _.find(this.emails, function(i) { return i.value != ''; }).value;
|
||||
fn = _.find(this.emails, function(i) { return i.value !== ''; }).value;
|
||||
}
|
||||
else if (this.c_cn && this.c_cn.length > 0) {
|
||||
fn = this.c_cn;
|
||||
@@ -201,7 +201,7 @@
|
||||
if (this.role) description.push(this.role);
|
||||
if (this.orgUnits && this.orgUnits.length > 0)
|
||||
_.forEach(this.orgUnits, function(unit) {
|
||||
if (unit.value != '')
|
||||
if (unit.value !== '')
|
||||
description.push(unit.value);
|
||||
});
|
||||
if (this.org) description.push(this.org);
|
||||
@@ -307,7 +307,7 @@
|
||||
if (angular.isUndefined(this.emails)) {
|
||||
this.emails = [{type: type, value: ''}];
|
||||
}
|
||||
else if (!_.find(this.emails, function(i) { return i.value == ''; })) {
|
||||
else if (_.isUndefined(_.find(this.emails, function(i) { return i.value === ''; }))) {
|
||||
this.emails.push({type: type, value: ''});
|
||||
}
|
||||
return this.emails.length - 1;
|
||||
@@ -317,7 +317,7 @@
|
||||
if (angular.isUndefined(this.phones)) {
|
||||
this.phones = [{type: type, value: ''}];
|
||||
}
|
||||
else if (!_.find(this.phones, function(i) { return i.value == ''; })) {
|
||||
else if (_.isUndefined(_.find(this.phones, function(i) { return i.value === ''; }))) {
|
||||
this.phones.push({type: type, value: ''});
|
||||
}
|
||||
return this.phones.length - 1;
|
||||
@@ -327,7 +327,7 @@
|
||||
if (angular.isUndefined(this.urls)) {
|
||||
this.urls = [{type: type, value: url}];
|
||||
}
|
||||
else if (!_.find(this.urls, function(i) { return i.value == url; })) {
|
||||
else if (_.isUndefined(_.find(this.urls, function(i) { return i.value == url; }))) {
|
||||
this.urls.push({type: type, value: url});
|
||||
}
|
||||
return this.urls.length - 1;
|
||||
@@ -338,11 +338,11 @@
|
||||
this.addresses = [{type: type, postoffice: postoffice, street: street, street2: street2, locality: locality, region: region, country: country, postalcode: postalcode}];
|
||||
}
|
||||
else if (!_.find(this.addresses, function(i) {
|
||||
return i.street == street
|
||||
&& i.street2 == street2
|
||||
&& i.locality == locality
|
||||
&& i.country == country
|
||||
&& i.postalcode == postalcode;
|
||||
return i.street == street &&
|
||||
i.street2 == street2 &&
|
||||
i.locality == locality &&
|
||||
i.country == country &&
|
||||
i.postalcode == postalcode;
|
||||
})) {
|
||||
this.addresses.push({type: type, postoffice: postoffice, street: street, street2: street2, locality: locality, region: region, country: country, postalcode: postalcode});
|
||||
}
|
||||
@@ -355,7 +355,7 @@
|
||||
if (angular.isUndefined(this.refs)) {
|
||||
this.refs = [card];
|
||||
}
|
||||
else if (email.length == 0) {
|
||||
else if (email.length === 0) {
|
||||
this.refs.push(card);
|
||||
}
|
||||
else {
|
||||
@@ -469,4 +469,13 @@
|
||||
});
|
||||
return card;
|
||||
};
|
||||
|
||||
Card.prototype.toString = function() {
|
||||
var desc = this.id + ' ' + this.$$fullname;
|
||||
|
||||
if (this.$$email)
|
||||
desc += ' <' + this.$$email + '>';
|
||||
|
||||
return '[' + desc + ']';
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -35,31 +35,31 @@
|
||||
function addOrgUnit() {
|
||||
var i = vm.card.$addOrgUnit('');
|
||||
focus('orgUnit_' + i);
|
||||
};
|
||||
}
|
||||
function addEmail() {
|
||||
var i = vm.card.$addEmail('');
|
||||
focus('email_' + i);
|
||||
};
|
||||
}
|
||||
function addPhone() {
|
||||
var i = vm.card.$addPhone('');
|
||||
focus('phone_' + i);
|
||||
};
|
||||
}
|
||||
function addUrl() {
|
||||
var i = vm.card.$addUrl('', '');
|
||||
focus('url_' + i);
|
||||
};
|
||||
}
|
||||
function addAddress() {
|
||||
var i = vm.card.$addAddress('', '', '', '', '', '', '', '');
|
||||
focus('address_' + i);
|
||||
};
|
||||
}
|
||||
function addMember() {
|
||||
var i = vm.card.$addMember('');
|
||||
focus('ref_' + i);
|
||||
};
|
||||
}
|
||||
function userFilter($query, excludedCards) {
|
||||
AddressBook.selectedFolder.$filter($query, {dry: true, excludeLists: true}, excludedCards);
|
||||
return AddressBook.selectedFolder.$cards;
|
||||
};
|
||||
}
|
||||
function save(form) {
|
||||
if (form.$valid) {
|
||||
vm.card.$save()
|
||||
@@ -79,10 +79,10 @@
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
function reset() {
|
||||
vm.card.$reset();
|
||||
};
|
||||
}
|
||||
function cancel() {
|
||||
vm.card.$reset();
|
||||
if (vm.card.isNew) {
|
||||
@@ -95,7 +95,7 @@
|
||||
// Cancelling the edition of an existing card
|
||||
$state.go('app.addressbook.card.view', { cardId: vm.card.id });
|
||||
}
|
||||
};
|
||||
}
|
||||
function confirmDelete(card) {
|
||||
Dialog.confirm(l('Warning'),
|
||||
l('Are you sure you want to delete the card of %{0}?', card.$fullname()))
|
||||
@@ -115,7 +115,7 @@
|
||||
card.$fullname()));
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
angular
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
};
|
||||
}],
|
||||
template: '<address ng-bind-html="addressLines(data)"></address>'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
angular
|
||||
|
||||
Reference in New Issue
Block a user