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
26
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 23

def initialize(page:)
  @page = page
  @tabs = tabs&.map { |tab| Tab.new(**tab) }
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



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

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



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

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

#render_sidebarObject



96
97
98
99
100
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 96

def render_sidebar
  sidebar = self.sidebar

  page_with_sidebar_aside { sidebar } if sidebar
end

#render_tableObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 78

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



69
70
71
72
73
74
75
76
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 69

def render_title
  back_url = self.back_url

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

#row_fade(_record) ⇒ Object



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

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



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

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



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

def search_name
  :q
end

#search_optionsObject



56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/components/solidus_admin/ui/pages/index/component.rb', line 56

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



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

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



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

def title
  model_class.model_name.human.pluralize
end

#turbo_framesObject



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

def turbo_frames
  []
end