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.

Standardize action text associations for page sections to use include… (#13028)

Damian Legawieca4798d91bf9f
diff --git a/core/app/models/spree/page_section.rb b/core/app/models/spree/page_section.rb
index 10ae06f737..551282295f 100644
--- a/core/app/models/spree/page_section.rb
+++ b/core/app/models/spree/page_section.rb
@@ -23,11 +23,18 @@ module Spree
has_one_attached :asset, service: Spree.public_storage_service_name
alias image asset
+ #
+ # Rich Text
+ #
+ has_rich_text :text
+ has_rich_text :description
+
#
# Validations
#
validates :name, :pageable, presence: true
validates :asset, content_type: Rails.application.config.active_storage.web_image_content_types
+
#
# Callbacks
#
diff --git a/core/app/models/spree/page_sections/announcement_bar.rb b/core/app/models/spree/page_sections/announcement_bar.rb
index 95f5ae6be0..463f61b7dd 100644
--- a/core/app/models/spree/page_sections/announcement_bar.rb
+++ b/core/app/models/spree/page_sections/announcement_bar.rb
@@ -1,8 +1,6 @@
module Spree
module PageSections
class AnnouncementBar < Spree::PageSection
- has_rich_text :text
-
before_validation :set_default_text, on: :create
BACKGROUND_COLOR_DEFAULT = '#F5F5F4'
diff --git a/core/app/models/spree/page_sections/featured_posts.rb b/core/app/models/spree/page_sections/featured_posts.rb
index 38e70d7c8c..b1b3fa1205 100644
--- a/core/app/models/spree/page_sections/featured_posts.rb
+++ b/core/app/models/spree/page_sections/featured_posts.rb
@@ -1,8 +1,6 @@
module Spree
module PageSections
class FeaturedPosts < Spree::PageSection
- has_rich_text :description
-
before_validation :make_heading_size_valid
before_validation :make_max_posts_to_show_valid
before_validation :make_alignment_valid
diff --git a/core/app/models/spree/page_sections/featured_taxon.rb b/core/app/models/spree/page_sections/featured_taxon.rb
index 4b70f335ce..6efcba064a 100644
--- a/core/app/models/spree/page_sections/featured_taxon.rb
+++ b/core/app/models/spree/page_sections/featured_taxon.rb
@@ -9,8 +9,6 @@ module Spree
queries.reduce(:or)
}
- has_rich_text :description
-
before_validation :make_heading_size_valid
before_validation :make_alignment_valid
before_validation :make_taxon_id_valid
diff --git a/core/app/models/spree/page_sections/related_products.rb b/core/app/models/spree/page_sections/related_products.rb
index 28f2f51d10..a3f449a099 100644
--- a/core/app/models/spree/page_sections/related_products.rb
+++ b/core/app/models/spree/page_sections/related_products.rb
@@ -1,8 +1,6 @@
module Spree
module PageSections
class RelatedProducts < Spree::PageSection
- has_rich_text :description
-
before_validation :make_heading_size_valid
before_validation :make_alignment_valid
diff --git a/storefront/app/helpers/spree/page_helper.rb b/storefront/app/helpers/spree/page_helper.rb
index e0a67d97c4..8dce65a158 100644
--- a/storefront/app/helpers/spree/page_helper.rb
+++ b/storefront/app/helpers/spree/page_helper.rb
@@ -12,7 +12,7 @@ module Spree
page ||= current_page
sections = current_page_preview.present? ? current_page_preview.sections : page.sections
- sections_html = sections.includes(:links, { asset_attachment: :blob }, { blocks: [:rich_text_text, :links] }).map do |section|
+ sections_html = sections.includes(:links, :rich_text_text, :rich_text_description, { asset_attachment: :blob }, { blocks: [:rich_text_text, :links] }).map do |section|
render_section(section, variables)
end.join.html_safe
diff --git a/storefront/app/helpers/spree/theme_helper.rb b/storefront/app/helpers/spree/theme_helper.rb
index 0ba87db972..ad8100936c 100644
--- a/storefront/app/helpers/spree/theme_helper.rb
+++ b/storefront/app/helpers/spree/theme_helper.rb
@@ -72,7 +72,7 @@ module Spree
#
# @return [Hash] the theme layout sections
def theme_layout_sections
- @theme_layout_sections ||= current_theme_or_preview.sections.includes(:links, { asset_attachment: :blob },
+ @theme_layout_sections ||= current_theme_or_preview.sections.includes(:links, :rich_text_text, :rich_text_description, { asset_attachment: :blob },
{ blocks: [:rich_text_text, :links] }).all.each_with_object({}) do |section, hash|
hash[section.type.to_s.demodulize.underscore] = section
end