Merge pull request #11501 from jibees/9146-improve-user-feedback-in-oc-edit-page-for-hidden-inventory

Improve user feedback in oc edit page for hidden inventory
This commit is contained in:
Filipe
2023-09-13 16:26:39 +01:00
committed by GitHub
4 changed files with 49 additions and 1 deletions

View File

@@ -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'" }

View File

@@ -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 }}

View File

@@ -3347,6 +3347,8 @@ 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)."
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:"

View File

@@ -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)