mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Convert text to form fields
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
%tr.variant{ng: {repeat: 'variant in product.variants'}}
|
||||
%td
|
||||
%td {{ variant.options_text }}
|
||||
%td {{ variant.price }} - {{ variantOverrides[variant.id].price }}
|
||||
%td {{ variant.on_hand }} - {{ variantOverrides[variant.id].count_on_hand }}
|
||||
%td
|
||||
%input{name: 'variant-overrides-{{ variant.id }}-price', type: 'text', ng: {model: 'variantOverrides[variant.id].price'}, placeholder: '{{ variant.price }}'}
|
||||
|
||||
%td
|
||||
%input{name: 'variant-overrides-{{ variant.id }}-count-on-hand', type: 'text', ng: {model: 'variantOverrides[variant.id].count_on_hand'}, placeholder: '{{ variant.on_hand }}'}
|
||||
|
||||
@@ -59,7 +59,8 @@ feature %q{
|
||||
it "displays the list of products with variants" do
|
||||
page.should have_table_row ['PRODUCER', 'PRODUCT', 'PRICE', 'ON HAND']
|
||||
page.should have_table_row [producer.name, product.name, '', '']
|
||||
page.should have_table_row ['', '1g', '1.23 -', '12 -']
|
||||
page.should have_input "variant-overrides-#{variant.id}-price", placeholder: '1.23'
|
||||
page.should have_input "variant-overrides-#{variant.id}-count-on-hand", placeholder: '12'
|
||||
end
|
||||
|
||||
it "filters the products to those the hub can add to an order cycle" do
|
||||
@@ -78,7 +79,8 @@ feature %q{
|
||||
end
|
||||
|
||||
it "product values are affected by overrides" do
|
||||
page.should have_table_row ['', '1g', '1.23 - 77.77', '12 - 11111']
|
||||
page.should have_input "variant-overrides-#{variant.id}-price", with: '77.77', placeholder: '1.23'
|
||||
page.should have_input "variant-overrides-#{variant.id}-count-on-hand", with: '11111', placeholder: '12'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,6 +16,16 @@ module WebHelper
|
||||
end
|
||||
end
|
||||
|
||||
def have_input(name, opts={})
|
||||
selector = "[name='#{name}']"
|
||||
selector += "[placeholder='#{opts[:placeholder]}']" if opts.key? :placeholder
|
||||
|
||||
element = page.all(selector).first
|
||||
element.value.should == opts[:with] if element && opts.key?(:with)
|
||||
|
||||
have_selector selector
|
||||
end
|
||||
|
||||
|
||||
def current_path_should_be path
|
||||
current_path = URI.parse(current_url).path
|
||||
|
||||
Reference in New Issue
Block a user