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 |
# File 'app/components/solidus_admin/products/index/component.rb', line 29 def batch_actions [ { display_name: t('.batch_actions.delete'), action: solidus_admin.products_path, method: :delete, icon: 'delete-bin-7-line', }, { display_name: t('.batch_actions.discontinue'), action: solidus_admin.discontinue_products_path, method: :put, icon: 'pause-circle-line', }, { display_name: t('.batch_actions.activate'), action: solidus_admin.activate_products_path, method: :put, icon: 'play-circle-line', }, ] end |
#columns ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'app/components/solidus_admin/products/index/component.rb', line 75 def columns [ image_column, name_column, status_column, price_column, stock_column, ] end |
#filters ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/components/solidus_admin/products/index/component.rb', line 63 def filters Spree::OptionType.all.map do |option_type| { presentation: option_type.presentation, combinator: 'or', attribute: "variants_option_values", predicate: "in", options: option_type.option_values.pluck(:name, :id), } end end |
#image_column ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/components/solidus_admin/products/index/component.rb', line 85 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
102 103 104 105 106 107 108 109 |
# File 'app/components/solidus_admin/products/index/component.rb', line 102 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
125 126 127 128 129 130 131 132 |
# File 'app/components/solidus_admin/products/index/component.rb', line 125 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
52 53 54 55 56 57 58 59 60 61 |
# File 'app/components/solidus_admin/products/index/component.rb', line 52 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
111 112 113 114 115 116 |
# File 'app/components/solidus_admin/products/index/component.rb', line 111 def status_column { header: :status, data: ->(product) { component('products/status').from_product(product) } } end |
#stock_column ⇒ Object
118 119 120 121 122 123 |
# File 'app/components/solidus_admin/products/index/component.rb', line 118 def stock_column { header: :stock, data: ->(product) { component('products/stock').from_product(product) } } end |