Class: SolidusAdmin::UI::Pages::Index::Component

Inherits:
BaseComponent
  • Object
show all
Includes:
Layout::PageHelpers
Defined in:
app/components/solidus_admin/ui/pages/index/component.rb

Defined Under Namespace

Classes: Tab

Instance Method Summary collapse

Constructor Details

#initialize(page:) ⇒ Component

Returns a new instance of Component.



23
24
25
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 23

def initialize(page:)
  @page = page
end

Instance Method Details

#back_urlObject



11
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 11

def back_url; end

#batch_actionsObject



18
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 18

def batch_actions; []; end

#columnsObject



21
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 21

def columns; []; end

#filtersObject



20
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 20

def filters; []; end

#model_classObject



10
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 10

def model_class; end

#next_page_pathObject



57
58
59
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 57

def next_page_path
  solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
end

#page_actionsObject



14
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 14

def page_actions; end

#prev_page_pathObject



53
54
55
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 53

def prev_page_path
  solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
end

#render_sidebarObject



101
102
103
104
105
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 101

def render_sidebar
  sidebar = self.sidebar

  page_with_sidebar_aside { sidebar } if sidebar
end

#render_tableObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 83

def render_table
  render component('ui/table').new(
    id: stimulus_id,
    data: {
      class: model_class,
      rows:,
      fade: -> { row_fade(_1) },
      prev: prev_page_path,
      next: next_page_path,
      columns:,
      batch_actions:,
      url: -> { row_url(_1) },
    },
    search: search_options,
    sortable: sortable_options,
  )
end

#render_titleObject



74
75
76
77
78
79
80
81
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 74

def render_title
  back_url = self.back_url

  safe_join [
    (page_header_back back_url if back_url),
    page_header_title(title),
  ]
end

#renderable_tabsObject



31
32
33
34
35
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 31

def renderable_tabs
  return unless tabs

  tabs.map { |tab| Tab.new(**tab) }
end

#row_fade(_record) ⇒ Object



27
28
29
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 27

def row_fade(_record)
  false
end

#row_url(_record) ⇒ Object



17
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 17

def row_url(_record); end

#rowsObject



49
50
51
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 49

def rows
  @page.records
end

#scopesObject



19
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 19

def scopes; []; end

#search_keyObject



12
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 12

def search_key; end

#search_nameObject



45
46
47
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 45

def search_name
  :q
end

#search_optionsObject



61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 61

def search_options
  return unless search_url

  {
    name: search_name,
    value: search_params,
    url: search_url,
    searchbar_key: search_key,
    filters:,
    scopes:,
  }
end

#search_paramsObject



41
42
43
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 41

def search_params
  params[:q]
end

#search_urlObject



13
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 13

def search_url; end


15
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 15

def sidebar; end

#sortable_optionsObject



16
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 16

def sortable_options; end

#tabsObject

Template methods



9
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 9

def tabs; end

#titleObject



37
38
39
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 37

def title
  model_class.model_name.human.pluralize
end

#turbo_framesObject



107
108
109
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 107

def turbo_frames
  []
end