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.27 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.26 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.45 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.25 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.23 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.44 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.22 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.43 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.21 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.42 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.20 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.41 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.19 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.40 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.18 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.39 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.17 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.38 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.5.16 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb
workarea-admin-3.4.37 app/controllers/workarea/admin/bulk_action_product_edits_controller.rb