Sha256: 62c4b6b644851d09a897ea62bf835eca5753663af1491d46b523a8400edd11c3

Contents?: true

Size: 1.44 KB

Versions: 62

Compression:

Stored size: 1.44 KB

Contents

module Workarea
  module Admin
    class BulkActionProductEditsController < Admin::ApplicationController
      required_permissions :catalog
      before_action :find_bulk_action

      def edit
      end

      def update
        @bulk_action.reset_to_default!

        if @bulk_action.update_attributes(params[:bulk_action])
          flash[:success] =
            t('workarea.admin.bulk_action_product_edits.flash_messages.success')
          redirect_to review_bulk_action_product_edit_path(@bulk_action)
        else
          flash[:error] =
            t('workarea.admin.bulk_action_product_edits.flash_messages.error')
          render :edit
        end
      end

      def review
      end

      def publish
        release = SavePublishing.new(nil, params).release

        if release.nil? || release.valid?
          @bulk_action.update_attributes(release_id: release.try(:id))
          PublishBulkAction.perform_async(@bulk_action.id)

          flash[:success] =
            t('workarea.admin.bulk_action_product_edits.flash_messages.publish')

          redirect_to catalog_products_path
        else
          flash[:error] = release.errors.full_messages
          render :review
        end
      end

      private

      def find_bulk_action
        model = BulkAction::ProductEdit.find(params[:id])
        @bulk_action = Admin::BulkActionProductEditViewModel.new(
          model,
          view_model_options
        )
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.5.15 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.36 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.14 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.35 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.13 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.34 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.12 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.33 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.11 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.10 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.32 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.9 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.31 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.8 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.30 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.7 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.29 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.6 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.28 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.5 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb