Sha256: 00985d55462af2831087020f30c602a4b517c01dc57503140d8821a795bdc502

Contents?: true

Size: 1.48 KB

Versions: 28

Compression:

Stored size: 1.48 KB

Contents

module Workarea
  module Admin
    class FulfillmentSkusController < Admin::ApplicationController
      required_permissions :catalog

      before_action :find_sku, except: :index
      after_action :track_index_filters, only: :index

      def index
        search = Search::AdminFulfillmentSkus.new(view_model_options)
        @search = SearchViewModel.new(search, view_model_options)
      end

      def show; end

      def create
        if @sku.save
          flash[:success] =
            t('workarea.admin.fulfillment_skus.flash_messages.created', id: @sku.id)
          redirect_to fulfillment_sku_path(@sku)
        else
          render :new, status: :unprocessable_entity
        end
      end

      def edit; end

      def update
        if @sku.update(params[:sku])
          flash[:success] = t('workarea.admin.fulfillment_skus.flash_messages.saved', id: @sku.id)
          redirect_to fulfillment_sku_path(@sku)
        else
          render :edit, status: :unprocessable_entity
        end
      end

      def destroy
        @sku.destroy

        flash[:success] = t('workarea.admin.fulfillment_skus.flash_messages.removed', id: @sku.id)
        redirect_to fulfillment_skus_path
      end

      private

      def find_sku
        model =
          if params[:id].present?
            Fulfillment::Sku.find_or_create_by(id: params[:id])
          else
            Fulfillment::Sku.new(params[:sku])
          end

        @sku = FulfillmentSkuViewModel.new(model)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-admin-3.5.6 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.5 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.4 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.3 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.2 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.1 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.0 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.0.beta.1 app/controllers/workarea/admin/fulfillment_skus_controller.rb