Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[admin] Add scopes and controller helpers for ui/table #5516

Merged
merged 14 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Don't add filter hidden inputs if not required in ui/table
This helps keeping the query URL short.

Co-Authored-By: Rainer Dema <[email protected]>
  • Loading branch information
elia and rainerdema committed Nov 24, 2023
commit 13ab92ac6e363b8c8c878f910852b9df6f1843b9
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
checked: selection.checked,
size: :s,
form: @form,
"data-action": "#{stimulus_id}#search #{stimulus_id}#sortCheckboxes",
"data-action": "#{stimulus_id}#search #{stimulus_id}#sortCheckboxes #{stimulus_id}#updateHiddenInputs",
"data-#{stimulus_id}-target": "checkbox"
) %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class extends Controller {
useDebounce(this, { wait: 50 })
useClickOutside(this)
this.init()
this.updateHiddenInputs()
}

clickOutside(event) {
Expand Down Expand Up @@ -44,6 +45,15 @@ export default class extends Controller {
this.highlightFilter()
}

updateHiddenInputs() {
this.checkboxTargets.forEach((checkbox) => {
const hiddenElements = checkbox.parentElement.querySelectorAll("input[type='hidden']")
checkbox.checked
? hiddenElements.forEach(e => e.removeAttribute("disabled"))
: hiddenElements.forEach(e => e.setAttribute("disabled", true))
})
}

sortCheckboxes() {
const checkboxes = this.checkboxTargets

Expand Down