mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-31 20:52:17 +01:00
General cleanup
This commit is contained in:
parent
be69f83adb
commit
c649b4cbf1
10
js/app.js
10
js/app.js
@ -424,7 +424,6 @@ OC.Contacts = OC.Contacts || {
|
|||||||
console.log('status.nomorecontacts', result);
|
console.log('status.nomorecontacts', result);
|
||||||
self.$contactList.hide();
|
self.$contactList.hide();
|
||||||
self.$firstRun.show();
|
self.$firstRun.show();
|
||||||
// TODO: Show a first-run page.
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind('status.visiblecontacts', function(e, result) {
|
$(document).bind('status.visiblecontacts', function(e, result) {
|
||||||
@ -716,7 +715,7 @@ OC.Contacts = OC.Contacts || {
|
|||||||
groupId = response.id;
|
groupId = response.id;
|
||||||
groupName = response.name;
|
groupName = response.name;
|
||||||
self.groups.addTo(ids, groupId, function(result) {
|
self.groups.addTo(ids, groupId, function(result) {
|
||||||
if(result.status === 'success') {
|
if(!result.error) {
|
||||||
$.each(ids, function(idx, id) {
|
$.each(ids, function(idx, id) {
|
||||||
// Delay each contact to not trigger too many ajax calls
|
// Delay each contact to not trigger too many ajax calls
|
||||||
// at a time.
|
// at a time.
|
||||||
@ -738,8 +737,7 @@ OC.Contacts = OC.Contacts || {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// TODO: Use message returned from groups object.
|
OC.notify({message:result.message});
|
||||||
OC.notify({message:t('contacts', t('contacts', 'Error adding to group.'))});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -754,7 +752,7 @@ OC.Contacts = OC.Contacts || {
|
|||||||
if(action === 'add') {
|
if(action === 'add') {
|
||||||
self.groups.addTo(ids, $opt.val(), function(result) {
|
self.groups.addTo(ids, $opt.val(), function(result) {
|
||||||
console.log('after add', result);
|
console.log('after add', result);
|
||||||
if(result.status === 'success') {
|
if(!result.error) {
|
||||||
$.each(result.ids, function(idx, id) {
|
$.each(result.ids, function(idx, id) {
|
||||||
// Delay each contact to not trigger too many ajax calls
|
// Delay each contact to not trigger too many ajax calls
|
||||||
// at a time.
|
// at a time.
|
||||||
@ -787,7 +785,7 @@ OC.Contacts = OC.Contacts || {
|
|||||||
} else if(action === 'remove') {
|
} else if(action === 'remove') {
|
||||||
self.groups.removeFrom(ids, $opt.val(), function(result) {
|
self.groups.removeFrom(ids, $opt.val(), function(result) {
|
||||||
console.log('after remove', result);
|
console.log('after remove', result);
|
||||||
if(result.status === 'success') {
|
if(!result.error) {
|
||||||
var groupname = $opt.text(), groupid = $opt.val();
|
var groupname = $opt.text(), groupid = $opt.val();
|
||||||
$.each(result.ids, function(idx, id) {
|
$.each(result.ids, function(idx, id) {
|
||||||
var contact = self.contacts.findById(id);
|
var contact = self.contacts.findById(id);
|
||||||
|
@ -251,7 +251,6 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
$.when(this.storage.deleteProperty(this.metadata.backend, this.metadata.parent, this.id, params))
|
$.when(this.storage.deleteProperty(this.metadata.backend, this.metadata.parent, this.id, params))
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
if(!response.error) {
|
if(!response.error) {
|
||||||
// TODO: Test if removing from internal data structure works
|
|
||||||
if(self.multi_properties.indexOf(element) !== -1) {
|
if(self.multi_properties.indexOf(element) !== -1) {
|
||||||
// First find out if an existing element by looking for checksum
|
// First find out if an existing element by looking for checksum
|
||||||
var checksum = self.checksumFor(obj);
|
var checksum = self.checksumFor(obj);
|
||||||
@ -636,7 +635,6 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
* @returns The callback gets an object as argument with a variable 'status' of either 'success'
|
* @returns The callback gets an object as argument with a variable 'status' of either 'success'
|
||||||
* or 'error'. On success the 'data' property of that object contains the contact id as 'id', the
|
* or 'error'. On success the 'data' property of that object contains the contact id as 'id', the
|
||||||
* addressbook id as 'aid' and the contact data structure as 'details'.
|
* addressbook id as 'aid' and the contact data structure as 'details'.
|
||||||
* TODO: Use Storage for adding and make sure to get all metadata.
|
|
||||||
*/
|
*/
|
||||||
Contact.prototype.add = function(params, cb) {
|
Contact.prototype.add = function(params, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -938,9 +936,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
|
|
||||||
var buildAddressBookSelect = function(availableAddressBooks) {
|
var buildAddressBookSelect = function(availableAddressBooks) {
|
||||||
console.log('address books', availableAddressBooks.length, availableAddressBooks);
|
console.log('address books', availableAddressBooks.length, availableAddressBooks);
|
||||||
/* TODO:
|
/* TODO: Add method to change address book.
|
||||||
* - Check address books permissions.
|
|
||||||
* - Add method to change address book.
|
|
||||||
*/
|
*/
|
||||||
$.each(availableAddressBooks, function(idx, addressBook) {
|
$.each(availableAddressBooks, function(idx, addressBook) {
|
||||||
//console.log('addressBook', idx, addressBook);
|
//console.log('addressBook', idx, addressBook);
|
||||||
|
20
js/groups.js
20
js/groups.js
@ -213,7 +213,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
doPost = true;
|
doPost = true;
|
||||||
} else {
|
} else {
|
||||||
if(typeof cb == 'function') {
|
if(typeof cb == 'function') {
|
||||||
cb({status:'error', message:t('contacts', 'Contact is already in this group.')});
|
cb({error:true, message:t('contacts', 'Contact is already in this group.')});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(utils.isArray(contactid)) {
|
} else if(utils.isArray(contactid)) {
|
||||||
@ -226,7 +226,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
doPost = true;
|
doPost = true;
|
||||||
} else {
|
} else {
|
||||||
if(typeof cb == 'function') {
|
if(typeof cb == 'function') {
|
||||||
cb({status:'error', message:t('contacts', 'Contacts are already in this group.')});
|
cb({error:true, message:t('contacts', 'Contacts are already in this group.')});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -243,7 +243,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
$numelem.switchClass('active', '', 1000);
|
$numelem.switchClass('active', '', 1000);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
if(typeof cb === 'function') {
|
if(typeof cb === 'function') {
|
||||||
cb({status:'success', ids:ids});
|
cb({ids:ids});
|
||||||
} else {
|
} else {
|
||||||
$(document).trigger('status.group.contactadded', {
|
$(document).trigger('status.group.contactadded', {
|
||||||
contactid: contactid,
|
contactid: contactid,
|
||||||
@ -253,7 +253,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(typeof cb == 'function') {
|
if(typeof cb == 'function') {
|
||||||
cb({status:'error', message:response.message});
|
cb({error:true, message:response.message});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -280,13 +280,13 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
$numelem.switchClass('active', '', 1000);
|
$numelem.switchClass('active', '', 1000);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
if(typeof cb === 'function') {
|
if(typeof cb === 'function') {
|
||||||
cb({status:'success', ids:[id]});
|
cb({ids:[id]});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the contact is in the category remove it from internal list.
|
// If the contact is in the category remove it from internal list.
|
||||||
if(!contacts) {
|
if(!contacts) {
|
||||||
if(typeof cb === 'function') {
|
if(typeof cb === 'function') {
|
||||||
cb({status:'error', message:t('contacts', 'Couldn\'t get contact list.')});
|
cb({error:true, message:t('contacts', 'Couldn\'t get contact list.')});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
doPost = true;
|
doPost = true;
|
||||||
} else {
|
} else {
|
||||||
if(typeof cb == 'function') {
|
if(typeof cb == 'function') {
|
||||||
cb({status:'error', message:t('contacts', 'Contact is not in this group.')});
|
cb({error:true, message:t('contacts', 'Contact is not in this group.')});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(utils.isArray(contactid)) {
|
} else if(utils.isArray(contactid)) {
|
||||||
@ -311,7 +311,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
} else {
|
} else {
|
||||||
console.log(contactid, 'not in', contacts);
|
console.log(contactid, 'not in', contacts);
|
||||||
if(typeof cb == 'function') {
|
if(typeof cb == 'function') {
|
||||||
cb({status:'error', message:t('contacts', 'Contacts are not in this group.')});
|
cb({error:true, message:t('contacts', 'Contacts are not in this group.')});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -329,11 +329,11 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
$numelem.switchClass('active', '', 1000);
|
$numelem.switchClass('active', '', 1000);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
if(typeof cb === 'function') {
|
if(typeof cb === 'function') {
|
||||||
cb({status:'success', ids:ids});
|
cb({ids:ids});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(typeof cb == 'function') {
|
if(typeof cb == 'function') {
|
||||||
cb({status:'error', message:response.message});
|
cb({error:true, message:response.message});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -27,7 +27,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
* All methods returns a jQuery.Deferred object which resolves
|
* All methods returns a jQuery.Deferred object which resolves
|
||||||
* to either the requested response or an error object:
|
* to either the requested response or an error object:
|
||||||
* {
|
* {
|
||||||
* status: 'error',
|
* error: true,
|
||||||
* message: The error message
|
* message: The error message
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
@ -422,17 +422,8 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
processData: processData,
|
processData: processData,
|
||||||
data: params
|
data: params
|
||||||
};
|
};
|
||||||
|
|
||||||
var defer = $.Deferred();
|
var defer = $.Deferred();
|
||||||
/*$.when($.ajax(ajaxParams)).then(function(response) {
|
|
||||||
defer.resolve(new JSONResponse(response));
|
|
||||||
}).fail(function(jqxhr, textStatus, error) {
|
|
||||||
defer.reject(
|
|
||||||
new JSONResponse({
|
|
||||||
status:'error',
|
|
||||||
data:{message:t('contacts', 'Request failed: {error}', {error:textStatus + ', ' + error})}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});*/
|
|
||||||
|
|
||||||
var jqxhr = $.ajax(ajaxParams)
|
var jqxhr = $.ajax(ajaxParams)
|
||||||
.done(function(response) {
|
.done(function(response) {
|
||||||
@ -441,7 +432,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
.fail(function(jqxhr, textStatus, error) {
|
.fail(function(jqxhr, textStatus, error) {
|
||||||
defer.reject(
|
defer.reject(
|
||||||
new JSONResponse({
|
new JSONResponse({
|
||||||
status:'error',
|
error:true,
|
||||||
data:{message:t('contacts', 'Request failed: {error}', {error:textStatus + ', ' + error})}
|
data:{message:t('contacts', 'Request failed: {error}', {error:textStatus + ', ' + error})}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user