diff --git a/js/app.js b/js/app.js index 7403948e..272e1b90 100644 --- a/js/app.js +++ b/js/app.js @@ -424,7 +424,6 @@ OC.Contacts = OC.Contacts || { console.log('status.nomorecontacts', result); self.$contactList.hide(); self.$firstRun.show(); - // TODO: Show a first-run page. }); $(document).bind('status.visiblecontacts', function(e, result) { @@ -716,7 +715,7 @@ OC.Contacts = OC.Contacts || { groupId = response.id; groupName = response.name; self.groups.addTo(ids, groupId, function(result) { - if(result.status === 'success') { + if(!result.error) { $.each(ids, function(idx, id) { // Delay each contact to not trigger too many ajax calls // at a time. @@ -738,8 +737,7 @@ OC.Contacts = OC.Contacts || { }, 1000); }); } else { - // TODO: Use message returned from groups object. - OC.notify({message:t('contacts', t('contacts', 'Error adding to group.'))}); + OC.notify({message:result.message}); } }); } else { @@ -754,7 +752,7 @@ OC.Contacts = OC.Contacts || { if(action === 'add') { self.groups.addTo(ids, $opt.val(), function(result) { console.log('after add', result); - if(result.status === 'success') { + if(!result.error) { $.each(result.ids, function(idx, id) { // Delay each contact to not trigger too many ajax calls // at a time. @@ -787,7 +785,7 @@ OC.Contacts = OC.Contacts || { } else if(action === 'remove') { self.groups.removeFrom(ids, $opt.val(), function(result) { console.log('after remove', result); - if(result.status === 'success') { + if(!result.error) { var groupname = $opt.text(), groupid = $opt.val(); $.each(result.ids, function(idx, id) { var contact = self.contacts.findById(id); diff --git a/js/contacts.js b/js/contacts.js index d746218b..9ec3ed03 100644 --- a/js/contacts.js +++ b/js/contacts.js @@ -251,7 +251,6 @@ OC.Contacts = OC.Contacts || {}; $.when(this.storage.deleteProperty(this.metadata.backend, this.metadata.parent, this.id, params)) .then(function(response) { if(!response.error) { - // TODO: Test if removing from internal data structure works if(self.multi_properties.indexOf(element) !== -1) { // First find out if an existing element by looking for checksum 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' * 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'. - * TODO: Use Storage for adding and make sure to get all metadata. */ Contact.prototype.add = function(params, cb) { var self = this; @@ -938,9 +936,7 @@ OC.Contacts = OC.Contacts || {}; var buildAddressBookSelect = function(availableAddressBooks) { console.log('address books', availableAddressBooks.length, availableAddressBooks); - /* TODO: - * - Check address books permissions. - * - Add method to change address book. + /* TODO: Add method to change address book. */ $.each(availableAddressBooks, function(idx, addressBook) { //console.log('addressBook', idx, addressBook); diff --git a/js/groups.js b/js/groups.js index 5a1f71a0..0e4a86c2 100644 --- a/js/groups.js +++ b/js/groups.js @@ -213,7 +213,7 @@ OC.Contacts = OC.Contacts || {}; doPost = true; } else { 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)) { @@ -226,7 +226,7 @@ OC.Contacts = OC.Contacts || {}; doPost = true; } else { 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 { @@ -243,7 +243,7 @@ OC.Contacts = OC.Contacts || {}; $numelem.switchClass('active', '', 1000); }, 2000); if(typeof cb === 'function') { - cb({status:'success', ids:ids}); + cb({ids:ids}); } else { $(document).trigger('status.group.contactadded', { contactid: contactid, @@ -253,7 +253,7 @@ OC.Contacts = OC.Contacts || {}; } } else { 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); }, 2000); 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(!contacts) { 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; } @@ -297,7 +297,7 @@ OC.Contacts = OC.Contacts || {}; doPost = true; } else { 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)) { @@ -311,7 +311,7 @@ OC.Contacts = OC.Contacts || {}; } else { console.log(contactid, 'not in', contacts); 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); }, 2000); if(typeof cb === 'function') { - cb({status:'success', ids:ids}); + cb({ids:ids}); } } else { if(typeof cb == 'function') { - cb({status:'error', message:response.message}); + cb({error:true, message:response.message}); } } }); diff --git a/js/storage.js b/js/storage.js index cc8569f9..564db9d3 100644 --- a/js/storage.js +++ b/js/storage.js @@ -27,7 +27,7 @@ OC.Contacts = OC.Contacts || {}; * All methods returns a jQuery.Deferred object which resolves * to either the requested response or an error object: * { - * status: 'error', + * error: true, * message: The error message * } * @@ -422,17 +422,8 @@ OC.Contacts = OC.Contacts || {}; processData: processData, data: params }; + 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) .done(function(response) { @@ -441,7 +432,7 @@ OC.Contacts = OC.Contacts || {}; .fail(function(jqxhr, textStatus, error) { defer.reject( new JSONResponse({ - status:'error', + error:true, data:{message:t('contacts', 'Request failed: {error}', {error:textStatus + ', ' + error})} }) );