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.27 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.26 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.25 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.23 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.22 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.21 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.20 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.19 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.18 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.17 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.16 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.15 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.14 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.13 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.12 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.11 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.10 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.9 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.8 app/controllers/workarea/admin/fulfillment_skus_controller.rb
workarea-admin-3.5.7 app/controllers/workarea/admin/fulfillment_skus_controller.rb