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 dynamic filters to ui/table component #5376

Merged
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
Prev Previous commit
Next Next commit
Enable clickable filter labels for checkboxes
Enable functionality to allow users to toggle checkboxes by clicking
associated labels.
  • Loading branch information
rainerdema committed Oct 10, 2023
commit ef86996df98aa0eabe6aaa8cdeef2c9d54b0ca39
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
value="<%= selection.predicate.value %>">

<%= render component('ui/forms/checkbox').new(
id: selection.id,
name: selection.option.name,
value: selection.option.value,
checked: selection.checked,
Expand All @@ -56,7 +57,7 @@
"data-#{stimulus_id}-target": "checkbox"
) %>

<%= label_tag nil, selection.presentation, class: "ml-2 text-sm text-gray-700" %>
<%= label_tag selection.id, selection.presentation, class: "ml-2 text-sm text-gray-700" %>
</div>
<% end %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def initialize(
def before_render
@selections = @options.map.with_index do |(label, value), opt_index|
Selection.new(
"#{stimulus_id}--#{label}-#{value}",
label,
build(:attribute, @attribute, opt_index),
build(:predicate, @predicate, opt_index),
Expand Down Expand Up @@ -62,6 +63,6 @@ def checked?(value)
option: '[c][%<index>s][v][]'
}

Selection = Struct.new(:presentation, :attribute, :predicate, :option, :checked)
Selection = Struct.new(:id, :presentation, :attribute, :predicate, :option, :checked)
Attribute = Struct.new(:name, :value)
end