diff --git a/wise-webapp/src/main/webapp/js/buttonActions.js b/wise-webapp/src/main/webapp/js/buttonActions.js
deleted file mode 100644
index f6d45e39..00000000
--- a/wise-webapp/src/main/webapp/js/buttonActions.js
+++ /dev/null
@@ -1,243 +0,0 @@
-$(function () {
- // Creation buttons actions ...
- $("#newBtn").click(
- function () {
- $("#new-dialog-modal").dialogForm({
- redirect:"c/maps/{header.resourceId}/edit",
- url:"c/restful/maps"
- });
- }
- );
-
- $(document).on('click', '#createLabelBtn',
- function () {
- var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
- var url = mapIds.length == 0
- ? "c/restful/labels"
- : "c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(',');
-
- $("#new-folder-dialog-modal").dialogForm({
- url: url,
- postUpdate: function(data, id) {
- createLabelItem(data, id);
- tagMindmaps(data.id || id, data.title, data.color);
- }
- });
- }
- );
-
- $("#addLabelButton").click( function () {
- var labels;
- fetchLabels({
- postUpdate: function(data) {
- labels = data.labels;
- }
- });
-
- if (labels) {
- prepareLabelList(labels);
-
- $(document).one('click', '.chooseLabel',
- function () {
- var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
- if (mapIds.length > 0) {
- var labelId = $(this).attr('value');
- var labelName = $(this).text();
- var labelColor = $(this).attr('color');
- jQuery.ajax("c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','), {
- type:'POST',
- //dataType: "json",
- contentType:"application/json; charset=utf-8",
- data: JSON.stringify({id: labelId}),
- success: function() {
- tagMindmaps(labelId, labelName, labelColor);
- }
- });
- }
- }
- );
- }
- });
-
- $("#duplicateBtn").click(function () {
- // Map to be cloned ...
- var tableElem = $('#mindmapListTable');
- var rows = tableElem.dataTableExt.getSelectedRows();
- if (rows.length > 0) {
-
- // Obtain map name ...
- var rowData = tableElem.dataTable().fnGetData(rows[0]);
- $('#dupDialogTitle').text("Duplicate '" + rowData.title + "'");
-
- // Obtains map id ...
- var mapId = rowData.id;
-
- // Initialize dialog ...
- $("#duplicate-dialog-modal").dialogForm({
- redirect:"c/maps/{header.resourceId}/edit",
- url:"c/restful/maps/" + mapId
- });
- }
- });
-
- $("#renameBtn").click(function () {
- // Map to be cloned ...
- var tableElem = $('#mindmapListTable');
- var rows = tableElem.dataTableExt.getSelectedRows();
- if (rows.length > 0) {
-
- // Obtain map name ...
- var dataTable = tableElem.dataTable();
- var rowData = dataTable.fnGetData(rows[0]);
-
- // Fill dialog with default values ...
- var mapId = rowData.id;
- $("#rename-dialog-modal input[name='title']").attr('value', rowData.title);
- $("#rename-dialog-modal input[name='description']").attr('value', rowData.description);
-
- // Set title ...
- $('#renameDialogTitle').text("Rename '" + rowData.title + "'");
-
- // Initialize dialog ...
- $("#rename-dialog-modal").dialogForm({
- type:'PUT',
- clearForm:false,
- postUpdate:function (reqBodyData) {
- tableElem.dataTableExt.removeSelectedRows();
-
- rowData.title = reqBodyData.title;
- rowData.description = reqBodyData.description;
- dataTable.fnAddData(JSON.parse(JSON.stringify(rowData)));
- },
- url:"c/restful/maps/" + mapId
- });
- }
- });
-
- $("#deleteBtn").click(function () {
- var tableUI = $('#mindmapListTable');
-
- var mapIds = tableUI.dataTableExt.getSelectedMapsIds();
-
- if (mapIds.length > 0) {
- // Initialize dialog ...
- $("#delete-dialog-modal").dialogForm({
- type:'DELETE',
- postUpdate:function () {
- // Remove old entry ...
- tableUI.dataTableExt.removeSelectedRows();
- },
- url:"c/restful/maps/batch?ids=" + jQuery.makeArray(mapIds).join(',')
- });
- }
- });
-
- $("#printBtn").click(function () {
- var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
- if (mapIds.length > 0) {
- // Hack: IE ignore the base href tag ...
- var baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf("c/maps/"));
- window.open(baseUrl + 'c/maps/' + mapIds[0] + '/print');
- }
- });
-
- $("#infoBtn").click(function () {
- showEmbeddedDialog("c/maps/{mapId}/details", 'info-dialog-modal');
- });
-
- $("#historyBtn").click(function () {
- showEmbeddedDialog("c/maps/{mapId}/history", 'history-dialog-modal');
- });
-
- $("#publishBtn").click(function () {
- showEmbeddedDialog("c/maps/{mapId}/publish", "publish-dialog-modal");
- });
-
- $("#exportBtn").click(function () {
- showEmbeddedDialog("c/maps/{mapId}/export", 'export-dialog-modal');
- });
-
- $("#importBtn").click(function () {
- showEmbeddedDialog("c/maps/import", 'import-dialog-modal', true);
- });
-
- $("#shareBtn").click(function () {
- showEmbeddedDialog("c/maps/{mapId}/share", 'share-dialog-modal', true);
- });
-
- var showEmbeddedDialog = function (urlTemplate, dialogElemId, ignore) {
- var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
- if (mapIds.length > 0 || ignore) {
- var mapId = mapIds[0];
- $('#' + dialogElemId + ' .modal-body').load(urlTemplate.replace("{mapId}", mapId),
- function () {
- $('#' + dialogElemId + ' .btn-accept').unbind('click').click(function () {
- submitDialogForm();
- });
- $('#' + dialogElemId).modal();
- });
- }
- };
-
- $(document).on('click', '#foldersContainer li', function (event) {
- // Deselect previous option ...
- $('#foldersContainer li').removeClass('active');
- $('#foldersContainer i').removeClass('icon-white');
-
- // Select the new item ...
- var dataTable = $('#mindmapListTable').dataTable();
- $(this).addClass('active');
- $('#foldersContainer .active i').addClass('icon-white');
-
- $('input:checkbox').prop('checked', false);
- // Reload the table data ...
- dataTable.fnReloadAjax("c/restful/maps/?q=" + $(this).attr('data-filter'), callbackOnTableInit, true);
- event.preventDefault();
- });
-
- $(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);
- }
- })
- });
-
- $(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({
- postUpdate: function(data) {
- var labels = data.labels;
- for (var i = 0; i < labels.length; i++) {
- createLabelItem(labels[i], null)
- }
- }
- });
- })
-});
diff --git a/wise-webapp/src/main/webapp/js/labelActions.js b/wise-webapp/src/main/webapp/js/labelActions.js
deleted file mode 100644
index ec826923..00000000
--- a/wise-webapp/src/main/webapp/js/labelActions.js
+++ /dev/null
@@ -1,91 +0,0 @@
-function createLabelItem(data, id) {
- var labelId = data.id || id;
- $("#foldersContainer").find("ul").append(
- $("
").append(
- " " +
- "" +
- "" +
- "" + data.title + "
" +
- "" +
- ""
- )
- )
-}
-
-function labelTagsAsHtml(labels) {
- var result = "";
- for (var i = 0; i" +
- "" +
- "" +
- " " +
- label.title +
- ' ' +
- " | " +
- //" | " +
- "" +
- "x"+
- " | " +
- "
" +
- ""
- }
- return result;
-}
-
-function fetchLabels(options) {
- jQuery.ajax("c/restful/labels/", {
- async:false,
- dataType:'json',
- type:'GET',
- success:function (data) {
- if (options.postUpdate) {
- options.postUpdate(data)
- }
- },
- error:function (jqXHR, textStatus, errorThrown) {
- $('#messagesPanel div').text(errorThrown).parent().show();
- }
- });
-}
-
-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
- }])
- )
- }
- }
-}
-
-function prepareLabelList(labels) {
- var labelList = $("#labelList");
- var defaultValue = labelList.find("li[id=\"createLabelBtn\"]");
-
- //clear dropdown...
- labelList.find('li').remove();
-
- //append items to dropdown
- $.each(labels, function(index, value) {
- labelList.append(
- $('').attr('value', value.id).attr('color', value.color)
- .append(
- '' +
- "" +
- "" + value.title + "
" +
- '')
- );
- });
-
- //add the defaultValue
- labelList.append('')
- labelList.append(defaultValue);
-}
diff --git a/wise-webapp/src/main/webapp/js/mindmapList.js b/wise-webapp/src/main/webapp/js/mindmapList.js
index 16a9b1b3..a166452f 100644
--- a/wise-webapp/src/main/webapp/js/mindmapList.js
+++ b/wise-webapp/src/main/webapp/js/mindmapList.js
@@ -1,3 +1,5 @@
+/*--------------------------------------------- Common actions --------------------------------------------------**/
+
$.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, fnCallback, bStandingRedraw) {
if (typeof sNewSource != 'undefined' && sNewSource != null) {
oSettings.sAjaxSource = sNewSource;
@@ -239,5 +241,341 @@ setTimeout(function () {
jQuery("abbr.timeago").timeago()
}, 50000);
+/*--------------------------------------------- Button actions --------------------------------------------------**/
+$(function () {
+ // Creation buttons actions ...
+ $("#newBtn").click(
+ function () {
+ $("#new-dialog-modal").dialogForm({
+ redirect:"c/maps/{header.resourceId}/edit",
+ url:"c/restful/maps"
+ });
+ }
+ );
+ $(document).on('click', '#createLabelBtn',
+ function () {
+ var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
+ var url = mapIds.length == 0
+ ? "c/restful/labels"
+ : "c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(',');
+
+ $("#new-folder-dialog-modal").dialogForm({
+ url: url,
+ postUpdate: function(data, id) {
+ createLabelItem(data, id);
+ tagMindmaps(data.id || id, data.title, data.color);
+ }
+ });
+ }
+ );
+
+ $("#addLabelButton").click( function () {
+ var labels;
+ fetchLabels({
+ postUpdate: function(data) {
+ labels = data.labels;
+ }
+ });
+
+ if (labels) {
+ prepareLabelList(labels);
+
+ $(document).one('click', '.chooseLabel',
+ function () {
+ var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
+ if (mapIds.length > 0) {
+ var labelId = $(this).attr('value');
+ var labelName = $(this).text();
+ var labelColor = $(this).attr('color');
+ jQuery.ajax("c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','), {
+ type:'POST',
+ //dataType: "json",
+ contentType:"application/json; charset=utf-8",
+ data: JSON.stringify({id: labelId}),
+ success: function() {
+ tagMindmaps(labelId, labelName, labelColor);
+ }
+ });
+ }
+ }
+ );
+ }
+ });
+
+ $("#duplicateBtn").click(function () {
+ // Map to be cloned ...
+ var tableElem = $('#mindmapListTable');
+ var rows = tableElem.dataTableExt.getSelectedRows();
+ if (rows.length > 0) {
+
+ // Obtain map name ...
+ var rowData = tableElem.dataTable().fnGetData(rows[0]);
+ $('#dupDialogTitle').text("Duplicate '" + rowData.title + "'");
+
+ // Obtains map id ...
+ var mapId = rowData.id;
+
+ // Initialize dialog ...
+ $("#duplicate-dialog-modal").dialogForm({
+ redirect:"c/maps/{header.resourceId}/edit",
+ url:"c/restful/maps/" + mapId
+ });
+ }
+ });
+
+ $("#renameBtn").click(function () {
+ // Map to be cloned ...
+ var tableElem = $('#mindmapListTable');
+ var rows = tableElem.dataTableExt.getSelectedRows();
+ if (rows.length > 0) {
+
+ // Obtain map name ...
+ var dataTable = tableElem.dataTable();
+ var rowData = dataTable.fnGetData(rows[0]);
+
+ // Fill dialog with default values ...
+ var mapId = rowData.id;
+ $("#rename-dialog-modal input[name='title']").attr('value', rowData.title);
+ $("#rename-dialog-modal input[name='description']").attr('value', rowData.description);
+
+ // Set title ...
+ $('#renameDialogTitle').text("Rename '" + rowData.title + "'");
+
+ // Initialize dialog ...
+ $("#rename-dialog-modal").dialogForm({
+ type:'PUT',
+ clearForm:false,
+ postUpdate:function (reqBodyData) {
+ tableElem.dataTableExt.removeSelectedRows();
+
+ rowData.title = reqBodyData.title;
+ rowData.description = reqBodyData.description;
+ dataTable.fnAddData(JSON.parse(JSON.stringify(rowData)));
+ },
+ url:"c/restful/maps/" + mapId
+ });
+ }
+ });
+
+ $("#deleteBtn").click(function () {
+ var tableUI = $('#mindmapListTable');
+
+ var mapIds = tableUI.dataTableExt.getSelectedMapsIds();
+
+ if (mapIds.length > 0) {
+ // Initialize dialog ...
+ $("#delete-dialog-modal").dialogForm({
+ type:'DELETE',
+ postUpdate:function () {
+ // Remove old entry ...
+ tableUI.dataTableExt.removeSelectedRows();
+ },
+ url:"c/restful/maps/batch?ids=" + jQuery.makeArray(mapIds).join(',')
+ });
+ }
+ });
+
+ $("#printBtn").click(function () {
+ var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
+ if (mapIds.length > 0) {
+ // Hack: IE ignore the base href tag ...
+ var baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf("c/maps/"));
+ window.open(baseUrl + 'c/maps/' + mapIds[0] + '/print');
+ }
+ });
+
+ $("#infoBtn").click(function () {
+ showEmbeddedDialog("c/maps/{mapId}/details", 'info-dialog-modal');
+ });
+
+ $("#historyBtn").click(function () {
+ showEmbeddedDialog("c/maps/{mapId}/history", 'history-dialog-modal');
+ });
+
+ $("#publishBtn").click(function () {
+ showEmbeddedDialog("c/maps/{mapId}/publish", "publish-dialog-modal");
+ });
+
+ $("#exportBtn").click(function () {
+ showEmbeddedDialog("c/maps/{mapId}/export", 'export-dialog-modal');
+ });
+
+ $("#importBtn").click(function () {
+ showEmbeddedDialog("c/maps/import", 'import-dialog-modal', true);
+ });
+
+ $("#shareBtn").click(function () {
+ showEmbeddedDialog("c/maps/{mapId}/share", 'share-dialog-modal', true);
+ });
+
+ var showEmbeddedDialog = function (urlTemplate, dialogElemId, ignore) {
+ var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
+ if (mapIds.length > 0 || ignore) {
+ var mapId = mapIds[0];
+ $('#' + dialogElemId + ' .modal-body').load(urlTemplate.replace("{mapId}", mapId),
+ function () {
+ $('#' + dialogElemId + ' .btn-accept').unbind('click').click(function () {
+ submitDialogForm();
+ });
+ $('#' + dialogElemId).modal();
+ });
+ }
+ };
+
+ $(document).on('click', '#foldersContainer li', function (event) {
+ // Deselect previous option ...
+ $('#foldersContainer li').removeClass('active');
+ $('#foldersContainer i').removeClass('icon-white');
+
+ // Select the new item ...
+ var dataTable = $('#mindmapListTable').dataTable();
+ $(this).addClass('active');
+ $('#foldersContainer .active i').addClass('icon-white');
+
+ $('input:checkbox').prop('checked', false);
+ // Reload the table data ...
+ dataTable.fnReloadAjax("c/restful/maps/?q=" + $(this).attr('data-filter'), callbackOnTableInit, true);
+ event.preventDefault();
+ });
+
+ $(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);
+ }
+ })
+ });
+
+ $(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({
+ postUpdate: function(data) {
+ var labels = data.labels;
+ for (var i = 0; i < labels.length; i++) {
+ createLabelItem(labels[i], null)
+ }
+ }
+ });
+ })
+});
+
+/*--------------------------------------------- Label actions --------------------------------------------------**/
+function createLabelItem(data, id) {
+ var labelId = data.id || id;
+ $("#foldersContainer").find("ul").append(
+ $("").append(
+ " " +
+ "" +
+ "" +
+ "" + data.title + "
" +
+ "" +
+ ""
+ )
+ )
+}
+
+function labelTagsAsHtml(labels) {
+ var result = "";
+ for (var i = 0; i" +
+ "" +
+ "" +
+ " " +
+ label.title +
+ ' ' +
+ " | " +
+ //" | " +
+ "" +
+ "x"+
+ " | " +
+ "
" +
+ ""
+ }
+ return result;
+}
+
+function fetchLabels(options) {
+ jQuery.ajax("c/restful/labels/", {
+ async:false,
+ dataType:'json',
+ type:'GET',
+ success:function (data) {
+ if (options.postUpdate) {
+ options.postUpdate(data)
+ }
+ },
+ error:function (jqXHR, textStatus, errorThrown) {
+ $('#messagesPanel div').text(errorThrown).parent().show();
+ }
+ });
+}
+
+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
+ }])
+ )
+ }
+ }
+}
+
+function prepareLabelList(labels) {
+ var labelList = $("#labelList");
+ var defaultValue = labelList.find("li[id=\"createLabelBtn\"]");
+
+ //clear dropdown...
+ labelList.find('li').remove();
+
+ //append items to dropdown
+ $.each(labels, function(index, value) {
+ labelList.append(
+ $('').attr('value', value.id).attr('color', value.color)
+ .append(
+ '' +
+ "" +
+ "" + value.title + "
" +
+ '')
+ );
+ });
+
+ //add the defaultValue
+ labelList.append('')
+ labelList.append(defaultValue);
+}