mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
Implement a filter for category (#215)
- Also implement an is empty/is null condition.
This commit is contained in:
@@ -11,6 +11,11 @@ export default class extends Controller {
|
||||
"subConditionsList",
|
||||
];
|
||||
|
||||
connect() {
|
||||
// Hide value field on initial load if operator is "is_null"
|
||||
this.#toggleValueFieldVisibility();
|
||||
}
|
||||
|
||||
addSubCondition() {
|
||||
const html = this.subConditionTemplateTarget.innerHTML.replaceAll(
|
||||
"IDX_CHILD_PLACEHOLDER",
|
||||
@@ -52,6 +57,11 @@ export default class extends Controller {
|
||||
}
|
||||
|
||||
this.#updateOperatorsField(conditionFilter);
|
||||
this.#toggleValueFieldVisibility();
|
||||
}
|
||||
|
||||
handleOperatorChange(e) {
|
||||
this.#toggleValueFieldVisibility();
|
||||
}
|
||||
|
||||
get valueInputEl() {
|
||||
@@ -112,4 +122,18 @@ export default class extends Controller {
|
||||
#uniqueKey() {
|
||||
return Date.now();
|
||||
}
|
||||
|
||||
#toggleValueFieldVisibility() {
|
||||
const operator = this.operatorSelectTarget.value;
|
||||
|
||||
if (operator === "is_null") {
|
||||
this.filterValueTarget.classList.add("hidden");
|
||||
// Clear the value since it's not needed
|
||||
if (this.valueInputEl) {
|
||||
this.valueInputEl.value = "";
|
||||
}
|
||||
} else {
|
||||
this.filterValueTarget.classList.remove("hidden");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user