Wire up collection filtering: it should be performed in the generic cards view

This commit is contained in:
Jorge Manrubia
2025-10-02 10:30:32 +02:00
parent 08c6a38492
commit 2f38cb3ecd
3 changed files with 10 additions and 3 deletions
@@ -5,7 +5,7 @@ import { post } from "@rails/request.js"
export default class extends Controller {
static classes = ["filtersSet"]
static targets = ["field", "form"]
static values = { refreshUrl: String, noFilteringUrl: String }
static values = { refreshUrl: String, noFilteringUrl: String, cardsUrl: String }
initialize() {
this.debouncedToggle = debounce(this.#toggle.bind(this), 50)
@@ -31,6 +31,12 @@ export default class extends Controller {
this.debouncedToggle()
}
submitToGenericCardsView() {
this.formTarget.action = this.cardsUrlValue
this.formTarget.dataset.turboFrame = "top"
this.formTarget.requestSubmit()
}
#toggle() {
this.element.classList.toggle(this.filtersSetClass, this.#hasFiltersSet)
}