diff --git a/backend/app/assets/javascripts/spree/backend/stock_management.js b/backend/app/assets/javascripts/spree/backend/stock_management.js index 917d21dbb7d..60bc2996d1b 100644 --- a/backend/app/assets/javascripts/spree/backend/stock_management.js +++ b/backend/app/assets/javascripts/spree/backend/stock_management.js @@ -3,6 +3,7 @@ Spree.ready(function() { var $el = $(this); var model = new Spree.Models.StockItem($el.data('stock-item')); var trackInventory = $el.data('track-inventory'); + var canEdit = $el.data('can-edit') new Spree.Views.Stock.EditStockItemRow({ el: $el, stockLocationName: $el.data('stock-location-name'), @@ -16,6 +17,14 @@ Spree.ready(function() { title: '"Track inventory" option disabled for this variant' }); } + + if (canEdit == false) { + $('.js-edit-stock-item input').attr({ + disabled: true, + class: 'with-tip', + title: 'You do not have permission to manage stock' + }); + } }); $('.js-add-stock-item').each(function() { diff --git a/backend/app/views/spree/admin/stock_items/_stock_management.html.erb b/backend/app/views/spree/admin/stock_items/_stock_management.html.erb index c5d21f1c5f9..b358016b294 100644 --- a/backend/app/views/spree/admin/stock_items/_stock_management.html.erb +++ b/backend/app/views/spree/admin/stock_items/_stock_management.html.erb @@ -72,7 +72,7 @@ <% variant.stock_items.each do |item| %> <% if @stock_item_stock_locations.include?(item.stock_location) %> -