-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3360 from projectblacklight/backport-3347
Backport: Extract BulkActionsComponent
- Loading branch information
Showing
4 changed files
with
30 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="dropdown bulk-actions-dropdown"> | ||
<%= button %> | ||
<div class="dropdown-menu" aria-labelledby="bulk-actions-button"> | ||
<% bulk_actions.each do |key, _config| %> | ||
<%= link_to t("spotlight.bulk_actions.#{key}.heading"), '#', class: 'dropdown-item', data: { toggle: "modal", "bs-toggle": "modal", target: "##{key.to_s.dasherize}-modal", "bs-target": "##{key.to_s.dasherize}-modal" } %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spotlight | ||
# Displays the "Bulk actions" button and dropdown | ||
class BulkActionComponent < ViewComponent::Base | ||
def initialize(bulk_actions:, button_classes: 'btn btn-secondary dropdown-toggle') | ||
@bulk_actions = bulk_actions | ||
@button_classes = button_classes | ||
super | ||
end | ||
|
||
attr_reader :button_classes, :bulk_actions | ||
|
||
def button | ||
button_tag t(:'spotlight.bulk_actions.label'), id: 'bulk-actions-button', class: button_classes, | ||
data: { toggle: 'dropdown', 'bs-toggle': 'dropdown' }, | ||
aria: { haspopup: true, expanded: false } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
<div class="dropdown bulk-actions-dropdown"> | ||
<button class="btn btn-secondary dropdown-toggle" type="button" id="bulk-actions-button" data-toggle="dropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
<%= t(:'spotlight.bulk_actions.label') %> | ||
</button> | ||
<div class="dropdown-menu" aria-labelledby="bulk-actions-button"> | ||
<% blacklight_config.bulk_actions.each do |key, _config| %> | ||
<%= link_to t("spotlight.bulk_actions.#{key}.heading"), '#', class: 'dropdown-item', data: { toggle: "modal", "bs-toggle": "modal", target: "##{key.to_s.dasherize}-modal", "bs-target": "##{key.to_s.dasherize}-modal" } %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<%= render Spotlight::BulkActionComponent.new(bulk_actions: blacklight_config.bulk_actions) %> | ||
|
||
<%= render_filtered_partials(blacklight_config.bulk_actions) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters