Sha256: 62ee6d07d888e813bcde1eb8553d67073edc13ff359ef8b83898de0f4a1b263a

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

class SolidusAdmin::ShippingMethods::Index::Component < SolidusAdmin::Shipping::Component
  def model_class
    Spree::ShippingMethod
  end

  def row_url(shipping_method)
    spree.edit_admin_shipping_method_path(shipping_method)
  end

  def search_url
    solidus_admin.shipping_methods_path
  end

  def search_key
    :name_or_description_cont
  end

  def page_actions
    render component("ui/button").new(
      tag: :a,
      text: t('.add'),
      href: spree.new_admin_shipping_method_path,
      icon: "add-line",
      class: "align-self-end w-full",
    )
  end

  def batch_actions
    [
      {
        label: t('.batch_actions.delete'),
        action: solidus_admin.shipping_methods_path,
        method: :delete,
        icon: 'delete-bin-7-line',
      },
    ]
  end

  def columns
    [
      {
        header: :name,
        data: -> { [_1.admin_name.presence, _1.name].compact.join(' / ') },
      },
      {
        header: :zone,
        data: -> { _1.zones.pluck(:name).to_sentence },
      },
      {
        header: :calculator,
        data: -> { _1.calculator&.description },
      },
      {
        header: :available_to_users,
        data: -> { _1.available_to_users? ? component('ui/badge').yes : component('ui/badge').no },
      },
    ]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_admin-0.3.2 app/components/solidus_admin/shipping_methods/index/component.rb
solidus_admin-0.3.1 app/components/solidus_admin/shipping_methods/index/component.rb
solidus_admin-0.3.0 app/components/solidus_admin/shipping_methods/index/component.rb