Sha256: dc6c11d2203ae0391fe650200863b71c14804d12f9a7da623cb6dc70a2993921

Contents?: true

Size: 1.31 KB

Versions: 11

Compression:

Stored size: 1.31 KB

Contents

module Locomotive
  class TranslationsController < BaseController

    account_required & within_site

    before_action :load_translation, only: [:edit, :update]

    helper_method :translation_nav_params

    def index
      authorize Translation
      @translations = service.all(params.slice(:page, :per_page, :q, :filter_by))
      respond_with @translations
    end

    def edit
      authorize @translation
      respond_with @translation
    end

    def update
      authorize @translation
      service.update(@translation, translation_params[:values].to_h)
      respond_with @translation, location: translations_path(current_site, translation_nav_params)
    end

    def bulk_destroy
      authorize Translation, :destroy?
      service.bulk_destroy(params[:ids].split(','))
      respond_with current_site, location: translations_path(current_site, translation_nav_params)
    end

    protected

    def load_translation
      @translation = current_site.translations.find(params[:id])
    end

    def translation_params
      params.require(:translation).permit(values: current_site.locales)
    end

    def translation_nav_params
      params.permit(:filter_by, :q, :page, :per_page)
    end

    def service
      @service ||= Locomotive::TranslationService.new(current_site, current_locomotive_account)
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/controllers/locomotive/translations_controller.rb
locomotivecms-4.2.0.alpha1 app/controllers/locomotive/translations_controller.rb
locomotivecms-4.1.1 app/controllers/locomotive/translations_controller.rb
locomotivecms-4.1.0 app/controllers/locomotive/translations_controller.rb
locomotivecms-4.1.0.rc1 app/controllers/locomotive/translations_controller.rb
locomotivecms-4.0.3 app/controllers/locomotive/translations_controller.rb
locomotivecms-4.0.2 app/controllers/locomotive/translations_controller.rb
locomotivecms-4.0.1 app/controllers/locomotive/translations_controller.rb
locomotivecms-4.0.0 app/controllers/locomotive/translations_controller.rb
locomotivecms-4.0.0.rc0 app/controllers/locomotive/translations_controller.rb
locomotivecms-4.0.0.alpha3 app/controllers/locomotive/translations_controller.rb