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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Add new sections.
Matthew Kennedy13fc6ce881dd
diff --git a/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scss b/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scssindex 2dc2bcea6d..0de5c3d965 100644--- a/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scss+++ b/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scss@@ -10,6 +10,8 @@display: none;}+ // Reduce the padding size for cols inside the+ // page sections drag and drop organizer, we need that space badly..col-xl, .col-xl-auto, .col-xl-12,.col-xl-11, .col-xl-10, .col-xl-9,.col-xl-8, .col-xl-7, .col-xl-6,diff --git a/backend/app/views/spree/admin/cms_sections/types/_spree_cms_sections_carousel.html.erb b/backend/app/views/spree/admin/cms_sections/types/_spree_cms_sections_carousel.html.erbnew file mode 100644index 0000000000..e71f5403f3--- /dev/null+++ b/backend/app/views/spree/admin/cms_sections/types/_spree_cms_sections_carousel.html.erb@@ -0,0 +1,27 @@+<div class="row">+ <div class="col-12">+ <%= f.field_container :title, class: ['form-group'] do %>+ <%= f.label :title, Spree.t(:title) %>+ <%= f.text_field :title, class: 'form-control' %>+ <%= f.error_message_on :title %>+ <% end %>++ <%= f.field_container :subtitle, class: ['form-group'] do %>+ <%= f.label :subtitle, Spree.t(:subtitle) %>+ <%= f.text_field :subtitle, class: 'form-control' %>+ <%= f.error_message_on :subtitle %>+ <% end %>+ </div>++ <div class="col-12"><hr></div>+ <div class="col-12 col-md-6">+ <%= f.field_container :linked_resource_type, class: ['form-group'] do %>+ <%= f.label :linked_resource_type, Spree.t('admin.navigation.link_to') %>+ <%= f.select(:linked_resource_type, @cms_section.links_to, {include_blank: false}, class: 'link_switcher') %>+ <%= f.error_message_on :linked_resource_type %>+ <% end %>+ </div>+ <div class="col-12 col-md-6">+ <%= render "spree/admin/shared/link_fields", resource: @cms_section, f: f %>+ </div>+</div>diff --git a/backend/app/views/spree/admin/cms_sections/types/_spree_cms_sections_categorybannersquare.html.erb b/backend/app/views/spree/admin/cms_sections/types/_spree_cms_sections_categorybannersquare.html.erbnew file mode 100644index 0000000000..accbe49dd5--- /dev/null+++ b/backend/app/views/spree/admin/cms_sections/types/_spree_cms_sections_categorybannersquare.html.erb@@ -0,0 +1,53 @@+<div class="row">+ <div class="col-12 col-md-6">+ <%= f.field_container :title, class: ['form-group'] do %>+ <%= f.label :title, Spree.t(:title) %>+ <%= f.text_field :title, class: 'form-control' %>+ <%= f.error_message_on :title %>+ <% end %>++ <%= f.field_container :subtitle, class: ['form-group'] do %>+ <%= f.label :subtitle, Spree.t(:subtitle) %>+ <%= f.text_field :subtitle, class: 'form-control' %>+ <%= f.error_message_on :subtitle %>+ <% end %>+ </div>+ <div class="col-12 col-md-6">+ <%= f.field_container :upper_image, class: ['form-group'] do %>+ <% if @cms_section.upper_image.attached? && @cms_section.upper_image.variable? %>+ <%= image_tag main_app.url_for(@cms_section.upper_image.variant(resize: '244x104>')) %>+ <% elsif @cms_section.upper_image.attached? && @cms_section.upper_image.image? %>+ <%= image_tag main_app.url_for(@cms_section.upper_image) %>+ <% end %>+ <%= f.field_container :upper_image, class: ['form-group'] do %>+ <%= f.label :upper_image, Spree.t(:upper_image) %><br>+ <%= f.file_field :upper_image %>+ <%= f.error_message_on :upper_image %>+ <% end %>+ <% end %>++ <%= f.field_container :lower_image, class: ['form-group'] do %>+ <% if @cms_section.lower_image.attached? && @cms_section.lower_image.variable? %>+ <%= image_tag main_app.url_for(@cms_section.lower_image.variant(resize: '244x104>')) %>+ <% elsif @cms_section.lower_image.attached? && @cms_section.lower_image.image? %>+ <%= image_tag main_app.url_for(@cms_section.lower_image) %>+ <% end %>+ <%= f.field_container :lower_image, class: ['form-group'] do %>+ <%= f.label :lower_image, Spree.t(:lower_image) %><br>+ <%= f.file_field :lower_image %>+ <%= f.error_message_on :lower_image %>+ <% end %>+ <% end %>+ </div>+ <div class="col-12"><hr></div>+ <div class="col-12 col-md-6">+ <%= f.field_container :linked_resource_type, class: ['form-group'] do %>+ <%= f.label :linked_resource_type, Spree.t('admin.navigation.link_to') %>+ <%= f.select(:linked_resource_type, @cms_section.links_to, {include_blank: false}, class: 'link_switcher') %>+ <%= f.error_message_on :linked_resource_type %>+ <% end %>+ </div>+ <div class="col-12 col-md-6">+ <%= render "spree/admin/shared/link_fields", resource: @cms_section, f: f %>+ </div>+</div>diff --git a/core/app/models/concerns/spree/product_scopes.rb b/core/app/models/concerns/spree/product_scopes.rbindex 048d2b9535..faf7bef2b2 100644--- a/core/app/models/concerns/spree/product_scopes.rb+++ b/core/app/models/concerns/spree/product_scopes.rb@@ -107,8 +107,7 @@ module Spree"MIN(#{Classification.table_name}.position) AS min_position"].join(', ')).- group(:id).- order(min_position: :asc)+ group(:id)end# a scope that finds all products having property specified by name, object or iddiff --git a/core/app/models/spree/cms/sections/carousel.rb b/core/app/models/spree/cms/sections/carousel.rbnew file mode 100644index 0000000000..c4af60e4a5--- /dev/null+++ b/core/app/models/spree/cms/sections/carousel.rb@@ -0,0 +1,20 @@+module Spree::Cms::Sections+ class Carousel < Spree::CmsSection+ after_initialize :default_values++ def links_to+ ['Spree::Taxon']+ end++ def widths+ ['Edge-to-Edge']+ end++ private++ def default_values+ self.width ||= 'Edge-to-Edge'+ self.linked_resource_type ||= 'Spree::Taxon'+ end+ end+enddiff --git a/core/app/models/spree/cms/sections/category_banner_square.rb b/core/app/models/spree/cms/sections/category_banner_square.rbnew file mode 100644index 0000000000..15ef1ad09b--- /dev/null+++ b/core/app/models/spree/cms/sections/category_banner_square.rb@@ -0,0 +1,23 @@+module Spree::Cms::Sections+ class CategoryBannerSquare < Spree::CmsSection+ after_initialize :default_values++ has_one_attached :upper_image+ has_one_attached :lower_image++ def links_to+ ['Spree::Taxon', 'Spree::Product']+ end++ def widths+ ['Half']+ end++ private++ def default_values+ self.width ||= 'Half'+ self.linked_resource_type ||= 'Spree::Taxon'+ end+ end+enddiff --git a/core/app/models/spree/cms_section.rb b/core/app/models/spree/cms_section.rbindex 0346ab7234..20caea79e6 100644--- a/core/app/models/spree/cms_section.rb+++ b/core/app/models/spree/cms_section.rb@@ -11,7 +11,10 @@ module SpreeTYPES = ['Spree::Cms::Sections::Hero','Spree::Cms::Sections::Promo',- 'Spree::Cms::Sections::FeaturedArticle']+ 'Spree::Cms::Sections::FeaturedArticle',+ 'Spree::Cms::Sections::Carousel',+ 'Spree::Cms::Sections::CategoryBannerSquare',+ 'Spree::Cms::Sections::CategoryBannerTall']def links_to[]diff --git a/frontend/app/views/spree/shared/_carousel_4_products.html.erb b/frontend/app/views/spree/shared/_carousel_4_products.html.erbindex ea2a1f23f5..87d2e3ffc3 100644--- a/frontend/app/views/spree/shared/_carousel_4_products.html.erb+++ b/frontend/app/views/spree/shared/_carousel_4_products.html.erb@@ -1,4 +1,4 @@-<% cache [common_product_cache_keys, products&.maximum(:updated_at)&.to_i, id, products&.ids&.join(',')] do %>+<% cache [common_product_cache_keys, products&.maximum(:updated_at), id, products&.ids&.join(',')] do %><div id="<%= id %>-mobile" class="carousel slide d-md-none homepage-carousel" data-interval="false"><div class="carousel-inner"><% products.each_slice(2).with_index do |sliced_items, index| %>diff --git a/frontend/app/views/spree/shared/cms/sections/_spree_cms_sections_carousel.html.erb b/frontend/app/views/spree/shared/cms/sections/_spree_cms_sections_carousel.html.erbnew file mode 100644index 0000000000..e6c87f8c28--- /dev/null+++ b/frontend/app/views/spree/shared/cms/sections/_spree_cms_sections_carousel.html.erb@@ -0,0 +1,5 @@+<div class="<%= width %>">+ <div class="<%= edge_to_edge %>">+ <div data-product-carousel data-product-carousel-taxon-id='<%= section.linked_resource.permalink %>' class="my-3"></div>+ </div>+</div>diff --git a/frontend/app/views/spree/shared/cms/sections/_spree_cms_sections_categorybannersquare.html.erb b/frontend/app/views/spree/shared/cms/sections/_spree_cms_sections_categorybannersquare.html.erbnew file mode 100644index 0000000000..6b778fb69d--- /dev/null+++ b/frontend/app/views/spree/shared/cms/sections/_spree_cms_sections_categorybannersquare.html.erb@@ -0,0 +1 @@+_spree_cms_sections_categorybannersquare.html.erb