Module: RubyCms::SettingsHelper
- Defined in:
- app/helpers/ruby_cms/settings_helper.rb
Constant Summary collapse
- TAB_CONFIG =
{ "general" => { icon: "🏠", fallback_label: "General" }, "navigation" => { icon: "🧭", fallback_label: "Navigation" }, "pagination" => { icon: "📄", fallback_label: "Pagination" }, "analytics" => { icon: "📈", fallback_label: "Analytics" }, "dashboard" => { icon: "🗂️", fallback_label: "Dashboard" }, "content" => { icon: "🧱", fallback_label: "Content" } }.freeze
Instance Method Summary collapse
- #render_setting_field(entry:, value:, tab:) ⇒ Object
- #setting_label(entry) ⇒ Object
-
#settings_nav_visibility_icon(entry) ⇒ Object
SVG path fragment for a nav item (matches sidebar), or nil.
- #settings_tab_config(category) ⇒ Object
- #settings_tab_description(category) ⇒ Object
- #settings_tab_label(category) ⇒ Object
Instance Method Details
#render_setting_field(entry:, value:, tab:) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/ruby_cms/settings_helper.rb', line 47 def render_setting_field(entry:, value:, tab:) case entry.type.to_sym when :integer render_integer_setting_field(entry:, value:, tab:) when :boolean render_boolean_setting_field(entry:, value:, tab:) when :json render_json_setting_field(entry:, value:, tab:) else render_string_setting_field(entry:, value:, tab:) end end |
#setting_label(entry) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/ruby_cms/settings_helper.rb', line 27 def setting_label(entry) key = entry.key.to_s # Keep familiar labels for nav and pagination keys. key = key.delete_prefix("nav_show_") key = key.delete_suffix("_per_page") key.tr("_", " ").humanize end |
#settings_nav_visibility_icon(entry) ⇒ Object
SVG path fragment for a nav item (matches sidebar), or nil.
38 39 40 41 42 43 44 45 |
# File 'app/helpers/ruby_cms/settings_helper.rb', line 38 def settings_nav_visibility_icon(entry) key_str = entry.key.to_s return nil unless key_str.start_with?("nav_show_") nav_key = key_str.delete_prefix("nav_show_") item = RubyCms.nav_registry.find {|e| e[:key].to_s == nav_key } item&.dig(:icon) end |
#settings_tab_config(category) ⇒ Object
14 15 16 |
# File 'app/helpers/ruby_cms/settings_helper.rb', line 14 def settings_tab_config(category) TAB_CONFIG[category.to_s] || { icon: "⚙️", fallback_label: category.to_s.humanize } end |
#settings_tab_description(category) ⇒ Object
23 24 25 |
# File 'app/helpers/ruby_cms/settings_helper.rb', line 23 def settings_tab_description(category) t("ruby_cms.admin.settings.categories.#{category}.description", default: "") end |
#settings_tab_label(category) ⇒ Object
18 19 20 21 |
# File 'app/helpers/ruby_cms/settings_helper.rb', line 18 def settings_tab_label(category) cfg = settings_tab_config(category) t("ruby_cms.admin.settings.categories.#{category}.label", default: cfg[:fallback_label]) end |