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
Clean up code.
Matthew Kennedy33f3283783fa
diff --git a/backend/app/assets/javascripts/spree/backend.js b/backend/app/assets/javascripts/spree/backend.jsindex 1da191a7ec..bfb1d3d2b4 100644--- a/backend/app/assets/javascripts/spree/backend.js+++ b/backend/app/assets/javascripts/spree/backend.js@@ -92,13 +92,13 @@ Spree.routes.stock_items_api = function (stockLocationId) {// API v2Spree.routes.countries_api_v2 = Spree.pathFor('api/v2/platform/countries')-Spree.routes.section_reposition_api_v2 = Spree.pathFor('/api/v2/platform/cms_sections/reposition')Spree.routes.menus_api_v2 = Spree.pathFor('api/v2/platform/menus')Spree.routes.menus_items_api_v2 = Spree.pathFor('api/v2/platform/menu_items')Spree.routes.option_types_api_v2 = Spree.pathFor('api/v2/platform/option_types')Spree.routes.option_values_api_v2 = Spree.pathFor('api/v2/platform/option_values')Spree.routes.pages_api_v2 = Spree.pathFor('api/v2/platform/cms_pages')Spree.routes.products_api_v2 = Spree.pathFor('/api/v2/platform/products')+Spree.routes.section_reposition_api_v2 = Spree.pathFor('/api/v2/platform/cms_sections')Spree.routes.taxons_api_v2 = Spree.pathFor('/api/v2/platform/taxons')Spree.routes.users_api_v2 = Spree.pathFor('api/v2/platform/users')diff --git a/backend/app/assets/javascripts/spree/backend/admin.js b/backend/app/assets/javascripts/spree/backend/admin.jsindex 6a2efbb93c..8252af5d6c 100644--- a/backend/app/assets/javascripts/spree/backend/admin.js+++ b/backend/app/assets/javascripts/spree/backend/admin.js@@ -65,10 +65,7 @@ $(document).ready(function() {el.parents('tr').fadeOut('hide', function() {$(this).remove()})- el.closest('div.menu-item').fadeOut('hide', function() {- $(this).remove()- })- el.closest('.removeable').fadeOut('hide', function() {+ el.closest('.removable-dom-element').fadeOut('hide', function() {$(this).remove()})const livePreview = document.getElementById('pageLivePreview')diff --git a/backend/app/assets/javascripts/spree/backend/cms/page.es6 b/backend/app/assets/javascripts/spree/backend/cms/page.es6index 7924639fe6..76f6792c99 100644--- a/backend/app/assets/javascripts/spree/backend/cms/page.es6+++ b/backend/app/assets/javascripts/spree/backend/cms/page.es6@@ -55,7 +55,7 @@ function handleSectionReposition(evt) {new_position_idx: parseInt(evt.newIndex, 10)}- fetch(Spree.routes.section_reposition_api_v2, {+ fetch(Spree.routes.section_reposition_api_v2 + '/reposition', {method: 'PATCH',headers: {Authorization: 'Bearer ' + OAUTH_TOKEN,diff --git a/backend/app/assets/stylesheets/spree/backend/plugins/_tinymce_custom.scss b/backend/app/assets/stylesheets/spree/backend/plugins/_tinymce_custom.scssnew file mode 100644index 0000000000..88d4cc0696--- /dev/null+++ b/backend/app/assets/stylesheets/spree/backend/plugins/_tinymce_custom.scss@@ -0,0 +1,4 @@+// Removes Tiny MCE branding+.tox-statusbar__branding {+ display: none;+}diff --git a/backend/app/assets/stylesheets/spree/backend/shared/_base.scss b/backend/app/assets/stylesheets/spree/backend/shared/_base.scssindex 62c75fdd9c..aef18e044e 100644--- a/backend/app/assets/stylesheets/spree/backend/shared/_base.scss+++ b/backend/app/assets/stylesheets/spree/backend/shared/_base.scss@@ -15,10 +15,6 @@z-index: $zindex-dropdown;}-.tox-statusbar__branding {- display: none;-}-// No-margin and no-padding helper classes@each $side in top bottom left right {.no-margin-#{$side} { margin-#{side}: 0; }diff --git a/backend/app/assets/stylesheets/spree/backend/spree_admin.css.scss b/backend/app/assets/stylesheets/spree/backend/spree_admin.css.scssindex d1705a2033..972e20dec9 100644--- a/backend/app/assets/stylesheets/spree/backend/spree_admin.css.scss+++ b/backend/app/assets/stylesheets/spree/backend/spree_admin.css.scss@@ -24,6 +24,7 @@@import 'plugins/flatpickr';@import 'plugins/select2_bootstrap4';@import 'plugins/select2_custom';+@import 'plugins/tinymce_custom';@import 'shared/base';@import 'shared/forms';diff --git a/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scss b/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scssindex 0de5c3d965..e94f7860c7 100644--- a/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scss+++ b/backend/app/assets/stylesheets/spree/backend/views/_cms_pages.scss@@ -3,9 +3,11 @@overflow-y: scroll;max-height: 553px;padding-top: 5px !important;++ // Hide scroll-bar in live preview+ // sidebar.-ms-overflow-style: none; /* IE and Edge */scrollbar-width: none; /* Firefox */-&::-webkit-scrollbar {display: none;}@@ -74,6 +76,7 @@ body.cmsSectionFullScreenMode {.hide-on-full-screen-mode {display: none;}+#pageSectionsArea {position: fixed;top: 0;@@ -113,6 +116,7 @@ body.cmsSectionFullScreenMode {left: 19%;}}+.mobileLiveView {#pageLivePreview {width: 60%;diff --git a/backend/app/controllers/spree/admin/cms_sections_controller.rb b/backend/app/controllers/spree/admin/cms_sections_controller.rbindex f508c9d087..a6769fe967 100644--- a/backend/app/controllers/spree/admin/cms_sections_controller.rb+++ b/backend/app/controllers/spree/admin/cms_sections_controller.rb@@ -11,16 +11,6 @@ module Spreespree.edit_admin_cms_page_cms_section_path(@cms_page, @cms_section)end- def remove_icon- if @cms_section.icon&.destroy- flash[:success] = Spree.t('notice_messages.icon_removed')- redirect_to spree.edit_admin_cms_page_cms_section_path(@cms_page, @cms_section)- else- flash[:error] = Spree.t('errors.messages.cannot_remove_icon')- render :edit- end- end-privatedef parentdiff --git a/backend/app/helpers/spree/admin/menu_helper.rb b/backend/app/helpers/spree/admin/menu_helper.rbindex 911775cd0f..752cb1d1fd 100644--- a/backend/app/helpers/spree/admin/menu_helper.rb+++ b/backend/app/helpers/spree/admin/menu_helper.rb@@ -17,7 +17,7 @@ module Spreeinfo_row = menu_item_bar(menu, item)menu_container = content_tag(:div, raw(decendents.join), class: 'menu-container', data: { parent_id: item.id })- content_tag(:div, info_row + menu_container, class: 'menu-item menu-container-item dragable', data: { item_id: item.id })+ content_tag(:div, info_row + menu_container, class: 'menu-item menu-container-item dragable removable-dom-element', data: { item_id: item.id })enddef resorce_types_dropdown_valuesdiff --git a/backend/app/views/spree/admin/cms_pages/_section_template.html.erb b/backend/app/views/spree/admin/cms_pages/_section_template.html.erbindex 44a38112a4..fb9772dc39 100644--- a/backend/app/views/spree/admin/cms_pages/_section_template.html.erb+++ b/backend/app/views/spree/admin/cms_pages/_section_template.html.erb@@ -1,4 +1,4 @@-<div class="<%= width %> <%= boundary %> removeable" data-section-id="<%= section.id %>">+<div class="<%= width %> <%= boundary %> removable-dom-element" data-section-id="<%= section.id %>"><div class="row m-0 mb-1 pb-0 border bg-white"><div class="col move-handle d-flex flex-nowrap pr-0">diff --git a/core/app/models/spree/app_configuration.rb b/core/app/models/spree/app_configuration.rbindex 68e4f4f476..25f9628d9a 100644--- a/core/app/models/spree/app_configuration.rb+++ b/core/app/models/spree/app_configuration.rb@@ -76,7 +76,7 @@ module Spree@searcher_class ||= Spree::Core::Search::Baseend- # Sets the path used for products and taxons.+ # Sets the path used for products, taxons and pages.preference :storefront_products_path, :string, default: 'products'preference :storefront_taxons_path, :string, default: 't'preference :storefront_pages_path, :string, default: 'pages'diff --git a/frontend/app/assets/javascripts/spree/frontend/views/spree/shared/cms_sections.es6 b/frontend/app/assets/javascripts/spree/frontend/views/spree/shared/cms_sections.es6index f77cb1d32f..90ab55c124 100644--- a/frontend/app/assets/javascripts/spree/frontend/views/spree/shared/cms_sections.es6+++ b/frontend/app/assets/javascripts/spree/frontend/views/spree/shared/cms_sections.es6@@ -4,45 +4,43 @@ document.addEventListener('turbolinks:load', function() {if (!featurePageContent) return- const halfWidthElements = featurePageContent.querySelectorAll('.cms_full_section')+ const fullWidthElements = featurePageContent.querySelectorAll('.cms_full_section')- halfWidthElements.forEach(function(elem) {+ fullWidthElements.forEach(function(elem) {if (elem.previousElementSibling && elem.previousElementSibling.classList.contains('cms_half_section')) {- const siblings = getSiblings(elem);+ const siblings = getSiblings(elem)- if (!isEven(siblings.length)) { insertPlaceHolder(elem) }+ if (!isEven(siblings.length)) insertPlaceHolder(elem)}})+})- function insertPlaceHolder(elem) {- const el = document.createElement('aside');- el.classList.add('col-6', 'cms_half_section', 'd-none')+function insertPlaceHolder(elem) {+ const el = document.createElement('aside')+ el.classList.add('col-6', 'cms_half_section', 'd-none')- elem.insertAdjacentElement('beforebegin', el);- }+ elem.insertAdjacentElement('beforebegin', el)+}- function isEven(value) {- if (value % 2 === 0) {- return true;- } else {- return false;- }+function isEven(value) {+ if (value % 2 === 0) {+ return true+ } else {+ return false}+}- function getSiblings(elem) {- // Setup siblings array and get the first sibling- const siblings = [];- let sibling = elem.parentNode.firstChild;+function getSiblings(elem) {+ const siblings = []+ let sibling = elem.parentNode.firstChild- // Loop through each sibling and push to the array- while (sibling) {- if (sibling === elem) break+ while (sibling) {+ if (sibling === elem) break- if (sibling.nodeType === 1 && sibling !== elem && !sibling.classList.contains('cms_full_section')) {- siblings.push(sibling);- }- sibling = sibling.nextElementSibling;+ if (sibling.nodeType === 1 && sibling !== elem && !sibling.classList.contains('cms_full_section')) {+ siblings.push(sibling)}- return siblings;- };-})+ sibling = sibling.nextElementSibling+ }+ return siblings+}diff --git a/frontend/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss b/frontend/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scssindex e2321d9ea6..630b538bf1 100644--- a/frontend/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss+++ b/frontend/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss@@ -31,7 +31,6 @@text-overflow: ellipsis;}-// Aspect Ratios[style*="--aspect-ratio"] > :first-child {width: 100%;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 b2081e12d4..3c016fd600 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@@ -15,14 +15,6 @@height: 100%;}- @include media-breakpoint-up(md) {-- }-- @include media-breakpoint-up(lg) {-- }-.hero-content {position: absolute;z-index: 1;@@ -283,7 +275,6 @@}}-.full-width {width: 100vw;position: relative;