Several fixes for saving filters

- Unify terms with the settings form so that terms are saved normally in the same form.
- Fix filter normalization since it was sometimes failing to match the saved filters due to using quotes around number strings.
This commit is contained in:
Jorge Manrubia
2025-09-22 12:55:19 +02:00
parent 717f921a73
commit ce80c843d0
14 changed files with 66 additions and 64 deletions
@@ -5,26 +5,26 @@ import { post } from "@rails/request.js"
export default class extends Controller {
static classes = ["filtersSet"]
static targets = ["field", "form"]
static values = { refreshSaveToggleUrl: String }
static values = { refreshUrl: String }
initialize() {
this.debouncedChange = debounce(this.change.bind(this), 50)
this.debouncedToggle = debounce(this.#toggle.bind(this), 50)
}
connect() {
this.change()
this.#toggle()
}
change() {
this.#toggleFiltersSetClass()
this.#toggle()
this.#refreshSaveToggleButton()
}
async fieldTargetConnected(field) {
this.debouncedChange()
this.debouncedToggle()
}
#toggleFiltersSetClass(shouldAdd) {
#toggle() {
this.element.classList.toggle(this.filtersSetClass, this.#hasFiltersSet)
}
@@ -47,7 +47,7 @@ export default class extends Controller {
}
#refreshSaveToggleButton() {
post(this.refreshSaveToggleUrlValue, {
post(this.refreshUrlValue, {
body: this.#collectFilterFormData(),
responseKind: "turbo-stream"
})