@@ -7,6 +7,7 @@ import highlightSql from './sql-highlight.js';
77import { ajaxRemoveMessage , ajaxShowMessage } from './ajax-message.js' ;
88import getJsConfirmCommonParam from './functions/getJsConfirmCommonParam.js' ;
99import refreshMainContent from './functions/refreshMainContent.js' ;
10+ import checkIndexType from './indexes/checkIndexType.js' ;
1011
1112/**
1213 * @fileoverview function used for index manipulation pages
@@ -89,88 +90,6 @@ Indexes.getIndexArray = function (indexChoice) {
8990 return sourceArray ;
9091} ;
9192
92- /**
93- * Hides/shows the inputs and submits appropriately depending
94- * on whether the index type chosen is 'SPATIAL' or not.
95- */
96- Indexes . checkIndexType = function ( ) {
97- /**
98- * @var {JQuery<HTMLElement}, Dropdown to select the index choice.
99- */
100- var $selectIndexChoice = $ ( '#select_index_choice' ) ;
101- /**
102- * @var {JQuery<HTMLElement}, Dropdown to select the index type.
103- */
104- var $selectIndexType = $ ( '#select_index_type' ) ;
105- /**
106- * @var {JQuery<HTMLElement}, Table header for the size column.
107- */
108- var $sizeHeader = $ ( '#index_columns' ) . find ( 'thead tr' ) . children ( 'th' ) . eq ( 1 ) ;
109- /**
110- * @var {JQuery<HTMLElement}, Inputs to specify the columns for the index.
111- */
112- var $columnInputs = $ ( 'select[name="index[columns][names][]"]' ) ;
113- /**
114- * @var {JQuery<HTMLElement}, Inputs to specify sizes for columns of the index.
115- */
116- var $sizeInputs = $ ( 'input[name="index[columns][sub_parts][]"]' ) ;
117- /**
118- * @var {JQuery<HTMLElement}, Footer containing the controllers to add more columns
119- */
120- var $addMore = $ ( '#index_frm' ) . find ( '.add_more' ) ;
121-
122- if ( $selectIndexChoice . val ( ) === 'SPATIAL' ) {
123- // Disable and hide the size column
124- $sizeHeader . hide ( ) ;
125- $sizeInputs . each ( function ( ) {
126- $ ( this )
127- . prop ( 'disabled' , true )
128- . parent ( 'td' ) . hide ( ) ;
129- } ) ;
130-
131- // Disable and hide the columns of the index other than the first one
132- var initial = true ;
133- $columnInputs . each ( function ( ) {
134- var $columnInput = $ ( this ) ;
135- if ( ! initial ) {
136- $columnInput
137- . prop ( 'disabled' , true )
138- . parent ( 'td' ) . hide ( ) ;
139- } else {
140- initial = false ;
141- }
142- } ) ;
143-
144- // Hide controllers to add more columns
145- $addMore . hide ( ) ;
146- } else {
147- // Enable and show the size column
148- $sizeHeader . show ( ) ;
149- $sizeInputs . each ( function ( ) {
150- $ ( this )
151- . prop ( 'disabled' , false )
152- . parent ( 'td' ) . show ( ) ;
153- } ) ;
154-
155- // Enable and show the columns of the index
156- $columnInputs . each ( function ( ) {
157- $ ( this )
158- . prop ( 'disabled' , false )
159- . parent ( 'td' ) . show ( ) ;
160- } ) ;
161-
162- // Show controllers to add more columns
163- $addMore . show ( ) ;
164- }
165-
166- if ( $selectIndexChoice . val ( ) === 'SPATIAL' ||
167- $selectIndexChoice . val ( ) === 'FULLTEXT' ) {
168- $selectIndexType . val ( '' ) . prop ( 'disabled' , true ) ;
169- } else {
170- $selectIndexType . prop ( 'disabled' , false ) ;
171- }
172- } ;
173-
17493/**
17594 * Sets current index information into form parameters.
17695 *
@@ -643,7 +562,7 @@ Indexes.on = () => function () {
643562
644563 $ ( document ) . on ( 'change' , '#select_index_choice' , function ( event ) {
645564 event . preventDefault ( ) ;
646- Indexes . checkIndexType ( ) ;
565+ checkIndexType ( ) ;
647566 Functions . checkIndexName ( 'index_frm' ) ;
648567 } ) ;
649568
0 commit comments