Module: Tramway::Admin

Extended by:
AdditionalButtons, Navbar, Notifications, RecordsModels, SingletonModels, WelcomePageActions
Defined in:
lib/tramway/admin.rb,
lib/tramway/admin/engine.rb,
lib/tramway/admin/version.rb,
app/helpers/tramway/admin/cases_helper.rb,
app/jobs/tramway/admin/application_job.rb,
lib/tramway/admin/record_routes_helper.rb,
lib/tramway/admin/welcome_page_actions.rb,
app/helpers/tramway/admin/inputs_helper.rb,
app/helpers/tramway/admin/navbar_helper.rb,
app/helpers/tramway/admin/records_helper.rb,
app/helpers/tramway/admin/application_helper.rb,
app/mailers/tramway/admin/application_mailer.rb,
app/helpers/tramway/admin/russian_cases_helper.rb,
app/controllers/tramway/admin/singletons_controller.rb,
app/controllers/tramway/admin/application_controller.rb

Defined Under Namespace

Modules: AdditionalButtons, AdditionalButtonsBuilder, ApplicationHelper, CasesHelper, FocusGeneratorHelper, InputsHelper, Navbar, NavbarHelper, Notifications, RecordRoutesHelper, RecordsHelper, RecordsModels, RussianCasesHelper, SingletonHelper, SingletonModels, WelcomePageActions Classes: ApplicationController, ApplicationJob, ApplicationMailer, Engine, RecordsController, SingletonsController, WelcomeController

Constant Summary collapse

VERSION =
'1.26'

Class Attribute Summary collapse

Attributes included from WelcomePageActions

#welcome_page_actions

Class Method Summary collapse

Methods included from Navbar

navbar_items_for, navbar_structure

Methods included from Notifications

notificable_queries, set_notificable_queries

Methods included from AdditionalButtons

additional_buttons, set_additional_buttons

Methods included from SingletonModels

set_singleton_models, singleton_models, singleton_models_for

Methods included from RecordsModels

available_models, available_models_for, set_available_models

Class Attribute Details

.customized_admin_navbar ⇒ Object (readonly)

Returns the value of attribute customized_admin_navbar.



24
25
26
# File 'lib/tramway/admin.rb', line 24

def customized_admin_navbar
  @customized_admin_navbar
end

Class Method Details

.action_is_available?(record, project:, role:, model:, action:) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/tramway/admin.rb', line 45

def action_is_available?(record, project:, role:, model:, action:)
  actions = select_actions(project: project, role: role, model: model)
  availability = actions&.select do |a|
    if a.is_a? Symbol
      a == action.to_sym
    elsif a.is_a? Hash
      a.keys.first.to_sym == action.to_sym
    end
  end&.first

  return false unless availability.present?
  return true if availability.is_a? Symbol

  return availability.values.first.call record
end

.engine_class(project) ⇒ Object



26
27
28
29
# File 'lib/tramway/admin.rb', line 26

def engine_class(project)
  class_name = "::Tramway::#{project.to_s.camelize}"
  class_name.classify.safe_constantize
end

.get_models_by_key(checked_models, project, role) ⇒ Object



35
36
37
# File 'lib/tramway/admin.rb', line 35

def get_models_by_key(checked_models, project, role)
  checked_models && checked_models != [] && checked_models[project][role]&.keys || []
end

.models_array(models_type:, role:) ⇒ Object



39
40
41
42
43
# File 'lib/tramway/admin.rb', line 39

def models_array(models_type:, role:)
  instance_variable_get("@#{models_type}_models")&.map do |projects|
    projects.last[role]&.keys
  end&.flatten || []
end

.project_is_engine?(project) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/tramway/admin.rb', line 31

def project_is_engine?(project)
  engine_class(project)
end

.select_actions(project:, role:, model:) ⇒ Object



61
62
63
# File 'lib/tramway/admin.rb', line 61

def select_actions(project:, role:, model:)
  @singleton_models&.dig(project, role, model) || @available_models&.dig(project, role, model)
end