Sha256: fdad0c4cbeb547df49117fea5b292b62f07eb6d9ddb2c4b1eb45c12bab7d048c

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

module Spree
  module Admin
    module AdjustmentsHelper
      def adjustment_state(adjustment)
        state = adjustment.state.to_sym
        icon = { closed: 'lock', open: 'unlock' }
        content_tag(:span, '', class: icon[state])
      end

      def display_adjustable(adjustable)
        case adjustable
          when Spree::LineItem
            display_line_item(adjustable)
          when Spree::Shipment
            display_shipment(adjustable)
          when Spree::Order
            display_order(adjustable)
        end

      end

      private

      def display_line_item(line_item)
        variant = line_item.variant
        parts = []
        parts << variant.product.name
        parts << "(#{variant.options_text})" if variant.options_text.present?
        parts << line_item.display_total
        parts.join("<br>").html_safe
      end

      def display_shipment(shipment)
        "#{Spree.t(:shipment)} ##{shipment.number}<br>#{shipment.display_cost}".html_safe
      end

      def display_order(order)
        Spree.t(:order)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_backend-2.3.1 app/helpers/spree/admin/adjustments_helper.rb
spree_backend-2.2.4 app/helpers/spree/admin/adjustments_helper.rb
spree_backend-2.2.3 app/helpers/spree/admin/adjustments_helper.rb
spree_backend-2.3.0 app/helpers/spree/admin/adjustments_helper.rb
spree_backend-2.2.2 app/helpers/spree/admin/adjustments_helper.rb