Sha256: e977e7e4de2bfce872972a6252d9980981ba7cbb102de513cea97fd90f558cd9

Contents?: true

Size: 991 Bytes

Versions: 18

Compression:

Stored size: 991 Bytes

Contents

module Spotlight
  ##
  # Base CRUD controller for translations
  class TranslationsController < Spotlight::ApplicationController
    before_action :authenticate_user!, :set_language, :set_tab
    load_and_authorize_resource :exhibit, class: Spotlight::Exhibit

    def edit; end

    def update
      if current_exhibit.update(exhibit_params)
        I18n.reload! # reload since we're memoizing
        notice = t(:'helpers.submit.spotlight_default.updated', model: current_exhibit.class.model_name.human.downcase)
        redirect_to edit_exhibit_translations_path(current_exhibit, language: @language, tab: @tab), notice: notice
      else
        render 'edit'
      end
    end

    private

    def exhibit_params
      params.require(:exhibit).permit(translations_attributes: [:id, :locale, :key, :value])
    end

    def set_language
      @language = params[:language] || current_exhibit.available_locales.first
    end

    def set_tab
      @tab = params[:tab]
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.4.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.3.3 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.3.2 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.3.1 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.3.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.2.1 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.2.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.1.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.0.2 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.0.1 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.0.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.0.0.rc6 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.0.0.rc5 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.0.0.rc4 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.0.0.rc3 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.0.0.rc2 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.0.0.rc1 app/controllers/spotlight/translations_controller.rb