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 slug links, add RTE section and buy bar.
Matthew Kennedy0b08c469baf7
diff --git a/backend/app/assets/javascripts/spree/backend/global/tinymce.es6 b/backend/app/assets/javascripts/spree/backend/global/tinymce.es6index a579291d2e..0e3cbf2337 100644--- a/backend/app/assets/javascripts/spree/backend/global/tinymce.es6+++ b/backend/app/assets/javascripts/spree/backend/global/tinymce.es6@@ -3,9 +3,9 @@ document.addEventListener('DOMContentLoaded', function() {tinymce.init({selector: '.spree-rte',plugins: [- 'image table paste code link'+ 'image table paste code link table'],menubar: false,- toolbar: 'undo redo | styleselect | bold italic link | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | code '+ toolbar: 'undo redo | styleselect | bold italic link | alignleft aligncenter alignright alignjustify | table | bullist numlist outdent indent | code '});})diff --git a/backend/app/views/spree/admin/cms_sections/types/_product_buy_bar.html.erb b/backend/app/views/spree/admin/cms_sections/types/_product_buy_bar.html.erbnew file mode 100644index 0000000000..1752013969--- /dev/null+++ b/backend/app/views/spree/admin/cms_sections/types/_product_buy_bar.html.erb@@ -0,0 +1,30 @@+<div class="row">+ <div class="col-12 col-md-6">+ <%= f.field_container :overide_product_name, class: ['form-group'] do %>+ <%= f.label :overide_product_name, Spree.t('admin.cms.overide_product_name') %>+ <%= f.text_field :overide_product_name, class: 'form-control' %>+ <%= f.error_message_on :overide_product_name %>+ <% end %>++ <%= f.field_container :button_text, class: ['form-group'] do %>+ <%= f.label :button_text, Spree.t('admin.cms.button_text') %>+ <%= f.text_field :button_text, class: 'form-control' %>+ <%= f.error_message_on :button_text %>+ <% 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,+ spree_humanize_dropdown_values('Spree::Cms::Sections::ProductBuyBar',+ { const: 'LINKED_RESOURCE_TYPE' }),+ { 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/_rich_text_content.html.erb b/backend/app/views/spree/admin/cms_sections/types/_rich_text_content.html.erbnew file mode 100644index 0000000000..f7b1b50a3a--- /dev/null+++ b/backend/app/views/spree/admin/cms_sections/types/_rich_text_content.html.erb@@ -0,0 +1,7 @@+ <div class="col-12">+ <%= f.field_container :rte_content, class: ['form-group'] do %>+ <%= f.label :rte_content, Spree.t('content') %>+ <%= f.text_area :rte_content, { rows: "20", class: 'form-control spree-rte' } %>+ <%= f.error_message_on :rte_content %>+ <% end %>+ </div>diff --git a/core/app/models/concerns/spree/display_link.rb b/core/app/models/concerns/spree/display_link.rbindex 94d773dc01..b1d5205ede 100644--- a/core/app/models/concerns/spree/display_link.rb+++ b/core/app/models/concerns/spree/display_link.rb@@ -22,7 +22,7 @@ module Spreereturn if linked_resource.nil?if spree_routes.method_defined?(:page_path)- spree_routes.page_path(linked_resource)+ spree_routes.page_path(linked_resource.slug)else"/#{Spree::Config[:storefront_pages_path]}/#{linked_resource.slug}"enddiff --git a/core/app/models/spree/cms/sections/full_screen_hero_image.rb b/core/app/models/spree/cms/sections/full_screen_hero_image.rbindex e64eeb9e2d..85b25bd366 100644--- a/core/app/models/spree/cms/sections/full_screen_hero_image.rb+++ b/core/app/models/spree/cms/sections/full_screen_hero_image.rb@@ -5,7 +5,7 @@ module Spree::Cms::Sectionsstore :content, accessors: [:title, :button_text], coder: JSONstore :settings, accessors: [:gutters], coder: JSON- LINKED_RESOURCE_TYPE = ['Spree::Taxon', 'Spree::Product']+ LINKED_RESOURCE_TYPE = ['Spree::Taxon', 'Spree::Product', 'Spree::CmsPage']def gutters?gutters == 'Gutters'diff --git a/core/app/models/spree/cms/sections/product_buy_bar.rb b/core/app/models/spree/cms/sections/product_buy_bar.rbnew file mode 100644index 0000000000..84fd41c191--- /dev/null+++ b/core/app/models/spree/cms/sections/product_buy_bar.rb@@ -0,0 +1,21 @@+module Spree::Cms::Sections+ class ProductBuyBar < Spree::CmsSection+ after_initialize :default_values++ store :content, accessors: [:overide_product_name, :button_text], coder: JSON+ store :settings, accessors: [:show_price], coder: JSON++ LINKED_RESOURCE_TYPE = ['Spree::Product']++ def css_classes+ ['row', 'section-row', 'sticky-top'].compact+ end++ private++ def default_values+ self.fit ||= 'Screen'+ self.linked_resource_type ||= 'Spree::Product'+ end+ end+enddiff --git a/core/app/models/spree/cms/sections/rich_text_content.rb b/core/app/models/spree/cms/sections/rich_text_content.rbnew file mode 100644index 0000000000..79cb7909c0--- /dev/null+++ b/core/app/models/spree/cms/sections/rich_text_content.rb@@ -0,0 +1,19 @@+module Spree::Cms::Sections+ class RichTextContent < Spree::CmsSection+ after_initialize :default_values++ store :content, accessors: [:rte_content], coder: JSON+ store :settings, accessors: [:gutters], coder: JSON++ def gutters?+ gutters == 'Gutters'+ end++ private++ def default_values+ self.gutters ||= 'Gutters'+ self.fit ||= 'Container'+ end+ end+enddiff --git a/core/app/models/spree/cms_section.rb b/core/app/models/spree/cms_section.rbindex 2779eb33bb..cec149d07f 100644--- a/core/app/models/spree/cms_section.rb+++ b/core/app/models/spree/cms_section.rb@@ -29,12 +29,18 @@ module Spree'Spree::Cms::Sections::ProductCarousel','Spree::Cms::Sections::ThreeTaxonCategoriesBlock','Spree::Cms::Sections::StaticBrandingBar',- 'Spree::Cms::Sections::SideBySidePromotion']+ 'Spree::Cms::Sections::SideBySidePromotion',+ 'Spree::Cms::Sections::ProductBuyBar',+ 'Spree::Cms::Sections::RichTextContent']def boundaries['Container', 'Screen']end+ def css_classes+ ['row', 'section-row'].compact+ end+def gutters_sizes['Gutters', 'No Gutters']enddiff --git a/core/app/models/spree/menu.rb b/core/app/models/spree/menu.rbindex c481dd9e0c..d434b2940b 100644--- a/core/app/models/spree/menu.rb+++ b/core/app/models/spree/menu.rb@@ -1,6 +1,6 @@module Spreeclass Menu < Spree::Base- MENU_LOCATIONS = ['Header', 'Footer', 'Brands']+ MENU_LOCATIONS = ['Header', 'Footer', 'Brands', 'Demo Buy Bar']MENU_LOCATIONS_PARAMETERIZED = []MENU_LOCATIONS.each do |location|diff --git a/frontend/app/assets/stylesheets/spree/frontend/application.scss b/frontend/app/assets/stylesheets/spree/frontend/application.scssindex 9f97799d7e..bdba6ffb99 100644--- a/frontend/app/assets/stylesheets/spree/frontend/application.scss+++ b/frontend/app/assets/stylesheets/spree/frontend/application.scss@@ -28,6 +28,7 @@@import "spree/frontend/views/spree/shared/order_details";@import "spree/frontend/views/spree/shared/main_nav_bar";@import "spree/frontend/views/spree/errors/not_found";+@import "spree/frontend/views/spree/cms_sections/_index";@import "spree/frontend/views/spree/shared/carousel/thumbnails";@import "spree/frontend/views/spree/shared/carousel/single";@import "spree/frontend/views/spree/home/index";diff --git a/frontend/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/_index.scss b/frontend/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/_index.scssnew file mode 100644index 0000000000..2a5082d507--- /dev/null+++ b/frontend/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/_index.scss@@ -0,0 +1 @@+@import "spree/frontend/views/spree/cms_sections/product_buy_bar";diff --git a/frontend/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/product_buy_bar.scss b/frontend/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/product_buy_bar.scssnew file mode 100644index 0000000000..c219a06b55--- /dev/null+++ b/frontend/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/product_buy_bar.scss@@ -0,0 +1,20 @@+.row.section-row.sticky-top {+ z-index: 3;+ background-color: rgba(255, 255, 255, 0.95);+ padding: 5px 0;+ border-top: 1px solid $global-border-style;+ border-bottom: 1px solid $global-border-style;+ top: $spree-header-mobile-height + 24px;++ .buy-container {+ min-height: $spree-header-mobile-height;+ }++ li.buy-bar {+ a { color: grey;+ &.active {+ color: $header-font-color;+ }+ }+ }+}diff --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 07b48e73eb..46974bd3c4 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@@ -50,7 +50,7 @@@include media-breakpoint-up(md) {font-size: font-px-to-rem(44px);- width: 288px;+ width: 398px;}@include media-breakpoint-up(lg) {diff --git a/frontend/app/helpers/spree/cms_pages_helper.rb b/frontend/app/helpers/spree/cms_pages_helper.rbindex 7bba1464de..6ae588c6ee 100644--- a/frontend/app/helpers/spree/cms_pages_helper.rb+++ b/frontend/app/helpers/spree/cms_pages_helper.rb@@ -5,7 +5,7 @@ module Spreeenddef section_tags(section, &block)- inner_content = content_tag(:div, class: 'row section-row', &block)+ inner_content = content_tag(:div, class: section.css_classes , &block)if section.fullscreen?inner_contentdiff --git a/frontend/app/views/spree/shared/cms/sections/_product_buy_bar.html.erb b/frontend/app/views/spree/shared/cms/sections/_product_buy_bar.html.erbnew file mode 100644index 0000000000..3ef13182c4--- /dev/null+++ b/frontend/app/views/spree/shared/cms/sections/_product_buy_bar.html.erb@@ -0,0 +1,29 @@+<div class="col-12 buy-container">+ <div class="container-fluid h-100 header-spree-fluid">+ <div class="d-flex flex-nowrap align-items-center h-100 px-2">+ <figure class="logo flex-grow-1 header-spree-fluid-logo m-0">+ <h3 class="m-0 p-0"><%= section.linked_resource.name %></h3>+ </figure>++ <div class="d-flex h-100">+ <% if spree_menu('demo_buy_bar').present? %>+ <ul class="d-block d-md-flex h-100 m-0 p-0">+ <% spree_menu('demo_buy_bar').children.each do |link| %>+ <li class="p-0 mx-3 d-flex buy-bar">+ <%= spree_nav_link_tag(link, { class: "d-flex align-items-center" }) %>+ </li>+ <% end %>+ </ul>+ <% end %>+ </div>++ <div class="d-flex ml-3 align-items-center justify-content-end navbar-right">+ <% if section.link.present? && section.button_text.present? %>+ <div>+ <%= link_to section.button_text, section.link, class: 'btn btn-primary spree-btn px-5' %>+ </div>+ <% end %>+ </div>+ </div>+ </div>+</div>diff --git a/frontend/app/views/spree/shared/cms/sections/_rich_text_content.html.erb b/frontend/app/views/spree/shared/cms/sections/_rich_text_content.html.erbnew file mode 100644index 0000000000..cf6911b66c--- /dev/null+++ b/frontend/app/views/spree/shared/cms/sections/_rich_text_content.html.erb@@ -0,0 +1,3 @@+<div class="col-12">+ <%= raw section.rte_content %>+</div>