Remove callback param from CommonActions.refreshMain()
This removes the dependency on AJAX in common.js file. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
0160f0a8c6
commit
b3e40101ee
@ -106,9 +106,10 @@ AJAX.registerOnload('database/operations.js', function () {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
if ($('#checkbox_switch').is(':checked')) {
|
||||
CommonParams.set('db', data.newname);
|
||||
CommonActions.refreshMain(false, function () {
|
||||
CommonActions.refreshMain(false);
|
||||
AJAX.callback = () => {
|
||||
ajaxShowMessage(data.message);
|
||||
});
|
||||
};
|
||||
} else {
|
||||
CommonParams.set('db', data.db);
|
||||
ajaxShowMessage(data.message);
|
||||
@ -168,12 +169,10 @@ AJAX.registerOnload('database/operations.js', function () {
|
||||
// Database deleted successfully, refresh both the frames
|
||||
Navigation.reload();
|
||||
CommonParams.set('db', '');
|
||||
CommonActions.refreshMain(
|
||||
'index.php?route=/server/databases',
|
||||
function () {
|
||||
ajaxShowMessage(data.message);
|
||||
}
|
||||
);
|
||||
CommonActions.refreshMain('index.php?route=/server/databases');
|
||||
AJAX.callback = () => {
|
||||
ajaxShowMessage(data.message);
|
||||
};
|
||||
} else {
|
||||
ajaxShowMessage(data.error, false);
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import $ from 'jquery';
|
||||
import { AJAX } from './ajax.js';
|
||||
import { Navigation } from './navigation.js';
|
||||
|
||||
/**
|
||||
@ -130,11 +129,10 @@ const CommonActions = {
|
||||
*
|
||||
* @param {any} url Undefined to refresh to the same page
|
||||
* String to go to a different page, e.g: 'index.php'
|
||||
* @param {function | undefined} callback
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
refreshMain: function (url, callback = undefined) {
|
||||
refreshMain: function (url) {
|
||||
var newUrl = url;
|
||||
if (! newUrl) {
|
||||
newUrl = $('#selflink').find('a').attr('href') || window.location.pathname;
|
||||
@ -149,9 +147,6 @@ const CommonActions = {
|
||||
.appendTo('body')
|
||||
.trigger('click')
|
||||
.remove();
|
||||
if (typeof callback !== 'undefined') {
|
||||
AJAX.callback = callback;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1833,9 +1833,7 @@ Functions.onloadCreateTableEvents = function () {
|
||||
var tablesTable = $('#tablesForm').find('tbody').not('#tbl_summary_row');
|
||||
// this is the first table created in this db
|
||||
if (tablesTable.length === 0) {
|
||||
CommonActions.refreshMain(
|
||||
CommonParams.get('opendb_url')
|
||||
);
|
||||
CommonActions.refreshMain(CommonParams.get('opendb_url'));
|
||||
} else {
|
||||
/**
|
||||
* @var curr_last_row Object referring to the last <tr> element in {@link tablesTable}
|
||||
|
||||
@ -841,12 +841,13 @@ AJAX.registerOnload('sql.js', function () {
|
||||
} else {
|
||||
url = 'index.php?route=/server/sql';
|
||||
}
|
||||
CommonActions.refreshMain(url, function () {
|
||||
CommonActions.refreshMain(url);
|
||||
AJAX.callback = () => {
|
||||
$('#sqlqueryresultsouter')
|
||||
.show()
|
||||
.html(data.message);
|
||||
highlightSql($('#sqlqueryresultsouter'));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
$('.sqlqueryresults').trigger('makegrid');
|
||||
|
||||
@ -91,9 +91,10 @@ AJAX.registerOnload('table/operations.js', function () {
|
||||
'table',
|
||||
$form.find('input[name=\'new_name\']').val()
|
||||
);
|
||||
CommonActions.refreshMain(false, function () {
|
||||
CommonActions.refreshMain(false);
|
||||
AJAX.callback = () => {
|
||||
ajaxShowMessage(data.message);
|
||||
});
|
||||
};
|
||||
} else {
|
||||
ajaxShowMessage(data.message);
|
||||
}
|
||||
@ -117,9 +118,10 @@ AJAX.registerOnload('table/operations.js', function () {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
CommonParams.set('db', data.params.db);
|
||||
CommonParams.set('table', data.params.table);
|
||||
CommonActions.refreshMain('index.php?route=/table/sql', function () {
|
||||
CommonActions.refreshMain('index.php?route=/table/sql');
|
||||
AJAX.callback = () => {
|
||||
ajaxShowMessage(data.message);
|
||||
});
|
||||
};
|
||||
// Refresh navigation when the table is copied
|
||||
Navigation.reload();
|
||||
} else {
|
||||
@ -166,10 +168,11 @@ AJAX.registerOnload('table/operations.js', function () {
|
||||
$.post($form.attr('action'), $form.serialize(), function (data) {
|
||||
if (typeof data !== 'undefined' && data.success === true) {
|
||||
CommonParams.set('table', data.params.table);
|
||||
CommonActions.refreshMain(false, function () {
|
||||
CommonActions.refreshMain(false);
|
||||
AJAX.callback = () => {
|
||||
$('#page_content').html(data.message);
|
||||
highlightSql($('#page_content'));
|
||||
});
|
||||
};
|
||||
// Refresh navigation when the table is renamed
|
||||
Navigation.reload();
|
||||
} else {
|
||||
@ -290,12 +293,10 @@ AJAX.registerOnload('table/operations.js', function () {
|
||||
// Table deleted successfully, refresh both the frames
|
||||
Navigation.reload();
|
||||
CommonParams.set('table', '');
|
||||
CommonActions.refreshMain(
|
||||
CommonParams.get('opendb_url'),
|
||||
function () {
|
||||
ajaxShowMessage(data.message);
|
||||
}
|
||||
);
|
||||
CommonActions.refreshMain(CommonParams.get('opendb_url'));
|
||||
AJAX.callback = () => {
|
||||
ajaxShowMessage(data.message);
|
||||
};
|
||||
} else {
|
||||
ajaxShowMessage(data.error, false);
|
||||
}
|
||||
@ -324,12 +325,10 @@ AJAX.registerOnload('table/operations.js', function () {
|
||||
// Table deleted successfully, refresh both the frames
|
||||
Navigation.reload();
|
||||
CommonParams.set('table', '');
|
||||
CommonActions.refreshMain(
|
||||
CommonParams.get('opendb_url'),
|
||||
function () {
|
||||
ajaxShowMessage(data.message);
|
||||
}
|
||||
);
|
||||
CommonActions.refreshMain(CommonParams.get('opendb_url'));
|
||||
AJAX.callback = () => {
|
||||
ajaxShowMessage(data.message);
|
||||
};
|
||||
} else {
|
||||
ajaxShowMessage(data.error, false);
|
||||
}
|
||||
|
||||
@ -247,9 +247,10 @@ AJAX.registerOnload('table/relation.js', function () {
|
||||
$.post(url, params, function (data) {
|
||||
if (data.success === true) {
|
||||
ajaxRemoveMessage($msg);
|
||||
CommonActions.refreshMain(false, function () {
|
||||
CommonActions.refreshMain(false);
|
||||
AJAX.callback = () => {
|
||||
// Do nothing
|
||||
});
|
||||
};
|
||||
} else {
|
||||
ajaxShowMessage(window.Messages.strErrorProcessingRequest + ' : ' + data.error, false);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user