Sha256: 6b3d19e8af1b2201f4dcfb8c6d1d17fefcc46ab6bb79ae183a35593f0db88413

Contents?: true

Size: 1.43 KB

Versions: 8

Compression:

Stored size: 1.43 KB

Contents

module Spotlight
  ##
  # Edit and update an exhibit's appearance
  class AppearancesController < Spotlight::ApplicationController
    before_action :authenticate_user!
    load_and_authorize_resource id_param: :exhibit_id, instance_name: 'exhibit', class: 'Spotlight::Exhibit', parent: false

    def update
      if @exhibit.update(exhibit_params)
        notice = t(:'helpers.submit.spotlight_default.updated', model: @exhibit.class.model_name.human.downcase)
        redirect_to edit_exhibit_appearance_path(@exhibit), notice: notice
      else
        render 'edit'
      end
    end

    def edit
      add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
      add_breadcrumb t(:'spotlight.administration.sidebar.header'), exhibit_dashboard_path(@exhibit)
      add_breadcrumb t(:'spotlight.administration.sidebar.appearance'), edit_exhibit_appearance_path(@exhibit)
    end

    protected

    def exhibit_params
      params.require(:exhibit).permit(main_navigations_attributes: [:id, :display, :label, :weight],
                                      masthead_attributes: featured_image_params,
                                      thumbnail_attributes: featured_image_params)
    end

    def featured_image_params
      [
        :display,
        :source,
        :image,
        :remote_image_url,
        :document_global_id,
        :image_crop_x, :image_crop_y, :image_crop_w, :image_crop_h
      ]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
blacklight-spotlight-0.8.2 app/controllers/spotlight/appearances_controller.rb
blacklight-spotlight-0.8.1 app/controllers/spotlight/appearances_controller.rb
blacklight-spotlight-0.8.0 app/controllers/spotlight/appearances_controller.rb
blacklight-spotlight-0.7.2 app/controllers/spotlight/appearances_controller.rb
blacklight-spotlight-0.7.1 app/controllers/spotlight/appearances_controller.rb
blacklight-spotlight-0.7.0 app/controllers/spotlight/appearances_controller.rb
blacklight-spotlight-0.6.0 app/controllers/spotlight/appearances_controller.rb
blacklight-spotlight-0.5.0 app/controllers/spotlight/appearances_controller.rb