From 4200d85cc0a5fc1c34d2f0611c9ca6e7df995d80 Mon Sep 17 00:00:00 2001 From: Ezequiel Bergamaschi Date: Sat, 1 Feb 2014 01:42:54 -0300 Subject: [PATCH] adding delete action --- .../src/main/webapp/js/buttonActions.js | 28 +++++++++++++++++-- wise-webapp/src/main/webapp/js/mindmapList.js | 4 +-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/wise-webapp/src/main/webapp/js/buttonActions.js b/wise-webapp/src/main/webapp/js/buttonActions.js index 4a6061d7..c82a9a3b 100644 --- a/wise-webapp/src/main/webapp/js/buttonActions.js +++ b/wise-webapp/src/main/webapp/js/buttonActions.js @@ -182,7 +182,6 @@ $(function () { } }; - //live method is deprecated? $(document).on('click', '#foldersContainer li', function (event) { // Deselect previous option ... $('#foldersContainer li').removeClass('active'); @@ -208,12 +207,37 @@ $(function () { } ); + $(document).on('click', "#deleteLabelBtn", function() { + var me = $(this); + $("#delete-label-dialog-modal").dialogForm({ + url: "c/restful/labels/" + me.attr('labelid'), + type: 'DELETE', + postUpdate: function() { + var dataTable = $('#mindmapListTable').dataTable(); + //remove the selected tag... + $("#foldersContainer li.active").remove(); + //find the second li... (all) + $("#foldersContainer li:nth-child(2)").addClass("active"); + dataTable.fnReloadAjax("c/restful/maps/?q=all", callbackOnTableInit, true); + event.preventDefault(); + + } + }) + }); + $(document).ready(fetchLabels({ postUpdate: function(data) { var labels = data.labels; for (var i = 0; i < labels.length; i++) { - createLabelItem(labels[i]) + createLabelItem(labels[i], null) } } })) }); + +function reloadTable() { + // Reload the table data ... + var dataTable = $('#mindmapListTable').dataTable(); + dataTable.fnReloadAjax("c/restful/maps/?q=" + $(this).attr('data-filter'), callbackOnTableInit, true); + event.preventDefault(); +} diff --git a/wise-webapp/src/main/webapp/js/mindmapList.js b/wise-webapp/src/main/webapp/js/mindmapList.js index 1467cbc2..dae5bf1d 100644 --- a/wise-webapp/src/main/webapp/js/mindmapList.js +++ b/wise-webapp/src/main/webapp/js/mindmapList.js @@ -115,8 +115,8 @@ jQuery.fn.dialogForm = function (options) { type:options.type ? options.type : 'POST', contentType:"application/json; charset=utf-8", success:function (data, textStatus, jqXHR) { + var resourceId = jqXHR.getResponseHeader("ResourceId"); if (options.redirect) { - var resourceId = jqXHR.getResponseHeader("ResourceId"); var redirectUrl = options.redirect; redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId); @@ -125,7 +125,7 @@ jQuery.fn.dialogForm = function (options) { window.open(baseUrl + redirectUrl, '_self'); } else if (options.postUpdate) { - options.postUpdate(formData); + options.postUpdate(formData, resourceId); } dialogElem.modal('hide'); },