Class: SolidusAdmin::Users::Index::Component
- Inherits:
-
SolidusAdmin::UsersAndRoles::Component
- Object
- SolidusAdmin::UsersAndRoles::Component
- SolidusAdmin::Users::Index::Component
- Includes:
- LastLoginHelper
- Defined in:
- app/components/solidus_admin/users/index/component.rb
Instance Method Summary collapse
- #batch_actions ⇒ Object
- #columns ⇒ Object
- #filters ⇒ Object
- #model_class ⇒ Object
- #page_actions ⇒ Object
- #row_url(user) ⇒ Object
- #scopes ⇒ Object
- #search_key ⇒ Object
- #search_url ⇒ Object
Methods included from LastLoginHelper
Instance Method Details
#batch_actions ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'app/components/solidus_admin/users/index/component.rb', line 31 def batch_actions [ { label: t('.batch_actions.delete'), action: solidus_admin.users_path, method: :delete, icon: 'delete-bin-7-line', }, ] end |
#columns ⇒ Object
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 |
# File 'app/components/solidus_admin/users/index/component.rb', line 63 def columns [ { header: :email, data: :email, }, { header: :roles, data: ->(user) do roles = user.spree_roles.presence || [Spree::Role.new(name: 'customer')] safe_join(roles.map { color = case _1.name when 'admin' then :blue when 'customer' then :green else :graphite_light end render component('ui/badge').new(name: _1.name, color:) }) end, }, { header: :order_count, data: ->(user) { user.order_count }, }, { header: :lifetime_value, data: -> { _1.display_lifetime_value.to_html }, }, { header: :last_active, data: ->(user) { last_login(user) }, }, ] end |
#filters ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'app/components/solidus_admin/users/index/component.rb', line 52 def filters [ { label: Spree::Role.model_name.human.pluralize, attribute: "spree_roles_id", predicate: "in", options: Spree::Role.pluck(:name, :id) } ] end |
#model_class ⇒ Object
6 7 8 |
# File 'app/components/solidus_admin/users/index/component.rb', line 6 def model_class Spree.user_class end |
#page_actions ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/components/solidus_admin/users/index/component.rb', line 22 def page_actions render component("ui/button").new( tag: :a, text: t('.add'), href: spree.new_admin_user_path, icon: "add-line", ) end |
#row_url(user) ⇒ Object
18 19 20 |
# File 'app/components/solidus_admin/users/index/component.rb', line 18 def row_url(user) solidus_admin.edit_user_path(user) end |
#scopes ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'app/components/solidus_admin/users/index/component.rb', line 42 def scopes [ { name: :all, label: t('.scopes.all'), default: true }, { name: :customers, label: t('.scopes.customers') }, { name: :admin, label: t('.scopes.admin') }, { name: :with_orders, label: t('.scopes.with_orders') }, { name: :without_orders, label: t('.scopes.without_orders') }, ] end |
#search_key ⇒ Object
10 11 12 |
# File 'app/components/solidus_admin/users/index/component.rb', line 10 def search_key :email_cont end |
#search_url ⇒ Object
14 15 16 |
# File 'app/components/solidus_admin/users/index/component.rb', line 14 def search_url solidus_admin.users_path end |