Class: Ez::Settings::BaseCell
- Inherits:
-
Cell::ViewModel
- Object
- Cell::ViewModel
- Ez::Settings::BaseCell
- Includes:
- RequestDispatcher
- Defined in:
- app/cells/ez/settings/base_cell.rb
Constant Summary collapse
- SCOPE =
'ez_settings'
- LABEL =
'label'
- DESCRIPTION =
'description'
- INTERFACES =
'interfaces'
- GROUPS =
'groups'
- KEYS =
'keys'
- ACTIONS =
'actions'
- SAVE =
'save'
- CANCEL =
'cancel'
Class Method Summary collapse
Instance Method Summary collapse
- #controller ⇒ Object
- #css_for(item, dynamic: nil) ⇒ Object
- #css_map ⇒ Object
- #group_link(group, _options = {}) ⇒ Object
- #group_path(group) ⇒ Object
- #i18n_group_description(group) ⇒ Object
- #i18n_group_label(group) ⇒ Object
- #i18n_key_label(key) ⇒ Object
Methods included from RequestDispatcher
Class Method Details
.form ⇒ Object
23 24 25 26 27 28 |
# File 'app/cells/ez/settings/base_cell.rb', line 23 def self.form include ActionView::Helpers::FormHelper include SimpleForm::ActionViewExtensions::FormHelper include ActionView::RecordIdentifier include ActionView::Helpers::FormOptionsHelper end |
.option(name, default: nil) ⇒ Object
30 31 32 33 34 |
# File 'app/cells/ez/settings/base_cell.rb', line 30 def self.option(name, default: nil) define_method name do [name] end end |
Instance Method Details
#controller ⇒ Object
73 74 75 |
# File 'app/cells/ez/settings/base_cell.rb', line 73 def controller context[:controller] end |
#css_for(item, dynamic: nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'app/cells/ez/settings/base_cell.rb', line 36 def css_for(item, dynamic: nil) return "ez-settings-defined-#{item}" unless css_map[item] return css_map[item] unless dynamic if dynamic_css_map.dig(item, :if)&.call(controller, dynamic) dynamic_css_map.dig(item, :css_class) + ' ' + css_map[item] else css_map[item] end end |
#css_map ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/cells/ez/settings/base_cell.rb', line 47 def css_map { nav_label: 'ez-settings-nav-label', nav_menu: 'ez-settings-nav-menu', nav_menu_item: 'ez-settings-nav-menu-item', overview_page_wrapper: 'ez-settings-overview', overview_page_section: 'ez-settings-overview-section', overview_page_section_header: 'ez-settings-overview-section-header', overview_page_section_content: 'ez-settings-overview-section-content', overview_page_section_content_key: 'ez-settings-overview-section-content-key', overview_page_section_content_value: 'ez-settings-overview-section-content-value', group_page_wrapper: 'ez-settings-group-wrapper', group_page_inner_wrapper: 'ez-settings-group-inner-wrapper', group_page_header: 'ez-settings-group-header', group_page_form_wrapper: 'ez-settings-group-form-wrapper', group_page_form_inner: 'ez-settings-group-form-inner', group_page_form_field_row: 'ez-settings-group-form-field-row', group_page_form_string_wrapper: 'ez-settings-group-form-string-wrapper', group_page_form_boolean_wrapper: 'ez-settings-group-form-boolean-wrapper', group_page_form_select_wrapper: 'ez-settings-group-form-select-wrapper', group_page_actions_wrapper: 'ez-settings-group-actions-wrapper', group_page_actions_save_button: 'ez-settings-group-actions-save-btn', group_page_actions_cancel_link: 'ez-settings-group-actions-cancel-link' }.merge(interface.config.custom_css_map) end |
#group_link(group, _options = {}) ⇒ Object
77 78 79 80 81 |
# File 'app/cells/ez/settings/base_cell.rb', line 77 def group_link(group, = {}) link_to i18n_group_label(group), group_path(group), class: css_for(:nav_menu_item, dynamic: "settings/#{group.name}") end |
#group_path(group) ⇒ Object
83 84 85 |
# File 'app/cells/ez/settings/base_cell.rb', line 83 def group_path(group) "#{interface.config.default_path}/#{group.name}" end |
#i18n_group_description(group) ⇒ Object
92 93 94 95 |
# File 'app/cells/ez/settings/base_cell.rb', line 92 def i18n_group_description(group) t(DESCRIPTION, scope: [SCOPE, INTERFACES, group.interface, GROUPS, group.name], default: group.name.to_s.humanize) end |
#i18n_group_label(group) ⇒ Object
87 88 89 90 |
# File 'app/cells/ez/settings/base_cell.rb', line 87 def i18n_group_label(group) t(LABEL, scope: [SCOPE, INTERFACES, group.interface, GROUPS, group.name], default: group.name.to_s.humanize) end |
#i18n_key_label(key) ⇒ Object
97 98 99 100 |
# File 'app/cells/ez/settings/base_cell.rb', line 97 def i18n_key_label(key) t(LABEL, scope: [SCOPE, INTERFACES, key.interface, GROUPS, key.group, KEYS, key.name], default: key.name.to_s.humanize) end |