Sha256: 1610ecd1b27432d27402493f4978a291ee5fe140e12689b92ab3bf077f47056c

Contents?: true

Size: 1022 Bytes

Versions: 18

Compression:

Stored size: 1022 Bytes

Contents

# frozen_string_literal: true

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-3.0.0.alpha.2 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-3.0.0.alpha.1 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.13.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.12.1 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.12.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.11.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.10.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.9.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.8.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.7.2 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.7.1 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.7.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.6.1.1 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.6.1 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.6.0 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.5.2 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.5.1 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-2.5.0 app/controllers/spotlight/translations_controller.rb