Class: SolidusAdmin::Users::StoreCredits::Index::Component
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- SolidusAdmin::Users::StoreCredits::Index::Component
- Includes:
- Layout::PageHelpers
- Defined in:
- app/components/solidus_admin/users/store_credits/index/component.rb
Instance Method Summary collapse
- #columns ⇒ Object
-
#initialize(user:, store_credits:) ⇒ Component
constructor
A new instance of Component.
- #model_class ⇒ Object
- #new_store_credit_path ⇒ Object
- #rows ⇒ Object
- #show_path(store_credit) ⇒ Object
- #tabs ⇒ Object
Constructor Details
#initialize(user:, store_credits:) ⇒ Component
Returns a new instance of Component.
6 7 8 9 |
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 6 def initialize(user:, store_credits:) @user = user @store_credits = store_credits end |
Instance Method Details
#columns ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 57 def columns [ { header: :credited, col: { class: "w-[12%]" }, data: ->(store_credit) do link_to store_credit.display_amount.to_html, show_path(store_credit), class: "body-link text-sm" end }, { header: :authorized, col: { class: "w-[13%]" }, data: ->(store_credit) do link_to store_credit..to_html, show_path(store_credit), class: "body-link text-sm" end }, { header: :used, col: { class: "w-[9%]" }, data: ->(store_credit) do link_to store_credit.display_amount_used.to_html, show_path(store_credit), class: "body-link text-sm" end }, { header: :type, col: { class: "w-[13%]" }, data: ->(store_credit) do component('ui/badge').new(name: store_credit.credit_type.name, color: :blue) end }, { header: :created_by, col: { class: "w-[22%]" }, data: ->(store_credit) do content_tag :div, store_credit.created_by_email, class: "text-sm" end }, { header: :issued_on, col: { class: "w-[16%]" }, data: ->(store_credit) do content_tag :span, I18n.l(store_credit.created_at.to_date), class: "text-sm" end }, { header: :invalidated, col: { class: "w-[15%]" }, data: ->(store_credit) do if store_credit.invalidated? component('ui/badge').new(name: :yes, color: :red, size: :m) else component('ui/badge').new(name: :no, color: :green, size: :m) end end } ] end |
#model_class ⇒ Object
11 12 13 |
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 11 def model_class Spree::StoreCredit end |
#new_store_credit_path ⇒ Object
53 54 55 |
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 53 def new_store_credit_path solidus_admin.new_user_store_credit_path(user_id: @user.id) end |
#rows ⇒ Object
45 46 47 |
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 45 def rows @store_credits end |
#show_path(store_credit) ⇒ Object
49 50 51 |
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 49 def show_path(store_credit) solidus_admin.user_store_credit_path(@user, store_credit) end |
#tabs ⇒ Object
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 |
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 15 def tabs [ { text: t('.account'), href: solidus_admin.user_path(@user), current: false, }, { text: t('.addresses'), href: solidus_admin.addresses_user_path(@user), current: false, }, { text: t('.order_history'), href: solidus_admin.orders_user_path(@user), current: false, }, { text: t('.items'), href: spree.items_admin_user_path(@user), current: false, }, { text: t('.store_credit'), href: solidus_admin.user_store_credits_path(@user), current: true, }, ] end |