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.

Re-factor Side-by-Side Promotion to be Side-by-Side Images for wider use case than just Promotions.

Matthew Kennedy7892b0c47029
diff --git a/backend/app/views/spree/admin/cms_sections/_form.html.erb b/backend/app/views/spree/admin/cms_sections/_form.html.erb
index 66676dba96..bd24b77510 100644
--- a/backend/app/views/spree/admin/cms_sections/_form.html.erb
+++ b/backend/app/views/spree/admin/cms_sections/_form.html.erb
@@ -38,9 +38,11 @@
<div class="col-12">
<div class="card mb-3">
<div class="card-header d-flex">
- <h5 class="mb-0 d-flex flex-grow-1">
- <%= raw Spree.t('admin.cms.settings_for', section: spree_humanize_type(@cms_section.type)) %>
- </h5>
+ <div class="d-flex flex-grow-1">
+ <h5 class="mb-0">
+ <%= raw Spree.t('admin.cms.settings_for', section: spree_humanize_type(@cms_section.type)) %>
+ </h5>
+ </div>
<div class="d-flex">
<span data-show-info
data-alert-kind="info"
diff --git a/backend/app/views/spree/admin/cms_sections/types/_side_by_side_promotion.html.erb b/backend/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb
similarity index 91%
rename from backend/app/views/spree/admin/cms_sections/types/_side_by_side_promotion.html.erb
rename to backend/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb
index a6a56cda14..21d5a1cbc0 100644
--- a/backend/app/views/spree/admin/cms_sections/types/_side_by_side_promotion.html.erb
+++ b/backend/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb
@@ -1,7 +1,7 @@
<div class="row pb-0">
<div class="col-12 col-md-6 mb-3">
<div class="card p-3">
- <h5 class="border-bottom"><%= Spree.t('admin.cms.side_by_side.left_image') %></h5>
+ <h5 class="text-center"><%= Spree.t('admin.cms.side_by_side.left_image') %></h5>
<%= f.field_container :image_one, class: ['form-group'] do %>
<% if @cms_section.image_one.attached? && @cms_section.image_one.variable? %>
<figure class="admin-img-holder">
@@ -16,6 +16,7 @@
<%= f.file_field :image_one %>
<%= f.error_message_on :image_one %>
<% end %>
+ <small class="text-muted"><%= Spree.t('admin.cms.side_by_side.image_info') %></small>
<% end %>
<%= f.field_container :title_one, class: ['form-group'] do %>
@@ -30,10 +31,12 @@
<%= f.error_message_on :subtitle_one %>
<% end %>
+ <div class="col-12"><hr></div>
+
<%= f.field_container :link_type_one, class: ['form-group'] do %>
<%= f.label :link_type_one, Spree.t('admin.navigation.link_to') %>
<%= f.select(:link_type_one,
- spree_humanize_dropdown_values('Spree::Cms::Sections::SideBySidePromotion',
+ spree_humanize_dropdown_values('Spree::Cms::Sections::SideBySideImages',
{ const: 'LINKED_RESOURCE_TYPE' }),
{ include_blank: false },
class: 'link_switcher',
@@ -41,14 +44,12 @@
<%= f.error_message_on :link_type_one %>
<% end %>
<%= render "spree/admin/shared/link_fields", resource: @cms_section, linked_type: @cms_section.link_type_one, save_to: :link_one, f: f %>
-
- <small class="text-muted"><%= Spree.t('admin.cms.side_by_side.section_one_info') %></small>
</div>
</div>
<div class="col-12 col-md-6 mb-3">
<div class="card p-3">
- <h5 class="border-bottom"><%= Spree.t('admin.cms.side_by_side.right_image') %></h5>
+ <h5 class="text-center"><%= Spree.t('admin.cms.side_by_side.right_image') %></h5>
<%= f.field_container :image_two, class: ['form-group'] do %>
<% if @cms_section.image_two.attached? && @cms_section.image_two.variable? %>
<figure class="admin-img-holder">
@@ -63,6 +64,7 @@
<%= f.file_field :image_two %>
<%= f.error_message_on :image_two %>
<% end %>
+ <small class="text-muted"><%= Spree.t('admin.cms.side_by_side.image_info') %></small>
<% end %>
<%= f.field_container :title_two, class: ['form-group'] do %>
@@ -77,10 +79,12 @@
<%= f.error_message_on :subtitle_two %>
<% end %>
+ <div class="col-12"><hr></div>
+
<%= f.field_container :link_type_two, class: ['form-group'] do %>
<%= f.label :link_type_two, Spree.t('admin.navigation.link_to') %>
<%= f.select(:link_type_two,
- spree_humanize_dropdown_values('Spree::Cms::Sections::SideBySidePromotion',
+ spree_humanize_dropdown_values('Spree::Cms::Sections::SideBySideImages',
{ const: 'LINKED_RESOURCE_TYPE' }),
{ include_blank: false },
class: 'link_switcher',
@@ -88,8 +92,6 @@
<%= f.error_message_on :link_type_two %>
<% end %>
<%= render "spree/admin/shared/link_fields", resource: @cms_section, linked_type: @cms_section.link_type_two, save_to: :link_two, f: f %>
-
- <small class="text-muted"><%= Spree.t('admin.cms.side_by_side.section_two_info') %></small>
</div>
</div>
diff --git a/core/app/models/spree/cms/sections/side_by_side_promotion.rb b/core/app/models/spree/cms/sections/side_by_side_images.rb
similarity index 94%
rename from core/app/models/spree/cms/sections/side_by_side_promotion.rb
rename to core/app/models/spree/cms/sections/side_by_side_images.rb
index e05dfb89c9..4bfc685444 100644
--- a/core/app/models/spree/cms/sections/side_by_side_promotion.rb
+++ b/core/app/models/spree/cms/sections/side_by_side_images.rb
@@ -1,5 +1,5 @@
module Spree::Cms::Sections
- class SideBySidePromotion < Spree::CmsSection
+ class SideBySideImages < Spree::CmsSection
after_initialize :default_values
before_save :reset_link_attributes
diff --git a/core/app/models/spree/cms_section.rb b/core/app/models/spree/cms_section.rb
index 9e4471c433..9c4a972cfb 100644
--- a/core/app/models/spree/cms_section.rb
+++ b/core/app/models/spree/cms_section.rb
@@ -28,7 +28,7 @@ module Spree
'Spree::Cms::Sections::FeaturedArticle',
'Spree::Cms::Sections::ProductCarousel',
'Spree::Cms::Sections::ImageGallery',
- 'Spree::Cms::Sections::SideBySidePromotion',
+ 'Spree::Cms::Sections::SideBySideImages',
'Spree::Cms::Sections::RichTextContent']
def boundaries
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index ed30c137b6..b2474b19fe 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -562,14 +562,14 @@ en:
fit: Fit To
info_hero_image_body: "<p>The Hero Image section adds a large image with a button and tagline text to your page.</p>
<p>The button can link to a Product, Taxon or Page. This section can be set to fit within the central container or to the edges of the screen.</p>
- <p><b>Tip:</b> Use a hero image with no button text or title, and then set the <b>Fit:</b> to <b>Container</b> and <b>Gutters</b> to <b>Use Gutters</b> this creates an image section that looks perfect above a side-by-side promotions section or the three taxons sections.</p>
+ <p><b>Tip:</b> Use a hero image with no button text or title, and then set the <b>Fit:</b> to <b>Container</b> and <b>Gutters</b> to <b>Use Gutters</b> this creates an image section that looks great above a Side-by-Side Images section, or an Image Gallery section.</p>
<p>Experiment with the settings, and don't be afraid to use more than one Hero Image section per page.</p>"
info_image_gallery_body: "<p>The Image Gallery section can be configured in several ways. For example, each image can link to a product or taxon. If you do not provide a link, you can display three images. Additionally, you can also use labels to add text to your images.</p>
<p>There are two layout configurations for the Image Gallery section, with the taller image used on the left or the right. You can also set this section to fit the edges of the screen or the central container to match your website's style.</p>"
info_product_carousel_body: "<p>Product Carousel is a simple section to use. Search for the taxon you wish to display, save the changes, and the products in your chosen taxon will be displayed on your page.</p>"
info_featured_article_body: "<p>The Feature Article section allows you to add rich text to your page with a set title subtitle and linking button.</p>
<p>This section can be set to use full screen or container and also use gutters.</p>"
- info_side_by_side_promotion_body: "<p>Side-By-Side Promotions can be configured in several ways, you have the option of using them as plane images, images with text, and either of those options can be clickable links if a link is set.</p>
+ info_side_by_side_images_body: "<p>The Side-by-Side Images section can be configured in several ways, you have the option of using them as plane images, images with text, and either of those options can be clickable links if a link is set.</p>
<p><b>Tip:</b> You can blow these images out to the edge of the screen and remove the gutters to create a completely different look.</p>"
info_rich_text_content_body: "<p>The Rich Text Content section is simply a section that offers nothing more than an area of rich text editor content to be displayed on your page.</p>"
brand_bar:
@@ -606,8 +606,7 @@ en:
side_by_side:
left_image: Left Image
right_image: Right Image
- section_one_info: 'This section is displayed on the left hand side of the screen and stacks to fullscreen on mobile size screens. Please use an image with an aspect ratio of 54:35 (1468px x 952px).'
- section_two_info: 'This section is displayed on the right hand side of the screen and stacks to fullscreen on mobile size screens. Please use an image with an aspect ratio of 54:35 (1468px x 952px).'
+ image_info: 'Please use an image with an aspect ratio of 54:35 (1468px x 952px).'
three_taxon_block:
top_left_block: Top Left Block
section_one_info: 'This section is displayed in the top left of the three image block. Please use an image with an aspect ratio of 18:13 (1080px x 780px).'
diff --git a/core/lib/spree/testing_support/factories/cms_section_factory.rb b/core/lib/spree/testing_support/factories/cms_section_factory.rb
index 2933113f12..2fe0ab74d8 100644
--- a/core/lib/spree/testing_support/factories/cms_section_factory.rb
+++ b/core/lib/spree/testing_support/factories/cms_section_factory.rb
@@ -18,12 +18,8 @@ FactoryBot.define do
type { 'Spree::Cms::Sections::ImageGallery' }
end
- factory :cms_static_branding_bar_section do
- type { 'Spree::Cms::Sections::StaticBrandingBar' }
- end
-
factory :cms_side_by_side_promotion_section do
- type { 'Spree::Cms::Sections::SideBySidePromotion' }
+ type { 'Spree::Cms::Sections::SideBySideImages' }
end
end
end
diff --git a/frontend/app/views/spree/shared/cms/sections/_side_by_side_promotion.html.erb b/frontend/app/views/spree/shared/cms/sections/_side_by_side_images.html.erb
similarity index 100%
rename from frontend/app/views/spree/shared/cms/sections/_side_by_side_promotion.html.erb
rename to frontend/app/views/spree/shared/cms/sections/_side_by_side_images.html.erb
diff --git a/sample/db/samples/cms_sections.rb b/sample/db/samples/cms_sections.rb
index 45bd3952b8..300147cca2 100644
--- a/sample/db/samples/cms_sections.rb
+++ b/sample/db/samples/cms_sections.rb
@@ -232,7 +232,7 @@ PAGES.each do |page|
promos_section = Spree::CmsSection.where(
name: name_txt,
- type: 'Spree::Cms::Sections::SideBySidePromotion',
+ type: 'Spree::Cms::Sections::SideBySideImages',
cms_page: page
).first_or_create!