mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #4408 from luisramos0/poc_oc
Remove dead code from OC edit page code
This commit is contained in:
@@ -13,31 +13,11 @@
|
||||
-# No need to scope product list based on permissions, because if an incoming exchange is visible,
|
||||
-# then all of the variants within it should be visible. May change in the future?
|
||||
.exchange-product{'ng-repeat' => 'product in enterprises[exchange.enterprise_id].supplied_products'}
|
||||
|
||||
.exchange-product-details
|
||||
%label
|
||||
%input{ type: 'checkbox', name: 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
value: 1,
|
||||
'ng-hide' => 'product.variants.length > 0',
|
||||
'ng-model' => 'exchange.variants[product.master_id]',
|
||||
'ofn-sync-distributions' => '{{ product.master_id }}',
|
||||
'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
'ng-disabled' => 'product.variants.length > 0 || !order_cycle.editable_variants_for_incoming_exchanges.hasOwnProperty(exchange.enterprise_id) || order_cycle.editable_variants_for_incoming_exchanges[exchange.enterprise_id].indexOf(product.master_id) < 0' }
|
||||
%img{'ng-src' => '{{ product.image_url }}'}
|
||||
{{ product.name }}
|
||||
|
||||
-# When the master variant is in the order cycle but the product has variants, we want to
|
||||
-# be able to remove the master variant, since it serves no purpose. Display a checkbox to do so.
|
||||
.exchange-product-variant{'ng-show' => 'exchange.variants[product.master_id] && product.variants.length > 0'}
|
||||
%label
|
||||
%input{ type: 'checkbox', name: 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
value: 1,
|
||||
'ng-model' => 'exchange.variants[product.master_id]',
|
||||
'ofn-sync-distributions' => '{{ product.master_id }}',
|
||||
'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
'ng-disabled' => '!order_cycle.editable_variants_for_incoming_exchanges.hasOwnProperty(exchange.enterprise_id) || order_cycle.editable_variants_for_incoming_exchanges[exchange.enterprise_id].indexOf(product.master_id) < 0' }
|
||||
{{ 'admin.obsolete_master' | t }}
|
||||
|
||||
.exchange-product-variant{'ng-repeat' => 'variant in product.variants'}
|
||||
%label
|
||||
%input{ type: 'checkbox', name: 'order_cycle_incoming_exchange_{{ $parent.$parent.$index }}_variants_{{ variant.id }}',
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/ TODO: Unify this with exchange_distributed_products_form
|
||||
%td{:colspan => 4}
|
||||
.exchange-select-all-variants
|
||||
%label
|
||||
= check_box_tag 'order_cycle_incoming_exchange_{{ $parent.$index }}_select_all_variants', 1, 1, 'ng-model' => 'exchange.select_all_variants', 'ng-change' => 'setExchangeVariants(exchange, suppliedVariants(exchange.enterprise_id), exchange.select_all_variants)', 'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_select_all_variants'
|
||||
= t('admin.select_all')
|
||||
|
||||
.exchange-products
|
||||
-# No need to scope product list based on permissions, because if an incoming exchange is visible,
|
||||
-# then all of the variants within it should be visible. May change in the future?
|
||||
.exchange-product{'ng-repeat' => 'product in enterprises[exchange.enterprise_id].supplied_products'}
|
||||
|
||||
.exchange-product-details
|
||||
%label
|
||||
= check_box_tag 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}', 1, 1, 'ng-hide' => 'product.variants.length > 0', 'ng-model' => 'exchange.variants[product.master_id]', 'ofn-sync-distributions' => '{{ product.master_id }}', 'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
'ng-disabled' => 'product.variants.length > 0 || !order_cycle.editable_variants_for_incoming_exchanges.hasOwnProperty(exchange.enterprise_id) || order_cycle.editable_variants_for_incoming_exchanges[exchange.enterprise_id].indexOf(product.master_id) < 0'
|
||||
%img{'ng-src' => '{{ product.image_url }}'}
|
||||
{{ product.name }}
|
||||
|
||||
-# When the master variant is in the order cycle but the product has variants, we want to
|
||||
-# be able to remove the master variant, since it serves no purpose. Display a checkbox to do so.
|
||||
.exchange-product-variant{'ng-show' => 'exchange.variants[product.master_id] && product.variants.length > 0'}
|
||||
%label
|
||||
= check_box_tag 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}', 1, 1, 'ng-model' => 'exchange.variants[product.master_id]', 'ofn-sync-distributions' => '{{ product.master_id }}', 'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
|
||||
'ng-disabled' => '!order_cycle.editable_variants_for_incoming_exchanges.hasOwnProperty(exchange.enterprise_id) || order_cycle.editable_variants_for_incoming_exchanges[exchange.enterprise_id].indexOf(product.master_id) < 0'
|
||||
= t('admin.obsolete_master')
|
||||
|
||||
.exchange-product-variant{'ng-repeat' => 'variant in product.variants'}
|
||||
%label
|
||||
= check_box_tag 'order_cycle_incoming_exchange_{{ $parent.$parent.$index }}_variants_{{ variant.id }}', 1, 1, 'ng-model' => 'exchange.variants[variant.id]', 'ofn-sync-distributions' => '{{ variant.id }}', 'id' => 'order_cycle_incoming_exchange_{{ $parent.$parent.$index }}_variants_{{ variant.id }}',
|
||||
'ng-disabled' => '!order_cycle.editable_variants_for_incoming_exchanges.hasOwnProperty(exchange.enterprise_id) || order_cycle.editable_variants_for_incoming_exchanges[exchange.enterprise_id].indexOf(variant.id) < 0'
|
||||
{{ variant.label }}
|
||||
@@ -331,7 +331,6 @@ en:
|
||||
volume: Volume
|
||||
items: Items
|
||||
select_all: Select all
|
||||
obsolete_master: Obsolete master
|
||||
|
||||
# General form elements
|
||||
quick_search: Quick Search
|
||||
|
||||
@@ -594,30 +594,6 @@ feature '
|
||||
expect(occ.name).to eq "COPY OF #{oc.name}"
|
||||
end
|
||||
|
||||
scenario "removing a master variant from an order cycle when further variants have been added" do
|
||||
# Given a product with a variant, with its master variant included in the order cycle
|
||||
# (this usually happens when a product is added to an order cycle, then variants are added
|
||||
# to the product after the fact)
|
||||
s = create(:supplier_enterprise)
|
||||
p = create(:simple_product, supplier: s)
|
||||
v = create(:variant, product: p)
|
||||
d = create(:distributor_enterprise)
|
||||
oc = create(:simple_order_cycle, suppliers: [s], distributors: [d], variants: [p.master])
|
||||
exchange_ids = oc.exchanges.pluck :id
|
||||
expect(ExchangeVariant.where(exchange_id: exchange_ids, variant_id: p.master.id)).not_to be_empty
|
||||
|
||||
# When I go to the order cycle page and remove the obsolete master
|
||||
quick_login_as_admin
|
||||
visit edit_admin_order_cycle_path(oc)
|
||||
within("table.exchanges tbody tr.supplier") { page.find('td.products').click }
|
||||
page.find("#order_cycle_incoming_exchange_0_variants_#{p.master.id}").click # uncheck
|
||||
click_button "Update"
|
||||
|
||||
# Then the master variant should have been removed from all exchanges
|
||||
expect(page).to have_content "Your order cycle has been updated."
|
||||
expect(ExchangeVariant.where(exchange_id: exchange_ids, variant_id: p.master.id)).to be_empty
|
||||
end
|
||||
|
||||
describe "ensuring that hubs in order cycles have valid shipping and payment methods" do
|
||||
context "when they don't" do
|
||||
let(:hub) { create(:distributor_enterprise) }
|
||||
|
||||
Reference in New Issue
Block a user