feat: add client-side toggle logic and multi-mode serialization for string filters
This commit is contained in:
@@ -108,9 +108,17 @@
|
|||||||
{ name: "filter-group", key: "group" }
|
{ name: "filter-group", key: "group" }
|
||||||
];
|
];
|
||||||
textFields.forEach(function (tf) {
|
textFields.forEach(function (tf) {
|
||||||
|
var modifierEl = form.querySelector('[name="' + tf.name + '-modifier"]:checked');
|
||||||
|
var modifier = modifierEl ? modifierEl.value : "EQUALS";
|
||||||
|
|
||||||
|
var isPresence = modifier === "IS_NULL" || modifier === "NOT_NULL";
|
||||||
|
if (isPresence) {
|
||||||
|
filter[tf.key] = { modifier: modifier };
|
||||||
|
} else {
|
||||||
var el = form.querySelector('[name="' + tf.name + '"]');
|
var el = form.querySelector('[name="' + tf.name + '"]');
|
||||||
if (el && el.value.trim()) {
|
if (el && el.value.trim()) {
|
||||||
filter[tf.key] = { value: el.value.trim(), modifier: "EQUALS" };
|
filter[tf.key] = { value: el.value.trim(), modifier: modifier };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -300,6 +308,23 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Enable/disable the input text box depending on selected string modifier. */
|
||||||
|
window.toggleStringFilterInput = function (radio) {
|
||||||
|
var container = radio.closest(".flex-col");
|
||||||
|
if (!container) return;
|
||||||
|
var textInput = container.querySelector('input[type="text"]');
|
||||||
|
if (!textInput) return;
|
||||||
|
var val = radio.value;
|
||||||
|
if (val === "IS_NULL" || val === "NOT_NULL") {
|
||||||
|
textInput.disabled = true;
|
||||||
|
textInput.value = "";
|
||||||
|
textInput.classList.add("opacity-50", "cursor-not-allowed");
|
||||||
|
} else {
|
||||||
|
textInput.disabled = false;
|
||||||
|
textInput.classList.remove("opacity-50", "cursor-not-allowed");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Show the preset name input field and the confirm button. */
|
/** Show the preset name input field and the confirm button. */
|
||||||
window.showPresetNameInput = function () {
|
window.showPresetNameInput = function () {
|
||||||
var input = document.getElementById("preset-name-input");
|
var input = document.getElementById("preset-name-input");
|
||||||
|
|||||||
Reference in New Issue
Block a user