Sha256: c2df3cbb1404d2d85c5f0b3d0cdb9ba0900730c72218766539a934068be99a57

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true
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 ||= Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: params[:id], use_valkyrie: false)
    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

6 entries across 6 versions & 1 rubygems

Version Path
hyrax-3.0.2 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-3.0.1 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-3.0.0 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-3.0.0.pre.rc4 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-3.0.0.pre.rc3 app/controllers/hyrax/workflow_actions_controller.rb
hyrax-3.0.0.pre.rc2 app/controllers/hyrax/workflow_actions_controller.rb