Differentiation of on-boarding process by url

This commit is contained in:
Rob H
2014-09-12 11:00:34 +10:00
parent 043cc915e7
commit 6ee3010fa7
11 changed files with 158 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, CurrentUser, SpreeApiKey, Loading, availableCountries) ->
Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, CurrentUser, spreeApiKey, Loading, availableCountries, enterpriseAttributes) ->
new class EnterpriseRegistrationService
enterprise:
user_ids: [CurrentUser.id]
@@ -6,6 +6,10 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
address: {}
country: availableCountries[0]
constructor: ->
for key, value of enterpriseAttributes
@enterprise[key] = value
create: =>
# Loading.message = "Creating " + @enterprise.name
# $http(
@@ -14,7 +18,7 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
# data:
# enterprise: @prepare()
# params:
# token: SpreeApiKey
# token: spreeApiKey
# ).success((data) =>
# Loading.clear()
# @enterprise.id = data
@@ -34,21 +38,22 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
# data:
# enterprise: @prepare()
# params:
# token: SpreeApiKey
# token: spreeApiKey
# ).success((data) ->
# Loading.clear()
# RegistrationService.select(step)
# ).error((data) ->
# Loading.clear()
# console.log angular.toJson(data)
# alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.')
# alert('Failed to update your enterprise.\nPlease ensure all fields are completely filled out.')
# )
RegistrationService.select(step)
prepare: =>
enterprise = {}
for a, v of @enterprise when a isnt 'address' && a isnt 'country' && a isnt 'id'
enterprise[a] = v
excluded = [ 'address', 'country', 'id' ]
for key, value of @enterprise when key not in excluded
enterprise[key] = value
enterprise.address_attributes = @enterprise.address
enterprise.address_attributes.country_id = @enterprise.country.id
enterprise

View File

@@ -4,7 +4,7 @@
%h5
Who is responsible for managing
%span{ ng: { class: "{brick: enterprise.is_distributor, turquoise: !enterprise.is_distributor}" } }
{{ enterprise.name }}
{{ enterprise.name }}?
%ng-include{ src: "'registration/steps.html'" }
%form{ name: 'contact', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "create(contact)" } }
.row.content

View File

@@ -1,38 +1,40 @@
.container#registration-details
.container#registration-details{bindonce: true}
.header
%h2 Let's Get Started
%h5 Woot! First we need to know what sort of enterprise you are:
%h5{ bo: { if: "enterprise.type != 'single'" } } Woot! First we need to know what sort of enterprise you are:
%h5{ bo: { if: "enterprise.type == 'single'" } } Woot! First we need to know the name of your farm:
%ng-include{ src: "'registration/steps.html'" }
%form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('address',details)" } }
.row
.small-12.columns.field
%label{ for: 'enterprise_name' } Enterprise Name:
%label{ for: 'enterprise_name', bo: { if: "enterprise.type != 'single'" } } Enterprise Name:
%label{ for: 'enterprise_name', bo: { if: "enterprise.type == 'single'" } } Farm Name:
%input.chunky.small-12.columns{ id: 'enterprise_name', name: 'name', placeholder: "eg. Charlie's Awesome Farm", required: true, ng: { model: 'enterprise.name' } }
%span.error.small-12.columns{ ng: { show: "details.name.$error.required && submitted" } }
You need to enter a name for your enterprise!
.row#enterprise-types{ 'data-equalizer' => true }
.row#enterprise-types{ 'data-equalizer' => true, bo: { if: "enterprise.type != 'single'" } }
.small-12.columns.field
.row
.small-12.columns
%label Choose one:
.row
.small-12.medium-4.large-4.columns{ 'data-equalizer-watch' => true }
%a.panel.producer-panel{ href: "#", ng: { click: "enterprise.is_distributor = false; enterprise.is_primary_producer = true", class: "{selected: (!enterprise.is_distributor && enterprise.is_primary_producer)}" } }
%a.panel#producer-panel{ href: "#", ng: { click: "enterprise.is_distributor = false; enterprise.is_primary_producer = true", class: "{selected: (!enterprise.is_distributor && enterprise.is_primary_producer)}" } }
.left
%render-svg{ path: "/assets/map-icon-producer.svg" }
/ %render-svg{ path: "/assets/map-icon-producer.svg" }
%h4 I'm A Producer
%p Producers make yummy things to eat &/or drink. You're a producer if you grow it, raise it, brew it, bake it, ferment it, milk it or mould it.
.small-12.medium-4.large-4.columns{ 'data-equalizer-watch' => true }
%a.panel.hub-panel{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = false", class: "{selected: (enterprise.is_distributor && !enterprise.is_primary_producer)}" } }
%a.panel#hub-panel{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = false", class: "{selected: (enterprise.is_distributor && !enterprise.is_primary_producer)}" } }
.left
%render-svg{ path: "/assets/map-icon-hub.svg" }
/ %render-svg{ path: "/assets/map-icon-hub.svg" }
%h4 I'm A Hub
%p Hubs connect the producer to the eater. Hubs can be co-ops, independent retailers, buying groups, wholesalers, CSA box schemes, farm-gate stalls, etc.
.small-12.medium-4.large-4.columns{ 'data-equalizer-watch' => true }
%a.panel.both-panel{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = true", class: "{selected: (enterprise.is_distributor && enterprise.is_primary_producer)}" } }
%a.panel#both-panel{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = true", class: "{selected: (enterprise.is_distributor && enterprise.is_primary_producer)}" } }
.left
%render-svg{path: "/assets/map-icon-both.svg"}
/ %render-svg{path: "/assets/map-icon-both.svg"}
%h4 I'm Both
%p Hey there, Jack-of-all-trades! Not only do you produce things to eat &/or drink, you also want to sell your yummies through an Open Food Network shopfront.
.row.buttons