Sha256: 160a235184cb4ff504e3e26dcddccd1115efdfb7df226aefc4a9a81a07147cf8

Contents?: true

Size: 1.45 KB

Versions: 76

Compression:

Stored size: 1.45 KB

Contents

module Spree
  module Admin
    class ShippingMethodsController < ResourceController
      before_action :load_data, except: :index
      before_action :set_shipping_category, only: [:create, :update]
      before_action :set_zones, only: [:create, :update]

      def destroy
        @object.destroy

        flash[:success] = flash_message_for(@object, :successfully_removed)

        respond_with(@object) do |format|
          format.html { redirect_to collection_url }
          format.js  { render_js_for_destroy }
        end
      end

      private

      def set_shipping_category
        return true if params["shipping_method"][:shipping_categories] == ""
        @shipping_method.shipping_categories = Spree::ShippingCategory.where(:id => params["shipping_method"][:shipping_categories])
        @shipping_method.save
        params[:shipping_method].delete(:shipping_categories)
      end

      def set_zones
        return true if params["shipping_method"][:zones] == ""
        @shipping_method.zones = Spree::Zone.where(:id => params["shipping_method"][:zones])
        @shipping_method.save
        params[:shipping_method].delete(:zones)
      end

      def location_after_save
        edit_admin_shipping_method_path(@shipping_method)
      end

      def load_data
        @available_zones = Zone.order(:name)
        @tax_categories = Spree::TaxCategory.order(:name)
        @calculators = ShippingMethod.calculators.sort_by(&:name)
      end
    end
  end
end

Version data entries

76 entries across 76 versions & 2 rubygems

Version Path
spree_backend-3.1.14 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.13 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.12 app/controllers/spree/admin/shipping_methods_controller.rb
solidus_backend-1.2.3 app/controllers/spree/admin/shipping_methods_controller.rb
solidus_backend-1.1.4 app/controllers/spree/admin/shipping_methods_controller.rb
solidus_backend-1.0.7 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.11 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.10 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.9 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.8 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.7 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.6 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.5 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.4 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.3 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.2 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.0.10 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.1 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.0 app/controllers/spree/admin/shipping_methods_controller.rb
spree_backend-3.1.0.rc4 app/controllers/spree/admin/shipping_methods_controller.rb