Class: SolidusAdmin::Products::Index::Component
- Inherits:
-
UI::Pages::Index::Component
- Object
- UI::Pages::Index::Component
- SolidusAdmin::Products::Index::Component
- Defined in:
- app/components/solidus_admin/products/index/component.rb
Instance Method Summary collapse
- #batch_actions ⇒ Object
- #columns ⇒ Object
- #filters ⇒ Object
- #image_column ⇒ Object
- #model_class ⇒ Object
- #name_column ⇒ Object
- #page_actions ⇒ Object
- #price_column ⇒ Object
- #row_url(product) ⇒ Object
- #scopes ⇒ Object
- #search_key ⇒ Object
- #search_url ⇒ Object
- #status_column ⇒ Object
- #stock_column ⇒ Object
Instance Method Details
#batch_actions ⇒ Object
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 |
# File 'app/components/solidus_admin/products/index/component.rb', line 29 def batch_actions [ { label: t('.batch_actions.delete'), action: solidus_admin.products_path, method: :delete, icon: 'delete-bin-7-line', require_confirmation: true, }, { label: t('.batch_actions.discontinue'), action: solidus_admin.discontinue_products_path, method: :put, icon: 'pause-circle-line', require_confirmation: true, }, { label: t('.batch_actions.activate'), action: solidus_admin.activate_products_path, method: :put, icon: 'play-circle-line', require_confirmation: true, }, ] end |
#columns ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'app/components/solidus_admin/products/index/component.rb', line 78 def columns [ image_column, name_column, status_column, price_column, stock_column, ] end |
#filters ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/components/solidus_admin/products/index/component.rb', line 66 def filters Spree::OptionType.all.map do |option_type| { label: option_type.presentation, combinator: 'or', attribute: "option_values_id", predicate: "in", options: option_type.option_values.pluck(:name, :id), } end end |
#image_column ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/components/solidus_admin/products/index/component.rb', line 88 def image_column { col: { class: "w-[72px]" }, header: tag.span('aria-label': t('.image'), role: 'text'), data: ->(product) do image = product.gallery.images.first or return render( component('ui/thumbnail').new( src: image.url(:small), alt: product.name ) ) end } end |
#model_class ⇒ Object
4 5 6 |
# File 'app/components/solidus_admin/products/index/component.rb', line 4 def model_class Spree::Product end |
#name_column ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'app/components/solidus_admin/products/index/component.rb', line 105 def name_column { header: :name, data: ->(product) do content_tag :div, product.name end } end |
#page_actions ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/components/solidus_admin/products/index/component.rb', line 20 def page_actions render component("ui/button").new( tag: :a, text: t('.add'), href: spree.new_admin_product_path, icon: "add-line", ) end |
#price_column ⇒ Object
128 129 130 131 132 133 134 135 |
# File 'app/components/solidus_admin/products/index/component.rb', line 128 def price_column { header: :price, data: ->(product) do content_tag :div, product.master.display_price&.to_html end } end |
#row_url(product) ⇒ Object
16 17 18 |
# File 'app/components/solidus_admin/products/index/component.rb', line 16 def row_url(product) solidus_admin.product_path(product) end |
#scopes ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'app/components/solidus_admin/products/index/component.rb', line 55 def scopes [ { name: :all, label: t('.scopes.all'), default: true }, { name: :in_stock, label: t('.scopes.in_stock') }, { name: :out_of_stock, label: t('.scopes.out_of_stock') }, { name: :available, label: t('.scopes.available') }, { name: :discontinued, label: t('.scopes.discontinued') }, { name: :deleted, label: t('.scopes.deleted') }, ] end |
#search_key ⇒ Object
8 9 10 |
# File 'app/components/solidus_admin/products/index/component.rb', line 8 def search_key :name_or_variants_including_master_sku_cont end |
#search_url ⇒ Object
12 13 14 |
# File 'app/components/solidus_admin/products/index/component.rb', line 12 def search_url solidus_admin.products_path end |
#status_column ⇒ Object
114 115 116 117 118 119 |
# File 'app/components/solidus_admin/products/index/component.rb', line 114 def status_column { header: :status, data: ->(product) { component('products/status').from_product(product) } } end |
#stock_column ⇒ Object
121 122 123 124 125 126 |
# File 'app/components/solidus_admin/products/index/component.rb', line 121 def stock_column { header: :stock, data: ->(product) { component('products/stock').from_product(product) } } end |