Sha256: 76929832dc9caa69bf36c01eb01fc50877861da9f5f117076235b89989ff5015

Contents?: true

Size: 1.53 KB

Versions: 23

Compression:

Stored size: 1.53 KB

Contents

require 'tramway/admin/engine'

module Tramway
  User.layout_path = 'tramway/admin/application'

  module Admin
    class << self
      def set_available_models(*models, project:)
        @available_models ||= {}
        @available_models[project] ||= []
        @available_models[project] += models
      end

      def available_models_for(project)
        (@available_models[project.to_sym] || []) + "::Tramway::#{project.to_s.camelize}".constantize.dependencies.map do |dependency|
          @available_models[dependency]
        end.flatten.compact
      end

      def available_models
        @available_models.values.flatten
      end

      def set_singleton_models(*models, project:)
        @singleton_models ||= {}
        @singleton_models[project] ||= []
        @singleton_models[project] += models
      end

      def singleton_models_for(project)
        (@singleton_models[project.to_sym] || []) + "::Tramway::#{project.to_s.camelize}".constantize.dependencies.map do |dependency|
          @singleton_models[dependency]
        end.flatten.compact
      end

      def singleton_models
        @singleton_models.values.flatten
      end

      def set_additional_buttons(buttons, project:)
        @additional_buttons ||= {}
        @additional_buttons[project] ||= {}
        @additional_buttons[project].merge! buttons
      end

      def additional_buttons(view: nil, record: nil, project: nil)
        @additional_buttons&.dig record, view
      end

      def customized_admin_navbar
        @customized_admin_navbar
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
tramway-admin-1.7.3 lib/tramway/admin.rb
tramway-admin-1.7.2 lib/tramway/admin.rb
tramway-admin-1.7.1 lib/tramway/admin.rb
tramway-admin-1.7 lib/tramway/admin.rb
tramway-admin-1.6.3 lib/tramway/admin.rb
tramway-admin-1.6.2 lib/tramway/admin.rb
tramway-admin-1.6.1 lib/tramway/admin.rb
tramway-admin-1.6 lib/tramway/admin.rb
tramway-admin-1.5.1 lib/tramway/admin.rb
tramway-admin-1.5 lib/tramway/admin.rb
tramway-admin-1.4 lib/tramway/admin.rb
tramway-admin-1.3.9 lib/tramway/admin.rb
tramway-admin-1.3.8 lib/tramway/admin.rb
tramway-admin-1.3.7 lib/tramway/admin.rb
tramway-admin-1.3.6 lib/tramway/admin.rb
tramway-admin-1.3.5 lib/tramway/admin.rb
tramway-admin-1.3.4 lib/tramway/admin.rb
tramway-admin-1.3.3 lib/tramway/admin.rb
tramway-admin-1.3.2 lib/tramway/admin.rb
tramway-admin-1.3.1 lib/tramway/admin.rb