Module: Maglev::Editor::SettingsHelper

Defined in:
app/helpers/maglev/editor/settings_helper.rb

Instance Method Summary collapse

Instance Method Details

#section_block_form_settings(section, section_block, advanced: false) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/maglev/editor/settings_helper.rb', line 18

def section_block_form_settings(section, section_block, advanced: false)
  render Maglev::Editor::SettingsGroupComponent.new(
    values: section_block.settings,
    definitions: advanced ? section_block.definition.advanced_settings : section_block.definition.main_settings,
    paths: section_settings_paths,
    scope: {
      input: 'section_block',
      i18n: "maglev.themes.#{section.theme_id}.sections.#{section.type}.blocks.types.#{section_block.type}"
    }
  )
end

#section_form_settings(section, advanced: false) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/maglev/editor/settings_helper.rb', line 6

def section_form_settings(section, advanced: false)
  render Maglev::Editor::SettingsGroupComponent.new(
    values: section.settings,
    definitions: advanced ? section.definition.advanced_settings : section.definition.main_settings,
    paths: section_settings_paths,
    scope: {
      input: 'section',
      i18n: "maglev.themes.#{section.theme_id}.sections.#{section.type}"
    }
  )
end

#section_settings_pathsObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/helpers/maglev/editor/settings_helper.rb', line 38

def section_settings_paths
  {
    collection_items_path: lambda { |definition, _|
      editor_combobox_collection_items_path(collection_id: definition.options[:collection_id])
    },
    assets_path: ->(_, context) { editor_assets_path(source: context[:source], picker: true) },
    edit_link_path: lambda { |_, context|
      edit_editor_link_path(input_name: context[:input_name], link: context[:value])
    },
    icons_path: ->(_, context) { editor_icons_path(source: context[:source]) }
  }
end

#style_form_settings(style, theme) ⇒ Object



30
31
32
33
34
35
36
# File 'app/helpers/maglev/editor/settings_helper.rb', line 30

def style_form_settings(style, theme)
  render Maglev::Editor::SettingsGroupComponent.new(
    values: style,
    definitions: theme.style_settings,
    scope: { input: 'style', i18n: 'maglev.editor' }
  )
end