From ff7629ba2c4d7292972551431ad160894a12c581 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Wed, 28 Dec 2022 17:00:55 +0100 Subject: [PATCH 1/3] Display information on outgoing product when variant aren't available Update en.yml --- .../admin/panels/exchange_products_distributed.html.haml | 5 ++++- config/locales/en.yml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/templates/admin/panels/exchange_products_distributed.html.haml b/app/assets/javascripts/templates/admin/panels/exchange_products_distributed.html.haml index fc0326f116..a51c9c0631 100644 --- a/app/assets/javascripts/templates/admin/panels/exchange_products_distributed.html.haml +++ b/app/assets/javascripts/templates/admin/panels/exchange_products_distributed.html.haml @@ -19,7 +19,7 @@ .name {{ product.name }} .supplier {{ product.supplier_name }} - .exchange-product-variant{'ng-repeat' => 'variant in product.variants | visibleVariants:exchange:order_cycle.visible_variants_for_outgoing_exchanges | filter:variantSuppliedToOrderCycle'} + .exchange-product-variant{'ng-repeat' => 'variant in product.variants | visibleVariants:exchange:order_cycle.visible_variants_for_outgoing_exchanges | filter:variantSuppliedToOrderCycle as filteredVariants'} %label %input{ type: 'checkbox', name: 'order_cycle_outgoing_exchange_{{ $parent.$parent.$index }}_variants_{{ variant.id }}', value: 1, @@ -27,5 +27,8 @@ 'id' => 'order_cycle_outgoing_exchange_{{ $parent.$parent.$index }}_variants_{{ variant.id }}', 'ng-disabled' => '!order_cycle.editable_variants_for_outgoing_exchanges.hasOwnProperty(exchange.enterprise_id) || order_cycle.editable_variants_for_outgoing_exchanges[exchange.enterprise_id].indexOf(variant.id) < 0' } {{ variant.label }} + + %em{ 'ng-if' => 'filteredVariants.length === 0' } + {{ 'js.admin.panels.exchange_products.no_variants' | t }} %div{ 'ng-include' => "'admin/panels/exchange_products_panel_footer.html'" } diff --git a/config/locales/en.yml b/config/locales/en.yml index efeaadafd3..fcf0e30bd0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3347,6 +3347,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using select_all_variants: "Select All %{total_number_of_variants} Variants" variants_loaded: "%{num_of_variants_loaded} of %{total_number_of_variants} Variants Loaded" loading_variants: "Loading Variants" + no_variants: "No variant available for this product (hidden via inventory settings)." tag_rules: shipping_method_tagged_top: "Shipping methods tagged" shipping_method_tagged_bottom: "are:" From ff8b9465c7a69bf19bdff82c6a862d1e1761b5d2 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Wed, 28 Dec 2022 17:05:35 +0100 Subject: [PATCH 2/3] Display info on outgoing products panel when some variants hidden --- .../admin/panels/exchange_products_panel_header.html.haml | 2 ++ config/locales/en.yml | 1 + 2 files changed, 3 insertions(+) diff --git a/app/assets/javascripts/templates/admin/panels/exchange_products_panel_header.html.haml b/app/assets/javascripts/templates/admin/panels/exchange_products_panel_header.html.haml index b5433e1706..266ddbc118 100644 --- a/app/assets/javascripts/templates/admin/panels/exchange_products_panel_header.html.haml +++ b/app/assets/javascripts/templates/admin/panels/exchange_products_panel_header.html.haml @@ -1,5 +1,7 @@ .exchange-load-all-variants %div {{ 'js.admin.panels.exchange_products.variants_loaded' | t:{ num_of_variants_loaded: enterprises[exchange.enterprise_id].loaded_variants, total_number_of_variants: exchangeTotalVariants(exchange) } }} + %em{ 'ng-if': 'enterprises[exchange.enterprise_id].loaded_variants > exchangeTotalVariants(exchange)' } + {{ 'js.admin.panels.exchange_products.some_variants_hidden' | t }} %a{ 'ng-click' => 'loadAllExchangeProducts(exchange)', 'ng-show' => 'enterprises[exchange.enterprise_id].last_page_loaded < enterprises[exchange.enterprise_id].num_of_pages' } {{ 'js.admin.panels.exchange_products.load_all_variants' | t }} diff --git a/config/locales/en.yml b/config/locales/en.yml index fcf0e30bd0..7652de335b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3348,6 +3348,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using variants_loaded: "%{num_of_variants_loaded} of %{total_number_of_variants} Variants Loaded" loading_variants: "Loading Variants" no_variants: "No variant available for this product (hidden via inventory settings)." + some_variants_hidden: "(Some variants might be hidden via inventory settings)" tag_rules: shipping_method_tagged_top: "Shipping methods tagged" shipping_method_tagged_bottom: "are:" From 637096534f63126ee19ff8879fae3577ad6691d3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Wed, 6 Sep 2023 11:36:38 +0200 Subject: [PATCH 3/3] Implement spec for #9146 issue --- spec/system/admin/order_cycles/simple_spec.rb | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index a465a36097..9a3f576662 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -368,6 +368,47 @@ describe ' end end + context "when variants are hidden via inventory settings" do + let(:oc) do + create(:simple_order_cycle, suppliers: [supplier_managed], + coordinator: distributor_managed, + distributors: [distributor_managed], + name: 'Order Cycle 1' ) + end + let(:product) { create(:product, supplier: supplier_managed) } + let(:v1) { create(:variant, product: product ) } + let(:inventory_item_v1) { + create(:inventory_item, enterprise: distributor_managed, variant: v1, visible: false) + } + before do + # Incoming exchange + ex_in = oc.exchanges.where(sender_id: supplier_managed, receiver_id: distributor_managed, + incoming: true).first + ex_in.update(variant_ids: [v1.id]) + ex_in.save! + + # Outgoing exchange + ex_out = oc.exchanges.where(sender_id: distributor_managed, + receiver_id: distributor_managed, incoming: false).first + ex_out.update(variant_ids: [v1.id,]) + v1.inventory_items = [inventory_item_v1] + ex_out.save! + + # hide via inventory settings variant v1 + supplier_managed.update preferred_product_selection_from_inventory_only: true + oc.update prefers_product_selection_from_coordinator_inventory_only: false + end + + it "shows a warning when going to 'outgoing products' tab" do + visit edit_admin_order_cycle_path(oc) + click_link "Outgoing Products" + within "tr.distributor-#{distributor_managed.id}" do + page.find("td.products").click + end + expect(page).to have_content "(Some variants might be hidden via inventory settings)" + end + end + it "cloning an order cycle" do oc = create(:simple_order_cycle, coordinator: distributor_managed)