Pull out type change form into a partial

This commit is contained in:
Rob Harrington
2014-10-23 17:22:25 +11:00
parent 3c839be743
commit d2efd25e8d
2 changed files with 49 additions and 52 deletions

View File

@@ -0,0 +1,48 @@
= form_for @enterprise, url: main_app.set_sells_admin_enterprise_path(@enterprise), html: { name: "enterprise", novalidate: true } do |enterprise_form|
-# Have to use hidden:'true' on this input rather than type:'hidden' as the latter seems to break ngPattern and therefore validation
%input{ hidden: "true", name: "sells", ng: { required: true, pattern: "/^(none|own)$/", model: 'sells', value: "sells"} }
.options.sixteen.columns.alpha
- if @enterprise.is_primary_producer
%input{ type: 'checkbox', hidden: true, name: "producer_profile_only", ng: { required: true, model: 'producer_profile_only', value: "producer_profile_only"} }
.basic_producer.option.one-third.column.alpha
%a.full-width.button.selector{ ng: { click: "sells='none';producer_profile_only=true;", class: "{selected: sells=='none' && producer_profile_only==true}" } }
.top
%h3 Producer Profile
%p Connect through OFN
.bottom ALWAYS FREE
%p.description
You want to use Open Food Network as a place for people to find and contact you.
.producer_shop.option.one-third.column
%a.full-width.button.selector{ ng: { click: "sells='none';producer_profile_only=false;", class: "{selected: sells=='none' && producer_profile_only==false}" } }
.top
%h3 Sell products
%p As a supplier
.bottom ALWAYS FREE
%p.description
Add your products to Open Food Network, allowing customers to see your product range, and allowing you to act as a supplier to other shopfronts.
.full_hub.option.one-third.column.omega.disabled
%a.full-width.button.selector{ ng: { click: "sells='own';producer_profile_only=false;", class: "{selected: sells=='own' && producer_profile_only==false}" } }
.top
%h3 Sell products
%p Through an OFN shopfront
.bottom 30 DAY TRIAL
%p.description
Test out having your own shopfront with full access to all Shopfront features for 30 days. After your trial expires you can keep your Shopfront for a subscription cost of $50 per month.
- else
.shop_profile.option.one-third.column.alpha
%a.full-width.button.selector{ ng: { class: "{selected: sells=='none'}" } }
.top
%h3 Shop Profile
%p Get a listing
.bottom ALWAYS FREE
%p.description
You want to use OFN as a place for people to find and contact you.
.sixteen.columns.alpha
.admin-cta
%span.error{ ng: { show: "(enterprise.sells.$error.pattern || enterprise.sells.$error.pattern) && submitted" } }
Please choose one of the options above.
%input{ type: 'submit', value: 'Next', ng: { click: "submit(enterprise)" } }

View File

@@ -10,55 +10,4 @@
%h2 Next step
%p Choose your starting point:
= form_for @enterprise, url: main_app.set_sells_admin_enterprise_path(@enterprise), html: { name: "enterprise", novalidate: true } do |enterprise_form|
-# Have to use hidden:'true' on this input rather than type:'hidden' as the latter seems to break ngPattern and therefore validation
%input{ hidden: "true", name: "sells", ng: { required: true, pattern: "/^(none|own)$/", model: 'sells', value: "sells"} }
.options.sixteen.columns.alpha
- if @enterprise.is_primary_producer
%input{ type: 'checkbox', hidden: true, name: "producer_profile_only", ng: { required: true, model: 'producer_profile_only', value: "producer_profile_only"} }
.basic_producer.option.one-third.column.alpha
%a.full-width.button.selector{ ng: { click: "sells='none';producer_profile_only=true;", class: "{selected: sells=='none' && producer_profile_only==true}" } }
.top
%h3 Producer Profile
%p Connect through OFN
.bottom ALWAYS FREE
%p.description
You want to use Open Food Network as a place for people to find and contact you.
.producer_shop.option.one-third.column
%a.full-width.button.selector{ ng: { click: "sells='none';producer_profile_only=false;", class: "{selected: sells=='none' && producer_profile_only==false}" } }
.top
%h3 Sell products
%p As a supplier
.bottom ALWAYS FREE
%p.description
Add your products to Open Food Network, allowing customers to see your product range, and allowing you to act as a supplier to other shopfronts.
.full_hub.option.one-third.column.omega.disabled
%a.full-width.button.selector{ ng: { click: "sells='own';producer_profile_only=false;", class: "{selected: sells=='own' && producer_profile_only==false}" } }
.top
%h3 Sell products
%p Through an OFN shopfront
.bottom 30 DAY TRIAL
%p.description
Test out having your own shopfront with full access to all Shopfront features for 30 days. After your trial expires you can keep your Shopfront for a subscription cost of $50 per month.
- else
.shop_profile.option.one-third.column.alpha
%a.full-width.button.selector{ ng: { class: "{selected: sells=='none'}" } }
.top
%h3 Shop Profile
%p Get a listing
.bottom ALWAYS FREE
%p.description
You want to use OFN as a place for people to find and contact you.
.sixteen.columns.alpha
.admin-cta
%span.error{ ng: { show: "(enterprise.sells.$error.pattern || enterprise.sells.$error.pattern) && submitted" } }
Please choose one of the options above.
%input{ type: 'submit', value: 'Next', ng: { click: "submit(enterprise)" } }
= render partial: "change_type_form"