retrieve label list on mindmapList

This commit is contained in:
Ezequiel Bergamaschi 2014-01-26 18:21:55 -03:00 committed by Ezequiel Bergamaschi
parent 306a2a2ada
commit 194a7f200e

View File

@ -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 ... // Update toolbar events ...
function updateStarred(spanElem) { function updateStarred(spanElem) {
@ -244,6 +261,14 @@ function callbackOnTableInit() {
updateStatusToolbar(); updateStatusToolbar();
} }
function createLabelItem(data) {
$("#foldersContainer").find("ul").append(
$("<li data-filter=\"" + data.title + "\">").append(
"<a href=\"#\"> <i class=\"icon-tag\"></i>" + data.title + "</a>"
)
)
}
$(function () { $(function () {
// Creation buttons actions ... // Creation buttons actions ...
$("#newMapBtn").click( $("#newMapBtn").click(
@ -257,15 +282,10 @@ $(function () {
$("#newFolderBtn").click( $("#newFolderBtn").click(
function () { function () {
fetchLabels()
$("#new-folder-dialog-modal").dialogForm({ $("#new-folder-dialog-modal").dialogForm({
url:"c/restful/labels", url:"c/restful/labels",
postUpdate: function (data) { postUpdate: createLabelItem
$("#foldersContainer").find("ul").append(
$("<li data-filter=\"" + data.title + "\">").append(
"<a href=\"#\"> <i class=\"icon-tag\"></i>" + data.title + "</a>"
)
)
}
}); });
} }
); );
@ -413,7 +433,9 @@ $(function () {
$("#dropdownLabel").prop("disabled", true); $("#dropdownLabel").prop("disabled", true);
} }
} }
) );
$(document).ready(fetchLabels())
}); });
// Register time update functions .... // Register time update functions ....