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
Update Taxon section
Matthew Kennedyb50c355c0d15
diff --git a/.solargraph.yml b/.solargraph.ymlindex 7083c64553..bd86828bc5 100644--- a/.solargraph.yml+++ b/.solargraph.yml@@ -8,7 +8,8 @@ exclude:- vendor/**/*- ".bundle/**/*"- sample/**/*-- cmd/**/*+- cmd/lib/spree_cmd/templates/extension/extension.gemspec+- cmd/spree_cmd.gemspec- guides/**/*- sandbox/**/*- pkg/**/*diff --git a/backend/app/views/spree/admin/cms_sections/types/_carousel.html.erb b/backend/app/views/spree/admin/cms_sections/types/_carousel.html.erbindex 680fc9731a..44e7c35363 100644--- a/backend/app/views/spree/admin/cms_sections/types/_carousel.html.erb+++ b/backend/app/views/spree/admin/cms_sections/types/_carousel.html.erb@@ -1,5 +1,4 @@<div class="row">-<div class="col-12"><%= render "spree/admin/shared/link_fields", resource: @cms_section, f: f %></div>diff --git a/backend/app/views/spree/admin/cms_sections/types/_featured_article.html.erb b/backend/app/views/spree/admin/cms_sections/types/_featured_article.html.erbindex 1ea6682264..5d4b7937eb 100644--- a/backend/app/views/spree/admin/cms_sections/types/_featured_article.html.erb+++ b/backend/app/views/spree/admin/cms_sections/types/_featured_article.html.erb@@ -43,7 +43,11 @@<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.select(:linked_resource_type,+ spree_humanize_dropdown_values('Spree::Cms::Sections::FeaturedArticle',+ { const: 'LINKED_RESOURCE_TYPE' }),+ {include_blank: false},+ class: 'link_switcher') %><%= f.error_message_on :linked_resource_type %><% end %></div>diff --git a/backend/app/views/spree/admin/cms_sections/types/_hero.html.erb b/backend/app/views/spree/admin/cms_sections/types/_hero.html.erbindex bf1ff9a226..d87b1b9ee0 100644--- a/backend/app/views/spree/admin/cms_sections/types/_hero.html.erb+++ b/backend/app/views/spree/admin/cms_sections/types/_hero.html.erb@@ -47,7 +47,11 @@<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.select(:linked_resource_type,+ spree_humanize_dropdown_values('Spree::Cms::Sections::Hero',+ { const: 'LINKED_RESOURCE_TYPE' }),+ {include_blank: false},+ class: 'link_switcher') %><%= f.error_message_on :linked_resource_type %><% end %></div>diff --git a/backend/app/views/spree/admin/cms_sections/types/_promo.html.erb b/backend/app/views/spree/admin/cms_sections/types/_promo.html.erbindex 83978533bc..93302175cb 100644--- a/backend/app/views/spree/admin/cms_sections/types/_promo.html.erb+++ b/backend/app/views/spree/admin/cms_sections/types/_promo.html.erb@@ -57,7 +57,11 @@<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.select(:linked_resource_type,+ spree_humanize_dropdown_values('Spree::Cms::Sections::Promo',+ { const: 'LINKED_RESOURCE_TYPE' }),+ {include_blank: false},+ class: 'link_switcher') %><%= f.error_message_on :linked_resource_type %><% end %></div>diff --git a/backend/app/views/spree/admin/cms_sections/types/_menu_category.html.erb b/backend/app/views/spree/admin/cms_sections/types/_taxon_category.html.erbsimilarity index 55%rename from backend/app/views/spree/admin/cms_sections/types/_menu_category.html.erbrename to backend/app/views/spree/admin/cms_sections/types/_taxon_category.html.erbindex c6b3810064..d20035eb6f 100644--- a/backend/app/views/spree/admin/cms_sections/types/_menu_category.html.erb+++ b/backend/app/views/spree/admin/cms_sections/types/_taxon_category.html.erb@@ -1,5 +1,18 @@<div class="row"><div class="col-12 col-md-6">+ <%= f.field_container :image_one, class: ['form-group'] do %>+ <% if @cms_section.image_one.attached? && @cms_section.image_one.variable? %>+ <%= image_tag main_app.url_for(@cms_section.image_one.variant(resize: '244x104>')) %>+ <% elsif @cms_section.image_one.attached? && @cms_section.image_one.image? %>+ <%= image_tag main_app.url_for(@cms_section.image_one) %>+ <% end %>+ <%= f.field_container :image_one, class: ['form-group'] do %>+ <%= f.label :image_one, Spree.t(:image_one) %><br>+ <%= f.file_field :image_one %>+ <%= f.error_message_on :image_one %>+ <% end %>+ <% end %>+<%= f.field_container :title, class: ['form-group'] do %><%= f.label :title, Spree.t(:title) %><%= f.select :title,@@ -17,6 +30,18 @@</div><div class="col-12 col-md-6">+ <%= f.field_container :image_two, class: ['form-group'] do %>+ <% if @cms_section.image_two.attached? && @cms_section.image_two.variable? %>+ <%= image_tag main_app.url_for(@cms_section.image_two.variant(resize: '244x104>')) %>+ <% elsif @cms_section.image_two.attached? && @cms_section.image_two.image? %>+ <%= image_tag main_app.url_for(@cms_section.image_two) %>+ <% end %>+ <%= f.field_container :image_two, class: ['form-group'] do %>+ <%= f.label :image_two, Spree.t(:image_two) %><br>+ <%= f.file_field :image_two %>+ <%= f.error_message_on :image_two %>+ <% end %>+ <% end %><%= f.field_container :subtitle, class: ['form-group'] do %><%= f.label :subtitle, Spree.t(:subtitle) %><%= f.select :subtitle,@@ -34,6 +59,18 @@</div><div class="col-12 col-md-6">+ <%= f.field_container :image_three, class: ['form-group'] do %>+ <% if @cms_section.image_three.attached? && @cms_section.image_three.variable? %>+ <%= image_tag main_app.url_for(@cms_section.image_three.variant(resize: '244x104>')) %>+ <% elsif @cms_section.image_three.attached? && @cms_section.image_three.image? %>+ <%= image_tag main_app.url_for(@cms_section.image_three) %>+ <% end %>+ <%= f.field_container :image_three, class: ['form-group'] do %>+ <%= f.label :image_three, Spree.t(:image_three) %><br>+ <%= f.file_field :image_three %>+ <%= f.error_message_on :image_three %>+ <% end %>+ <% end %><%= f.field_container :button_text, class: ['form-group'] do %><%= f.label :button_text, Spree.t(:button_text) %><%= f.select :button_text,diff --git a/core/app/models/spree/cms/sections/carousel.rb b/core/app/models/spree/cms/sections/carousel.rbindex 3b2f32f461..aa8194a50f 100644--- a/core/app/models/spree/cms/sections/carousel.rb+++ b/core/app/models/spree/cms/sections/carousel.rb@@ -2,9 +2,7 @@ module Spree::Cms::Sectionsclass Carousel < Spree::CmsSectionafter_initialize :default_values- def links_to- ['Spree::Taxon']- end+ LINKED_RESOURCE_TYPE = ['Spree::Taxon']def widths['Full']diff --git a/core/app/models/spree/cms/sections/featured_article.rb b/core/app/models/spree/cms/sections/featured_article.rbindex 6f3ca9f25b..a2911121c7 100644--- a/core/app/models/spree/cms/sections/featured_article.rb+++ b/core/app/models/spree/cms/sections/featured_article.rb@@ -2,9 +2,7 @@ module Spree::Cms::Sectionsclass FeaturedArticle < Spree::CmsSectionafter_initialize :default_values- def links_to- ['Spree::Taxon', 'Spree::Product']- end+ LINKED_RESOURCE_TYPE = ['Spree::Taxon', 'Spree::Product', 'Spree::CmsPage']def widths['Full', 'Half']diff --git a/core/app/models/spree/cms/sections/hero.rb b/core/app/models/spree/cms/sections/hero.rbindex f9809038a9..b076b192ef 100644--- a/core/app/models/spree/cms/sections/hero.rb+++ b/core/app/models/spree/cms/sections/hero.rb@@ -5,9 +5,7 @@ module Spree::Cms::Sectionshas_one :icon, as: :viewable, dependent: :destroy, class_name: 'Spree::Icon'accepts_nested_attributes_for :icon, reject_if: :all_blank- def links_to- ['Spree::Taxon', 'Spree::Product']- end+ LINKED_RESOURCE_TYPE = ['Spree::Taxon', 'Spree::Product']def widths['Full']diff --git a/core/app/models/spree/cms/sections/promo.rb b/core/app/models/spree/cms/sections/promo.rbindex 396d731127..65e6418a9c 100644--- a/core/app/models/spree/cms/sections/promo.rb+++ b/core/app/models/spree/cms/sections/promo.rb@@ -5,9 +5,7 @@ module Spree::Cms::Sectionshas_one :icon, as: :viewable, dependent: :destroy, class_name: 'Spree::Icon'accepts_nested_attributes_for :icon, reject_if: :all_blank- def links_to- ['Spree::Taxon', 'Spree::Product']- end+ LINKED_RESOURCE_TYPE = ['Spree::Taxon', 'Spree::Product']# Overide this per section typedef widthsdiff --git a/core/app/models/spree/cms/sections/menu_category.rb b/core/app/models/spree/cms/sections/taxon_category.rbsimilarity index 57%rename from core/app/models/spree/cms/sections/menu_category.rbrename to core/app/models/spree/cms/sections/taxon_category.rbindex 2279832ae2..8759d9b5a0 100644--- a/core/app/models/spree/cms/sections/menu_category.rb+++ b/core/app/models/spree/cms/sections/taxon_category.rb@@ -1,7 +1,11 @@module Spree::Cms::Sections- class MenuCategory < Spree::CmsSection+ class TaxonCategory < Spree::CmsSectionafter_initialize :default_values+ has_one_attached :image_one+ has_one_attached :image_two+ has_one_attached :image_three+def widths['Full']enddiff --git a/core/app/models/spree/cms_section.rb b/core/app/models/spree/cms_section.rbindex 1bb337c2e1..7573199e70 100644--- a/core/app/models/spree/cms_section.rb+++ b/core/app/models/spree/cms_section.rb@@ -3,22 +3,19 @@ module Spreeinclude Spree::DisplayLinkacts_as_list scope: :cms_page- belongs_to :cms_page+ belongs_to :cms_page, touch: truebelongs_to :linked_resource, polymorphic: truedefault_scope { order(position: :asc) }+ LINKED_RESOURCE_TYPE = []+TYPES = ['Spree::Cms::Sections::Hero','Spree::Cms::Sections::Promo','Spree::Cms::Sections::FeaturedArticle','Spree::Cms::Sections::Carousel',- 'Spree::Cms::Sections::MenuCategory']-- # Overide this per section type- def links_to- []- end+ 'Spree::Cms::Sections::TaxonCategory']# Overide this per section typedef boundariesdiff --git a/frontend/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss b/frontend/app/assets/stylesheets/spree/frontend/views/spree/home/index.scssindex a0511ff32d..6f8f23123b 100644--- a/frontend/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss+++ b/frontend/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss@@ -207,6 +207,7 @@max-height: 70%;min-width: 60%;max-width: 80%;+ bottom: 35px;&-small-text {font-weight: 500;diff --git a/frontend/app/controllers/spree/home_controller.rb b/frontend/app/controllers/spree/home_controller.rbindex 4050b60814..7b99be25e3 100644--- a/frontend/app/controllers/spree/home_controller.rb+++ b/frontend/app/controllers/spree/home_controller.rb@@ -15,12 +15,26 @@ module Spreeendif http_cache_enabled?- fresh_when etag: store_etag, last_modified: store_last_modified, public: true+ fresh_when etag: store_etag, last_modified: last_modified_index, public: trueendendprivate+ def etag_index+ [+ store_etag,+ last_modified_index,+ ]+ end++ def last_modified_index+ page_last_modified = @cms_home_page.maximum(:updated_at)&.utc if @cms_home_page.respond_to?(:maximum)+ current_store_last_modified = current_store.updated_at.utc++ [page_last_modified, current_store_last_modified].compact.max+ end+def accurate_titleif @cms_home_page@cms_home_page.seo_titlediff --git a/frontend/app/views/spree/shared/cms/sections/_featured_article.html.erb b/frontend/app/views/spree/shared/cms/sections/_featured_article.html.erbindex 8df7c62806..74a038a709 100644--- a/frontend/app/views/spree/shared/cms/sections/_featured_article.html.erb+++ b/frontend/app/views/spree/shared/cms/sections/_featured_article.html.erb@@ -1,6 +1,6 @@-<<%= element %> class="<%= width %>">+<<%= element %> class="<%= width %> mb-3"><div class="<%= boundary %>">- <div class="homepage-fashion-trends-box mb-3">+ <div class="homepage-fashion-trends-box"><div class="text-center"><% if section.title.present? %>@@ -12,11 +12,14 @@<% end %><div class="homepage-fashion-trends-box-description-text text-center mb-3">- <%= raw section.content %>+ <div class="mb-3">+ <%= raw section.content %>+ </div>++ <% if section.button_text.present? && section.link.present? %>+ <%= link_to section.button_text, section.link, class: 'btn text-center spree-btn btn-outline-primary w-75' %>+ <% end %></div>- <% if section.button_text.present? && section.link.present? %>- <%= link_to section.button_text, section.link, class: 'btn text-center spree-btn btn-outline-primary' %>- <% end %></div></div></div>diff --git a/frontend/app/views/spree/shared/cms/sections/_menu_category.html.erb b/frontend/app/views/spree/shared/cms/sections/_menu_category.html.erbdeleted file mode 100644index a541714115..0000000000--- a/frontend/app/views/spree/shared/cms/sections/_menu_category.html.erb+++ /dev/null@@ -1,35 +0,0 @@-<div class="col-6">- <%= link_to spree.nested_taxons_path(section.title), class: "homepage-taxon-box mb-3" do %>- <img class="w-100 lazyload"- data-src="<%= asset_path('homepage/category_banner_upper.jpg') %>"- data-srcset="<%= image_source_set('homepage/category_banner_upper') %>"- alt="<%= section.title %>">-- <div class="homepage-taxon-box-text">- <h3><%= section.title %></h3>- </div>- <% end %>- <%= link_to spree.nested_taxons_path(section.subtitle), class: "homepage-taxon-box" do %>- <img class="w-100 lazyload"- data-src="<%= asset_path('homepage/category_banner_lower.jpg') %>"- data-srcset="<%= image_source_set('homepage/category_banner_lower') %>"- alt="<%= section.subtitle %>">-- <div class="homepage-taxon-box-text" role="img" aria-label="Sportswear">- <h3><%= section.subtitle %></h3>- </div>- <% end %>-</div>--<div class="col-6 d-flex flex-column">- <%= link_to spree.nested_taxons_path(section.button_text), class: "homepage-taxon-box flex-grow-1" do %>- <img class="w-100 lazyload"- data-src="<%= asset_path('homepage/big_category_banner.jpg') %>"- data-srcset="<%= image_source_set('homepage/big_category_banner') %>"- alt="<%= section.button_text %>">-- <div class="homepage-taxon-box-text">- <h3><%= section.button_text %></h3>- </div>- <% end %>-</div>diff --git a/frontend/app/views/spree/shared/cms/sections/_promo.html.erb b/frontend/app/views/spree/shared/cms/sections/_promo.html.erbindex ad59355839..d337eff17f 100644--- a/frontend/app/views/spree/shared/cms/sections/_promo.html.erb+++ b/frontend/app/views/spree/shared/cms/sections/_promo.html.erb@@ -1,11 +1,10 @@-<aside class="<%= width %>">+<aside class="<%= width %> mb-3"><div class="<%= boundary %>"><%= link_to section.link do %><div class="d-flex- align-items-center+ align-items-endjustify-content-centerbg-light text-center- mb-3overflow-hiddenhomepage-bottom-box"style="--aspect-ratio:54/35;">@@ -30,7 +29,7 @@alt="<%= section.icon.alt %>"><% end %>- <div class="homepage-bottom-box-inner p-1 p-sm-2 p-md-3 p-lg-5" role="img" aria-label="New Collection">+ <div class="homepage-bottom-box-inner p-1 p-sm-2 p-md-4" role="img" aria-label="New Collection"><div class="homepage-bottom-box-inner-small-text"><%= section.title %></div>diff --git a/frontend/app/views/spree/shared/cms/sections/_taxon_category.html.erb b/frontend/app/views/spree/shared/cms/sections/_taxon_category.html.erbnew file mode 100644index 0000000000..2e2e8e4c36--- /dev/null+++ b/frontend/app/views/spree/shared/cms/sections/_taxon_category.html.erb@@ -0,0 +1,81 @@+<div class="col-6 mb-3">+ <%= link_to spree.nested_taxons_path(section.title), class: "homepage-taxon-box mb-3" do %>++ <% if section.image_one.attached? && section.image_one.variable? %>+ <!-- XS to MD -->+ <img class="d-md-none lazyload"+ data-src="<%= main_app.url_for(section.image_one.attachment.variant(resize: '387x250>')) %>"+ data-srcset="<%= main_app.url_for(section.image_one.attachment.variant(resize: '387x250>')) %>"+ alt="<%= section.title %>">++ <!-- MD to XL -->+ <img class="d-none d-md-block d-xl-none lazyload"+ data-src="<%= main_app.url_for(section.image_one.attachment.variant(resize: '734x476>')) %>"+ data-srcset="<%= main_app.url_for(section.image_one.attachment.variant(resize: '734x476>')) %>"+ alt="<%= section.title %>">++ <!-- XL UP -->+ <img class="d-none d-xl-block lazyload"+ data-src="<%= main_app.url_for(section.image_one.attachment.variant(resize: '1468x952>')) %>"+ data-srcset="<%= main_app.url_for(section.image_one.attachment.variant(resize: '1468x952>')) %>"+ alt="<%= section.title %>">+ <% end %>++ <div class="homepage-taxon-box-text">+ <h3><%= section.title %></h3>+ </div>+ <% end %>+ <%= link_to spree.nested_taxons_path(section.button_text), class: "homepage-taxon-box" do %>+ <% if section.image_three.attached? && section.image_three.variable? %>+ <!-- XS to MD -->+ <img class="d-md-none lazyload"+ data-src="<%= main_app.url_for(section.image_three.attachment.variant(resize: '387x250>')) %>"+ data-srcset="<%= main_app.url_for(section.image_three.attachment.variant(resize: '387x250>')) %>"+ alt="<%= section.button_text %>">++ <!-- MD to XL -->+ <img class="d-none d-md-block d-xl-none lazyload"+ data-src="<%= main_app.url_for(section.image_three.attachment.variant(resize: '734x476>')) %>"+ data-srcset="<%= main_app.url_for(section.image_three.attachment.variant(resize: '734x476>')) %>"+ alt="<%= section.button_text %>">++ <!-- XL UP -->+ <img class="d-none d-xl-block lazyload"+ data-src="<%= main_app.url_for(section.image_three.attachment.variant(resize: '1468x952>')) %>"+ data-srcset="<%= main_app.url_for(section.image_three.attachment.variant(resize: '1468x952>')) %>"+ alt="<%= section.button_text %>">+ <% end %>++ <div class="homepage-taxon-box-text" role="img" aria-label="Sportswear">+ <h3><%= section.button_text %></h3>+ </div>+ <% end %>+</div>++<div class="col-6 mb-3 d-flex flex-column">+ <%= link_to spree.nested_taxons_path(section.subtitle), class: "homepage-taxon-box flex-grow-1" do %>+ <% if section.image_two.attached? && section.image_two.variable? %>+ <!-- XS to MD -->+ <img class="d-md-none lazyload"+ data-src="<%= main_app.url_for(section.image_two.variant(resize: '387x250>')) %>"+ data-srcset="<%= main_app.url_for(section.image_two.variant(resize: '387x250>')) %>"+ alt="<%= section.subtitle %>">++ <!-- MD to XL -->+ <img class="d-none d-md-block d-xl-none lazyload"+ data-src="<%= main_app.url_for(section.image_two.variant(resize: '734x476>')) %>"+ data-srcset="<%= main_app.url_for(section.image_two.variant(resize: '734x476>')) %>"+ alt="<%= section.subtitle %>">++ <!-- XL UP -->+ <img class="d-none d-xl-block lazyload"+ data-src="<%= main_app.url_for(section.image_two.variant(resize: '1468x952>')) %>"+ data-srcset="<%= main_app.url_for(section.image_two.variant(resize: '1468x952>')) %>"+ alt="<%= section.subtitle %>">+ <% end %>++ <div class="homepage-taxon-box-text">+ <h3><%= section.subtitle %></h3>+ </div>+ <% end %>+</div>