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 images to the menu items index.
Matthew Kennedy3e682b29ef65
diff --git a/backend/app/assets/stylesheets/spree/backend/shared/_base.scss b/backend/app/assets/stylesheets/spree/backend/shared/_base.scssindex 86e9692450..699a1ef883 100644--- a/backend/app/assets/stylesheets/spree/backend/shared/_base.scss+++ b/backend/app/assets/stylesheets/spree/backend/shared/_base.scss@@ -59,3 +59,9 @@.button_to {display: inline-block;}++.truncate {+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}diff --git a/backend/app/assets/stylesheets/spree/backend/shared/_sortable_js_tree.scss b/backend/app/assets/stylesheets/spree/backend/shared/_sortable_js_tree.scssindex 04bb448a88..66d91181b6 100644--- a/backend/app/assets/stylesheets/spree/backend/shared/_sortable_js_tree.scss+++ b/backend/app/assets/stylesheets/spree/backend/shared/_sortable_js_tree.scss@@ -28,4 +28,21 @@ $nestable-background-color: rgb(214, 214, 214);border: 1px dashed var(--gray);border-radius: 5px;}++ .menu_items_image_holder {+ position: relative;+ border: 1px solid $main-items-border-color;+ border-radius: 7px;+ overflow: hidden;+ width: 45px;+ height: 45px;+ img {+ position: absolute;+ left: 50%;+ top: 50%;+ height: 100%;+ width: auto;+ transform: translate(-50%,-50%);+ }+ }}diff --git a/backend/app/helpers/spree/admin/menu_helper.rb b/backend/app/helpers/spree/admin/menu_helper.rbindex 6829cc9a13..2ad1396028 100644--- a/backend/app/helpers/spree/admin/menu_helper.rb+++ b/backend/app/helpers/spree/admin/menu_helper.rb@@ -9,8 +9,18 @@ module Spreeedit_button = link_to_edit(item, no_text: true, url: spree.edit_admin_menu_menu_item_path(menu, item))delete_button = link_to_delete(item, no_text: true, url: spree.admin_menu_menu_item_path(menu, item)) if can?(:destroy, item)+ menu_item_type = content_tag(:small, item.item_type, class: 'form-text text-muted mt-0')++ image = if item.image_asset.attached? && item.image_asset.image?+ content_tag(:div, content_tag(:div, (image_tag main_app.url_for(item.image_asset)), class: 'menu_items_image_holder'), class: 'ml-2')+ else+ ''+ end++ description_sub_area = content_tag(:div, content_tag(:div, item.name) + content_tag(:div, menu_item_type))+move_handle = content_tag(:div, svg_icon(name: 'sort.svg', width: '20', height: '20'), class: 'move-handle d-flex align-items-center p-3')- description_area = content_tag(:div, item.name, class: 'd-flex align-items-center w-100')+ description_area = content_tag(:div, description_sub_area + image, class: 'd-flex align-items-center w-100 truncate')buttons_area = content_tag(:div, edit_button + delete_button, class: 'd-flex align-items-center space-buttons px-2')content_tag(:div, move_handle + description_area + buttons_area,diff --git a/backend/app/views/spree/admin/menu_items/_form.html.erb b/backend/app/views/spree/admin/menu_items/_form.html.erbindex f38ffccb26..8ecf277599 100644--- a/backend/app/views/spree/admin/menu_items/_form.html.erb+++ b/backend/app/views/spree/admin/menu_items/_form.html.erb@@ -17,7 +17,14 @@</div><hr>- <%= f.select :parent_id, nested_set_options(Spree::MenuItem, @menu_item) {|i| "#{'-' * i.level} #{i.name}" }, {include_blank: true}, {class: 'select2-clear'} %>+ <%= f.field_container :parent_id, class: ['form-group'] do %>+ <%= f.label :parent_id, Spree.t('admin.navigation.nested_under') %>+ <%= f.select :parent_id, nested_set_options(@menu.menu_items, @menu_item) {|i| "#{'-' * i.level} #{i.name}" }, {include_blank: true}, {class: 'select2-clear'} %>+ <%= f.error_message_on :parent_id %>+ <small class="form-text text-muted">+ <%= Spree.t('admin.navigation.nested_under_info') %>+ </small>+ <% end %></div></div></div>@@ -43,7 +50,7 @@<%= f.field_container :image_asset, class: ['form-group'] do %><% if @menu_item.image_asset.attached? && @menu_item.image_asset.variable? %><%= image_tag main_app.url_for(@menu_item.image_asset.variant(resize: '244x104>')) %>- <% elsif @menu_item.image_asset.attached? && @store.image_asset.image? %>+ <% elsif @menu_item.image_asset.attached? && @menu_item.image_asset.image? %><%= image_tag main_app.url_for(@menu_item.image_asset) %><% end %><%= f.field_container :image_asset, class: ['form-group'] do %>diff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex a1b3808c7f..ecb7c585d8 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -583,6 +583,7 @@ en:link_to: Link Tonew_menu: New Menunew_menu_item: New Menu Item+ nested_under_info: Quickly nest your link in the menu.item_type: Item Typeopen_link_in_new_window: Open this link in a new windowmenu_item_type_message: "For more information about Menu Item Types and nesting Menu Items, visit the documentation by