Skip to content
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
7 changes: 7 additions & 0 deletions lib/ruby_ui/combobox/combobox_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default class extends Controller {

static targets = [
"input",
"toggle",
"popover",
"item",
"emptyState",
Expand Down Expand Up @@ -39,6 +40,12 @@ export default class extends Controller {
return input.dataset.text || input.parentElement.innerText
}

toggleInputs() {
const isChecked = this.toggleTarget.checked
this.inputTargets.forEach(input => input.checked = isChecked)
this.updateTriggerContent()
}

updateTriggerContent() {
const checkedInputs = this.inputTargets.filter(input => input.checked)

Expand Down
20 changes: 20 additions & 0 deletions lib/ruby_ui/combobox/combobox_toggle_all_checkbox.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module RubyUI
class ComboboxToggleAllCheckbox < Base
def view_template
render RubyUI::ComboboxCheckbox.new(**attrs)
end

private

def default_attrs
{
data: {
ruby_ui__combobox_target: "toggle",
action: "change->ruby-ui--combobox#toggleInputs"
}
}
end
end
end