Module: SettingsHelper
- Defined in:
- lib/generators/ruby_cms/templates/helpers/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" }, "custom" => { icon: "✨", fallback_label: "App" } }.freeze
Instance Method Summary collapse
- #render_setting_field(entry:, value:, tab:) ⇒ Object
- #setting_label(entry) ⇒ Object
- #settings_category_short_desc(category) ⇒ Object
- #settings_nav_visibility_icon(entry) ⇒ Object
-
#settings_rail_icon_svg(category) ⇒ Object
SVG fragment for rail/quick-link icons.
- #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
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/generators/ruby_cms/templates/helpers/settings_helper.rb', line 71 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
55 56 57 58 59 60 |
# File 'lib/generators/ruby_cms/templates/helpers/settings_helper.rb', line 55 def setting_label(entry) key = entry.key.to_s key = key.delete_prefix("nav_show_") key = key.delete_suffix("_per_page") key.tr("_", " ").humanize end |
#settings_category_short_desc(category) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/generators/ruby_cms/templates/helpers/settings_helper.rb', line 42 def settings_category_short_desc(category) case category.to_s when "general" then "Site naam, locale, en globale opties" when "navigation" then "Sidebar volgorde en zichtbaarheid" when "pagination" then "Aantal items per pagina" when "analytics" then "Privacy, retentie en drempelwaarden" when "dashboard" then "Blokken zichtbaar op dashboard" when "content" then "Content blocks en visuele editor" when "custom" then "App-specifieke instellingen" else "Configuratie" end end |
#settings_nav_visibility_icon(entry) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/generators/ruby_cms/templates/helpers/settings_helper.rb', line 62 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_rail_icon_svg(category) ⇒ Object
SVG fragment for rail/quick-link icons. Categories use heroicon-style outline SVG.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/ruby_cms/templates/helpers/settings_helper.rb', line 28 def settings_rail_icon_svg(category) case category.to_s when "overview" then '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M3 13l4-4 5 5 9-9"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M14 5h7v7"/>' when "general" then '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M10.325 4.317a1.724 1.724 0 013.35 0 1.724 1.724 0 002.573 1.066 1.724 1.724 0 012.368 2.368 1.724 1.724 0 001.066 2.573 1.724 1.724 0 010 3.35 1.724 1.724 0 00-1.066 2.573 1.724 1.724 0 01-2.368 2.368 1.724 1.724 0 00-2.573 1.066 1.724 1.724 0 01-3.35 0 1.724 1.724 0 00-2.573-1.066 1.724 1.724 0 01-2.368-2.368 1.724 1.724 0 00-1.066-2.573 1.724 1.724 0 010-3.35 1.724 1.724 0 001.066-2.573 1.724 1.724 0 012.368-2.368 1.724 1.724 0 002.573-1.066z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>' when "navigation" then '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7"/>' when "pagination" then '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>' when "analytics" then '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>' when "dashboard" then '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"/>' when "content" then '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"/>' when "custom" then '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"/>' else '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" d="M10.325 4.317a1.724 1.724 0 013.35 0 1.724 1.724 0 002.573 1.066 1.724 1.724 0 012.368 2.368 1.724 1.724 0 001.066 2.573 1.724 1.724 0 010 3.35 1.724 1.724 0 00-1.066 2.573 1.724 1.724 0 01-2.368 2.368 1.724 1.724 0 00-2.573 1.066 1.724 1.724 0 01-3.35 0 1.724 1.724 0 00-2.573-1.066 1.724 1.724 0 01-2.368-2.368 1.724 1.724 0 00-1.066-2.573 1.724 1.724 0 010-3.35 1.724 1.724 0 001.066-2.573 1.724 1.724 0 012.368-2.368 1.724 1.724 0 002.573-1.066z"/>' end.html_safe end |
#settings_tab_config(category) ⇒ Object
14 15 16 |
# File 'lib/generators/ruby_cms/templates/helpers/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 'lib/generators/ruby_cms/templates/helpers/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 'lib/generators/ruby_cms/templates/helpers/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 |