From 15e7a5a4df22ec538fa65414521b4a13aca53db3 Mon Sep 17 00:00:00 2001 From: Nihal Mohammed Date: Tue, 12 Apr 2022 12:46:52 +0530 Subject: [PATCH] Rename product_stock_display to product_low_stock_display Rename product_stock_display to product_low_stock_display in enterprise_serializer and shop_variant_controller --- .../controllers/shop_variant_controller.js.coffee | 2 +- app/models/enterprise.rb | 2 +- app/serializers/api/admin/enterprise_serializer.rb | 2 +- app/serializers/api/enterprise_shopfront_serializer.rb | 2 +- app/services/permitted_attributes/enterprise.rb | 2 +- .../admin/enterprises/form/_shop_preferences.html.haml | 8 ++++---- spec/system/consumer/shopping/shopping_spec.rb | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/shop_variant_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/shop_variant_controller.js.coffee index b47cba4aef..c3afec6f3a 100644 --- a/app/assets/javascripts/darkswarm/controllers/shop_variant_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/shop_variant_controller.js.coffee @@ -71,4 +71,4 @@ angular.module('Darkswarm').controller "ShopVariantCtrl", ($scope, $modal, Cart, $modal.open(templateUrl: "bulk_buy_modal.html", scope: $scope, windowClass: "product-bulk-modal") $scope.displayRemainingInStock = -> - Shopfront.shopfront.preferred_product_stock_display && $scope.available() <= 3 && !$scope.variant.line_item.quantity + Shopfront.shopfront.preferred_product_low_stock_display && $scope.available() <= 3 && !$scope.variant.line_item.quantity diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index ee4a2c75c6..d27d605d1d 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -20,7 +20,7 @@ class Enterprise < ApplicationRecord preference :shopfront_order_cycle_order, :string, default: "orders_close_at" preference :shopfront_product_sorting_method, :string, default: "by_category" preference :invoice_order_by_supplier, :boolean, default: false - preference :product_stock_display, :boolean, default: false + preference :product_low_stock_display, :boolean, default: false # Allow hubs to restrict visible variants to only those in their inventory preference :product_selection_from_inventory_only, :boolean, default: false diff --git a/app/serializers/api/admin/enterprise_serializer.rb b/app/serializers/api/admin/enterprise_serializer.rb index 8527531fc4..2cef7c454c 100644 --- a/app/serializers/api/admin/enterprise_serializer.rb +++ b/app/serializers/api/admin/enterprise_serializer.rb @@ -14,7 +14,7 @@ module Api :logo, :promo_image, :terms_and_conditions, :terms_and_conditions_file_name, :terms_and_conditions_updated_at, :preferred_invoice_order_by_supplier, - :preferred_product_stock_display + :preferred_product_low_stock_display has_one :owner, serializer: Api::Admin::UserSerializer has_many :users, serializer: Api::Admin::UserSerializer diff --git a/app/serializers/api/enterprise_shopfront_serializer.rb b/app/serializers/api/enterprise_shopfront_serializer.rb index e777318127..cee6cc5145 100644 --- a/app/serializers/api/enterprise_shopfront_serializer.rb +++ b/app/serializers/api/enterprise_shopfront_serializer.rb @@ -9,7 +9,7 @@ module Api :instagram, :linkedin, :twitter, :facebook, :is_primary_producer, :is_distributor, :phone, :visible, :email_address, :hash, :logo, :promo_image, :path, :category, :active, :producers, :orders_close_at, :hubs, :taxons, :supplied_taxons, :pickup, - :delivery, :preferred_product_stock_display + :delivery, :preferred_product_low_stock_display has_one :address, serializer: Api::AddressSerializer has_many :supplied_properties, serializer: Api::PropertySerializer diff --git a/app/services/permitted_attributes/enterprise.rb b/app/services/permitted_attributes/enterprise.rb index 7cbc5499bd..2c7346eaf7 100644 --- a/app/services/permitted_attributes/enterprise.rb +++ b/app/services/permitted_attributes/enterprise.rb @@ -34,7 +34,7 @@ module PermittedAttributes :preferred_shopfront_producer_order, :preferred_shopfront_order_cycle_order, :show_customer_names_to_suppliers, :preferred_shopfront_product_sorting_method, :preferred_invoice_order_by_supplier, - :preferred_product_stock_display + :preferred_product_low_stock_display ] end end diff --git a/app/views/admin/enterprises/form/_shop_preferences.html.haml b/app/views/admin/enterprises/form/_shop_preferences.html.haml index af468047de..be2d5d2045 100644 --- a/app/views/admin/enterprises/form/_shop_preferences.html.haml +++ b/app/views/admin/enterprises/form/_shop_preferences.html.haml @@ -78,11 +78,11 @@ %div{'ofn-with-tip' => t('.display_remaining_stock_tip')} %a= t 'admin.whats_this' .three.columns - = f.radio_button :preferred_product_stock_display, true, 'ng-model' => 'Enterprise.preferred_product_stock_display', 'ng-value' => 'true' - = f.label :preferred_product_stock_display, t('.enabled'), value: :true + = f.radio_button :preferred_product_low_stock_display, true, 'ng-model' => 'Enterprise.preferred_product_low_stock_display', 'ng-value' => 'true' + = f.label :preferred_product_low_stock_display, t('.enabled'), value: :true .five.columns.omega - = f.radio_button :preferred_product_stock_display, false, 'ng-model' => 'Enterprise.preferred_product_stock_display', 'ng-value' => 'false' - = f.label :preferred_product_stock_display, t('.disabled'), value: :false + = f.radio_button :preferred_product_low_stock_display, false, 'ng-model' => 'Enterprise.preferred_product_low_stock_display', 'ng-value' => 'false' + = f.label :preferred_product_low_stock_display, t('.disabled'), value: :false .row .three.columns.alpha diff --git a/spec/system/consumer/shopping/shopping_spec.rb b/spec/system/consumer/shopping/shopping_spec.rb index 8dfb8e2c79..1fdc0b756c 100644 --- a/spec/system/consumer/shopping/shopping_spec.rb +++ b/spec/system/consumer/shopping/shopping_spec.rb @@ -377,7 +377,7 @@ describe "As a consumer I want to shop with a distributor", js: true do end it "shows quantity of remaining stock for products with quantity less < 3 when product_stock_display is true" do - distributor.set_preference(:product_stock_display, true) + distributor.set_preference(:product_low_stock_display, true) variant.update on_hand: 2 visit shop_path