From d2efd25e8d76d3eae497903810b6539681395117 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 23 Oct 2014 17:22:25 +1100 Subject: [PATCH] Pull out type change form into a partial --- .../overview/_change_type_form.html.haml | 48 +++++++++++++++++ .../spree/admin/overview/welcome.html.haml | 53 +------------------ 2 files changed, 49 insertions(+), 52 deletions(-) create mode 100644 app/views/spree/admin/overview/_change_type_form.html.haml diff --git a/app/views/spree/admin/overview/_change_type_form.html.haml b/app/views/spree/admin/overview/_change_type_form.html.haml new file mode 100644 index 0000000000..041c0b15e2 --- /dev/null +++ b/app/views/spree/admin/overview/_change_type_form.html.haml @@ -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)" } } \ No newline at end of file diff --git a/app/views/spree/admin/overview/welcome.html.haml b/app/views/spree/admin/overview/welcome.html.haml index b5b031eefb..1934db1706 100644 --- a/app/views/spree/admin/overview/welcome.html.haml +++ b/app/views/spree/admin/overview/welcome.html.haml @@ -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"