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.

Fix some page sections in the page builder (#12329)

Łukasz Adamczyk208e0eca9583
diff --git a/admin/app/views/spree/admin/page_blocks/forms/_buttons.html.erb b/admin/app/views/spree/admin/page_blocks/forms/_buttons.html.erb
index 68d22ba30e..94b33f359a 100644
--- a/admin/app/views/spree/admin/page_blocks/forms/_buttons.html.erb
+++ b/admin/app/views/spree/admin/page_blocks/forms/_buttons.html.erb
@@ -1,13 +1,13 @@
<%= render 'spree/admin/page_blocks/forms/link', f: f %>
<div class="form-group">
- <%= f.label :preferred_button_style_1 %>
+ <%= f.label :preferred_button_style_1, Spree.t('admin.page_builder.button_style') %>
<%= f.select :preferred_button_style_1, options_for_select(['primary', 'secondary'], @page_block.preferred_button_style_1), { }, { class: 'custom-select', data: { action: 'auto-submit#submit' } } %>
</div>
<% content_for(:design_tab) do %>
<div class="form-group">
- <%= f.label "Buttons alignment" %>
- <%= f.select :preferred_buttons_alignment, options_for_select(['left', 'center', 'right'], @page_block.preferred_buttons_alignment), {}, { class: 'custom-select', data: { action: 'auto-submit#submit' } } %>
+ <%= f.label :preferred_text_alignment, Spree.t('admin.page_builder.button_alignment') %>
+ <%= f.select :preferred_text_alignment, options_for_select(['left', 'center', 'right'], @page_block.preferred_text_alignment), {}, { class: 'custom-select', data: { action: 'auto-submit#submit' } } %>
</div>
<% end %>
diff --git a/admin/app/views/spree/admin/page_sections/forms/_image_with_text.html.erb b/admin/app/views/spree/admin/page_sections/forms/_image_with_text.html.erb
index 5f9167f06b..d81b50cd64 100644
--- a/admin/app/views/spree/admin/page_sections/forms/_image_with_text.html.erb
+++ b/admin/app/views/spree/admin/page_sections/forms/_image_with_text.html.erb
@@ -10,16 +10,10 @@
</div>
</div>
- <div class="form-group">
- <%= lf.label :label, 'Label' %>
- <%= lf.text_field :label, class: 'form-control', data: { action: 'blur->auto-submit#submit' }, placeholder: 'eg. About us', required: true %>
- </div>
-
<div class="custom-control custom-checkbox pb-2">
<%= lf.check_box :open_in_new_tab, class: 'custom-control-input', data: { action: 'auto-submit#submit' } %>
<%= lf.label :open_in_new_tab, class: 'custom-control-label' %>
</div>
-
<% end %>
<div class="alert alert-info">Clicking on the image will send the user to the selected page/URL</div>
</div>
diff --git a/admin/config/locales/en.yml b/admin/config/locales/en.yml
index e07957346a..415c944e68 100644
--- a/admin/config/locales/en.yml
+++ b/admin/config/locales/en.yml
@@ -336,4 +336,39 @@ en:
currencies_link: To add more currencies, go to <a href="%{link}">Store Settings</a>
stock_locations_link: To add more stock locations please go to <a href="%{link}">Stock Locations</a>
search_results:
- no_variants: We couldn't find any variants matching your search :(
\ No newline at end of file
+ no_variants: We couldn't find any variants matching your search :(
+ page_builder:
+ show_more_button: Show explore category button
+ heading: Heading
+ heading_size: Heading size
+ heading_alignment: Heading alignment
+ description_alignment: Description alignment
+ use_description_from_admin: Use description from admin
+ button_text: Button's text
+ show_taxon_image: Show taxon image
+ category: Category
+ maximum_products_to_show: Maximum products to show
+ button_style: Button style
+ posts_to_show: Posts to show
+ maximum_posts_to_show: Maximum posts to show
+ desktop_image_alignment: Image alignment for desktop
+ vertical_alignment: Vertical alignment
+ overlay_transparency: Overlay transparency
+ title: Title
+ separated: Separated
+ youtube_video_url: Youtube video URL
+ max_video_width_on_desktop: Max video width on desktop
+ border_color: Border color
+ border_top_width: Border top width
+ border_bottom_width: Border bottom width
+ bottom_padding: Bottom padding
+ button_background_color: Button background color
+ button_text_color: Button text color
+ desktop_logo_height: Logo height (desktop)
+ height: Height
+ nav_centered: Nav centered
+ logo_centered: Logo centered
+ left_aligned: Left aligned
+ text_color: Text color
+ top_padding: Top padding
+ button_alignment: Button alignment
diff --git a/core/app/models/spree/page_sections/featured_taxon.rb b/core/app/models/spree/page_sections/featured_taxon.rb
index a3686ecf55..4fc9156457 100644
--- a/core/app/models/spree/page_sections/featured_taxon.rb
+++ b/core/app/models/spree/page_sections/featured_taxon.rb
@@ -39,7 +39,7 @@ module Spree
end
def description_to_use
- @description_to_use ||= preferred_use_description_from_admin ? taxon&.description : description
+ @description_to_use ||= preferred_use_description_from_admin && description.blank? ? taxon&.description : description
end
def display_name
diff --git a/core/app/models/spree/page_sections/image_banner.rb b/core/app/models/spree/page_sections/image_banner.rb
index 5598681566..bb0a1a0fbe 100644
--- a/core/app/models/spree/page_sections/image_banner.rb
+++ b/core/app/models/spree/page_sections/image_banner.rb
@@ -12,15 +12,15 @@ module Spree
[
Spree::PageBlocks::Heading.new(
text: Spree.t('page_sections.image_banner.heading_default'),
- text_alignment: 'center',
- container_alignment: 'center',
- width_desktop: 50
+ preferred_text_alignment: 'center',
+ preferred_container_alignment: 'center',
+ preferred_width_desktop: 50
),
Spree::PageBlocks::Text.new(
text: Spree.t('page_sections.image_banner.text_default'),
- text_alignment: 'center',
- container_alignment: 'center',
- width_desktop: 50
+ preferred_text_alignment: 'center',
+ preferred_container_alignment: 'center',
+ preferred_width_desktop: 50
),
Spree::PageBlocks::Buttons.new
]
diff --git a/core/app/models/spree/page_sections/video.rb b/core/app/models/spree/page_sections/video.rb
index 76b78426b5..0e5539023a 100644
--- a/core/app/models/spree/page_sections/video.rb
+++ b/core/app/models/spree/page_sections/video.rb
@@ -3,8 +3,8 @@ module Spree
class Video < Spree::PageSection
alias video asset
- after_create :create_video_embed, if: -> { youtube_video_url.present? }
- after_update :update_video_embed, if: -> { saved_change_to_youtube_video_url? || video_embed.nil? }
+ after_create :create_video_embed, if: -> { preferred_youtube_video_url.present? }
+ after_update :update_video_embed, if: -> { video_url_changed? || video_embed.nil? }
after_destroy :destroy_video_embed
preference :youtube_video_url, :string
@@ -16,27 +16,27 @@ module Spree
@default_blocks.presence || [
Spree::PageBlocks::Heading.new(
text: Spree.t('page_sections.video.heading_1_default'),
- text_alignment: nil,
- container_alignment: nil,
- bottom_padding: 8,
- top_padding: 24,
- size: 'small'
+ preferred_text_alignment: nil,
+ preferred_container_alignment: nil,
+ preferred_bottom_padding: 8,
+ preferred_top_padding: 24,
+ preferred_size: 'small'
),
Spree::PageBlocks::Heading.new(
text: Spree.t('page_sections.video.heading_2_default'),
- text_alignment: nil,
- container_alignment: nil,
- bottom_padding: 8,
- top_padding: 24,
- size: 'large'
+ preferred_text_alignment: nil,
+ preferred_container_alignment: nil,
+ preferred_bottom_padding: 8,
+ preferred_top_padding: 24,
+ preferred_size: 'large'
),
Spree::PageBlocks::Heading.new(
text: store.name,
- text_alignment: nil,
- container_alignment: nil,
- bottom_padding: 8,
- top_padding: 24,
- size: 'small'
+ preferred_text_alignment: nil,
+ preferred_container_alignment: nil,
+ preferred_bottom_padding: 8,
+ preferred_top_padding: 24,
+ preferred_size: 'small'
)
]
end
@@ -55,6 +55,11 @@ module Spree
private
+ def video_url_changed?
+ saved_change_to_preferences? &&
+ saved_change_to_preferences[0][:youtube_video_url] != saved_change_to_preferences[1][:youtube_video_url]
+ end
+
def create_video_embed
oembed_response = oembed_cached_response(preferred_youtube_video_url)