Module: Maglev::Editor::SectionBlocksHelper
- Defined in:
- app/helpers/maglev/editor/section_blocks_helper.rb
Instance Method Summary collapse
- #add_child_section_block_button(section, section_block) ⇒ Object
- #add_child_section_block_dropdown_button(_section, parent_id, block_definitions) ⇒ Object
- #add_child_section_block_no_dropdown_button(section, parent_id, block_type) ⇒ Object
- #add_section_block_button(section, block_definitions) ⇒ Object
- #add_section_block_dropdown_button(_section, block_definitions) ⇒ Object
- #add_section_block_no_dropdown_button(section, block_type) ⇒ Object
- #delete_section_block_button(section, section_block, maglev_editing_route_context) ⇒ Object
- #delete_section_block_button_form_attributes(section, section_block) ⇒ Object
- #section_block_button_common_attributes(section) ⇒ Object
- #section_block_button_dropdown_attributes ⇒ Object
Instance Method Details
#add_child_section_block_button(section, section_block) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'app/helpers/maglev/editor/section_blocks_helper.rb', line 63 def (section, section_block) block_definitions = section.child_block_definitions_of(section_block.id) if block_definitions.one? (section, section_block.id, block_definitions.first.type) elsif block_definitions.any? (section, section_block.id, block_definitions) end end |
#add_child_section_block_dropdown_button(_section, parent_id, block_definitions) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/helpers/maglev/editor/section_blocks_helper.rb', line 85 def (_section, parent_id, block_definitions) render Maglev::Uikit::DropdownComponent.new do |dropdown| dropdown.with_trigger do (class: , **) do render Maglev::Uikit::IconComponent.new(name: 'add', size: '1.15rem') end end content_tag(:div, class: 'p-4 min-w-64') do render 'maglev/editor/section_blocks/new', blocks: block_definitions, parent_id: parent_id end end end |
#add_child_section_block_no_dropdown_button(section, parent_id, block_type) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/helpers/maglev/editor/section_blocks_helper.rb', line 72 def (section, parent_id, block_type) ( editor_section_blocks_path(section, block_type: block_type, parent_id: parent_id, lock_version: source_lock_version, **maglev_editing_route_context), class: , name: 'add_child_section_block', **(section) ) do render Maglev::Uikit::IconComponent.new(name: 'add', size: '1.15rem') end end |
#add_section_block_button(section, block_definitions) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/maglev/editor/section_blocks_helper.rb', line 29 def (section, block_definitions) if block_definitions.blank? '' elsif block_definitions.one? (section, block_definitions.first.type) else (section, block_definitions) end end |
#add_section_block_dropdown_button(_section, block_definitions) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/helpers/maglev/editor/section_blocks_helper.rb', line 49 def (_section, block_definitions) render Maglev::Uikit::DropdownComponent.new do |dropdown| dropdown.with_trigger do (t('maglev.editor.section_blocks.index.add_button'), class: (size: :big), **) end content_tag(:div, class: 'p-4 min-w-64') do render 'maglev/editor/section_blocks/new', blocks: block_definitions, parent_id: nil end end end |
#add_section_block_no_dropdown_button(section, block_type) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/maglev/editor/section_blocks_helper.rb', line 39 def (section, block_type) ( t('maglev.editor.section_blocks.index.add_button'), editor_section_blocks_path(section, block_type: block_type, lock_version: source_lock_version, **maglev_editing_route_context), class: (size: :big), **(section) ) end |
#delete_section_block_button(section, section_block, maglev_editing_route_context) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/maglev/editor/section_blocks_helper.rb', line 7 def (section, section_block, maglev_editing_route_context) ( editor_section_block_path(section, section_block, **maglev_editing_route_context), method: :delete, class: , data: { turbo_confirm: t('maglev.editor.section_blocks.index.confirm_delete') }, form: (section, section_block) ) do render Maglev::Uikit::IconComponent.new(name: 'delete_bin', size: '1.15rem') end end |
#delete_section_block_button_form_attributes(section, section_block) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/maglev/editor/section_blocks_helper.rb', line 19 def (section, section_block) { data: { action: 'turbo:submit-end->editor-preview-notification-center#deleteSectionBlock', 'editor-preview-notification-center-section-id-param': section.id, 'editor-preview-notification-center-section-block-id-param': section_block.id } } end |
#section_block_button_common_attributes(section) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/helpers/maglev/editor/section_blocks_helper.rb', line 99 def (section) { method: :post, form: { data: { turbo_frame: '_top', action: 'turbo:submit-end->editor-preview-notification-center#addSectionBlock', 'editor-preview-notification-center-section-id-param': section.id } } } end |
#section_block_button_dropdown_attributes ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'app/helpers/maglev/editor/section_blocks_helper.rb', line 112 def { type: 'button', data: { action: 'click->uikit-dropdown#toggle', 'uikit-dropdown-target': 'button' } } end |