Sha256: 66e887ff995503d2d19379c450737c13e7f360985f78644f49f185e19c0bf49a

Contents?: true

Size: 1.27 KB

Versions: 46

Compression:

Stored size: 1.27 KB

Contents

module Hyrax
  class WorkflowActionsController < ApplicationController
    before_action :authenticate_user!

    def update
      if workflow_action_form.save
        after_update_response
      else
        respond_to do |wants|
          wants.html { render 'hyrax/base/unauthorized', status: :unauthorized }
          wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
        end
      end
    end

    private

      def curation_concern
        @curation_concern ||= ActiveFedora::Base.find(params[:id])
      end

      def workflow_action_form
        @workflow_action_form ||= Hyrax::Forms::WorkflowActionForm.new(
          current_ability: current_ability,
          work: curation_concern,
          attributes: workflow_action_params
        )
      end

      def workflow_action_params
        params.require(:workflow_action).permit(:name, :comment)
      end

      def after_update_response
        respond_to do |wants|
          wants.html { redirect_to [main_app, curation_concern], notice: "The #{curation_concern.human_readable_type} has been updated." }
          wants.json { render 'hyrax/base/show', status: :ok, location: polymorphic_path([main_app, curation_concern]) }
        end
      end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.9.5 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.9.4 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.9.3 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.9.2 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.9.1 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.9.0 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.8.0 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.7.2 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.7.1 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.7.0 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.6.0 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.5.1 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.5.0 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-3.0.0.pre.beta2 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.4.1 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-3.0.0.pre.beta1 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.4.0 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.3.3 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-2.3.2 app/controllers/hyrax/workflow_actions_controller.rb