From a810fc88ac0eb9898ce7f2fe23ff4e7a490522b4 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 19 Dec 2014 12:57:56 +1100 Subject: [PATCH] Dedicated new enterprise form --- app/assets/javascripts/admin/util.js.erb | 7 ++ .../admin/dashboard-single-ent.css.sass | 6 +- .../admin/enterprises/_new_form.html.haml | 105 ++++++++++++++++++ app/views/admin/enterprises/new.html.haml | 8 +- .../single_enterprise_dashboard.html.haml | 5 - spec/features/admin/enterprises_spec.rb | 22 ---- 6 files changed, 123 insertions(+), 30 deletions(-) create mode 100644 app/views/admin/enterprises/_new_form.html.haml diff --git a/app/assets/javascripts/admin/util.js.erb b/app/assets/javascripts/admin/util.js.erb index 93f1c50a64..bc963d4612 100644 --- a/app/assets/javascripts/admin/util.js.erb +++ b/app/assets/javascripts/admin/util.js.erb @@ -28,3 +28,10 @@ show_flash_error = function(message) { } } } + +$(document).ready(function(){ + $('a.close').click(function(event){ + event.preventDefault(); + $(this).parent().slideUp(250); + }); +}); diff --git a/app/assets/stylesheets/admin/dashboard-single-ent.css.sass b/app/assets/stylesheets/admin/dashboard-single-ent.css.sass index dc0c42fa49..567999b43d 100644 --- a/app/assets/stylesheets/admin/dashboard-single-ent.css.sass +++ b/app/assets/stylesheets/admin/dashboard-single-ent.css.sass @@ -1,6 +1,7 @@ @import ../darkswarm/mixins .alert-box + position: relative display: block background-color: #eff5dc border: 1px solid #9fc820 @@ -11,7 +12,10 @@ transition: opacity 300ms ease-out padding: 0.77778em 1.33333em 0.77778em 0.77778em a.close - float: right + position: absolute + right: 5px + top: 0px + font-size: 1.5em .dashboard_item.single-ent diff --git a/app/views/admin/enterprises/_new_form.html.haml b/app/views/admin/enterprises/_new_form.html.haml new file mode 100644 index 0000000000..bb43a421fb --- /dev/null +++ b/app/views/admin/enterprises/_new_form.html.haml @@ -0,0 +1,105 @@ +.row + .three.columns.alpha + = f.label :name + .nine.columns.omega + = f.text_field :name, { placeholder: "eg. Professor Plum's Biodynamic Truffles", class: "fullwidth" } + +- if spree_current_user.admin? + .row{ ng: { app: "admin.users" } } + .three.columns.alpha + =f.label :owner_id, 'Owner' + .with-tip{'data-powertip' => "The primary user responsible for this enterprise."} + %a What's this? + .nine.columns.omega + - owner_email = @enterprise.andand.owner.andand.email || "" + = f.hidden_field :owner_id, class: "select2 fullwidth", 'ofn-user-autocomplete' => true, email: owner_email +.row + .three.columns.alpha + %label Primary Producer? + .with-tip{'data-powertip' => "Select 'Producer' if you are a primary producer of food."} + %a What's this? + .five.columns.omega + = f.check_box :is_primary_producer, 'ng-model' => 'Enterprise.is_primary_producer' +   + = f.label :is_primary_producer, 'I am a Producer' +- if spree_current_user.admin? + .row + .alpha.eleven.columns + .three.columns.alpha + = f.label :sells, 'Sells' + .with-tip{'data-powertip' => "None - enterprise does not sell to customers directly.
Own - Enterprise sells own products to customers.
Any - Enterprise can sell own or other enterprises products.
"} + %a What's this? + .two.columns + = f.radio_button :sells, "none", 'ng-model' => 'Enterprise.sells' +   + = f.label :sells, "None", value: "none" + .two.columns + = f.radio_button :sells, "own", 'ng-model' => 'Enterprise.sells' +   + = f.label :sells, "Own", value: "own" + .four.columns.omega + = f.radio_button :sells, "any", 'ng-model' => 'Enterprise.sells' +   + = f.label :sells, "Any", value: "any" + + +.row + .alpha.three.columns + = f.label :contact, 'Contact Name' + .omega.nine.columns + = f.text_field :contact, { placeholder: "eg. Gustav Plum"} +.row + .alpha.three.columns + = f.label :email + .omega.nine.columns + = f.text_field :email, { placeholder: "eg. gustav@truffles.com", "ng-model" => "Enterprise.email" } + .alert-box + %i.icon-info-sign + If we don't recognise this email address we'll send you a confirmation email to make sure it belongs to you. You'll need to use the link in the email we send to fully activate your new enterprise. + %a.close{ href: "" } × +.row + .alpha.three.columns + = f.label :phone + .omega.nine.columns + = f.text_field :phone, { placeholder: "eg. 98 7654 3210"} +.row + .alpha.three.columns + = f.label :website + .omega.nine.columns + = f.text_field :website, { placeholder: "eg. www.truffles.com"} + += f.fields_for :address do |af| + .row + .three.columns.alpha + = af.label :address1 + .nine.columns.omega + = af.text_field :address1, { placeholder: "eg. 123 High Street"} + .row + .alpha.three.columns + = af.label :address2 + .nine.columns.omega + = af.text_field :address2 + .row + .three.columns.alpha + = af.label :city, 'Suburb' + \/ + = af.label :zipcode, 'Postcode' + .four.columns + = af.text_field :city, { placeholder: "eg. Northcote"} + .five.columns.omega + = af.text_field :zipcode, { placeholder: "eg. 3070"} + .row + .three.columns.alpha + = af.label :state_id, 'State' + \/ + = af.label :country_id, 'Country' + .four.columns + = af.collection_select :state_id, af.object.country.states, :id, :name, {}, :class => "select2 fullwidth" + .five.columns.omega + = af.collection_select :country_id, available_countries, :id, :name, {}, :class => "select2 fullwidth" +.row + .twelve.columns.alpha +   +.row + .twelve.columns.alpha + = render partial: "spree/admin/shared/new_resource_links" \ No newline at end of file diff --git a/app/views/admin/enterprises/new.html.haml b/app/views/admin/enterprises/new.html.haml index 634044bf30..8f21067941 100644 --- a/app/views/admin/enterprises/new.html.haml +++ b/app/views/admin/enterprises/new.html.haml @@ -6,6 +6,10 @@ - content_for :page_actions do %li= button_link_to "Back to enterprises list", main_app.admin_enterprises_path, icon: 'icon-arrow-left' -= render 'admin/enterprises/form_data' -= render 'admin/enterprises/ng_form', action: 'new' +-# Form + += form_for [main_app, :admin, @enterprise], html: { "nav-check" => '', "nav-callback" => '' } do |f| + .row + .twelve.columns.fullwidth_inputs + = render 'new_form', f: f diff --git a/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml b/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml index 6f48b73fa2..f8cb1fb5d9 100644 --- a/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml +++ b/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml @@ -40,11 +40,6 @@ %strong= "Manage #{@enterprise.name}." %a.close{ href: "#" } × - :javascript - $('a.close').click(function(){ - $(this).parent().slideUp(250); - }); - .row .alpha.seven.columns.dashboard_item.single-ent#map .header diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 4a751c4aab..e7f7ea14cf 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -131,40 +131,18 @@ feature %q{ select2_search admin.email, from: 'Owner' select2_search admin.email, from: 'Owner' choose 'Any' - select2_search eg1.name, from: 'Groups' - click_link "Payment Methods" - check "enterprise_payment_method_ids_#{payment_method.id}" - - click_link "Shipping Methods" - check "enterprise_shipping_method_ids_#{shipping_method.id}" - - click_link "Contact" fill_in 'enterprise_contact', :with => 'Kirsten or Ren' fill_in 'enterprise_phone', :with => '0413 897 321' fill_in 'enterprise_email', :with => 'info@eaterprises.com.au' fill_in 'enterprise_website', :with => 'http://eaterprises.com.au' - click_link "Social" - fill_in 'enterprise_twitter', :with => '@eaterprises' - fill_in 'enterprise_facebook', :with => 'facebook.com/eaterprises' - fill_in 'enterprise_instagram', :with => 'eaterprises' - - click_link "Business Details" - fill_in 'enterprise_abn', :with => '09812309823' - fill_in 'enterprise_acn', :with => '' - - click_link "Address" fill_in 'enterprise_address_attributes_address1', :with => '35 Ballantyne St' fill_in 'enterprise_address_attributes_city', :with => 'Thornbury' fill_in 'enterprise_address_attributes_zipcode', :with => '3072' select2_search 'Australia', :from => 'Country' select2_search 'Victoria', :from => 'State' - click_link "About" - long_description = find :css, "text-angular div.ta-scroll-window div.ta-bind" - long_description.set 'Connecting farmers and eaters' - click_button 'Create' flash_message.should == 'Enterprise "Eaterprises" has been successfully created!' end