Sha256: fecb03203613cd942bdf60158a76d37cab0f0c97ed39f85c1fc0f7b63b0713a5

Contents?: true

Size: 1.33 KB

Versions: 29

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true
module Hyrax
  class ContentBlocksController < ApplicationController
    load_and_authorize_resource
    with_themed_layout 'dashboard'

    def edit
      add_breadcrumb t(:'hyrax.controls.home'), root_path
      add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
      add_breadcrumb t(:'hyrax.admin.sidebar.configuration'), '#'
      add_breadcrumb t(:'hyrax.admin.sidebar.content_blocks'), hyrax.edit_content_blocks_path
    end

    def update
      respond_to do |format|
        if @content_block.update(value: update_value_from_params)
          format.html { redirect_to hyrax.edit_content_blocks_path, notice: t(:'hyrax.content_blocks.updated') }
        else
          format.html { render :edit }
        end
      end
    end

    private

    def permitted_params
      params.require(:content_block).permit(:marketing,
                                            :announcement,
                                            :researcher)
    end

    # When a request comes to the controller, it will be for one and
    # only one of the content blocks. Params always looks like:
    #   {'about_page' => 'Here is an awesome about page!'}
    # So reach into permitted params and pull out the first value.
    def update_value_from_params
      permitted_params.values.first
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/controllers/hyrax/content_blocks_controller.rb
hyrax-5.0.4 app/controllers/hyrax/content_blocks_controller.rb
hyrax-5.0.3 app/controllers/hyrax/content_blocks_controller.rb
hyrax-5.0.2 app/controllers/hyrax/content_blocks_controller.rb
hyrax-5.0.1 app/controllers/hyrax/content_blocks_controller.rb
hyrax-5.0.0 app/controllers/hyrax/content_blocks_controller.rb
hyrax-5.0.0.rc3 app/controllers/hyrax/content_blocks_controller.rb
hyrax-5.0.0.rc2 app/controllers/hyrax/content_blocks_controller.rb
hyrax-5.0.0.rc1 app/controllers/hyrax/content_blocks_controller.rb
hyrax-3.6.0 app/controllers/hyrax/content_blocks_controller.rb
hyrax-4.0.0 app/controllers/hyrax/content_blocks_controller.rb
hyrax-4.0.0.rc3 app/controllers/hyrax/content_blocks_controller.rb
hyrax-4.0.0.rc2 app/controllers/hyrax/content_blocks_controller.rb
hyrax-4.0.0.rc1 app/controllers/hyrax/content_blocks_controller.rb
hyrax-3.5.0 app/controllers/hyrax/content_blocks_controller.rb
hyrax-4.0.0.beta2 app/controllers/hyrax/content_blocks_controller.rb
hyrax-3.4.2 app/controllers/hyrax/content_blocks_controller.rb
hyrax-4.0.0.beta1 app/controllers/hyrax/content_blocks_controller.rb
hyrax-3.4.1 app/controllers/hyrax/content_blocks_controller.rb
hyrax-3.4.0 app/controllers/hyrax/content_blocks_controller.rb