From e7c7e6eed8da8a72600bbc754ef1fa5f4530967a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Mon, 30 Jan 2023 13:06:33 -0300 Subject: [PATCH] Extract Indexed.checkIndexType() to a module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- js/src/modules/functions.js | 4 +- js/src/modules/indexes.js | 85 +----------------------- js/src/modules/indexes/checkIndexType.js | 83 +++++++++++++++++++++++ 3 files changed, 87 insertions(+), 85 deletions(-) create mode 100644 js/src/modules/indexes/checkIndexType.js diff --git a/js/src/modules/functions.js b/js/src/modules/functions.js index 8fe63ef8ae..0e0f5e0e28 100644 --- a/js/src/modules/functions.js +++ b/js/src/modules/functions.js @@ -2,7 +2,6 @@ import $ from 'jquery'; import { AJAX } from './ajax.js'; import { Navigation } from './navigation.js'; import { CommonParams } from './common.js'; -import { Indexes } from './indexes.js'; import { Config } from './config.js'; import tooltip from './tooltip.js'; import highlightSql from './sql-highlight.js'; @@ -12,6 +11,7 @@ import { escapeHtml } from './functions/escape.js'; import getImageTag from './functions/getImageTag.js'; import handleRedirectAndReload from './functions/handleRedirectAndReload.js'; import refreshMainContent from './functions/refreshMainContent.js'; +import checkIndexType from './indexes/checkIndexType.js'; /* global DatabaseStructure */ // js/database/structure.js /* global firstDayOfCalendar, themeImagePath */ // templates/javascript/variables.twig @@ -2759,7 +2759,7 @@ Functions.indexRenameDialog = function (url, title, callbackSuccess, callbackFai }; Functions.showIndexEditDialog = function ($outer) { - Indexes.checkIndexType(); + checkIndexType(); Functions.checkIndexName('index_frm'); var $indexColumns = $('#index_columns'); $indexColumns.find('td').each(function () { diff --git a/js/src/modules/indexes.js b/js/src/modules/indexes.js index 1a5ddc0a1d..05d47fd2d5 100644 --- a/js/src/modules/indexes.js +++ b/js/src/modules/indexes.js @@ -7,6 +7,7 @@ import highlightSql from './sql-highlight.js'; import { ajaxRemoveMessage, ajaxShowMessage } from './ajax-message.js'; import getJsConfirmCommonParam from './functions/getJsConfirmCommonParam.js'; import refreshMainContent from './functions/refreshMainContent.js'; +import checkIndexType from './indexes/checkIndexType.js'; /** * @fileoverview function used for index manipulation pages @@ -89,88 +90,6 @@ Indexes.getIndexArray = function (indexChoice) { return sourceArray; }; -/** - * Hides/shows the inputs and submits appropriately depending - * on whether the index type chosen is 'SPATIAL' or not. - */ -Indexes.checkIndexType = function () { - /** - * @var {JQuery function () { $(document).on('change', '#select_index_choice', function (event) { event.preventDefault(); - Indexes.checkIndexType(); + checkIndexType(); Functions.checkIndexName('index_frm'); }); diff --git a/js/src/modules/indexes/checkIndexType.js b/js/src/modules/indexes/checkIndexType.js new file mode 100644 index 0000000000..5780f1d197 --- /dev/null +++ b/js/src/modules/indexes/checkIndexType.js @@ -0,0 +1,83 @@ +import $ from 'jquery'; + +/** + * Hides/shows the inputs and submits appropriately depending + * on whether the index type chosen is 'SPATIAL' or not. + */ +export default function checkIndexType () { + /** + * @var {JQuery