From d67a16f550f7c1fc98712c04a0806af361cfc58b Mon Sep 17 00:00:00 2001 From: Claudio Barril Date: Sun, 2 Feb 2014 04:10:00 -0300 Subject: [PATCH] ui support of untag mindmap --- .../src/main/webapp/js/buttonActions.js | 24 ++++++++++++++++--- .../src/main/webapp/js/labelActions.js | 7 +++--- .../src/main/webapp/jsp/mindmapList.jsp | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/wise-webapp/src/main/webapp/js/buttonActions.js b/wise-webapp/src/main/webapp/js/buttonActions.js index 186cea12..559ce66a 100644 --- a/wise-webapp/src/main/webapp/js/buttonActions.js +++ b/wise-webapp/src/main/webapp/js/buttonActions.js @@ -20,7 +20,7 @@ $(function () { url: url, postUpdate: function(data, id) { createLabelItem(data, id); - tagMindmaps(data.title, data.color); + tagMindmaps(data.id || id, data.title, data.color); } }); } @@ -66,11 +66,11 @@ $(function () { if (mapIds.length > 0) { jQuery.ajax("c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','), { type:'POST', - dataType: "json", + //dataType: "json", contentType:"application/json; charset=utf-8", data: JSON.stringify({id: labelId}), success: function() { - tagMindmaps(labelName, labelColor); + tagMindmaps(labelId, labelName, labelColor); } }); } @@ -243,6 +243,24 @@ $(function () { }) }); + $(document).on('click', ".closeTag", function() { + var me = $(this); + var data = { + mindmapId: me.parents("td").find("a").attr("value"), + labelId: me.attr("value") + }; + jQuery.ajax("c/restful/labels/maps", { + async:false, + //dataType:'json', comentado momentaneamente, problema con jquery 2.1.0 + data:JSON.stringify(data), + type:'DELETE', + contentType:"application/json; charset=utf-8", + success: function() { + me.closest("table").remove(); + } + }); + }); + $(document).ready(function() { // add labels to filter list... fetchLabels({ diff --git a/wise-webapp/src/main/webapp/js/labelActions.js b/wise-webapp/src/main/webapp/js/labelActions.js index 0f9de596..4d6b0b69 100644 --- a/wise-webapp/src/main/webapp/js/labelActions.js +++ b/wise-webapp/src/main/webapp/js/labelActions.js @@ -25,8 +25,8 @@ function labelTagsAsHtml(labels) { '' + "" + //"" + - "" + - "x"+ + "" + + "x"+ "" + "" + "" @@ -50,13 +50,14 @@ function fetchLabels(options) { }); } -function tagMindmaps(labelName, labelColor) { +function tagMindmaps(id, labelName, labelColor) { //tag selected mindmaps... var rows = $('#mindmapListTable').dataTableExt.getSelectedRows(); for (var i = 0; i < rows.length; i++) { if ($(rows[i]).find(".labelTag:contains('" + labelName + "')").length == 0) { $(rows[i]).find('.mindmapName').parent().append( labelTagsAsHtml([{ + id: id, title: labelName, color: labelColor }]) diff --git a/wise-webapp/src/main/webapp/jsp/mindmapList.jsp b/wise-webapp/src/main/webapp/jsp/mindmapList.jsp index 407b2ab2..5dd93e26 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapList.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapList.jsp @@ -62,7 +62,7 @@ bUseRendered:false, mDataProp:"title", fnRender:function (obj) { - return '' + $('').text(obj.aData.title).html() + '' + labelTagsAsHtml(obj.aData.labels); + return '' + $('').text(obj.aData.title).html() + '' + labelTagsAsHtml(obj.aData.labels); } }, {