Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Page builder: ability to add more blocks to in sections (#12733)

Łukasz Adamczykc41e289d4e75
diff --git a/admin/app/views/spree/admin/page_builder/_sidebar_block.html.erb b/admin/app/views/spree/admin/page_builder/_sidebar_block.html.erb
index 39e971e3b9..17a10037c0 100644
--- a/admin/app/views/spree/admin/page_builder/_sidebar_block.html.erb
+++ b/admin/app/views/spree/admin/page_builder/_sidebar_block.html.erb
@@ -7,15 +7,16 @@
} do %>
<div class="d-flex align-items-center justify-content-between sidebar-block-title p-1 rounded-sm">
<div class="d-flex align-items-center flex-fill">
- <%= icon "#{block.icon_name}", class: 'mr-2' if block.icon_name.present? %>
- <%= link_to block.display_name, edit_admin_page_section_block_path(block.section, block),
- class: 'block-edit-link flex-fill text-dark',
- data: {
- turbo_frame: :page_sidebar,
- action: 'click->page-builder#makeOverlayActive',
- page_builder_editor_id_param: "block-#{block.id}"
- }
- %>
+ <%= link_to(edit_admin_page_section_block_path(block.section, block),
+ class: 'block-edit-link flex-fill text-dark',
+ data: {
+ turbo_frame: :page_sidebar,
+ action: 'click->page-builder#makeOverlayActive',
+ page_builder_editor_id_param: "block-#{block.id}"
+ }) do %>
+ <%= icon "#{block.icon_name}", class: 'mr-2' if block.icon_name.present? %>
+ <%= block.display_name %>
+ <% end %>
</div>
<div class="d-flex align-items-center d-none">
<% if block.section.can_sort_blocks? %>
diff --git a/core/app/models/spree/page_blocks/products/buy_buttons.rb b/core/app/models/spree/page_blocks/products/buy_buttons.rb
index 48f4ed861d..42fcd0c1c6 100644
--- a/core/app/models/spree/page_blocks/products/buy_buttons.rb
+++ b/core/app/models/spree/page_blocks/products/buy_buttons.rb
@@ -6,6 +6,14 @@ module Spree
BOTTOM_PADDING_DEFAULT = 20
preference :text_color, :string
+
+ def icon_name
+ 'shopping-cart-plus'
+ end
+
+ def display_name
+ Spree.t('page_blocks.products.buy_buttons.display_name')
+ end
end
end
end
diff --git a/core/app/models/spree/page_blocks/products/quantity_selector.rb b/core/app/models/spree/page_blocks/products/quantity_selector.rb
index 5e02bb5dc8..614c97cc8f 100644
--- a/core/app/models/spree/page_blocks/products/quantity_selector.rb
+++ b/core/app/models/spree/page_blocks/products/quantity_selector.rb
@@ -6,6 +6,10 @@ module Spree
BOTTOM_PADDING_DEFAULT = 20
preference :text_color, :string
+
+ def icon_name
+ 'selector'
+ end
end
end
end
diff --git a/core/app/models/spree/page_blocks/products/variant_picker.rb b/core/app/models/spree/page_blocks/products/variant_picker.rb
index d62ccfcda2..1a28b20792 100644
--- a/core/app/models/spree/page_blocks/products/variant_picker.rb
+++ b/core/app/models/spree/page_blocks/products/variant_picker.rb
@@ -3,6 +3,10 @@ module Spree
module Products
class VariantPicker < Spree::PageBlock
preference :text_color, :string
+
+ def icon_name
+ 'select'
+ end
end
end
end
diff --git a/core/app/models/spree/page_sections/featured_product.rb b/core/app/models/spree/page_sections/featured_product.rb
index da9343d24c..0da4df56c6 100644
--- a/core/app/models/spree/page_sections/featured_product.rb
+++ b/core/app/models/spree/page_sections/featured_product.rb
@@ -41,6 +41,10 @@ module Spree
def blocks_available?
true
end
+
+ def can_sort_blocks?
+ true
+ end
end
end
end
diff --git a/core/app/models/spree/page_sections/image_banner.rb b/core/app/models/spree/page_sections/image_banner.rb
index bb0a1a0fbe..d8c703a1f3 100644
--- a/core/app/models/spree/page_sections/image_banner.rb
+++ b/core/app/models/spree/page_sections/image_banner.rb
@@ -26,10 +26,22 @@ module Spree
]
end
+ def available_blocks_to_add
+ [
+ Spree::PageBlocks::Buttons,
+ Spree::PageBlocks::Heading,
+ Spree::PageBlocks::Text
+ ]
+ end
+
def blocks_available?
true
end
+ def can_sort_blocks?
+ true
+ end
+
def icon_name
'slideshow'
end
diff --git a/core/app/models/spree/page_sections/image_with_text.rb b/core/app/models/spree/page_sections/image_with_text.rb
index 2420ef4d1a..4ef61dfe0b 100644
--- a/core/app/models/spree/page_sections/image_with_text.rb
+++ b/core/app/models/spree/page_sections/image_with_text.rb
@@ -27,6 +27,14 @@ module Spree
]
end
+ def available_blocks_to_add
+ [
+ Spree::PageBlocks::Buttons,
+ Spree::PageBlocks::Heading,
+ Spree::PageBlocks::Text
+ ]
+ end
+
def default_links
@default_links.presence || [
Spree::PageLink.new(
@@ -40,6 +48,10 @@ module Spree
true
end
+ def can_sort_blocks?
+ true
+ end
+
def icon_name
'photo'
end
diff --git a/core/app/models/spree/page_sections/rich_text.rb b/core/app/models/spree/page_sections/rich_text.rb
index 6e6fffc9a2..c06025b539 100644
--- a/core/app/models/spree/page_sections/rich_text.rb
+++ b/core/app/models/spree/page_sections/rich_text.rb
@@ -8,10 +8,21 @@ module Spree
]
end
+ def available_blocks_to_add
+ [
+ Spree::PageBlocks::Heading,
+ Spree::PageBlocks::Text
+ ]
+ end
+
def blocks_available?
true
end
+ def can_sort_blocks?
+ true
+ end
+
def icon_name
'text-caption'
end
diff --git a/core/app/models/spree/page_sections/video.rb b/core/app/models/spree/page_sections/video.rb
index 6746bb10f0..9362060afa 100644
--- a/core/app/models/spree/page_sections/video.rb
+++ b/core/app/models/spree/page_sections/video.rb
@@ -44,6 +44,10 @@ module Spree
]
end
+ def available_blocks_to_add
+ [Spree::PageBlocks::Heading]
+ end
+
def icon_name
'movie'
end
@@ -52,6 +56,10 @@ module Spree
true
end
+ def can_sort_blocks?
+ true
+ end
+
def video_embed
@video_embed ||= ::ActionText::VideoEmbed.find_by(id: preferred_youtube_video_embed_id) if preferred_youtube_video_embed_id.present?
end
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 726027c213..1aef0dd486 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -1464,6 +1464,9 @@ en:
newsletter_form:
button_text_default: Submit
placeholder_default: Enter your email
+ products:
+ buy_buttons:
+ display_name: Add To Cart
page_not_found: Sorry! Page you are looking can’t be found.
page_sections:
announcement_bar: