phpmyadmin/resources/js/modules/indexes/checkIndexName.ts
Maurício Meneghini Fauth 01e4a87bbd
Move resources/js/src to resources/js
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
2025-05-22 13:43:59 -03:00

33 lines
918 B
TypeScript

import $ from 'jquery';
/**
* Ensures indexes names are valid according to their type and, for a primary
* key, lock index name to 'PRIMARY'
* @param {string} formId Variable which parses the form name as
* the input
* @return {boolean} false if there is no index form, true else
*/
export default function checkIndexName (formId) {
if ($('#' + formId).length === 0) {
return false;
}
// Gets the elements pointers
var $theIdxName = $('#input_index_name');
var $theIdxChoice = $('#select_index_choice');
// Index is a primary key
if ($theIdxChoice.find('option:selected').val() === 'PRIMARY') {
$theIdxName.val('PRIMARY');
$theIdxName.prop('disabled', true);
} else {
if ($theIdxName.val() === 'PRIMARY') {
$theIdxName.val('');
}
$theIdxName.prop('disabled', false);
}
return true;
}