diff --git a/ChangeLog b/ChangeLog index 25cfbd2f2..21fa1e96a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-10 Francis Lachapelle + + * UI/WebServerResources/ContactsUI.js + (onCategoriesMenuItemCallback): new callback that refreshes the + displayed card when a category is added or removed. + 2011-03-10 Wolfgang Sourdeau * UI/WebServerResources/ContactsUI.js (onCategoriesMenuItemClick): diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index 8a27fad8a..5a71bb9ff 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -1338,12 +1338,12 @@ function onCategoriesMenuItemClick() { var contactsList = $("contactsList"); var rowIds = contactsList.getSelectedRowsId(); if (rowIds.length > 0) { - log("coucou..."); for (var i = 0; i < rowIds.length; i++) { var url = (URLForFolderID(Contact.currentAddressBook) + "/" + rowIds[i] + "/" + method); url += "?category=" + encodeURIComponent(this.category); - triggerAjaxRequest(url); + triggerAjaxRequest(url, onCategoriesMenuItemCallback, + { 'addressBook' : Contact.currentAddressBook, 'id' : rowIds[i] }); if (set) { setCategoryOnNode($(rowIds[i]), this.category); } @@ -1354,6 +1354,21 @@ function onCategoriesMenuItemClick() { } } +function onCategoriesMenuItemCallback(http) { + if (http.readyState == 4) + if (isHttpStatus204(http.status)) { + var contact = http.callbackData; + if (cachedContacts[contact.addressBook + "/" + contact.id]) + delete cachedContacts[contact.addressBook + "/" + contact.id]; + if (contact.addressBook == Contact.currentAddressBook + && contact.id == Contact.currentContact) + loadContact(Contact.currentContact); + } + else { + log("onCategoriesMenuItemCallback failed: error " + http.status + " (" + http.responseText + ")"); + } +} + function setCategoryOnNode(contactNode, category) { var catList = contactNode.getAttribute("categories"); var catsArray = catList.split(",");