Sha256: c0ae5c7fba42256ee7bc4bfce41bb965bd66d9111424750179ed966df1f4eed1

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

# frozen_string_literal: true

module Decidim
  module TermCustomizer
    class AdminEngine < ::Rails::Engine
      isolate_namespace Decidim::TermCustomizer::Admin

      paths["db/migrate"] = nil
      paths["lib/tasks"] = nil

      routes do
        resources :translation_sets, path: :sets, except: [:show] do
          resources :translations, except: [:show] do
            collection do
              post :export
              get :import, action: :new_import
              post :import
              resource :translations_destroy, only: [:new, :destroy]
            end
          end
          resources :add_translations, only: [:index, :create] do
            collection do
              get :search
            end
          end
        end

        resources :caches, only: [:index] do
          collection do
            delete :clear
          end
        end

        root to: "translation_sets#index"
      end

      initializer "decidim_term_customizer.admin_mount_routes" do
        Decidim::Core::Engine.routes do
          mount Decidim::TermCustomizer::AdminEngine, at: "/admin/term_customizer", as: "decidim_admin_term_customizer"
        end
      end

      initializer "decidim_term_customizer.admin_assets" do |app|
        app.config.assets.precompile += %w(translation_sets_admin_manifest.js)
      end

      initializer "decidim_term_customizer.admin_menu" do
        Decidim.menu :admin_menu do |menu|
          menu.item I18n.t("menu.term_customizer", scope: "decidim.term_customizer"),
                    decidim_admin_term_customizer.translation_sets_path,
                    icon_name: "text",
                    position: 7.1,
                    active: :inclusive,
                    if: allowed_to?(:update, :organization, organization: current_organization)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-term_customizer-0.17.1 lib/decidim/term_customizer/admin_engine.rb