Class: EasyAdmin::BatchActionBarComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/easy_admin/batch_action_bar_component.rb

Instance Method Summary collapse

Methods inherited from BaseComponent

#easy_admin_url_helpers, #helpers, #rails_url_helpers

Methods included from Permissions::Component

#current_user_can?, #current_user_has_role?, #if_can, #if_has_role, #permission_attrs, #permission_button, #permission_case, #permission_classes, #permission_field, #permission_link, #unless_can, #unless_has_role

Methods included from FieldsHelper

#field_component, #render_field

Methods included from DashboardsHelper

#delta_badge_classes, #metric_value_classes, #render_card, #sparkline_color, #sparkline_points, #trend_direction, #trend_icon, #trend_indicator_classes

Constructor Details

#initialize(resource_class:, current_user: nil) ⇒ BatchActionBarComponent

Returns a new instance of BatchActionBarComponent.



3
4
5
6
# File 'app/components/easy_admin/batch_action_bar_component.rb', line 3

def initialize(resource_class:, current_user: nil)
  @resource_class = resource_class
  @current_user = current_user
end

Instance Method Details

#view_templateObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/components/easy_admin/batch_action_bar_component.rb', line 8

def view_template
  # iOS-style floating action bar
  div(
    class: "fixed bottom-0 inset-x-0 pb-safe z-50 pointer-events-none",
    data: { batch_selection_target: "actionBar" }
  ) do
    div(class: "px-4 pb-4 pointer-events-auto") do
      div(
        class: "bg-white/95 backdrop-blur-xl rounded-2xl shadow-2xl border border-gray-200/50 transform translate-y-full transition-all duration-300 ease-out opacity-0",
        style: "transform: translateY(100%); opacity: 0;",
        data: { batch_selection_target: "actionBarContent" }
      ) do
        # Top section with selection count and cancel
        div(class: "flex items-center justify-between px-5 py-3 border-b border-gray-200/50") do
          div(class: "flex items-center space-x-3") do
            # Selection indicator with animated background
            div(class: "relative") do
              div(class: "absolute inset-0 bg-blue-500 rounded-full animate-pulse opacity-20")
              div(class: "relative bg-blue-500 text-white text-sm font-semibold rounded-full px-3 py-1.5 min-w-[2rem] text-center") do
                span(data: { batch_selection_target: "counter" }) { "0" }
              end
            end
            
            span(class: "text-sm font-medium text-gray-700") do
              "selected"
            end
          end
          
          # Cancel button
          button(
            type: "button",
            class: "text-sm font-medium text-gray-500 hover:text-gray-700 transition-colors",
            data: { action: "click->batch-selection#clearSelection" }
          ) do
            "Cancel"
          end
        end
        
        # Actions section
        div(class: "p-3") do
          div(class: "flex flex-col sm:flex-row sm:flex-wrap gap-2") do
            available_batch_actions.each do |action_class|
              render_ios_action_button(action_class)
            end
          end
        end
      end
    end
  end
end