Pull-request: #16666 Fixes: #16424 Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
commit
4df8cd0b3c
@ -152,15 +152,26 @@ function checkForCheckbox (multiEdit) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function verifyAfterSearchFieldChange (index, searchFormId) {
|
||||
var $thisInput = $('input[name=\'criteriaValues[' + index + ']\']');
|
||||
// Add data-skip-validators attribute to skip validation in changeValueFieldType function
|
||||
if ($('#fieldID_' + index).data('data-skip-validators')) {
|
||||
$(searchFormId).validate().destroy();
|
||||
return;
|
||||
}
|
||||
// validation for integer type
|
||||
if ($thisInput.data('type') === 'INT') {
|
||||
if ($thisInput.data('type') === 'INT' ||
|
||||
$thisInput.data('type') === 'TINYINT') {
|
||||
// Trim spaces if it's an integer
|
||||
$thisInput.val($thisInput.val().trim());
|
||||
|
||||
var hasMultiple = $thisInput.prop('multiple');
|
||||
|
||||
if (hasMultiple) {
|
||||
$(searchFormId).validate();
|
||||
$(searchFormId).validate({
|
||||
// update errors as we write
|
||||
onkeyup: function (element) {
|
||||
$(element).valid();
|
||||
}
|
||||
});
|
||||
// validator method for IN(...), NOT IN(...)
|
||||
// BETWEEN and NOT BETWEEN
|
||||
jQuery.validator.addMethod('validationFunctionForMultipleInt', function (value) {
|
||||
@ -170,9 +181,16 @@ function verifyAfterSearchFieldChange (index, searchFormId) {
|
||||
);
|
||||
validateMultipleIntField($thisInput, true);
|
||||
} else {
|
||||
$(searchFormId).validate();
|
||||
$(searchFormId).validate({
|
||||
// update errors as we write
|
||||
onkeyup: function (element) {
|
||||
$(element).valid();
|
||||
}
|
||||
});
|
||||
validateIntField($thisInput, true);
|
||||
}
|
||||
// Update error on dropdown change
|
||||
$thisInput.valid();
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,6 +223,9 @@ function validateMultipleIntField (jqueryInput, returnValueIfFine) {
|
||||
function validateIntField (jqueryInput, returnValueIfIsNumber) {
|
||||
var mini = parseInt(jqueryInput.data('min'));
|
||||
var maxi = parseInt(jqueryInput.data('max'));
|
||||
// removing previous rules
|
||||
jqueryInput.rules('remove');
|
||||
|
||||
jqueryInput.rules('add', {
|
||||
number: {
|
||||
param: true,
|
||||
@ -797,8 +818,18 @@ function changeValueFieldType (elem, searchIndex) {
|
||||
if (0 === fieldsValue.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var type = $(elem).val();
|
||||
|
||||
if ('LIKE' === type ||
|
||||
'LIKE %...%' === type ||
|
||||
'NOT LIKE' === type
|
||||
) {
|
||||
$('#fieldID_' + searchIndex).data('data-skip-validators', true);
|
||||
return;
|
||||
} else {
|
||||
$('#fieldID_' + searchIndex).data('data-skip-validators', false);
|
||||
}
|
||||
|
||||
if ('IN (...)' === type ||
|
||||
'NOT IN (...)' === type ||
|
||||
'BETWEEN' === type ||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* @requires js/functions.js
|
||||
*/
|
||||
|
||||
/* global changeValueFieldType */ // js/table/change.js
|
||||
/* global changeValueFieldType, verifyAfterSearchFieldChange */ // js/table/change.js
|
||||
/* global openGISEditor, gisEditorLoaded, loadJSAndGISEditor, loadGISEditor */ // js/gis_data_editor.js
|
||||
|
||||
var TableSelect = {};
|
||||
@ -81,6 +81,7 @@ AJAX.registerOnload('table/select.js', function () {
|
||||
$.each(tableRows, function (index, item) {
|
||||
$(item).on('change', function () {
|
||||
changeValueFieldType(this, index);
|
||||
verifyAfterSearchFieldChange(index, '#tbl_search_form');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
** @requires js/functions.js
|
||||
**/
|
||||
|
||||
/* global changeValueFieldType, verifyAfterSearchFieldChange */ // js/table/change.js
|
||||
|
||||
/**
|
||||
** Display Help/Info
|
||||
@ -133,8 +134,8 @@ AJAX.registerOnload('table/zoom_plot_jqplot.js', function () {
|
||||
var tableRows = $('#inputSection select.column-operator');
|
||||
$.each(tableRows, function (index, item) {
|
||||
$(item).on('change', function () {
|
||||
// eslint-disable-next-line no-undef
|
||||
changeValueFieldType(this, index);
|
||||
verifyAfterSearchFieldChange(index, '#zoom_search_form');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -412,7 +412,7 @@ class SearchController extends AbstractController
|
||||
. 'data-max="' . $minMaxValues[1] . '"';
|
||||
}
|
||||
|
||||
$htmlAttributes .= ' onchange="return '
|
||||
$htmlAttributes .= ' onfocus="return '
|
||||
. 'verifyAfterSearchFieldChange(' . $column_index . ', \'#tbl_search_form\')"';
|
||||
|
||||
$value = $this->template->render('table/search/input_box', [
|
||||
|
||||
@ -468,8 +468,8 @@ class ZoomSearchController extends AbstractController
|
||||
. 'data-max="' . $minMaxValues[1] . '"';
|
||||
}
|
||||
|
||||
$htmlAttributes .= ' onchange="return '
|
||||
. 'verifyAfterSearchFieldChange(' . $column_index . ', \'#zoom_search_form\')"';
|
||||
$htmlAttributes .= ' onfocus="return '
|
||||
. 'verifyAfterSearchFieldChange(' . $search_index . ', \'#zoom_search_form\')"';
|
||||
|
||||
$value = $this->template->render('table/search/input_box', [
|
||||
'str' => '',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user