Sha256: b7aa49049c0da89f4f71fa31c4f9462bf4e64c2610aa6eb8cb57d9e52c6c61fa

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

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
      attach_breadcrumbs
    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 attach_breadcrumbs
      add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
      add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
      add_breadcrumb t(:'spotlight.curation.sidebar.translations')
    end

    def exhibit_params
      params.require(:exhibit).permit(translations_attributes: %i[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

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.9 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-3.0.0.alpha.8 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-3.0.0.alpha.7 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-3.0.0.alpha.6 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-3.0.0.alpha.5 app/controllers/spotlight/translations_controller.rb
blacklight-spotlight-3.0.0.alpha.4 app/controllers/spotlight/translations_controller.rb