add label to mindmap ui logic

This commit is contained in:
Ezequiel Bergamaschi 2014-01-29 02:55:44 -03:00 committed by Ezequiel Bergamaschi
parent ed55fd824f
commit 9edea47dbd
2 changed files with 31 additions and 6 deletions

View File

@ -22,15 +22,32 @@ $(function () {
function () {
fetchLabels({
postUpdate: function(data) {
var labelList = $("#labelId");
//clear dropdown...
labelList.find("option").remove();
if (data.labels.length == 0) {
window.alert('no hay labels, como resolvemos esto?');
return;
}
//append items to dropdown
$.each(data.labels, function(index, value) {
$("#labelList").append($('<option></option>').val(index).html(value.title));
})
labelList.append($('<option></option>').val(value.id).html(value.title));
});
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
$("#add-label-dialog-modal").dialogForm({
type:'PUT',
url:"c/restful/labels/maps?ids=" + jQuery.makeArray(mapIds).join(','),
postUpdate: function(data) {
}
});
}
});
$("#add-label-dialog-modal").dialogForm({
//url:"c/restful/labels",
//postUpdate: createLabelItem
});
}
);

View File

@ -98,6 +98,14 @@ jQuery.fn.dialogForm = function (options) {
$('#' + containerId + ' input').each(function (index, elem) {
formData[elem.name] = elem.value;
});
//No me gusta, revisar only support one select in the form
var dropdown = $('#' + containerId + ' option:selected');
if (dropdown.val()) {
formData['id'] = dropdown.val();
formData['title'] = dropdown.html();
}
$(acceptBtn).button('loading');
var dialogElem = this;
jQuery.ajax(url, {