From 194a7f200ec2f899d38c8762f959b17304bdfb9b Mon Sep 17 00:00:00 2001 From: Ezequiel Bergamaschi Date: Sun, 26 Jan 2014 18:21:55 -0300 Subject: [PATCH] retrieve label list on mindmapList --- wise-webapp/src/main/webapp/js/mindmapList.js | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/wise-webapp/src/main/webapp/js/mindmapList.js b/wise-webapp/src/main/webapp/js/mindmapList.js index 024a4605..f0b4c969 100644 --- a/wise-webapp/src/main/webapp/js/mindmapList.js +++ b/wise-webapp/src/main/webapp/js/mindmapList.js @@ -190,6 +190,23 @@ function updateStatusToolbar() { } } +function fetchLabels() { + jQuery.ajax("c/restful/labels/", { + async:false, + dataType:'json', + type:'GET', + success:function (data) { + var labels = data.labels; + for (var i = 0; i < labels.length; i++) { + createLabelItem(labels[i]) + } + }, + error:function (jqXHR, textStatus, errorThrown) { + $('#messagesPanel div').text(errorThrown).parent().show(); + } + }); +} + // Update toolbar events ... function updateStarred(spanElem) { @@ -244,6 +261,14 @@ function callbackOnTableInit() { updateStatusToolbar(); } +function createLabelItem(data) { + $("#foldersContainer").find("ul").append( + $("
  • ").append( + " " + data.title + "" + ) + ) +} + $(function () { // Creation buttons actions ... $("#newMapBtn").click( @@ -257,15 +282,10 @@ $(function () { $("#newFolderBtn").click( function () { + fetchLabels() $("#new-folder-dialog-modal").dialogForm({ url:"c/restful/labels", - postUpdate: function (data) { - $("#foldersContainer").find("ul").append( - $("
  • ").append( - " " + data.title + "" - ) - ) - } + postUpdate: createLabelItem }); } ); @@ -413,7 +433,9 @@ $(function () { $("#dropdownLabel").prop("disabled", true); } } - ) + ); + + $(document).ready(fetchLabels()) }); // Register time update functions ....