Remove Indexes object from the Window global object

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2022-11-29 14:39:16 -03:00
parent b7a710e83f
commit 49865fe647
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
16 changed files with 14 additions and 23 deletions

View File

@ -3,10 +3,10 @@ import { AJAX } from './ajax.js';
import { Navigation } from './navigation.js';
import { CommonActions, CommonParams } from './common.js';
import { mysqlDocKeyword, mysqlDocBuiltin } from './modules/doc-links.js';
import { Indexes } from './indexes.js';
/* global ChartType, ColumnType, DataTable, JQPlotChartFactory */ // js/chart.js
/* global DatabaseStructure */ // js/database/structure.js
/* global Indexes */ // js/indexes.js
/* global firstDayOfCalendar, maxInputVars, mysqlDocTemplate, themeImagePath */ // templates/javascript/variables.twig
/**

View File

@ -10,9 +10,7 @@ import { CommonActions, CommonParams } from './common.js';
*
* @requires jQueryUI
*/
var Indexes = {};
window.Indexes = Indexes;
const Indexes = {};
/**
* Returns the array of indexes based on the index choice
@ -803,3 +801,5 @@ Indexes.on = () => function () {
}
});
};
export { Indexes };

View File

@ -5,8 +5,7 @@ import { KeyHandlerEvents } from './keyhandler.js';
import { Navigation } from './navigation.js';
import { PageSettings } from './page_settings.js';
import { crossFramingProtection } from './cross_framing_protection.js';
/* global Indexes */
import { Indexes } from './indexes.js';
AJAX.registerOnload('main.js', () => AJAX.removeSubmitEvents());
$(AJAX.loadEventHandler());
@ -39,8 +38,8 @@ $(Functions.breadcrumbScrollToTop());
$(Navigation.onload());
AJAX.registerTeardown('indexes.js', Indexes.off());
AJAX.registerOnload('indexes.js', Indexes.on());
AJAX.registerTeardown('main.js', Indexes.off());
AJAX.registerOnload('main.js', Indexes.on());
$(() => Functions.checkNumberOfFields());

View File

@ -77,7 +77,6 @@ class SqlController extends AbstractController
$this->addScriptFiles([
'vendor/jquery/jquery.uitablefilter.js',
'table/change.js',
'indexes.js',
'gis_data_editor.js',
'multi_column_sort.js',
]);

View File

@ -188,7 +188,7 @@ class AddFieldController extends AbstractController
$GLOBALS['active_page'] = Url::getFromRoute('/table/structure');
$this->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js', 'indexes.js']);
$this->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js']);
$this->checkParameters(['server', 'db', 'table', 'num_fields']);

View File

@ -153,7 +153,7 @@ class CreateController extends AbstractController
// Do not display the table in the header since it hasn't been created yet
$this->response->getHeader()->getMenu()->setTable('');
$this->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js', 'indexes.js']);
$this->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js']);
$this->checkParameters(['server', 'db']);

View File

@ -91,8 +91,6 @@ final class IndexRenameController extends AbstractController
$formParams['old_index'] = $_POST['index'];
}
$this->addScriptFiles(['indexes.js']);
$this->render('table/index_rename_form', [
'index' => $index,
'form_params' => $formParams,

View File

@ -139,8 +139,6 @@ class IndexesController extends AbstractController
$form_params['old_index'] = $_POST['index'];
}
$this->addScriptFiles(['indexes.js']);
$this->render('table/index_form', [
'fields' => $fields,
'index' => $index,

View File

@ -93,7 +93,7 @@ final class RelationController extends AbstractController
return;
}
$this->addScriptFiles(['table/relation.js', 'indexes.js']);
$this->addScriptFiles(['table/relation.js']);
// Set the database
$this->dbi->selectDb($GLOBALS['db']);

View File

@ -83,7 +83,7 @@ final class ReplaceController extends AbstractController
$this->dbi->selectDb($GLOBALS['db']);
$this->addScriptFiles(['makegrid.js', 'sql.js', 'indexes.js', 'gis_data_editor.js']);
$this->addScriptFiles(['makegrid.js', 'sql.js', 'gis_data_editor.js']);
$insertRows = $_POST['insert_rows'] ?? null;
if (is_numeric($insertRows) && $insertRows != $GLOBALS['cfg']['InsertRows']) {

View File

@ -90,7 +90,7 @@ final class ChangeController extends AbstractController
$checkUserPrivileges = new CheckUserPrivileges($this->dbi);
$checkUserPrivileges->getPrivileges();
$this->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js', 'indexes.js']);
$this->addScriptFiles(['vendor/jquery/jquery.uitablefilter.js']);
$this->checkParameters(['server', 'db', 'table', 'num_fields']);

View File

@ -66,7 +66,7 @@ final class PartitioningController extends AbstractController
$this->response->addHTML($pageSettings->getErrorHTML());
$this->response->addHTML($pageSettings->getHTML());
$this->addScriptFiles(['table/structure.js', 'indexes.js']);
$this->addScriptFiles(['table/structure.js']);
$partitionDetails = null;
if (! isset($_POST['partition_by'])) {

View File

@ -121,7 +121,7 @@ class StructureController extends AbstractController
$checkUserPrivileges = new CheckUserPrivileges($this->dbi);
$checkUserPrivileges->getPrivileges();
$this->addScriptFiles(['table/structure.js', 'indexes.js']);
$this->addScriptFiles(['table/structure.js']);
$relationParameters = $this->relation->getRelationParameters();

View File

@ -142,7 +142,6 @@ class Header
$this->scripts->addFile('shared.js');
$this->scripts->addFile('menu_resizer.js');
$this->scripts->addFile('config.js');
$this->scripts->addFile('indexes.js');
$this->scripts->addFile('main.js');
$this->scripts->addCode($this->getJsParamsCode());

View File

@ -264,7 +264,6 @@ class HeaderTest extends AbstractTestCase
['name' => 'shared.js', 'fire' => 0],
['name' => 'menu_resizer.js', 'fire' => 1],
['name' => 'config.js', 'fire' => 1],
['name' => 'indexes.js', 'fire' => 1],
['name' => 'main.js', 'fire' => 1],
];
$this->assertSame($expected, $scripts->getFiles());

View File

@ -40,7 +40,6 @@ module.exports = [
'gis_data_editor': './js/src/gis_data_editor.js',
'home': './js/src/home.js',
'import': './js/src/import.js',
'indexes': './js/src/indexes.js',
'jqplot/plugins/jqplot.byteFormatter': './js/src/jqplot/plugins/jqplot.byteFormatter.js',
'jquery.sortable-table': './js/src/jquery.sortable-table.js',
'main': './js/src/main.js',