Sha256: fc63a20b5b59f95606602321818a233ef978a470547a0a0caef06f6c2b405d44

Contents?: true

Size: 1.13 KB

Versions: 9

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Lcms
  module Engine
    module Admin
      class ResourceBulkEditsController < AdminController
        before_action :load_resources

        def new
          if @resources.any?
            @resource = BulkEditResourcesService.new(@resources).init_sample
          else
            redirect_to lcms_engine.admin_resources_path, alert: t('.no_resources')
          end
        end

        def create
          BulkEditResourcesService.new(@resources, resource_params).edit!
          resources_count_msg = t(:resources_count, count: @resources.count)
          notice = t('.success', count: @resources.count, resources_count: resources_count_msg)
          redirect_to lcms_engine.admin_resources_path, notice: notice
        end

        private

        def load_resources
          @resources = Resource.where(id: params[:ids]).includes(:standards)
        end

        def resource_params
          params.require(:resource)
            .permit(standard_ids: [],
                    grades: [],
                    resource_type_list: [],
                    tag_list: [])
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb
lcms-engine-0.5.4 app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb
lcms-engine-0.5.3 app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb
lcms-engine-0.5.2 app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb
lcms-engine-0.5.1 app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb
lcms-engine-0.5.0 app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb
lcms-engine-0.4.2 app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb
lcms-engine-0.4.1 app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb
lcms-engine-0.4.0 app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb