more comprehensible vc form display flow
This commit is contained in:
parent
2ec659baac
commit
722ba58085
|
@ -1403,8 +1403,15 @@ function copyVisualConsoleItem(baseUrl, vcId, vcItemId, callback) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When invoking modals from JS, some DOM id could be repeated.
|
||||||
|
* This method cleans DOM to avoid duplicated IDs.
|
||||||
|
*/
|
||||||
|
function cleanupDOM() {
|
||||||
|
$("#modalVCItemForm").empty();
|
||||||
|
}
|
||||||
/* Defined in operations/visual_console/view.php */
|
/* Defined in operations/visual_console/view.php */
|
||||||
/* global showMsg,cleanupDOM,$,load_modal */
|
/* global handleFormResponse,$,load_modal */
|
||||||
function createOrUpdateVisualConsoleItem(
|
function createOrUpdateVisualConsoleItem(
|
||||||
visualConsole,
|
visualConsole,
|
||||||
asyncTaskManager,
|
asyncTaskManager,
|
||||||
|
@ -1420,7 +1427,17 @@ function createOrUpdateVisualConsoleItem(
|
||||||
target: $("#modalVCItemForm"),
|
target: $("#modalVCItemForm"),
|
||||||
form: "itemForm",
|
form: "itemForm",
|
||||||
url: baseUrl + "ajax.php",
|
url: baseUrl + "ajax.php",
|
||||||
ajax_callback: showMsg,
|
ajax_callback: function(response) {
|
||||||
|
var item = handleFormResponse(response);
|
||||||
|
|
||||||
|
if (item == false) {
|
||||||
|
// Error.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Success.
|
||||||
|
console.log(item);
|
||||||
|
},
|
||||||
cleanup: cleanupDOM,
|
cleanup: cleanupDOM,
|
||||||
modal: {
|
modal: {
|
||||||
title: title,
|
title: title,
|
||||||
|
|
|
@ -541,7 +541,7 @@ ui_require_css_file('form');
|
||||||
/**
|
/**
|
||||||
* Process ajax responses and shows a dialog with results.
|
* Process ajax responses and shows a dialog with results.
|
||||||
*/
|
*/
|
||||||
function showMsg(data) {
|
function handleFormResponse(data) {
|
||||||
var title = "<?php echo __('Success'); ?>";
|
var title = "<?php echo __('Success'); ?>";
|
||||||
var text = '';
|
var text = '';
|
||||||
var failed = 0;
|
var failed = 0;
|
||||||
|
@ -564,40 +564,34 @@ ui_require_css_file('form');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#modalVCItemFormMsg').empty();
|
if (failed == 1) {
|
||||||
$('#modalVCItemFormMsg').html(text);
|
$('#modalVCItemFormMsg').empty();
|
||||||
$('#modalVCItemFormMsg').dialog({
|
$('#modalVCItemFormMsg').html(text);
|
||||||
width: 450,
|
$('#modalVCItemFormMsg').dialog({
|
||||||
position: {
|
width: 450,
|
||||||
my: 'center',
|
position: {
|
||||||
at: 'center',
|
my: 'center',
|
||||||
of: window,
|
at: 'center',
|
||||||
collision: 'fit'
|
of: window,
|
||||||
},
|
collision: 'fit'
|
||||||
title: title,
|
},
|
||||||
buttons: [
|
title: title,
|
||||||
{
|
buttons: [
|
||||||
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
{
|
||||||
text: 'OK',
|
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||||
click: function(e) {
|
text: 'OK',
|
||||||
if (!failed) {
|
click: function(e) {
|
||||||
$(".ui-dialog-content").dialog("close");
|
|
||||||
$('.info').hide();
|
|
||||||
cleanupDOM();
|
|
||||||
} else {
|
|
||||||
$(this).dialog('close');
|
$(this).dialog('close');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
});
|
||||||
});
|
// Failed.
|
||||||
}
|
return false;
|
||||||
/**
|
}
|
||||||
* When invoking modals from JS, some DOM id could be repeated.
|
|
||||||
* This method cleans DOM to avoid duplicated IDs.
|
// Success, return result.
|
||||||
*/
|
return data['result'];
|
||||||
function cleanupDOM() {
|
|
||||||
$("#modalVCItemForm").empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue