Module: Tramway::Admin
- Extended by:
- AdditionalButtons, Forms, 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: ActionsHelper, AdditionalButtons, AdditionalButtonsBuilder, ApplicationHelper, CasesHelper, FocusGeneratorHelper, Forms, InputsHelper, Navbar, NavbarHelper, Notifications, RecordRoutesHelper, RecordsHelper, RecordsModels, RussianCasesHelper, SingletonHelper, SingletonModels, WelcomePageActions Classes: ApplicationController, ApplicationJob, ApplicationMailer, Engine, HasAndBelongsToManyRecordsController, RecordsController, SingletonsController, WelcomeController
Constant Summary collapse
- VERSION =
'1.28'
Class Attribute Summary collapse
-
.customized_admin_navbar ⇒ Object
readonly
Returns the value of attribute customized_admin_navbar.
Attributes included from WelcomePageActions
Attributes included from Forms
Class Method Summary collapse
- .action_is_available?(record, project:, role:, model_name:, action:) ⇒ Boolean
- .engine_class(project) ⇒ Object
- .get_models_by_key(checked_models, project, role) ⇒ Object
- .models_array(models_type:, role:) ⇒ Object
- .project_is_engine?(project) ⇒ Boolean
- .select_actions(project:, role:, model_name:) ⇒ Object
- .stringify_keys(hash) ⇒ Object
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.
26 27 28 |
# File 'lib/tramway/admin.rb', line 26 def @customized_admin_navbar end |
Class Method Details
.action_is_available?(record, project:, role:, model_name:, action:) ⇒ Boolean
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/tramway/admin.rb', line 55 def action_is_available?(record, project:, role:, model_name:, action:) actions = select_actions(project: project, role: role, model_name: model_name) 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 availability.values.first.call record end |
.engine_class(project) ⇒ Object
28 29 30 31 |
# File 'lib/tramway/admin.rb', line 28 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
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tramway/admin.rb', line 37 def get_models_by_key(checked_models, project, role) unless project.present? error = Tramway::Error.new( plugin: :admin, method: :get_models_by_key, message: "Looks like you have not create at lease one instance of #{Tramway::Core.application.model_class} model" ) raise error. end checked_models && checked_models != [] && checked_models[project][role]&.keys || [] end |
.models_array(models_type:, role:) ⇒ Object
49 50 51 52 53 |
# File 'lib/tramway/admin.rb', line 49 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
33 34 35 |
# File 'lib/tramway/admin.rb', line 33 def project_is_engine?(project) engine_class(project) end |
.select_actions(project:, role:, model_name:) ⇒ Object
71 72 73 |
# File 'lib/tramway/admin.rb', line 71 def select_actions(project:, role:, model_name:) stringify_keys(@singleton_models&.dig(project, role))&.dig(model_name) || stringify_keys(@available_models&.dig(project, role))&.dig(model_name) end |
.stringify_keys(hash) ⇒ Object
75 76 77 78 79 |
# File 'lib/tramway/admin.rb', line 75 def stringify_keys(hash) hash&.reduce({}) do |new_hash, pair| new_hash.merge! pair[0].to_s => pair[1] end end |