ui support of untag mindmap

This commit is contained in:
Claudio Barril 2014-02-02 04:10:00 -03:00
parent 8db7f5015f
commit d67a16f550
3 changed files with 26 additions and 7 deletions

View File

@ -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({

View File

@ -25,8 +25,8 @@ function labelTagsAsHtml(labels) {
'</div>' +
"</td>" +
//"<td style='padding: 0; background-color: #d8d4d4'></td>" +
"<td class='closeTag' style='background-color:"+ label.color +"'>" +
"<span style='top: -1px;position: relative;font-size: 11px' title='remove'>x</span>"+
"<td class='closeTag' style='background-color:" + label.color +"' value='" + label.id + "' >" +
"<span style='top: -1px;position: relative;font-size: 11px' title='delete label'>x</span>"+
"</td>" +
"</tr></tbody>" +
"</table>"
@ -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
}])

View File

@ -62,7 +62,7 @@
bUseRendered:false,
mDataProp:"title",
fnRender:function (obj) {
return '<a class="mindmapName" href="c/maps/' + obj.aData.id + '/edit">' + $('<span></span>').text(obj.aData.title).html() + '</a>' + labelTagsAsHtml(obj.aData.labels);
return '<a class="mindmapName" value="'+ obj.aData.id +'" href="c/maps/' + obj.aData.id + '/edit">' + $('<span></span>').text(obj.aData.title).html() + '</a>' + labelTagsAsHtml(obj.aData.labels);
}
},
{