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 */
|
||||
/* global showMsg,cleanupDOM,$,load_modal */
|
||||
/* global handleFormResponse,$,load_modal */
|
||||
function createOrUpdateVisualConsoleItem(
|
||||
visualConsole,
|
||||
asyncTaskManager,
|
||||
|
@ -1420,7 +1427,17 @@ function createOrUpdateVisualConsoleItem(
|
|||
target: $("#modalVCItemForm"),
|
||||
form: "itemForm",
|
||||
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,
|
||||
modal: {
|
||||
title: title,
|
||||
|
|
|
@ -541,7 +541,7 @@ ui_require_css_file('form');
|
|||
/**
|
||||
* Process ajax responses and shows a dialog with results.
|
||||
*/
|
||||
function showMsg(data) {
|
||||
function handleFormResponse(data) {
|
||||
var title = "<?php echo __('Success'); ?>";
|
||||
var text = '';
|
||||
var failed = 0;
|
||||
|
@ -564,40 +564,34 @@ ui_require_css_file('form');
|
|||
});
|
||||
}
|
||||
|
||||
$('#modalVCItemFormMsg').empty();
|
||||
$('#modalVCItemFormMsg').html(text);
|
||||
$('#modalVCItemFormMsg').dialog({
|
||||
width: 450,
|
||||
position: {
|
||||
my: 'center',
|
||||
at: 'center',
|
||||
of: window,
|
||||
collision: 'fit'
|
||||
},
|
||||
title: title,
|
||||
buttons: [
|
||||
{
|
||||
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
text: 'OK',
|
||||
click: function(e) {
|
||||
if (!failed) {
|
||||
$(".ui-dialog-content").dialog("close");
|
||||
$('.info').hide();
|
||||
cleanupDOM();
|
||||
} else {
|
||||
if (failed == 1) {
|
||||
$('#modalVCItemFormMsg').empty();
|
||||
$('#modalVCItemFormMsg').html(text);
|
||||
$('#modalVCItemFormMsg').dialog({
|
||||
width: 450,
|
||||
position: {
|
||||
my: 'center',
|
||||
at: 'center',
|
||||
of: window,
|
||||
collision: 'fit'
|
||||
},
|
||||
title: title,
|
||||
buttons: [
|
||||
{
|
||||
class: "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
text: 'OK',
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
/**
|
||||
* When invoking modals from JS, some DOM id could be repeated.
|
||||
* This method cleans DOM to avoid duplicated IDs.
|
||||
*/
|
||||
function cleanupDOM() {
|
||||
$("#modalVCItemForm").empty();
|
||||
]
|
||||
});
|
||||
// Failed.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Success, return result.
|
||||
return data['result'];
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue