From bebe0c41f64d4137db6665b241c57f7c2250b857 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 11:50:46 +1000 Subject: [PATCH 001/120] Styling for hubs and producers - adding rounded corners, making current shop less intense --- .../darkswarm/active_table.css.sass | 6 ++++- .../stylesheets/darkswarm/branding.css.sass | 12 ---------- .../stylesheets/darkswarm/hub_node.css.sass | 23 ++++++------------- app/assets/stylesheets/darkswarm/mixins.sass | 4 ++++ 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/active_table.css.sass b/app/assets/stylesheets/darkswarm/active_table.css.sass index 695ee3039a..36df754b66 100644 --- a/app/assets/stylesheets/darkswarm/active_table.css.sass +++ b/app/assets/stylesheets/darkswarm/active_table.css.sass @@ -44,6 +44,7 @@ .active_table_row // Inherits from active_table border: 1px solid transparent + @include border-radius(0.5em) // Foundation overrides margin-left: 0 @@ -63,14 +64,18 @@ border-right: 1px solid $disabled-bright border-top: 0 border-bottom: 0 + @include border-radius(0) .active_table_row:first-child border-top: 1px solid $disabled-bright + color: $dark-grey + @include border-radius-mixed(0.5em, 0.5em, 0, 0) &:hover, &:active, &:focus // color: $dark-grey .active_table_row:last-child border-bottom: 1px solid $disabled-bright + @include border-radius-mixed(0, 0, 0.5em, 0.5em) //Open row sections @@ -104,7 +109,6 @@ color: $dark-grey &.open .active_table_row:first-child - &, & * color: $dark-grey diff --git a/app/assets/stylesheets/darkswarm/branding.css.sass b/app/assets/stylesheets/darkswarm/branding.css.sass index 68f60dde53..fabb82130f 100644 --- a/app/assets/stylesheets/darkswarm/branding.css.sass +++ b/app/assets/stylesheets/darkswarm/branding.css.sass @@ -1,15 +1,3 @@ -// ORIGINAL -// $clr-brick: #8f301d -// $clr-brick-light: #f5e4e1 -// $clr-brick-ultra-light: #f7f4ef -// $clr-brick-bright: #db583d -// $clr-brick-light-bright: #f4bbb0 - -// $clr-turquoise: #097563 -// $clr-turquoise-light: #cef2ec -// $clr-turquoise-ultra-light: #e6faf7 -// $clr-turquoise-bright: #1d8f7c - $clr-brick: #c1122b $clr-brick-light: #f5e6e7 $clr-brick-ultra-light: #faf5f6 diff --git a/app/assets/stylesheets/darkswarm/hub_node.css.sass b/app/assets/stylesheets/darkswarm/hub_node.css.sass index 0ef4d83672..c4ae2d0082 100644 --- a/app/assets/stylesheets/darkswarm/hub_node.css.sass +++ b/app/assets/stylesheets/darkswarm/hub_node.css.sass @@ -15,7 +15,6 @@ color: $clr-brick-bright //Hub and Producer icons - // i.ofn-i_040-hub i.ofn-i_063-hub, i.ofn-i_064-hub-reversed, i.ofn-i_059-producer, i.ofn-i_060-producer-reversed font-size: 2rem display: inline-block @@ -75,17 +74,6 @@ &:hover, &:active, &:focus border: none color: $disabled-dark - &.open - .active_table_row:first-child - color: $disabled-dark - strong - color: $disabled-dark - &:hover, &:active, &:focus - color: $disabled-dark - strong - color: $disabled-dark - .active_table_row:nth-child(2) - background-color: rgba(255, 255, 255, 0) //Padding second row &.open @@ -96,13 +84,16 @@ &.current //overwrites active_table &.closed, &.open - .active_table_row:first-child - background-color: $clr-brick + .active_table_row:first-child, .active_table_row:last-child + background-color: rgba(245, 230, 231, 0.95) opacity: 1 &:hover, &:focus, &:active opacity: 0.9 - &, & * - color: white + &.closed + a, a * + color: $clr-brick + &:hover, &:active, &:focus + color: $clr-brick-bright &.open, &.closed .active_table_row border-color: $clr-brick diff --git a/app/assets/stylesheets/darkswarm/mixins.sass b/app/assets/stylesheets/darkswarm/mixins.sass index 2da53e9c50..6eef888a17 100644 --- a/app/assets/stylesheets/darkswarm/mixins.sass +++ b/app/assets/stylesheets/darkswarm/mixins.sass @@ -20,6 +20,10 @@ -webkit-border-radius: $border-radius border-radius: $border-radius +@mixin border-radius-mixed($border-radius-TL, $border-radius-TR, $border-radius-BR, $border-radius-BL) + -webkit-border-radius: $border-radius-TL $border-radius-TR $border-radius-BR $border-radius-BL + border-radius: $border-radius-TL $border-radius-TR $border-radius-BR $border-radius-BL + @mixin transform-translate($translate) -ms-transform: $translate -webkit-transform: $translate From 997479f5befac68381c7984db0af9a971a834a89 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 13:05:21 +1000 Subject: [PATCH 002/120] Change label on mobile menu --- app/views/shared/menu/_mobile_menu.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shared/menu/_mobile_menu.html.haml b/app/views/shared/menu/_mobile_menu.html.haml index 6cc81cab9d..b5045c7ed9 100644 --- a/app/views/shared/menu/_mobile_menu.html.haml +++ b/app/views/shared/menu/_mobile_menu.html.haml @@ -17,13 +17,13 @@ %a{"ofn-scroll-to" => "hubs"} %span.nav-primary %i.ofn-i_040-hub - Hubs + Shops - else %li.li-menu %a{href: root_path + "#/#hubs"} %span.nav-primary %i.ofn-i_040-hub - Hubs + Shops %li.li-menu %a{href: main_app.map_path} %span.nav-primary From 58f28f112a76471b7cca6e8c11718040c6979d57 Mon Sep 17 00:00:00 2001 From: Rob H Date: Mon, 8 Sep 2014 20:57:49 +1000 Subject: [PATCH 003/120] Enterprise index type selection is only visible to super admin --- app/views/admin/enterprises/index.html.haml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/admin/enterprises/index.html.haml b/app/views/admin/enterprises/index.html.haml index c8b3cce3d4..c783277b63 100644 --- a/app/views/admin/enterprises/index.html.haml +++ b/app/views/admin/enterprises/index.html.haml @@ -13,14 +13,16 @@ %col{style: "width: 25%;"}/ %col{style: "width: 10%;"}/ %col{style: "width: 5%;"}/ - %col{style: "width: 10%;"}/ + - if spree_current_user.admin? + %col{style: "width: 10%;"}/ %col{style: "width: 20%;"}/ %thead %tr{"data-hook" => "enterprises_header"} %th Name %th Role %th Visible? - %th Type + - if spree_current_user.admin? + %th Type %th %tbody = f.fields_for :collection do |enterprise_form| @@ -34,7 +36,8 @@ = enterprise_form.check_box :is_distributor Hub %td= enterprise_form.check_box :visible - %td= enterprise_form.select :type, Enterprise::TYPES, {}, class: 'select2 fullwidth' + - if spree_current_user.admin? + %td= enterprise_form.select :type, Enterprise::TYPES, {}, class: 'select2 fullwidth' %td{"data-hook" => "admin_users_index_row_actions"} = render 'actions', enterprise: enterprise - if @enterprises.empty? From 31de5d45ea7e9e03c1ed7711c985eb269a5b6c08 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 29 Aug 2014 11:09:19 +1000 Subject: [PATCH 004/120] Adding owner to enterprise --- app/models/enterprise.rb | 7 +++++ app/models/spree/user_decorator.rb | 1 + .../20140828023619_add_owner_to_enterprise.rb | 20 +++++++++++++ db/schema.rb | 5 +++- spec/factories.rb | 1 + spec/models/enterprise_spec.rb | 30 +++++++++++++++++-- spec/models/spree/user_spec.rb | 13 ++++++++ 7 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20140828023619_add_owner_to_enterprise.rb diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 004923097e..57316f7c4b 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -16,6 +16,7 @@ class Enterprise < ActiveRecord::Base has_many :enterprise_fees has_many :enterprise_roles, :dependent => :destroy has_many :users, through: :enterprise_roles + belongs_to :owner, class_name: 'Spree::User', foreign_key: :owner_id has_and_belongs_to_many :payment_methods, join_table: 'distributors_payment_methods', class_name: 'Spree::PaymentMethod', foreign_key: 'distributor_id' has_many :distributor_shipping_methods, foreign_key: :distributor_id has_many :shipping_methods, through: :distributor_shipping_methods @@ -46,7 +47,9 @@ class Enterprise < ActiveRecord::Base validates :name, presence: true validates :type, presence: true, inclusion: {in: TYPES} validates :address, presence: true, associated: true + validates :owner, presence: true + before_validation :ensure_owner_is_manager, if: lambda { owner_id_changed? } before_validation :set_unused_address_fields after_validation :geocode_address @@ -234,4 +237,8 @@ class Enterprise < ActiveRecord::Base def geocode_address address.geocode if address.changed? end + + def ensure_owner_is_manager + users << owner unless users.include? owner + end end diff --git a/app/models/spree/user_decorator.rb b/app/models/spree/user_decorator.rb index 9dbc8226f5..7ee42af088 100644 --- a/app/models/spree/user_decorator.rb +++ b/app/models/spree/user_decorator.rb @@ -1,6 +1,7 @@ Spree.user_class.class_eval do has_many :enterprise_roles, :dependent => :destroy has_many :enterprises, through: :enterprise_roles + has_many :owned_enterprises, class_name: 'Enterprise', foreign_key: :owner_id has_one :cart accepts_nested_attributes_for :enterprise_roles, :allow_destroy => true diff --git a/db/migrate/20140828023619_add_owner_to_enterprise.rb b/db/migrate/20140828023619_add_owner_to_enterprise.rb new file mode 100644 index 0000000000..0d859ff84b --- /dev/null +++ b/db/migrate/20140828023619_add_owner_to_enterprise.rb @@ -0,0 +1,20 @@ +class AddOwnerToEnterprise < ActiveRecord::Migration + def up + add_column :enterprises, :owner_id, :integer + add_index :enterprises, :owner_id + + Enterprise.all.each do |e| + owner = e.users.find{ |u| !u.admin? } + admin_owner = e.users.find &:admin? + any_admin = Spree::User.admin.first + e.update_column :owner_id, (owner || admin_owner || any_admin ) + end + + add_foreign_key :enterprises, :spree_users, column: :owner_id + change_column :enterprises, :owner_id, :integer, null: false + end + + def down + remove_column :enterprises, :owner_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 462e89c952..e74f748fa9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140826043521) do +ActiveRecord::Schema.define(:version => 20140828023619) do create_table "adjustment_metadata", :force => true do |t| t.integer "adjustment_id" @@ -265,9 +265,11 @@ ActiveRecord::Schema.define(:version => 20140826043521) do t.string "instagram" t.string "linkedin" t.string "type", :default => "profile", :null => false + t.integer "owner_id", :null => false end add_index "enterprises", ["address_id"], :name => "index_enterprises_on_address_id" + add_index "enterprises", ["owner_id"], :name => "index_enterprises_on_owner_id" create_table "exchange_fees", :force => true do |t| t.integer "exchange_id" @@ -1069,6 +1071,7 @@ ActiveRecord::Schema.define(:version => 20140826043521) do add_foreign_key "enterprise_roles", "spree_users", name: "enterprise_roles_user_id_fk", column: "user_id" add_foreign_key "enterprises", "spree_addresses", name: "enterprises_address_id_fk", column: "address_id" + add_foreign_key "enterprises", "spree_users", name: "enterprises_owner_id_fk", column: "owner_id" add_foreign_key "exchange_fees", "enterprise_fees", name: "exchange_fees_enterprise_fee_id_fk" add_foreign_key "exchange_fees", "exchanges", name: "exchange_fees_exchange_id_fk" diff --git a/spec/factories.rb b/spec/factories.rb index 849d38abf3..d605b5b759 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -82,6 +82,7 @@ FactoryGirl.define do end factory :enterprise, :class => Enterprise do + owner { FactoryGirl.create :user } sequence(:name) { |n| "Enterprise #{n}" } type 'full' description 'enterprise' diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index c517a3ed41..c9d4426d74 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe Enterprise do describe "associations" do + it { should belong_to(:owner) } it { should have_many(:supplied_products) } it { should have_many(:distributed_orders) } it { should belong_to(:address) } @@ -51,11 +52,34 @@ describe Enterprise do e.suppliers end end + + describe "ownership" do + let(:u1) { create(:user) } + let(:u2) { create(:user) } + let(:e) { create(:enterprise, owner: u1 ) } + + it "allows owner to be changed" do + expect(e.owner).to eq u1 + expect(e.users).to include u1 + expect(e.users).to_not include u2 + e.owner = u2 + e.save! + e.reload + expect(e.owner).to eq u2 + expect(e.users).to include u1, u2 + end + end end describe "validations" do subject { FactoryGirl.create(:distributor_enterprise, :address => FactoryGirl.create(:address)) } it { should validate_presence_of(:name) } + + it "requires an owner" do + expect{ + e = create(:enterprise, owner: nil) + }.to raise_error ActiveRecord::RecordInvalid, "Validation failed: Owner can't be blank" + end end describe "delegations" do @@ -74,7 +98,7 @@ describe Enterprise do Enterprise.visible.should == [s1] end end - + describe "distributors_with_active_order_cycles" do it "finds active distributors by order cycles" do s = create(:supplier_enterprise) @@ -441,8 +465,8 @@ describe Enterprise do end describe "presentation of attributes" do - let(:distributor) { - create(:distributor_enterprise, + let(:distributor) { + create(:distributor_enterprise, website: "http://www.google.com", facebook: "www.facebook.com/roger", linkedin: "https://linkedin.com") diff --git a/spec/models/spree/user_spec.rb b/spec/models/spree/user_spec.rb index 4e9ad94fac..166ae6dab5 100644 --- a/spec/models/spree/user_spec.rb +++ b/spec/models/spree/user_spec.rb @@ -1,4 +1,17 @@ describe Spree.user_class do + describe "associations" do + it { should have_many(:owned_enterprises) } + + describe "enterprise ownership" do + let(:u) { create(:user) } + let(:e1) { create(:enterprise, owner: u) } + let(:e2) { create(:enterprise, owner: u) } + it "provides access to owned enteprises" do + expect(u.owned_enterprises).to include e1, e2 + end + end + end + context "#create" do it "should send a signup email" do From 138e0281a3d8add9e57f130686de1d8630b12aa5 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 29 Aug 2014 15:51:43 +1000 Subject: [PATCH 005/120] Specify owner for enterprise create action --- app/controllers/admin/enterprises_controller.rb | 14 +++++--------- app/models/enterprise.rb | 2 +- app/views/admin/enterprises/_form.html.haml | 4 ++++ .../admin/enterprises_controller_spec.rb | 2 ++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/controllers/admin/enterprises_controller.rb b/app/controllers/admin/enterprises_controller.rb index ceeb26abfc..838175126f 100644 --- a/app/controllers/admin/enterprises_controller.rb +++ b/app/controllers/admin/enterprises_controller.rb @@ -3,9 +3,9 @@ module Admin before_filter :load_enterprise_set, :only => :index before_filter :load_countries, :except => :index before_filter :load_methods_and_fees, :only => [:new, :edit, :update, :create] - create.after :grant_management before_filter :check_type, only: :update before_filter :check_bulk_type, only: :bulk_update + before_filter :check_owner, only: :create helper 'spree/products' include OrderCyclesHelper @@ -39,14 +39,6 @@ module Admin private - # When an enterprise user creates another enterprise, it is granted management - # permission for it - def grant_management - unless spree_current_user.has_spree_role? 'admin' - spree_current_user.enterprise_roles.create(enterprise: @object) - end - end - def load_enterprise_set @enterprise_set = EnterpriseSet.new :collection => collection end @@ -81,6 +73,10 @@ module Admin params[:enterprise].delete :type unless spree_current_user.admin? end + def check_owner + params[:enterprise][:owner_id] = spree_current_user.id unless spree_current_user.admin? + end + # Overriding method on Spree's resource controller def location_after_save if params[:enterprise].key? :producer_properties_attributes diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 57316f7c4b..a146fc4cc4 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -239,6 +239,6 @@ class Enterprise < ActiveRecord::Base end def ensure_owner_is_manager - users << owner unless users.include? owner + users << owner unless users.include?(owner) || owner.admin? end end diff --git a/app/views/admin/enterprises/_form.html.haml b/app/views/admin/enterprises/_form.html.haml index dbf986c7aa..dba1dd552d 100644 --- a/app/views/admin/enterprises/_form.html.haml +++ b/app/views/admin/enterprises/_form.html.haml @@ -23,6 +23,10 @@ .eight.columns.omega = f.collection_select :group_ids, EnterpriseGroup.all, :id, :name, {}, class: "select2 fullwidth", multiple: true, placeholder: "Start typing to search available groups..." + - if spree_current_user.admin? + / Select box for assigning owner goes here + = f.hidden_field :owner_id, value: @enterprise.owner_id || spree_current_user.id + .row .three.columns.alpha %label Enterprise Type(s) diff --git a/spec/controllers/admin/enterprises_controller_spec.rb b/spec/controllers/admin/enterprises_controller_spec.rb index 14faf26287..bdad9558fa 100644 --- a/spec/controllers/admin/enterprises_controller_spec.rb +++ b/spec/controllers/admin/enterprises_controller_spec.rb @@ -22,6 +22,7 @@ module Admin it "grants management permission if the current user is an enterprise user" do controller.stub spree_current_user: user + enterprise_params[:enterprise][:owner_id] = user spree_put :create, enterprise_params enterprise = Enterprise.find_by_name 'zzz' @@ -30,6 +31,7 @@ module Admin it "does not grant management permission to admins" do controller.stub spree_current_user: admin_user + enterprise_params[:enterprise][:owner_id] = admin_user spree_put :create, enterprise_params enterprise = Enterprise.find_by_name 'zzz' From 4bde6a0a3d86c5645b6727f8ad0c49ab888e7d22 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 29 Aug 2014 18:33:39 +1000 Subject: [PATCH 006/120] WIP: VERY SLOW PAGE LOAD: Super admin can edit owner of enterprise from edit screen --- app/views/admin/enterprises/_form.html.haml | 9 ++++++-- spec/features/admin/enterprises_spec.rb | 25 ++++++++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/views/admin/enterprises/_form.html.haml b/app/views/admin/enterprises/_form.html.haml index dba1dd552d..71299c57ba 100644 --- a/app/views/admin/enterprises/_form.html.haml +++ b/app/views/admin/enterprises/_form.html.haml @@ -24,8 +24,13 @@ .eight.columns.omega = f.collection_select :group_ids, EnterpriseGroup.all, :id, :name, {}, class: "select2 fullwidth", multiple: true, placeholder: "Start typing to search available groups..." - if spree_current_user.admin? - / Select box for assigning owner goes here - = f.hidden_field :owner_id, value: @enterprise.owner_id || spree_current_user.id + .row + .three.columns.alpha + %label Owner + .with-tip{'data-powertip' => "The primary user responsible for this enterprise."} + %a What's this? + .eight.columns + = f.collection_select :owner_id, Spree::User.all, :id, :email, {}, :class => "select2 fullwidth" .row .three.columns.alpha diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index a824716d95..90139c9c29 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -71,28 +71,24 @@ feature %q{ shipping_method = create(:shipping_method) enterprise_fee = create(:enterprise_fee) - login_to_admin_section - - click_link 'Enterprises' + # Navigating + admin = quick_login_as_admin + visit '/admin/enterprises' click_link 'New Enterprise' - fill_in 'enterprise_name', :with => 'Eaterprises' - choose 'Full' - fill_in 'enterprise_description', :with => 'Connecting farmers and eaters' - fill_in 'enterprise_long_description', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' - fill_in 'enterprise_distributor_info', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' - + # Checking shipping and payment method sidebars work uncheck 'enterprise_is_primary_producer' check 'enterprise_is_distributor' - - select eg1.name, from: 'enterprise_group_ids' - page.should_not have_checked_field "enterprise_payment_method_ids_#{payment_method.id}" page.should_not have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}" + # Filling in details + fill_in 'enterprise_name', :with => 'Eaterprises' + select admin.email, from: 'enterprise_own/er_id' + choose 'Full' check "enterprise_payment_method_ids_#{payment_method.id}" check "enterprise_shipping_method_ids_#{shipping_method.id}" - + select eg1.name, from: 'enterprise_group_ids' 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' @@ -108,6 +104,9 @@ feature %q{ fill_in 'enterprise_address_attributes_zipcode', :with => '3072' select('Australia', :from => 'enterprise_address_attributes_country_id') select('Victoria', :from => 'enterprise_address_attributes_state_id') + fill_in 'enterprise_description', :with => 'Connecting farmers and eaters' + fill_in 'enterprise_long_description', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' + fill_in 'enterprise_distributor_info', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' click_button 'Create' flash_message.should == 'Enterprise "Eaterprises" has been successfully created!' From 8e91e4513d939947f65435609fcf8cdf86e9d3bb Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 29 Aug 2014 22:55:51 +1000 Subject: [PATCH 007/120] Remove rich text editors from about us in enterprise editor --- app/views/admin/enterprises/_form.html.haml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/app/views/admin/enterprises/_form.html.haml b/app/views/admin/enterprises/_form.html.haml index 71299c57ba..ff2a7fd660 100644 --- a/app/views/admin/enterprises/_form.html.haml +++ b/app/views/admin/enterprises/_form.html.haml @@ -1,6 +1,3 @@ -- content_for :head do - = render 'shared/cms_elrte_head' - - content_for :page_actions do %li= button_link_to "Back to enterprises list", main_app.admin_enterprises_path, icon: 'icon-arrow-left' @@ -183,20 +180,13 @@ .row .alpha.three.columns = f.label :long_description, 'About Us' - %br - Tell us about yourself. This information appears on your public profile (under "About Us") .omega.eight.columns - = f.text_area :long_description, class: 'rich_text', placeholder: 'Tell us about yourself. This information appears on your public profile (under "About Us")' + = f.text_area :long_description, rows: 6, placeholder: 'Tell us about yourself. This information appears on your public profile (under "About Us")', class: 'fullwidth' .row .alpha.three.columns = f.label :distributor_info, 'How does your hub work?' - %br - %em (Hub only) - %br - Explain your distribution offer/s - this information appears on your public profile (under "How does it work?") .omega.eight.columns - = f.text_area :distributor_info, class: 'rich_text', placeholder: 'Hub only: Explain your distribution offer/s - this is more detailed information that the user can access by clicking on "How does it work?"' - / TODO: editor breaks scrolling with arrow keys + = f.text_area :distributor_info, rows: 6, placeholder: 'Hub only: Explain your distribution offer/s - this is more detailed information that the user can access by clicking on "How does it work?"', class: 'fullwidth' %fieldset.eleven.columns.alpha.no-border-bottom %legend IMAGES .row From 73a32fdaf1232b967e9e3eb05e5c71022892acfb Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 29 Aug 2014 23:10:23 +1000 Subject: [PATCH 008/120] Remove distributor_info: 'how does it work' from enterprises edit page --- .../enterprises/show/add_distributor_info.html.haml.deface | 4 ---- app/views/admin/enterprises/_form.html.haml | 5 ----- spec/features/admin/enterprises_spec.rb | 1 - 3 files changed, 10 deletions(-) delete mode 100644 app/overrides/admin/enterprises/show/add_distributor_info.html.haml.deface diff --git a/app/overrides/admin/enterprises/show/add_distributor_info.html.haml.deface b/app/overrides/admin/enterprises/show/add_distributor_info.html.haml.deface deleted file mode 100644 index 866d632e18..0000000000 --- a/app/overrides/admin/enterprises/show/add_distributor_info.html.haml.deface +++ /dev/null @@ -1,4 +0,0 @@ -/ insert_after "[data-hook='long_description']" -%tr{'data-hook' => 'distributor_info'} - %th Distributor Info: - %td= @enterprise.distributor_info.andand.html_safe \ No newline at end of file diff --git a/app/views/admin/enterprises/_form.html.haml b/app/views/admin/enterprises/_form.html.haml index ff2a7fd660..6625e91097 100644 --- a/app/views/admin/enterprises/_form.html.haml +++ b/app/views/admin/enterprises/_form.html.haml @@ -182,11 +182,6 @@ = f.label :long_description, 'About Us' .omega.eight.columns = f.text_area :long_description, rows: 6, placeholder: 'Tell us about yourself. This information appears on your public profile (under "About Us")', class: 'fullwidth' - .row - .alpha.three.columns - = f.label :distributor_info, 'How does your hub work?' - .omega.eight.columns - = f.text_area :distributor_info, rows: 6, placeholder: 'Hub only: Explain your distribution offer/s - this is more detailed information that the user can access by clicking on "How does it work?"', class: 'fullwidth' %fieldset.eleven.columns.alpha.no-border-bottom %legend IMAGES .row diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 90139c9c29..958b8867dc 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -106,7 +106,6 @@ feature %q{ select('Victoria', :from => 'enterprise_address_attributes_state_id') fill_in 'enterprise_description', :with => 'Connecting farmers and eaters' fill_in 'enterprise_long_description', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' - fill_in 'enterprise_distributor_info', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' click_button 'Create' flash_message.should == 'Enterprise "Eaterprises" has been successfully created!' From 13d814ff23659b68ecfb554f0ae03450de773630 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 29 Aug 2014 23:37:25 +1000 Subject: [PATCH 009/120] Adding user autocomplete directive to speed up specification of owner for enterprises --- app/assets/javascripts/admin/all.js | 1 + .../admin/enterprises/enterprises.js.coffee | 2 +- .../directives/user_autocomplete.js.coffee | 19 +++++++++++++++++++ .../javascripts/admin/users/users.js.coffee | 1 + app/views/admin/enterprises/_form.html.haml | 4 ++-- spec/features/admin/enterprises_spec.rb | 13 ++++++------- .../request/authentication_workflow.rb | 4 ++-- 7 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 app/assets/javascripts/admin/users/directives/user_autocomplete.js.coffee create mode 100644 app/assets/javascripts/admin/users/users.js.coffee diff --git a/app/assets/javascripts/admin/all.js b/app/assets/javascripts/admin/all.js index 5ffb99ccb8..3fb5e69499 100644 --- a/app/assets/javascripts/admin/all.js +++ b/app/assets/javascripts/admin/all.js @@ -22,5 +22,6 @@ //= require ./payment_methods/payment_methods //= require ./products/products //= require ./shipping_methods/shipping_methods +//= require ./users/users //= require_tree . diff --git a/app/assets/javascripts/admin/enterprises/enterprises.js.coffee b/app/assets/javascripts/admin/enterprises/enterprises.js.coffee index cdf90cfb51..6189661035 100644 --- a/app/assets/javascripts/admin/enterprises/enterprises.js.coffee +++ b/app/assets/javascripts/admin/enterprises/enterprises.js.coffee @@ -1 +1 @@ -angular.module("admin.enterprises", ["admin.payment_methods", "admin.shipping_methods"]) \ No newline at end of file +angular.module("admin.enterprises", ["admin.payment_methods", "admin.shipping_methods", "admin.users"]) \ No newline at end of file diff --git a/app/assets/javascripts/admin/users/directives/user_autocomplete.js.coffee b/app/assets/javascripts/admin/users/directives/user_autocomplete.js.coffee new file mode 100644 index 0000000000..956f370fb7 --- /dev/null +++ b/app/assets/javascripts/admin/users/directives/user_autocomplete.js.coffee @@ -0,0 +1,19 @@ +angular.module("admin.users").directive "ofnUserAutocomplete", ($http) -> + link: (scope,element,attrs) -> + setTimeout -> + element.select2 + multiple: false + initSelection: (element, callback) -> + $http.get( Spree.url(Spree.routes.user_search, { ids: element.val() }) ).success (data) -> + callback(data[0]) if data.length > 0 + ajax: + url: Spree.routes.user_search + datatype: 'json' + data:(term, page) -> + { q: term } + results: (data, page) -> + { results: data } + formatResult: (user) -> + user.email + formatSelection: (user) -> + user.email \ No newline at end of file diff --git a/app/assets/javascripts/admin/users/users.js.coffee b/app/assets/javascripts/admin/users/users.js.coffee new file mode 100644 index 0000000000..6bfd47a894 --- /dev/null +++ b/app/assets/javascripts/admin/users/users.js.coffee @@ -0,0 +1 @@ +angular.module("admin.users", []) \ No newline at end of file diff --git a/app/views/admin/enterprises/_form.html.haml b/app/views/admin/enterprises/_form.html.haml index 6625e91097..0981f7dfc9 100644 --- a/app/views/admin/enterprises/_form.html.haml +++ b/app/views/admin/enterprises/_form.html.haml @@ -23,11 +23,11 @@ - if spree_current_user.admin? .row .three.columns.alpha - %label Owner + =f.label :owner_id, 'Owner' .with-tip{'data-powertip' => "The primary user responsible for this enterprise."} %a What's this? .eight.columns - = f.collection_select :owner_id, Spree::User.all, :id, :email, {}, :class => "select2 fullwidth" + = f.hidden_field :owner_id, class: "select2 fullwidth", 'ofn-user-autocomplete' => true .row .three.columns.alpha diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 958b8867dc..6817ca6c4e 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -64,7 +64,7 @@ feature %q{ page.should have_content e.name end - scenario "creating a new enterprise" do + scenario "creating a new enterprise", js:true do eg1 = create(:enterprise_group, name: 'eg1') eg2 = create(:enterprise_group, name: 'eg2') payment_method = create(:payment_method) @@ -73,8 +73,7 @@ feature %q{ # Navigating admin = quick_login_as_admin - visit '/admin/enterprises' - click_link 'New Enterprise' + visit '/admin/enterprises/new' # Checking shipping and payment method sidebars work uncheck 'enterprise_is_primary_producer' @@ -84,11 +83,11 @@ feature %q{ # Filling in details fill_in 'enterprise_name', :with => 'Eaterprises' - select admin.email, from: 'enterprise_own/er_id' + select2_search admin.email, from: 'Owner' choose 'Full' check "enterprise_payment_method_ids_#{payment_method.id}" check "enterprise_shipping_method_ids_#{shipping_method.id}" - select eg1.name, from: 'enterprise_group_ids' + select2_search eg1.name, from: 'Groups' 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' @@ -102,8 +101,8 @@ feature %q{ 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' - select('Australia', :from => 'enterprise_address_attributes_country_id') - select('Victoria', :from => 'enterprise_address_attributes_state_id') + select2_search 'Australia', :from => 'Country' + select2_search 'Victoria', :from => 'State' fill_in 'enterprise_description', :with => 'Connecting farmers and eaters' fill_in 'enterprise_long_description', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' diff --git a/spec/support/request/authentication_workflow.rb b/spec/support/request/authentication_workflow.rb index add8de9f28..49b1512cac 100644 --- a/spec/support/request/authentication_workflow.rb +++ b/spec/support/request/authentication_workflow.rb @@ -6,7 +6,7 @@ module AuthenticationWorkflow def quick_login_as_admin admin_role = Spree::Role.find_or_create_by_name!('admin') - admin_user = create(:user, + admin_user = create(:user, :password => 'passw0rd', :password_confirmation => 'passw0rd', :remember_me => false, @@ -25,7 +25,7 @@ module AuthenticationWorkflow def login_to_admin_section admin_role = Spree::Role.find_or_create_by_name!('admin') - admin_user = create(:user, + admin_user = create(:user, :password => 'passw0rd', :password_confirmation => 'passw0rd', :remember_me => false, From e106c7a0cda0b0a33cdbf67509703ac8194c87bf Mon Sep 17 00:00:00 2001 From: Rob H Date: Sat, 30 Aug 2014 01:21:35 +1000 Subject: [PATCH 010/120] Initialise user autocomplete element using data from element itself rather than AJAX request --- .../admin/users/directives/user_autocomplete.js.coffee | 3 +-- app/views/admin/enterprises/_form.html.haml | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/admin/users/directives/user_autocomplete.js.coffee b/app/assets/javascripts/admin/users/directives/user_autocomplete.js.coffee index 956f370fb7..a904d1bcce 100644 --- a/app/assets/javascripts/admin/users/directives/user_autocomplete.js.coffee +++ b/app/assets/javascripts/admin/users/directives/user_autocomplete.js.coffee @@ -4,8 +4,7 @@ angular.module("admin.users").directive "ofnUserAutocomplete", ($http) -> element.select2 multiple: false initSelection: (element, callback) -> - $http.get( Spree.url(Spree.routes.user_search, { ids: element.val() }) ).success (data) -> - callback(data[0]) if data.length > 0 + callback { id: element.val(), email: attrs.email } ajax: url: Spree.routes.user_search datatype: 'json' diff --git a/app/views/admin/enterprises/_form.html.haml b/app/views/admin/enterprises/_form.html.haml index 0981f7dfc9..6f86c3e703 100644 --- a/app/views/admin/enterprises/_form.html.haml +++ b/app/views/admin/enterprises/_form.html.haml @@ -27,7 +27,8 @@ .with-tip{'data-powertip' => "The primary user responsible for this enterprise."} %a What's this? .eight.columns - = f.hidden_field :owner_id, class: "select2 fullwidth", 'ofn-user-autocomplete' => true + - 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 From 7983b2f45a830cd842fa53d8f1f47e4c9d9816d0 Mon Sep 17 00:00:00 2001 From: Rob H Date: Sat, 30 Aug 2014 01:59:33 +1000 Subject: [PATCH 011/120] Adding changing ownership to enterprise update spec --- spec/features/admin/enterprises_spec.rb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 6817ca6c4e..283056ca5c 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -73,7 +73,8 @@ feature %q{ # Navigating admin = quick_login_as_admin - visit '/admin/enterprises/new' + visit '/admin/enterprises' + click_link 'New Enterprise' # Checking shipping and payment method sidebars work uncheck 'enterprise_is_primary_producer' @@ -110,7 +111,7 @@ feature %q{ flash_message.should == 'Enterprise "Eaterprises" has been successfully created!' end - scenario "editing an existing enterprise" do + scenario "editing an existing enterprise", js: true do @enterprise = create(:enterprise) e2 = create(:enterprise) eg1 = create(:enterprise_group, name: 'eg1') @@ -118,14 +119,18 @@ feature %q{ payment_method = create(:payment_method, distributors: [e2]) shipping_method = create(:shipping_method, distributors: [e2]) enterprise_fee = create(:enterprise_fee, enterprise: @enterprise ) + user = create(:user) - login_to_admin_section + admin = quick_login_as_admin - click_link 'Enterprises' - all("a", text:'Edit Profile').first.click + visit '/admin/enterprises' + within "tr.enterprise-#{@enterprise.id}" do + all("a", text: 'Edit Profile').first.click + end fill_in 'enterprise_name', :with => 'Eaterprises' choose 'Single' + select2_search user.email, from: 'Owner' fill_in 'enterprise_description', :with => 'Connecting farmers and eaters' fill_in 'enterprise_long_description', :with => 'Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro.' @@ -140,7 +145,7 @@ feature %q{ page.should have_selector "#shipping_methods" page.should have_selector "#enterprise_fees" - select eg1.name, from: 'enterprise_group_ids' + select2_search eg1.name, from: 'Groups' page.should_not have_checked_field "enterprise_payment_method_ids_#{payment_method.id}" page.should_not have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}" @@ -159,13 +164,15 @@ feature %q{ 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' - select('Australia', :from => 'enterprise_address_attributes_country_id') - select('Victoria', :from => 'enterprise_address_attributes_state_id') + select2_search 'Australia', :from => 'Country' + select2_search 'Victoria', :from => 'State' click_button 'Update' flash_message.should == 'Enterprise "Eaterprises" has been successfully updated!' page.should have_field 'enterprise_name', :with => 'Eaterprises' + @enterprise.reload + expect(@enterprise.owner).to eq user page.should have_checked_field "enterprise_payment_method_ids_#{payment_method.id}" page.should have_checked_field "enterprise_shipping_method_ids_#{shipping_method.id}" From 3e1f4628e3665a0483afd7984002d775e20ef828 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 3 Sep 2014 17:04:57 +1000 Subject: [PATCH 012/120] Can change owner of enterprises from index page --- app/views/admin/enterprises/index.html.haml | 9 ++++++--- spec/features/admin/enterprises_spec.rb | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/views/admin/enterprises/index.html.haml b/app/views/admin/enterprises/index.html.haml index c783277b63..d2ca8efb2f 100644 --- a/app/views/admin/enterprises/index.html.haml +++ b/app/views/admin/enterprises/index.html.haml @@ -11,11 +11,12 @@ %table#listing_enterprises.index %colgroup %col{style: "width: 25%;"}/ - %col{style: "width: 10%;"}/ + %col{style: "width: 15%;"}/ %col{style: "width: 5%;"}/ - if spree_current_user.admin? - %col{style: "width: 10%;"}/ - %col{style: "width: 20%;"}/ + %col{style: "width: 12%;"}/ + %col{style: "width: 18%;"}/ + %col{style: "width: 25%;"}/ %thead %tr{"data-hook" => "enterprises_header"} %th Name @@ -23,6 +24,7 @@ %th Visible? - if spree_current_user.admin? %th Type + %th Owner %th %tbody = f.fields_for :collection do |enterprise_form| @@ -38,6 +40,7 @@ %td= enterprise_form.check_box :visible - if spree_current_user.admin? %td= enterprise_form.select :type, Enterprise::TYPES, {}, class: 'select2 fullwidth' + %td= enterprise_form.select :owner_id, enterprise.users.map{ |e| [ e.email, e.id ] }, {}, class: "select2 fullwidth" %td{"data-hook" => "admin_users_index_row_actions"} = render 'actions', enterprise: enterprise - if @enterprises.empty? diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 283056ca5c..ee67dc1a73 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -38,6 +38,9 @@ feature %q{ scenario "editing enterprises in bulk" do s = create(:supplier_enterprise) d = create(:distributor_enterprise, type: 'profile') + d_manager = create_enterprise_user + d_manager.enterprise_roles.build(enterprise: d).save + expect(d.owner).to_not eq d_manager login_to_admin_section click_link 'Enterprises' @@ -46,12 +49,14 @@ feature %q{ expect(page).to have_checked_field "enterprise_set_collection_attributes_0_visible" uncheck "enterprise_set_collection_attributes_0_visible" select 'full', from: "enterprise_set_collection_attributes_0_type" + select d_manager.email, from: 'enterprise_set_collection_attributes_0_owner_id' end click_button "Update" flash_message.should == 'Enterprises updated successfully' distributor = Enterprise.find(d.id) expect(distributor.visible).to eq false expect(distributor.type).to eq 'full' + expect(distributor.owner).to eq d_manager end scenario "viewing an enterprise" do From e83e2295ede6e14df45c6f6f787f9440894dfcf4 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 4 Sep 2014 13:00:35 +1000 Subject: [PATCH 013/120] Adding some extra controller-level specs for enterprise ownership --- .../admin/enterprises_controller.rb | 11 ++++- .../admin/enterprises_controller_spec.rb | 45 ++++++++++++++++++- spec/models/enterprise_spec.rb | 2 +- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/enterprises_controller.rb b/app/controllers/admin/enterprises_controller.rb index 838175126f..64ba997950 100644 --- a/app/controllers/admin/enterprises_controller.rb +++ b/app/controllers/admin/enterprises_controller.rb @@ -5,7 +5,8 @@ module Admin before_filter :load_methods_and_fees, :only => [:new, :edit, :update, :create] before_filter :check_type, only: :update before_filter :check_bulk_type, only: :bulk_update - before_filter :check_owner, only: :create + before_filter :override_owner, only: :create + before_filter :check_owner, only: :update helper 'spree/products' include OrderCyclesHelper @@ -73,10 +74,16 @@ module Admin params[:enterprise].delete :type unless spree_current_user.admin? end - def check_owner + def override_owner params[:enterprise][:owner_id] = spree_current_user.id unless spree_current_user.admin? end + def check_owner + unless spree_current_user == @enterprise.owner || spree_current_user.admin? + params[:enterprise].delete :owner_id + end + end + # Overriding method on Spree's resource controller def location_after_save if params[:enterprise].key? :producer_properties_attributes diff --git a/spec/controllers/admin/enterprises_controller_spec.rb b/spec/controllers/admin/enterprises_controller_spec.rb index bdad9558fa..44421aad8e 100644 --- a/spec/controllers/admin/enterprises_controller_spec.rb +++ b/spec/controllers/admin/enterprises_controller_spec.rb @@ -2,7 +2,12 @@ require 'spec_helper' module Admin describe EnterprisesController do - let(:distributor) { create(:distributor_enterprise) } + let(:distributor_owner) do + user = create(:user) + user.spree_roles = [] + user + end + let(:distributor) { create(:distributor_enterprise, owner: distributor_owner ) } let(:user) do user = create(:user) user.spree_roles = [] @@ -37,6 +42,44 @@ module Admin enterprise = Enterprise.find_by_name 'zzz' admin_user.enterprise_roles.where(enterprise_id: enterprise).should be_empty end + + it "it overrides the owner_id submitted by the user unless current_user is super admin" do + controller.stub spree_current_user: user + enterprise_params[:enterprise][:owner_id] = admin_user + + spree_put :create, enterprise_params + enterprise = Enterprise.find_by_name 'zzz' + user.enterprise_roles.where(enterprise_id: enterprise).first.should be + end + end + + describe "updating an enterprise" do + it "allows current owner to change ownership" do + controller.stub spree_current_user: distributor_owner + update_params = { id: distributor, enterprise: { owner_id: user } } + spree_post :update, update_params + + distributor.reload + expect(distributor.owner).to eq user + end + + it "allows super admin to change ownership" do + controller.stub spree_current_user: admin_user + update_params = { id: distributor, enterprise: { owner_id: user } } + spree_post :update, update_params + + distributor.reload + expect(distributor.owner).to eq user + end + + it "does not allow managers to change ownership" do + controller.stub spree_current_user: user + update_params = { id: distributor, enterprise: { owner_id: user } } + spree_post :update, update_params + + distributor.reload + expect(distributor.owner).to eq distributor_owner + end end describe "updating an enterprise" do diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index c9d4426d74..c6418def09 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -58,7 +58,7 @@ describe Enterprise do let(:u2) { create(:user) } let(:e) { create(:enterprise, owner: u1 ) } - it "allows owner to be changed" do + it "adds new owner to list of managers" do expect(e.owner).to eq u1 expect(e.users).to include u1 expect(e.users).to_not include u2 From 2253859cd1f8605fada2abf5f7265c000da84a0f Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 4 Sep 2014 14:06:53 +1000 Subject: [PATCH 014/120] Adding enterprise limit to spree users --- ...3026_add_enterprise_limit_to_spree_users.rb | 18 ++++++++++++++++++ db/schema.rb | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20140904003026_add_enterprise_limit_to_spree_users.rb diff --git a/db/migrate/20140904003026_add_enterprise_limit_to_spree_users.rb b/db/migrate/20140904003026_add_enterprise_limit_to_spree_users.rb new file mode 100644 index 0000000000..b76a3da2d7 --- /dev/null +++ b/db/migrate/20140904003026_add_enterprise_limit_to_spree_users.rb @@ -0,0 +1,18 @@ +class AddEnterpriseLimitToSpreeUsers < ActiveRecord::Migration + def up + add_column :spree_users, :enterprise_limit, :integer, default: 1, null: false + + Spree::User.all.each do |u| + e_count = u.owned_enterprises.length + if u.admin? || e_count > 1 + e_limit = 100 + e_limit = 1000 if u.admin? + u.update_column :enterprise_limit, e_limit + end + end + end + + def down + remove_column :spree_users, :enterprise_limit + end +end diff --git a/db/schema.rb b/db/schema.rb index e74f748fa9..c8005a42e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140828023619) do +ActiveRecord::Schema.define(:version => 20140904003026) do create_table "adjustment_metadata", :force => true do |t| t.integer "adjustment_id" @@ -971,6 +971,7 @@ ActiveRecord::Schema.define(:version => 20140828023619) do t.string "spree_api_key", :limit => 48 t.datetime "reset_password_sent_at" t.string "api_key", :limit => 40 + t.integer "enterprise_limit", :default => 1, :null => false end add_index "spree_users", ["email"], :name => "email_idx_unique", :unique => true From 7fbc9aa680dc93f43eaf35ef7dd012f95d3a76ab Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 4 Sep 2014 14:48:08 +1000 Subject: [PATCH 015/120] User validates the number of enterprises owned --- app/models/spree/user_decorator.rb | 10 ++++++++++ spec/models/spree/user_spec.rb | 21 ++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/app/models/spree/user_decorator.rb b/app/models/spree/user_decorator.rb index 7ee42af088..9890d0ff7b 100644 --- a/app/models/spree/user_decorator.rb +++ b/app/models/spree/user_decorator.rb @@ -9,6 +9,8 @@ Spree.user_class.class_eval do attr_accessible :enterprise_ids, :enterprise_roles_attributes after_create :send_signup_confirmation + validate :owned_enterprises_count + def build_enterprise_roles Enterprise.all.each do |enterprise| unless self.enterprise_roles.find_by_enterprise_id enterprise.id @@ -20,4 +22,12 @@ Spree.user_class.class_eval do def send_signup_confirmation Spree::UserMailer.signup_confirmation(self).deliver end + + private + + def owned_enterprises_count + if owned_enterprises.size > enterprise_limit + errors.add(:owned_enterprises, "^The nominated user is not permitted to own own any more enterprises.") + end + end end diff --git a/spec/models/spree/user_spec.rb b/spec/models/spree/user_spec.rb index 166ae6dab5..e985d9bde8 100644 --- a/spec/models/spree/user_spec.rb +++ b/spec/models/spree/user_spec.rb @@ -3,17 +3,28 @@ describe Spree.user_class do it { should have_many(:owned_enterprises) } describe "enterprise ownership" do - let(:u) { create(:user) } - let(:e1) { create(:enterprise, owner: u) } - let(:e2) { create(:enterprise, owner: u) } + let(:u1) { create(:user) } + let(:u2) { create(:user) } + let(:e1) { create(:enterprise, owner: u1) } + let(:e2) { create(:enterprise, owner: u1) } + it "provides access to owned enteprises" do - expect(u.owned_enterprises).to include e1, e2 + expect(u1.owned_enterprises).to include e1, e2 + end + + it "enforces the limit on the number of enterprise owned" do + expect(u2.owned_enterprises).to eq [] + u2.owned_enterprises << e1 + u2.owned_enterprises << e2 + expect { + u2.save! + }.to raise_error ActiveRecord::RecordInvalid, "Validation failed: The nominated user is not permitted to own own any more enterprises." + end end end context "#create" do - it "should send a signup email" do Spree::UserMailer.should_receive(:signup_confirmation).and_return(double(:deliver => true)) create(:user) From f1c19ea64c94020fadc3d78c28cdb6fa14539510 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 10 Sep 2014 14:18:57 +1000 Subject: [PATCH 016/120] Enterprise validates owner enterprise_limit --- app/models/enterprise.rb | 11 +++- app/models/spree/user_decorator.rb | 12 ++-- spec/features/admin/enterprises_spec.rb | 57 ++++++++++++------- spec/models/enterprise_spec.rb | 17 +++++- spec/models/spree/user_spec.rb | 20 +++---- .../request/authentication_workflow.rb | 2 +- 6 files changed, 80 insertions(+), 39 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index a146fc4cc4..ccca96ab26 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -16,7 +16,7 @@ class Enterprise < ActiveRecord::Base has_many :enterprise_fees has_many :enterprise_roles, :dependent => :destroy has_many :users, through: :enterprise_roles - belongs_to :owner, class_name: 'Spree::User', foreign_key: :owner_id + belongs_to :owner, class_name: 'Spree::User', foreign_key: :owner_id, inverse_of: :owned_enterprises has_and_belongs_to_many :payment_methods, join_table: 'distributors_payment_methods', class_name: 'Spree::PaymentMethod', foreign_key: 'distributor_id' has_many :distributor_shipping_methods, foreign_key: :distributor_id has_many :shipping_methods, through: :distributor_shipping_methods @@ -47,7 +47,8 @@ class Enterprise < ActiveRecord::Base validates :name, presence: true validates :type, presence: true, inclusion: {in: TYPES} validates :address, presence: true, associated: true - validates :owner, presence: true + validates_presence_of :owner + validate :enforce_ownership_limit, if: lambda { owner_id_changed? } before_validation :ensure_owner_is_manager, if: lambda { owner_id_changed? } before_validation :set_unused_address_fields @@ -241,4 +242,10 @@ class Enterprise < ActiveRecord::Base def ensure_owner_is_manager users << owner unless users.include?(owner) || owner.admin? end + + def enforce_ownership_limit + unless owner.can_own_more_enterprises? + errors.add(:owner, "^You are not permitted to own own any more enterprises (limit is #{owner.enterprise_limit}).") + end + end end diff --git a/app/models/spree/user_decorator.rb b/app/models/spree/user_decorator.rb index 9890d0ff7b..2a177f84a0 100644 --- a/app/models/spree/user_decorator.rb +++ b/app/models/spree/user_decorator.rb @@ -1,7 +1,7 @@ Spree.user_class.class_eval do has_many :enterprise_roles, :dependent => :destroy has_many :enterprises, through: :enterprise_roles - has_many :owned_enterprises, class_name: 'Enterprise', foreign_key: :owner_id + has_many :owned_enterprises, class_name: 'Enterprise', foreign_key: :owner_id, inverse_of: :owner has_one :cart accepts_nested_attributes_for :enterprise_roles, :allow_destroy => true @@ -9,7 +9,7 @@ Spree.user_class.class_eval do attr_accessible :enterprise_ids, :enterprise_roles_attributes after_create :send_signup_confirmation - validate :owned_enterprises_count + validate :limit_owned_enterprises def build_enterprise_roles Enterprise.all.each do |enterprise| @@ -23,11 +23,15 @@ Spree.user_class.class_eval do Spree::UserMailer.signup_confirmation(self).deliver end + def can_own_more_enterprises? + owned_enterprises(:reload).size < enterprise_limit + end + private - def owned_enterprises_count + def limit_owned_enterprises if owned_enterprises.size > enterprise_limit - errors.add(:owned_enterprises, "^The nominated user is not permitted to own own any more enterprises.") + errors.add(:owned_enterprises, "^The nominated user is not permitted to own own any more enterprises (limit is #{enterprise_limit}).") end end end diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index ee67dc1a73..249528149d 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -257,13 +257,13 @@ feature %q{ let(:supplier2) { create(:supplier_enterprise, name: 'Another Supplier') } let(:distributor1) { create(:distributor_enterprise, name: 'First Distributor') } let(:distributor2) { create(:distributor_enterprise, name: 'Another Distributor') } + let(:enterprise_user) { create_enterprise_user } before(:each) do - @new_user = create_enterprise_user - @new_user.enterprise_roles.build(enterprise: supplier1).save - @new_user.enterprise_roles.build(enterprise: distributor1).save + enterprise_user.enterprise_roles.build(enterprise: supplier1).save + enterprise_user.enterprise_roles.build(enterprise: distributor1).save - login_to_admin_as @new_user + login_to_admin_as enterprise_user end scenario "can view enterprises I have permission to" do @@ -290,23 +290,42 @@ feature %q{ expect(page).to_not have_content "distributor2.name" end - scenario "creating an enterprise" do - # When I create an enterprise - click_link 'Enterprises' - click_link 'New Enterprise' - fill_in 'enterprise_name', with: 'zzz' - fill_in 'enterprise_address_attributes_address1', with: 'z' - fill_in 'enterprise_address_attributes_city', with: 'z' - fill_in 'enterprise_address_attributes_zipcode', with: 'z' - click_button 'Create' + context "creating an enterprise" do + before do + # When I create an enterprise + click_link 'Enterprises' + click_link 'New Enterprise' + fill_in 'enterprise_name', with: 'zzz' + fill_in 'enterprise_address_attributes_address1', with: 'z' + fill_in 'enterprise_address_attributes_city', with: 'z' + fill_in 'enterprise_address_attributes_zipcode', with: 'z' + end - # Then it should be created - page.should have_content 'Enterprise "zzz" has been successfully created!' - enterprise = Enterprise.last - enterprise.name.should == 'zzz' + scenario "without violating rules" do + click_button 'Create' - # And I should be managing it - Enterprise.managed_by(@new_user).should include enterprise + # Then it should be created + page.should have_content 'Enterprise "zzz" has been successfully created!' + enterprise = Enterprise.last + enterprise.name.should == 'zzz' + + # And I should be managing it + Enterprise.managed_by(enterprise_user).should include enterprise + end + + context "overstepping my owned enterprises limit" do + before do + create(:enterprise, owner: enterprise_user) + end + + it "shows me an error message" do + click_button 'Create' + + # Then it should show me an error + expect(page).to_not have_content 'Enterprise "zzz" has been successfully created!' + expect(page).to have_content "You are not permitted to own own any more enterprises (limit is 1)." + end + end end scenario "editing enterprises I have permission to" do diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index c6418def09..f6b3c13d2d 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe Enterprise do + include AuthenticationWorkflow describe "associations" do it { should belong_to(:owner) } @@ -54,9 +55,9 @@ describe Enterprise do end describe "ownership" do - let(:u1) { create(:user) } - let(:u2) { create(:user) } - let(:e) { create(:enterprise, owner: u1 ) } + let(:u1) { create_enterprise_user } + let(:u2) { create_enterprise_user } + let!(:e) { create(:enterprise, owner: u1 ) } it "adds new owner to list of managers" do expect(e.owner).to eq u1 @@ -68,6 +69,16 @@ describe Enterprise do expect(e.owner).to eq u2 expect(e.users).to include u1, u2 end + + it "validates ownership limit" do + expect(u1.enterprise_limit).to be 1 + expect(u1.owned_enterprises(:reload)).to eq [e] + e2 = create(:enterprise, owner: u2 ) + expect{ + e2.owner = u1 + e2.save! + }.to raise_error ActiveRecord::RecordInvalid, "Validation failed: You are not permitted to own own any more enterprises (limit is 1)." + end end end diff --git a/spec/models/spree/user_spec.rb b/spec/models/spree/user_spec.rb index e985d9bde8..f049c64b2f 100644 --- a/spec/models/spree/user_spec.rb +++ b/spec/models/spree/user_spec.rb @@ -3,23 +3,23 @@ describe Spree.user_class do it { should have_many(:owned_enterprises) } describe "enterprise ownership" do - let(:u1) { create(:user) } - let(:u2) { create(:user) } - let(:e1) { create(:enterprise, owner: u1) } - let(:e2) { create(:enterprise, owner: u1) } + let(:u1) { create(:user, enterprise_limit: 2) } + let(:u2) { create(:user, enterprise_limit: 1) } + let!(:e1) { create(:enterprise, owner: u1) } + let!(:e2) { create(:enterprise, owner: u1) } - it "provides access to owned enteprises" do - expect(u1.owned_enterprises).to include e1, e2 + it "provides access to owned enterprises" do + expect(u1.owned_enterprises(:reload)).to include e1, e2 end it "enforces the limit on the number of enterprise owned" do - expect(u2.owned_enterprises).to eq [] + expect(u2.owned_enterprises(:reload)).to eq [] u2.owned_enterprises << e1 - u2.owned_enterprises << e2 + expect(u2.save!).to_not raise_error expect { + u2.owned_enterprises << e2 u2.save! - }.to raise_error ActiveRecord::RecordInvalid, "Validation failed: The nominated user is not permitted to own own any more enterprises." - + }.to raise_error ActiveRecord::RecordInvalid, "Validation failed: The nominated user is not permitted to own own any more enterprises (limit is 1)." end end end diff --git a/spec/support/request/authentication_workflow.rb b/spec/support/request/authentication_workflow.rb index 49b1512cac..a2ee597f27 100644 --- a/spec/support/request/authentication_workflow.rb +++ b/spec/support/request/authentication_workflow.rb @@ -38,7 +38,7 @@ module AuthenticationWorkflow end def create_enterprise_user(enterprises = []) - new_user = create(:user, email: 'enterprise@hub.com', password: 'blahblah', :password_confirmation => 'blahblah', ) + new_user = create(:user, password: 'blahblah', :password_confirmation => 'blahblah') new_user.spree_roles = [] # for some reason unbeknown to me, this new user gets admin permissions by default. for enterprise in enterprises do new_user.enterprise_roles.build(enterprise: enterprise).save From 41b286f80f569dc92bee6442afeaafd7995f3021 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 10 Sep 2014 15:21:48 +1000 Subject: [PATCH 017/120] Delete specific E2ER in spec --- app/views/admin/enterprise_roles/index.html.haml | 2 +- spec/features/admin/enterprise_roles_spec.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/admin/enterprise_roles/index.html.haml b/app/views/admin/enterprise_roles/index.html.haml index 0881a8a50e..a6e0985a99 100644 --- a/app/views/admin/enterprise_roles/index.html.haml +++ b/app/views/admin/enterprise_roles/index.html.haml @@ -11,5 +11,5 @@ %table#enterprise-roles %tbody = render 'form' - %tr{"ng-repeat" => "enterprise_role in EnterpriseRoles.enterprise_roles | filter:query"} + %tr{"ng-repeat" => "enterprise_role in EnterpriseRoles.enterprise_roles | filter:query", id: "enterprise_role_{{enterprise_role.id}}"} = render 'enterprise_role' diff --git a/spec/features/admin/enterprise_roles_spec.rb b/spec/features/admin/enterprise_roles_spec.rb index 0e44c9cfe3..7256b4e03c 100644 --- a/spec/features/admin/enterprise_roles_spec.rb +++ b/spec/features/admin/enterprise_roles_spec.rb @@ -71,7 +71,9 @@ feature %q{ visit admin_enterprise_roles_path page.should have_relationship u, e - first("a.delete-enterprise-role").click + within("#enterprise_role_#{er.id}") do + find("a.delete-enterprise-role").click + end page.should_not have_relationship u, e EnterpriseRole.where(id: er.id).should be_empty From 60297eb5c816244373b4c218430245eb53029671 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 10 Sep 2014 15:49:19 +1000 Subject: [PATCH 018/120] Hide 'New Enterprise' link on index page when user has reached limit --- app/views/admin/enterprises/index.html.haml | 5 ++- spec/features/admin/enterprises_spec.rb | 50 ++++++++++++++------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/app/views/admin/enterprises/index.html.haml b/app/views/admin/enterprises/index.html.haml index d2ca8efb2f..44008b3bd2 100644 --- a/app/views/admin/enterprises/index.html.haml +++ b/app/views/admin/enterprises/index.html.haml @@ -2,8 +2,9 @@ Enterprises - content_for :page_actions do - %li#new_product_link - = button_link_to "New Enterprise", main_app.new_admin_enterprise_path, :icon => 'icon-plus', :id => 'admin_new_enterprise_link' + - if spree_current_user.can_own_more_enterprises? + %li#new_product_link + = button_link_to "New Enterprise", main_app.new_admin_enterprise_path, :icon => 'icon-plus', :id => 'admin_new_enterprise_link' = render 'admin/shared/enterprises_sub_menu' diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 249528149d..8d5f6bfee6 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -266,28 +266,44 @@ feature %q{ login_to_admin_as enterprise_user end - scenario "can view enterprises I have permission to" do - oc_user_coordinating = create(:simple_order_cycle, { coordinator: supplier1, name: 'Order Cycle 1' } ) - oc_for_other_user = create(:simple_order_cycle, { coordinator: supplier2, name: 'Order Cycle 2' } ) + context "listing enterprises" do + scenario "displays enterprises I have permission to manage" do + oc_user_coordinating = create(:simple_order_cycle, { coordinator: supplier1, name: 'Order Cycle 1' } ) + oc_for_other_user = create(:simple_order_cycle, { coordinator: supplier2, name: 'Order Cycle 2' } ) - click_link "Enterprises" + click_link "Enterprises" - within("tr.enterprise-#{distributor1.id}") do - expect(page).to have_content distributor1.name - expect(page).to have_checked_field "enterprise_set_collection_attributes_0_is_distributor" - expect(page).to have_unchecked_field "enterprise_set_collection_attributes_0_is_primary_producer" - expect(page).to have_select "enterprise_set_collection_attributes_0_type" + within("tr.enterprise-#{distributor1.id}") do + expect(page).to have_content distributor1.name + expect(page).to have_checked_field "enterprise_set_collection_attributes_0_is_distributor" + expect(page).to have_unchecked_field "enterprise_set_collection_attributes_0_is_primary_producer" + expect(page).to have_select "enterprise_set_collection_attributes_0_type" + end + + within("tr.enterprise-#{supplier1.id}") do + expect(page).to have_content supplier1.name + expect(page).to have_unchecked_field "enterprise_set_collection_attributes_1_is_distributor" + expect(page).to have_checked_field "enterprise_set_collection_attributes_1_is_primary_producer" + expect(page).to have_select "enterprise_set_collection_attributes_1_type" + end + + expect(page).to_not have_content "supplier2.name" + expect(page).to_not have_content "distributor2.name" + + expect(find("#content-header")).to have_link "New Enterprise" end - within("tr.enterprise-#{supplier1.id}") do - expect(page).to have_content supplier1.name - expect(page).to have_unchecked_field "enterprise_set_collection_attributes_1_is_distributor" - expect(page).to have_checked_field "enterprise_set_collection_attributes_1_is_primary_producer" - expect(page).to have_select "enterprise_set_collection_attributes_1_type" - end + context "when I have reached my enterprise ownership limit" do + it "does not display the link to create a new enterprise" do + enterprise_user.owned_enterprises.push [supplier1] - expect(page).to_not have_content "supplier2.name" - expect(page).to_not have_content "distributor2.name" + click_link "Enterprises" + + page.should have_content supplier1.name + page.should have_content distributor1.name + expect(find("#content-header")).to_not have_link "New Enterprise" + end + end end context "creating an enterprise" do From eb6af408d76a97ac874fcdd42646ef93d882e51d Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 10 Sep 2014 15:53:48 +1000 Subject: [PATCH 019/120] Trailing spaces crusader: one man, a million trailing spaces --- spec/features/admin/overview_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/features/admin/overview_spec.rb b/spec/features/admin/overview_spec.rb index 534f784ee0..184d68c80b 100644 --- a/spec/features/admin/overview_spec.rb +++ b/spec/features/admin/overview_spec.rb @@ -16,7 +16,7 @@ feature %q{ Spree::Admin::OverviewController.any_instance.stub(:spree_current_user).and_return @enterprise_user quick_login_as @enterprise_user end - + context "with no enterprises" do it "prompts the user to create a new enteprise" do visit '/admin' @@ -42,9 +42,8 @@ feature %q{ page.should have_selector ".dashboard_item#order_cycles" page.should have_selector ".dashboard_item#enterprises .list-item", text: d1.name page.should have_selector ".dashboard_item#enterprises .button.bottom", text: "MANAGE MY ENTERPRISES" - end - + context "but no products or order cycles" do it "prompts the user to create a new product and to manage order cycles" do visit '/admin' From 8cc5c2246ab691a465c2051b72b578f6c4a8f593 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 10 Sep 2014 15:54:17 +1000 Subject: [PATCH 020/120] Hide 'Create New' enterprise link on dashboard when user has reached limit --- app/views/spree/admin/overview/_enterprises_header.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/spree/admin/overview/_enterprises_header.html.haml b/app/views/spree/admin/overview/_enterprises_header.html.haml index d53828ca65..fcc7d269f2 100644 --- a/app/views/spree/admin/overview/_enterprises_header.html.haml +++ b/app/views/spree/admin/overview/_enterprises_header.html.haml @@ -1,7 +1,8 @@ %div.header.sixteen.columns.alpha{ :class => "#{@enterprises.count > 0 ? "" : "red"}"} %h3.thirteen.columns.alpha My Enterprises - if @enterprises.any? - %a.three.columns.omega.icon-plus.button.blue.white-bottom{ href: "#{main_app.new_admin_enterprise_path}" } - CREATE NEW + - if spree_current_user.can_own_more_enterprises? + %a.three.columns.omega.icon-plus.button.blue.white-bottom{ href: "#{main_app.new_admin_enterprise_path}" } + CREATE NEW - else %a.with-tip{ title: "Enterprises are Producers and/or Hubs and are the basic unit of organisation within the Open Food Network." } What's this? From 9085741f3c75b3ab806b25b3afcea68daee6a05b Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 11 Sep 2014 11:40:22 +1000 Subject: [PATCH 021/120] Removing enterprises form from user edit page --- .../users_add_enterprise_management.rb | 6 ----- .../admin/users/_enterprises_form.html.haml | 13 ---------- spec/features/admin/enterprise_user_spec.rb | 24 ------------------- 3 files changed, 43 deletions(-) delete mode 100644 app/overrides/users_add_enterprise_management.rb delete mode 100644 app/views/spree/admin/users/_enterprises_form.html.haml diff --git a/app/overrides/users_add_enterprise_management.rb b/app/overrides/users_add_enterprise_management.rb deleted file mode 100644 index 4ca1dd9e49..0000000000 --- a/app/overrides/users_add_enterprise_management.rb +++ /dev/null @@ -1,6 +0,0 @@ -Deface::Override.new(:virtual_path => "spree/admin/users/_form", - :insert_after => "[data-hook='admin_user_form_fields']", - :partial => "spree/admin/users/enterprises_form", - :name => "add_enterprises_to_user" - ) - diff --git a/app/views/spree/admin/users/_enterprises_form.html.haml b/app/views/spree/admin/users/_enterprises_form.html.haml deleted file mode 100644 index 03cecd41d5..0000000000 --- a/app/views/spree/admin/users/_enterprises_form.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -%fieldset - %legend 'Manage Enterprises' - = f.field_container :enterprise_roles do - - f.object.build_enterprise_roles - %table - = f.fields_for :enterprise_roles do |enterprise_form| - %tr - %td - = hidden_field_tag "#{enterprise_form.object_name}[_destroy]", 1, :id => nil - = check_box_tag "#{enterprise_form.object_name}[_destroy]", 0, !enterprise_form.object.new_record? - %td - = label_tag "#{enterprise_form.object_name}[_destroy]", enterprise_form.object.enterprise.name - = enterprise_form.hidden_field :enterprise_id diff --git a/spec/features/admin/enterprise_user_spec.rb b/spec/features/admin/enterprise_user_spec.rb index ed46a1e0c1..3431e92d36 100644 --- a/spec/features/admin/enterprise_user_spec.rb +++ b/spec/features/admin/enterprise_user_spec.rb @@ -31,30 +31,6 @@ feature %q{ user.enterprises.first.name.should == supplier2.name end end - - context "with existing enterprises managed" do - before do - user.enterprise_roles.create!(enterprise: supplier1) - user.enterprise_roles.create!(enterprise: distributor1) - end - - it "can remove and add enterprise management for a user" do - login_to_admin_section - - click_link 'Users' - click_link user.email - click_link 'Edit' - - uncheck distributor1.name # remove - check distributor2.name # add - - click_button 'Update' - - user.enterprises.count.should == 2 - user.enterprises.should include supplier1 - user.enterprises.should include distributor2 - end - end end describe "product management" do From a3f7fc1202dd9882aef1b22c23fc8b729ee4f6e3 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 11 Sep 2014 11:42:00 +1000 Subject: [PATCH 022/120] Adding column for enterprise limit on users index page --- .../index/add_enterprise_limit_column.html.haml.deface | 3 +++ .../add_enterprise_limit_column_header.html.haml.deface | 3 +++ .../users/index/reconfigure_column_spacing.html.haml.deface | 6 ++++++ 3 files changed, 12 insertions(+) create mode 100644 app/overrides/spree/admin/users/index/add_enterprise_limit_column.html.haml.deface create mode 100644 app/overrides/spree/admin/users/index/add_enterprise_limit_column_header.html.haml.deface create mode 100644 app/overrides/spree/admin/users/index/reconfigure_column_spacing.html.haml.deface diff --git a/app/overrides/spree/admin/users/index/add_enterprise_limit_column.html.haml.deface b/app/overrides/spree/admin/users/index/add_enterprise_limit_column.html.haml.deface new file mode 100644 index 0000000000..d16e186be8 --- /dev/null +++ b/app/overrides/spree/admin/users/index/add_enterprise_limit_column.html.haml.deface @@ -0,0 +1,3 @@ +/ insert_before "td[data-hook='admin_users_index_row_actions']" + +%td.user_enterprise_limit= user.enterprise_limit \ No newline at end of file diff --git a/app/overrides/spree/admin/users/index/add_enterprise_limit_column_header.html.haml.deface b/app/overrides/spree/admin/users/index/add_enterprise_limit_column_header.html.haml.deface new file mode 100644 index 0000000000..f2222ef012 --- /dev/null +++ b/app/overrides/spree/admin/users/index/add_enterprise_limit_column_header.html.haml.deface @@ -0,0 +1,3 @@ +/ insert_before "th[data-hook='admin_users_index_header_actions']" + +%th= sort_link @search,:enterprise_limit, t(:enterprise_limit) \ No newline at end of file diff --git a/app/overrides/spree/admin/users/index/reconfigure_column_spacing.html.haml.deface b/app/overrides/spree/admin/users/index/reconfigure_column_spacing.html.haml.deface new file mode 100644 index 0000000000..d666e1b7c5 --- /dev/null +++ b/app/overrides/spree/admin/users/index/reconfigure_column_spacing.html.haml.deface @@ -0,0 +1,6 @@ +/ replace "table#listing_users colgroup" + +%colgroup + %col{ style: "width: 65%" } + %col{ style: "width: 20%" } + %col{ style: "width: 15%" } \ No newline at end of file From 7780046d71aad5c1e71fbe61695794b2e1424c6e Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 11 Sep 2014 11:43:04 +1000 Subject: [PATCH 023/120] Clicking on user email takes me to the edit page rather than the annoying 'show' intermediary --- .../index/replace_show_link_with_edit_link.html.haml.deface | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 app/overrides/spree/admin/users/index/replace_show_link_with_edit_link.html.haml.deface diff --git a/app/overrides/spree/admin/users/index/replace_show_link_with_edit_link.html.haml.deface b/app/overrides/spree/admin/users/index/replace_show_link_with_edit_link.html.haml.deface new file mode 100644 index 0000000000..330e06ea9d --- /dev/null +++ b/app/overrides/spree/admin/users/index/replace_show_link_with_edit_link.html.haml.deface @@ -0,0 +1,3 @@ +/ replace "code[erb-loud]:contains('link_to user.email, object_url(user)')" + += link_to user.email, edit_object_url(user) \ No newline at end of file From c0e4a22a6ee5ba1c85c23b926b3e92c80ba47f54 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 11 Sep 2014 13:21:52 +1000 Subject: [PATCH 024/120] Adding enterprise_limit form element to user edit page --- app/models/spree/user_decorator.rb | 2 +- ...enterprise_limit_form_element.html.haml.deface | 5 +++++ spec/features/admin/enterprise_user_spec.rb | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 app/overrides/spree/admin/users/_form/add_enterprise_limit_form_element.html.haml.deface diff --git a/app/models/spree/user_decorator.rb b/app/models/spree/user_decorator.rb index 2a177f84a0..06a413b469 100644 --- a/app/models/spree/user_decorator.rb +++ b/app/models/spree/user_decorator.rb @@ -6,7 +6,7 @@ Spree.user_class.class_eval do accepts_nested_attributes_for :enterprise_roles, :allow_destroy => true - attr_accessible :enterprise_ids, :enterprise_roles_attributes + attr_accessible :enterprise_ids, :enterprise_roles_attributes, :enterprise_limit after_create :send_signup_confirmation validate :limit_owned_enterprises diff --git a/app/overrides/spree/admin/users/_form/add_enterprise_limit_form_element.html.haml.deface b/app/overrides/spree/admin/users/_form/add_enterprise_limit_form_element.html.haml.deface new file mode 100644 index 0000000000..0b00900b5c --- /dev/null +++ b/app/overrides/spree/admin/users/_form/add_enterprise_limit_form_element.html.haml.deface @@ -0,0 +1,5 @@ +/ insert_bottom "div[data-hook='admin_user_form_fields'] div.alpha" + += f.field_container :enterprise_limit do + = f.label :enterprise_limit, t(:enterprise_limit) + = f.text_field :enterprise_limit, :class => 'fullwidth' \ No newline at end of file diff --git a/spec/features/admin/enterprise_user_spec.rb b/spec/features/admin/enterprise_user_spec.rb index 3431e92d36..d4ea642a93 100644 --- a/spec/features/admin/enterprise_user_spec.rb +++ b/spec/features/admin/enterprise_user_spec.rb @@ -31,6 +31,21 @@ feature %q{ user.enterprises.first.name.should == supplier2.name end end + + context "with a limitted number of owned enterprises" do + scenario "setting the enterprise ownership limit" do + user.enterprise_limit.should == 1 + login_to_admin_section + click_link 'Users' + click_link user.email + + fill_in "user_enterprise_limit", with: 2 + + click_button 'Update' + user.reload + expect(user.enterprise_limit).to eq 2 + end + end end describe "product management" do From ad56594fe9ca57b4f6b92b3de4aa9a4f4d6736e3 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 11 Sep 2014 13:23:14 +1000 Subject: [PATCH 025/120] Removing obsolete spec --- spec/features/admin/enterprise_user_spec.rb | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/spec/features/admin/enterprise_user_spec.rb b/spec/features/admin/enterprise_user_spec.rb index d4ea642a93..77378f6cbd 100644 --- a/spec/features/admin/enterprise_user_spec.rb +++ b/spec/features/admin/enterprise_user_spec.rb @@ -17,21 +17,6 @@ feature %q{ let(:distributor_profile) { create(:distributor_enterprise, name: 'Distributor profile', type: 'profile') } describe "creating an enterprise user" do - context "with no enterprises managed" do - it "assigns an enterprise to a user" do - login_to_admin_section - click_link 'Users' - click_link user.email - click_link 'Edit' - - check supplier2.name - - click_button 'Update' - user.enterprises.count.should == 1 - user.enterprises.first.name.should == supplier2.name - end - end - context "with a limitted number of owned enterprises" do scenario "setting the enterprise ownership limit" do user.enterprise_limit.should == 1 From 16ad465571157a2857c69451b5c7978966b010c3 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 15:40:12 +1000 Subject: [PATCH 026/120] tweak placeholder name --- app/views/home/_hubs.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/_hubs.html.haml b/app/views/home/_hubs.html.haml index e93e312fb7..ede6750b83 100644 --- a/app/views/home/_hubs.html.haml +++ b/app/views/home/_hubs.html.haml @@ -14,7 +14,7 @@ / %i.ofn-i_020-search %input{type: :text, "ng-model" => "query", - placeholder: "Search by Shop or Suburb...", + placeholder: "Search by Name or Suburb...", "ng-debounce" => "150", "ofn-disable-enter" => true} From 71918539b812c78655d8c27ea6b815b461145067 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 15:40:35 +1000 Subject: [PATCH 027/120] Undo changing name Hubs to Shops, for the moment --- app/views/shared/menu/_mobile_menu.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shared/menu/_mobile_menu.html.haml b/app/views/shared/menu/_mobile_menu.html.haml index b5045c7ed9..6cc81cab9d 100644 --- a/app/views/shared/menu/_mobile_menu.html.haml +++ b/app/views/shared/menu/_mobile_menu.html.haml @@ -17,13 +17,13 @@ %a{"ofn-scroll-to" => "hubs"} %span.nav-primary %i.ofn-i_040-hub - Shops + Hubs - else %li.li-menu %a{href: root_path + "#/#hubs"} %span.nav-primary %i.ofn-i_040-hub - Shops + Hubs %li.li-menu %a{href: main_app.map_path} %span.nav-primary From 7d0cf2ace9442138c068a38c69cefe4ebc6f1676 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 15:41:01 +1000 Subject: [PATCH 028/120] Adding rounded corners to producers nodes for active table --- .../stylesheets/darkswarm/producer_node.css.sass | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/producer_node.css.sass b/app/assets/stylesheets/darkswarm/producer_node.css.sass index 25759d30e5..08c9fd87ef 100644 --- a/app/assets/stylesheets/darkswarm/producer_node.css.sass +++ b/app/assets/stylesheets/darkswarm/producer_node.css.sass @@ -1,4 +1,5 @@ @import branding +@import mixins .producers .active_table .active_table_node @@ -7,6 +8,7 @@ @media all and (max-width: 640px) .skinny-head background-color: $clr-turquoise-light + @include border-radius-mixed(0.5em, 0.5em, 0, 0) margin-top: -1rem margin-bottom: 1rem padding-top: 1rem @@ -14,6 +16,7 @@ .follow-icons &, & * font-size: 1.5rem + // Producer icons i.ofn-i_059-producer, i.ofn-i_060-producer-reversed @@ -75,9 +78,12 @@ //Closed row &.closed - &:hover, &:active, &:focus - .active_table_row.closed - border: 1px solid $clr-turquoise + .active_table_row.closed + border: 1px solid transparent + @media all and (max-width: 640px) + border-color: $clr-turquoise-light + &:hover, &:active, &:focus + border-color: $clr-turquoise From de7837aea986f154ef8cb8f21554940aa8188712 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 15:41:28 +1000 Subject: [PATCH 029/120] New greys and translucent colors for global use --- app/assets/stylesheets/darkswarm/branding.css.sass | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/darkswarm/branding.css.sass b/app/assets/stylesheets/darkswarm/branding.css.sass index fabb82130f..9fa27dcc96 100644 --- a/app/assets/stylesheets/darkswarm/branding.css.sass +++ b/app/assets/stylesheets/darkswarm/branding.css.sass @@ -1,5 +1,6 @@ $clr-brick: #c1122b $clr-brick-light: #f5e6e7 +$clr-brick-light-trans: rgba(245, 230, 231, 0.9) $clr-brick-ultra-light: #faf5f6 $clr-brick-bright: #eb4c46 $clr-brick-med-bright: #e5a2a0 @@ -10,6 +11,8 @@ $clr-turquoise-light: #ceefe4 $clr-turquoise-ultra-light: #e8f9f4 $clr-turquoise-bright: #23a877 -$disabled-dark: #999 +$disabled-light: #e5e5e5 $disabled-bright: #ccc +$disabled-dark: #999 +$med-grey: #666 $dark-grey: #333 \ No newline at end of file From af064a3fc790fde9fd47ddc4d3f264bf7c990326 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 15:42:08 +1000 Subject: [PATCH 030/120] Adding more spacing for fat view on small devices - vertical spacing for each chunk --- app/assets/stylesheets/darkswarm/active_table.css.sass | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/assets/stylesheets/darkswarm/active_table.css.sass b/app/assets/stylesheets/darkswarm/active_table.css.sass index 36df754b66..27b98850b7 100644 --- a/app/assets/stylesheets/darkswarm/active_table.css.sass +++ b/app/assets/stylesheets/darkswarm/active_table.css.sass @@ -81,6 +81,8 @@ //Open row sections .fat > div border-top: 1px solid #aaa + @media all and (max-width: 640px) + margin-top: 1em ul, ol font-size: 0.875rem From 1eef483c445ae379d9ac1875b9fa843210dc844b Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 15:42:37 +1000 Subject: [PATCH 031/120] Hub node styling for different use cases of active / inactive / current / open / closed --- .../stylesheets/darkswarm/hub_node.css.sass | 124 ++++++++++-------- 1 file changed, 72 insertions(+), 52 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/hub_node.css.sass b/app/assets/stylesheets/darkswarm/hub_node.css.sass index c4ae2d0082..7da56435ed 100644 --- a/app/assets/stylesheets/darkswarm/hub_node.css.sass +++ b/app/assets/stylesheets/darkswarm/hub_node.css.sass @@ -11,8 +11,10 @@ overflow-y: visible //Generic text link style - a:hover, a:active, a:focus - color: $clr-brick-bright + a, a * + color: $clr-brick + &:hover, &:active, &:focus + color: $clr-brick-bright //Hub and Producer icons i.ofn-i_063-hub, i.ofn-i_064-hub-reversed, i.ofn-i_059-producer, i.ofn-i_060-producer-reversed @@ -33,72 +35,90 @@ float: left font-weight: 700 - @media all and (max-width: 640px) - &.closed, &.open + //CLOSED row + &.closed + .active_table_row + border: 1px solid transparent + @media all and (max-width: 640px) + border-color: $clr-brick-light + &:hover, &:active, &:focus + border-color: $clr-brick-light-bright + + //OPEN row + &.open + .active_table_row, .active_table_row:first-child, .active_table_row:last-child + border-color: $clr-brick-light-bright + + &.open, &.closed + @media all and (max-width: 640px) .active_table_row:first-child .skinny-head background-color: $clr-brick-light + @include border-radius-mixed(0.5em, 0.5em, 0, 0) margin-top: -1rem margin-bottom: 1rem padding-top: 1rem padding-bottom: 1rem - &.inactive - &.closed, &.open - .active_table_row:first-child .skinny-head - background-color: white - &.current - &.closed, &.open - .active_table_row:first-child .skinny-head - background-color: $clr-brick-bright - &.current - &.inactive - &.closed, &.open - .active_table_row:first-child .skinny-head - background-color: #555 - - //Inactive row - &.inactive, &.inactive strong - color: $disabled-dark - &, & * - color: $disabled-dark - - a i.ofn-i_040-hub - color: $disabled-dark - &.current - &.inactive - &.closed, &.open - .active_table_row:first-child - background-color: $disabled-dark - &, & * - color: white - &.closed - &:hover, &:active, &:focus - border: none - color: $disabled-dark + label + margin-top: 1rem //Padding second row &.open .active_table_row:nth-child(2) padding-bottom: 0.75rem - - //Current selected row + + //CURRENT hub (shows selected hub) &.current //overwrites active_table &.closed, &.open + a, a * + color: $clr-brick + .active_table_row + border-color: $clr-brick .active_table_row:first-child, .active_table_row:last-child - background-color: rgba(245, 230, 231, 0.95) + background-color: $clr-brick-light-trans opacity: 1 &:hover, &:focus, &:active opacity: 0.9 - &.closed - a, a * - color: $clr-brick - &:hover, &:active, &:focus - color: $clr-brick-bright - &.open, &.closed - .active_table_row - border-color: $clr-brick - &.inactive - &.open, &.closed - .active_table_row - border-color: $disabled-dark + border-color: $clr-brick-bright + @media all and (max-width: 640px) + .active_table_row:first-child .skinny-head + background-color: rgba(255,255,255,0.85) + + //INACTIVE - closed hub + &.inactive + &.closed, &.open + &, & * + color: $disabled-dark + &.closed + .active_table_row, .active_table_row:first-child, .active_table_row:last-child + &:hover, &:active, &:focus + border-color: $disabled-bright + &.open + .active_table_row, .active_table_row:first-child, .active_table_row:last-child + border-color: $disabled-bright + // & Current hub + &.closed, &.open + &.current + .active_table_row, .active_table_row:first-child, .active_table_row:last-child + a, a * + color: $med-grey + border-color: $disabled-dark + background-color: rgba(220,220,220,0.5) + &:hover, &:focus, &:active + border-color: $disabled-dark + // Small devices + @media all and (max-width: 640px) + + .active_table_row:first-child .skinny-head + background-color: $disabled-bright + + // Small devices + @media all and (max-width: 640px) + .active_table_row, .active_table_row:first-child, .active_table_row:last-child + border-color: $disabled-bright + background-color: transparent + &:hover, &:focus, &:active + border-color: $disabled-dark + .active_table_row:first-child .skinny-head + background-color: $disabled-light From 24507c6c0aff54a1486094e47bbb8f7a59d947b1 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 16:29:38 +1000 Subject: [PATCH 032/120] turn off Profile filter again until ready to support this --- app/views/shared/components/_filter_controls.html.haml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/shared/components/_filter_controls.html.haml b/app/views/shared/components/_filter_controls.html.haml index d35727c087..4548085550 100644 --- a/app/views/shared/components/_filter_controls.html.haml +++ b/app/views/shared/components/_filter_controls.html.haml @@ -11,9 +11,9 @@ .small-12.medium-6.columns.text-right .profile-checkbox - / Hide until we're ready to work on this: + / Hide until we're ready to work on this: - / %input{type: "checkbox", name: "profile"}>< - / %label Show profiles - / %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but they may have their own physical or online shop elsewhere", "popover-placement" => "left"}>< - / %i.ofn-i_013-help + / %input{type: "checkbox", name: "profile"}>< + / %label Show profiles + / %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but they may have their own physical or online shop elsewhere", "popover-placement" => "left"}>< + / %i.ofn-i_013-help From 595aa760cb11c6372d762b39c78e984454143f51 Mon Sep 17 00:00:00 2001 From: Rob H Date: Tue, 19 Aug 2014 13:14:16 +1000 Subject: [PATCH 033/120] Loads registration page with authentication --- .../registration_controller.js.coffee | 5 +++ app/controllers/registration_controller.rb | 6 ++++ app/views/layouts/registration.html.haml | 36 +++++++++++++++++++ app/views/registration/index.html.haml | 2 ++ config/routes.rb | 2 ++ 5 files changed, 51 insertions(+) create mode 100644 app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee create mode 100644 app/controllers/registration_controller.rb create mode 100644 app/views/layouts/registration.html.haml create mode 100644 app/views/registration/index.html.haml diff --git a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee new file mode 100644 index 0000000000..1e26f157d1 --- /dev/null +++ b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee @@ -0,0 +1,5 @@ +Darkswarm.controller "RegistrationCtrl", ($scope, $location, AuthenticationService, CurrentUser)-> + if CurrentUser is undefined + $location.search('after_login', '/register/') + AuthenticationService.open() + diff --git a/app/controllers/registration_controller.rb b/app/controllers/registration_controller.rb new file mode 100644 index 0000000000..4aa170645f --- /dev/null +++ b/app/controllers/registration_controller.rb @@ -0,0 +1,6 @@ +class RegistrationController < BaseController + layout 'registration' + + def index + end +end diff --git a/app/views/layouts/registration.html.haml b/app/views/layouts/registration.html.haml new file mode 100644 index 0000000000..ff81ba8871 --- /dev/null +++ b/app/views/layouts/registration.html.haml @@ -0,0 +1,36 @@ +%html + %head + %meta{charset: 'utf-8'}/ + %meta{name: 'viewport', content: "width=device-width,initial-scale=1.0"}/ + + %title= content_for?(:title) ? yield(:title) : 'Welcome to Open Food Network' + - if Rails.env.production? + = favicon_link_tag + - else + = favicon_link_tag "/favicon-staging.ico" + %link{href: "https://fonts.googleapis.com/css?family=Open+Sans:400,700", rel: "stylesheet", type: "text/css"}/ + + = yield :scripts + %script{src: "//maps.googleapis.com/maps/api/js?libraries=places&sensor=false"} + = stylesheet_link_tag "darkswarm/all" + = javascript_include_tag "darkswarm/all" + + + = render "layouts/bugherd_script" + = csrf_meta_tags + + %body.off-canvas{"ng-app" => "Darkswarm"} + / [if lte IE 8] + = render partial: "shared/ie_warning" + = javascript_include_tag "iehack" + + = inject_json "user", "current_user" + + .off-canvas-wrap{offcanvas: true} + .inner-wrap + + %section{ role: "main" } + = yield + + #footer + %loading diff --git a/app/views/registration/index.html.haml b/app/views/registration/index.html.haml new file mode 100644 index 0000000000..7221f2e9fe --- /dev/null +++ b/app/views/registration/index.html.haml @@ -0,0 +1,2 @@ +%div{"ng-controller" => "RegistrationCtrl"} +%div{"ng-controller" => "AuthenticationCtrl"} \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 5230e798cc..f503fba839 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,8 @@ Openfoodnetwork::Application.routes.draw do get "/map", to: "map#index", as: :map + get "/register", to: "registration#index", as: :registration + resource :shop, controller: "shop" do get :products post :order_cycle From c92aa41e28833034de42e3cfbd4f101cbdc8abba Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 20 Aug 2014 10:33:32 +1000 Subject: [PATCH 034/120] Adding introduction and details pages to registration process --- .../registration_controller.js.coffee | 13 ++++--- .../services/registration_service.js.coffee | 26 ++++++++++++++ .../templates/registration.html.haml | 8 +++++ .../templates/registration/details.html.haml | 34 +++++++++++++++++++ .../registration/introduction.html.haml | 32 +++++++++++++++++ .../templates/registration/steps.html.haml | 6 ++++ app/controllers/registration_controller.rb | 3 ++ app/views/layouts/registration.html.haml | 2 +- app/views/registration/authenticate.html.haml | 1 + app/views/registration/index.html.haml | 3 +- config/routes.rb | 1 + .../registration_controller_spec.rb | 8 +++++ spec/features/consumer/registration_spec.rb | 33 ++++++++++++++++++ 13 files changed, 163 insertions(+), 7 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/services/registration_service.js.coffee create mode 100644 app/assets/javascripts/templates/registration.html.haml create mode 100644 app/assets/javascripts/templates/registration/details.html.haml create mode 100644 app/assets/javascripts/templates/registration/introduction.html.haml create mode 100644 app/assets/javascripts/templates/registration/steps.html.haml create mode 100644 app/views/registration/authenticate.html.haml create mode 100644 spec/controllers/registration_controller_spec.rb create mode 100644 spec/features/consumer/registration_spec.rb diff --git a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee index 1e26f157d1..33e4d03af4 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee @@ -1,5 +1,10 @@ -Darkswarm.controller "RegistrationCtrl", ($scope, $location, AuthenticationService, CurrentUser)-> - if CurrentUser is undefined - $location.search('after_login', '/register/') - AuthenticationService.open() +Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, CurrentUser) -> + $scope.current_user = CurrentUser + + $scope.currentStep = RegistrationService.currentStep + $scope.select = RegistrationService.select + $scope.steps = ['details'] + # ,'address','contact','about','images','social' + + $scope.enterprise = {} \ No newline at end of file diff --git a/app/assets/javascripts/darkswarm/services/registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/registration_service.js.coffee new file mode 100644 index 0000000000..0d7bfd2e73 --- /dev/null +++ b/app/assets/javascripts/darkswarm/services/registration_service.js.coffee @@ -0,0 +1,26 @@ +Darkswarm.factory "RegistrationService", (Navigation, $modal, $location)-> + + new class RegistrationService + current_step: 'introduction' + + constructor: -> + @open() + + open: => + @modalInstance = $modal.open + templateUrl: 'registration.html' + windowClass: "login-modal medium" + @modalInstance.result.then @close, @close + @select @current_step + + select: (step)=> + @current_step = step + Navigation.navigate '/' + @current_step + + active: Navigation.active + + currentStep: => + @current_step + + close: -> + Navigation.navigate "/" \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration.html.haml b/app/assets/javascripts/templates/registration.html.haml new file mode 100644 index 0000000000..f6dcea10fd --- /dev/null +++ b/app/assets/javascripts/templates/registration.html.haml @@ -0,0 +1,8 @@ +%div.registration-modal{"ng-controller" => "RegistrationCtrl"} + %div{ ng: { show: "currentStep() == 'introduction'" } } + %ng-include{ src: "'registration/introduction.html'" } + %div{ ng: { repeat: 'step in steps', show: "currentStep() == step" } } + %ng-include{ src: "'registration/'+ step + '.html'" } + +%a.close-reveal-modal{"ng-click" => "$close()"} + %i.ofn-i_009-close diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml new file mode 100644 index 0000000000..17020259c1 --- /dev/null +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -0,0 +1,34 @@ +%div + .row + %h2 Let's Get Started + .row + %h5 Woot! First we need to know what sort of enterprise you are: + %ng-include{ src: "'registration/steps.html'" } + .row + .small-12.columns{ style: 'background-color: #fff;'} + .row + %label{ for: 'enterprise_name'} Enterprise Name: + .row + %input.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm" } + .row + Choose One: + .row{ 'data-equalizer' => true } + %a#producer.small-4.columns{ 'data-equalizer-watch' => true, style: 'background-color: #efefef;', href: "#", ng: { click: "enterprise.type = 'producer'" } } + %div.small-1.columns + %div.small-11.columns + %h6 I'm A Producer + %span Producers are anyone making things to eat & drink - whether you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. + %a#hub.small-4.columns{ 'data-equalizer-watch' => true, style: 'background-color: #efefef;', href: "#", ng: { click: "enterprise.type = 'hub'" } } + %div.small-1.columns + %div.small-11.columns + %h6 I'm A Hub + %span Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, etc... + %a#both.small-4.columns{ 'data-equalizer-watch' => true, style: 'background-color: #efefef;', href: "#", ng: { click: "enterprise.type = 'both'" } } + %div.small-1.columns + %div.small-11.columns + %h6 I'm Both + %span Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! + .row + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" } } + + \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/introduction.html.haml b/app/assets/javascripts/templates/registration/introduction.html.haml new file mode 100644 index 0000000000..bca22b7567 --- /dev/null +++ b/app/assets/javascripts/templates/registration/introduction.html.haml @@ -0,0 +1,32 @@ +%div + .row + %h2 Hi there! + .row + %h5 This wizard will step you through creating a Profile on the Open Food Network. + .row + .small-2.columns   + .small-10.columns{ style: 'line-height: 150%;'} Your profile gives you an online presence on the Open Food Network, allowing you to easily connect with potential customers or partners. You can always choose to update your info later, as well as choose to upgrade your Profile to and Online Store, where you can sell products, track orders and receive payments. + %br + .row + .small-12.columns{ 'data-equalizer' => true } + .small-6.columns{ style: 'font-size: 80%' } + %span Creating a profile usually takes about 5-10 minutes. + %h6 You'll need the following: + %ol{ style: 'font-size: 100%' } + %li Your enterprise address and contact details + %li Your logo image + %li A pretty image to serve as your profile header + %li Some 'About Us' text + .small-6.columns{ style: 'background-color: #FFFFFF;'} + %h6 Your profile entitles you to: + A searchable listing in Hub / Producer view + %br + A pin on the OFN map to help users find you + .row + .large-12.columns + .row + Ready to go? + %br + .row + %input.button.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" } } + \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/steps.html.haml b/app/assets/javascripts/templates/registration/steps.html.haml new file mode 100644 index 0000000000..c54d0b947b --- /dev/null +++ b/app/assets/javascripts/templates/registration/steps.html.haml @@ -0,0 +1,6 @@ +.row + .small-2.columns{ ng: { repeat: 'step in steps', class: "{active: currentStep == step}" } } + %div{ style: 'text-transform: uppercase; text-align: center;background-color: #000; color: #fff;'} + {{ step }} + + \ No newline at end of file diff --git a/app/controllers/registration_controller.rb b/app/controllers/registration_controller.rb index 4aa170645f..c1d79db49c 100644 --- a/app/controllers/registration_controller.rb +++ b/app/controllers/registration_controller.rb @@ -2,5 +2,8 @@ class RegistrationController < BaseController layout 'registration' def index + if spree_current_user.nil? + redirect_to registration_auth_path(anchor: "login?after_login=/register") + end end end diff --git a/app/views/layouts/registration.html.haml b/app/views/layouts/registration.html.haml index ff81ba8871..8946a27de1 100644 --- a/app/views/layouts/registration.html.haml +++ b/app/views/layouts/registration.html.haml @@ -19,7 +19,7 @@ = render "layouts/bugherd_script" = csrf_meta_tags - %body.off-canvas{"ng-app" => "Darkswarm"} + %body.off-canvas{"ng-app" => "Darkswarm", style: 'background-image: url("/assets/home/ofn_bg_1.jpg")' } / [if lte IE 8] = render partial: "shared/ie_warning" = javascript_include_tag "iehack" diff --git a/app/views/registration/authenticate.html.haml b/app/views/registration/authenticate.html.haml new file mode 100644 index 0000000000..2b65757a5d --- /dev/null +++ b/app/views/registration/authenticate.html.haml @@ -0,0 +1 @@ +%div{"ng-controller" => "AuthenticationCtrl"} \ No newline at end of file diff --git a/app/views/registration/index.html.haml b/app/views/registration/index.html.haml index 7221f2e9fe..a1e8da858d 100644 --- a/app/views/registration/index.html.haml +++ b/app/views/registration/index.html.haml @@ -1,2 +1 @@ -%div{"ng-controller" => "RegistrationCtrl"} -%div{"ng-controller" => "AuthenticationCtrl"} \ No newline at end of file +%div{ "ng-controller" => "RegistrationCtrl" } \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f503fba839..6447715926 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,7 @@ Openfoodnetwork::Application.routes.draw do get "/map", to: "map#index", as: :map get "/register", to: "registration#index", as: :registration + get "/register/auth", to: "registration#authenticate", as: :registration_auth resource :shop, controller: "shop" do get :products diff --git a/spec/controllers/registration_controller_spec.rb b/spec/controllers/registration_controller_spec.rb new file mode 100644 index 0000000000..458a5fc33d --- /dev/null +++ b/spec/controllers/registration_controller_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +describe RegistrationController do + it "redirects to authentication page when user not logged in" do + get :index + response.should redirect_to registration_auth_path(anchor: "login?after_login=/register") + end +end diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb new file mode 100644 index 0000000000..c0bdba9810 --- /dev/null +++ b/spec/features/consumer/registration_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +feature "Registration", js: true do + describe "Registering a Profile" do + let(:user) { create(:user, password: "password", password_confirmation: "password") } + + it "Allows a logged in user to register a profile" do + visit registration_path + + expect(URI.parse(current_url).path).to eq registration_auth_path + + # Logging in + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_button 'Log in' + + # Log in was successful, introduction shown + expect(page).to have_content "This wizard will step you through creating a Profile on the Open Food Network." + expect(URI.parse(current_url).path).to eq registration_path + + # Done reading introduction + click_button "Let's get started!" + + # Filling in details + expect(page).to have_content "Woot! First we need to know what sort of enterprise you are:" + + fill_in 'enterprise_name', with: "My Awesome Enterprise" + click_link "both" + click_button "Continue" + end + end +end + \ No newline at end of file From 5f09f1b4f7675163a58f64a29ce415b92e2f54d5 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 20 Aug 2014 11:55:46 +1000 Subject: [PATCH 035/120] Pull out styling for registration process --- .../services/registration_service.js.coffee | 2 +- .../templates/registration/details.html.haml | 46 ++++++++++--------- .../templates/registration/steps.html.haml | 7 ++- .../darkswarm/registration.css.sass | 38 +++++++++++++++ 4 files changed, 67 insertions(+), 26 deletions(-) create mode 100644 app/assets/stylesheets/darkswarm/registration.css.sass diff --git a/app/assets/javascripts/darkswarm/services/registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/registration_service.js.coffee index 0d7bfd2e73..903454911d 100644 --- a/app/assets/javascripts/darkswarm/services/registration_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/registration_service.js.coffee @@ -9,7 +9,7 @@ Darkswarm.factory "RegistrationService", (Navigation, $modal, $location)-> open: => @modalInstance = $modal.open templateUrl: 'registration.html' - windowClass: "login-modal medium" + windowClass: "login-modal large" @modalInstance.result.then @close, @close @select @current_step diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index 17020259c1..f1521062c5 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -1,33 +1,37 @@ -%div - .row +#registration_details + .row#header %h2 Let's Get Started - .row %h5 Woot! First we need to know what sort of enterprise you are: %ng-include{ src: "'registration/steps.html'" } .row - .small-12.columns{ style: 'background-color: #fff;'} + .small-12.columns .row - %label{ for: 'enterprise_name'} Enterprise Name: + %label{ for: 'enterprise_name' } Enterprise Name: .row %input.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm" } .row Choose One: - .row{ 'data-equalizer' => true } - %a#producer.small-4.columns{ 'data-equalizer-watch' => true, style: 'background-color: #efefef;', href: "#", ng: { click: "enterprise.type = 'producer'" } } - %div.small-1.columns - %div.small-11.columns - %h6 I'm A Producer - %span Producers are anyone making things to eat & drink - whether you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. - %a#hub.small-4.columns{ 'data-equalizer-watch' => true, style: 'background-color: #efefef;', href: "#", ng: { click: "enterprise.type = 'hub'" } } - %div.small-1.columns - %div.small-11.columns - %h6 I'm A Hub - %span Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, etc... - %a#both.small-4.columns{ 'data-equalizer-watch' => true, style: 'background-color: #efefef;', href: "#", ng: { click: "enterprise.type = 'both'" } } - %div.small-1.columns - %div.small-11.columns - %h6 I'm Both - %span Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! + .row#enterprise_types{ 'data-equalizer' => true } + .medium-12.large-4.columns{ 'data-equalizer-watch' => true } + %a.small-12.columns.panel#producer{ href: "#", ng: { click: "enterprise.type = 'producer'", class: "{selected: enterprise.type == 'producer'}" } } + .small-2.columns + .small-10.columns + %h6 I'm A Producer + %span Producers are anyone making things to eat & drink - whether you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. + + .medium-12.large-4.columns{ 'data-equalizer-watch' => true } + %a.small-12.columns.panel#hub{ href: "#", ng: { click: "enterprise.type = 'hub'", class: "{selected: enterprise.type == 'hub'}" } } + .small-2.columns + .small-10.columns + %h6 I'm A Hub + %span Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, etc... + + .medium-12.large-4.columns{ 'data-equalizer-watch' => true } + %a.small-12.columns.panel#both{ href: "#", ng: { click: "enterprise.type = 'both'", class: "{selected: enterprise.type == 'both'}" } } + .small-2.columns + .small-10.columns + %h6 I'm Both + %span Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! .row %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" } } diff --git a/app/assets/javascripts/templates/registration/steps.html.haml b/app/assets/javascripts/templates/registration/steps.html.haml index c54d0b947b..1a44d1b378 100644 --- a/app/assets/javascripts/templates/registration/steps.html.haml +++ b/app/assets/javascripts/templates/registration/steps.html.haml @@ -1,6 +1,5 @@ -.row - .small-2.columns{ ng: { repeat: 'step in steps', class: "{active: currentStep == step}" } } - %div{ style: 'text-transform: uppercase; text-align: center;background-color: #000; color: #fff;'} - {{ step }} +.row#progress_bar + .small-2.columns.item{ ng: { repeat: 'step in steps', class: "{active: currentStep == step}" } } + {{ step }} \ No newline at end of file diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass new file mode 100644 index 0000000000..b7604fe12a --- /dev/null +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -0,0 +1,38 @@ +@import branding + +#progress_bar + margin-bottom: 15px + .item + padding: 12px 0px + text-transform: uppercase + text-align: center + background-color: #000 + color: #fff + +#registration_details + background-color: #ffffff + + #header + text-align: center + background-color: #efefef + + label + margin-bottom: 3px + + #enterprise_types + margin-bottom: 20px + a + background-color: #efefef + color: black + &:hover + background-color: #ffffff + &.selected + h6 + color: #ffffff + color: #ffffff + background-color: $clr-turquoise-bright + + input#enterprise_name + padding: 8px + font-size: 105% + margin-bottom: 15px From c53df00969f4e381309ff47d9ed76e763353e8d7 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 20 Aug 2014 12:52:55 +1000 Subject: [PATCH 036/120] Adding address step to registration process --- .../registration_controller.js.coffee | 4 +- .../templates/registration.html.haml | 2 +- .../templates/registration/address.html.haml | 41 +++++++++++++++++++ .../templates/registration/details.html.haml | 12 +++--- .../templates/registration/steps.html.haml | 2 +- .../darkswarm/registration.css.sass | 41 ++++++++++--------- 6 files changed, 73 insertions(+), 29 deletions(-) create mode 100644 app/assets/javascripts/templates/registration/address.html.haml diff --git a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee index 33e4d03af4..07f85d49c5 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee @@ -4,7 +4,7 @@ Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, CurrentUs $scope.currentStep = RegistrationService.currentStep $scope.select = RegistrationService.select - $scope.steps = ['details'] - # ,'address','contact','about','images','social' + $scope.steps = ['details','address'] + # ,'contact','about','images','social' $scope.enterprise = {} \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration.html.haml b/app/assets/javascripts/templates/registration.html.haml index f6dcea10fd..dba05f3429 100644 --- a/app/assets/javascripts/templates/registration.html.haml +++ b/app/assets/javascripts/templates/registration.html.haml @@ -1,4 +1,4 @@ -%div.registration-modal{"ng-controller" => "RegistrationCtrl"} +%div#registration-modal{"ng-controller" => "RegistrationCtrl"} %div{ ng: { show: "currentStep() == 'introduction'" } } %ng-include{ src: "'registration/introduction.html'" } %div{ ng: { repeat: 'step in steps', show: "currentStep() == step" } } diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml new file mode 100644 index 0000000000..e240fd781d --- /dev/null +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -0,0 +1,41 @@ +.container#registration-address + .row.header + %h2 {{ enterprise.name }} + %h5 Now we need to know where you are: + %ng-include{ src: "'registration/steps.html'" } + .row.content + .small-7.columns + .row + .small-12.columns + %label{ for: 'enterprise_address' } Address: + %input.chunky.small-12.columns{ id: 'enterprise_address', placeholder: "eg. 123 Cranberry Drive", ng: { model: 'enterprise.address' } } + .row + .small-8.columns + %label{ for: 'enterprise_suburb' } Suburb: + %input.chunky.small-12.columns{ id: 'enterprise_suburb', placeholder: "eg. Northcote", ng: { model: 'enterprise.suburb' } } + .small-4.columns + %label{ for: 'enterprise_postcode' } Postcode: + %input.chunky.small-12.columns{ id: 'enterprise_postcode', placeholder: "eg. 3070", ng: { model: 'enterprise.suburb' } } + .row + .small-8.columns + %label{ for: 'enterprise_country' } Country: + %input.chunky.small-12.columns{ id: 'enterprise_country', placeholder: "eg. Australia", ng: { model: 'enterprise.country' } } + .small-4.columns + %label{ for: 'enterprise_state' } State: + %input.chunky.small-12.columns{ id: 'enterprise_state', placeholder: "eg. Victoria", ng: { model: 'enterprise.state' } } + .small-5.columns + %h6 Location display + .row + .small-2.columns + %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } + .small-10.columns + %label{ for: 'enterpise_suburb_only' } Hide my street name and street number from the public (ie. only show the suburb) + .row   + .row + .small-2.columns + %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } + .small-10.columns + %label{ for: 'enterprise_on_map' } Blur my location on the map (show an approximate, not exact pin) + .row + %input.button.primary{ type: "button", value: "Back", ng: { click: "select('details')" }, style: 'float:left' } + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" }, style: 'float:right' } diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index f1521062c5..c6828f4823 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -1,17 +1,17 @@ -#registration_details - .row#header +.container#registration-details + .row.header %h2 Let's Get Started %h5 Woot! First we need to know what sort of enterprise you are: %ng-include{ src: "'registration/steps.html'" } - .row + .row.content .small-12.columns .row %label{ for: 'enterprise_name' } Enterprise Name: .row - %input.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm" } + %input.chunky.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm", ng: { model: 'enterprise.name' } } .row Choose One: - .row#enterprise_types{ 'data-equalizer' => true } + .row#enterprise-types{ 'data-equalizer' => true } .medium-12.large-4.columns{ 'data-equalizer-watch' => true } %a.small-12.columns.panel#producer{ href: "#", ng: { click: "enterprise.type = 'producer'", class: "{selected: enterprise.type == 'producer'}" } } .small-2.columns @@ -33,6 +33,6 @@ %h6 I'm Both %span Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! .row - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" } } + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" }, style: 'float:right' } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/steps.html.haml b/app/assets/javascripts/templates/registration/steps.html.haml index 1a44d1b378..905986816d 100644 --- a/app/assets/javascripts/templates/registration/steps.html.haml +++ b/app/assets/javascripts/templates/registration/steps.html.haml @@ -1,4 +1,4 @@ -.row#progress_bar +.row#progress-bar .small-2.columns.item{ ng: { repeat: 'step in steps', class: "{active: currentStep == step}" } } {{ step }} diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index b7604fe12a..58856b4010 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -1,25 +1,33 @@ @import branding -#progress_bar - margin-bottom: 15px - .item - padding: 12px 0px - text-transform: uppercase - text-align: center - background-color: #000 - color: #fff - -#registration_details - background-color: #ffffff - - #header +#registration-modal + .header text-align: center background-color: #efefef + .container + background-color: #ffffff + .content + margin-bottom: 15px + input.chunky + padding: 8px + font-size: 105% + margin-bottom: 15px + + #progress-bar + margin-bottom: 15px + .item + padding: 12px 0px + text-transform: uppercase + text-align: center + background-color: #000 + color: #fff + +#registration-details label margin-bottom: 3px - #enterprise_types + #enterprise-types margin-bottom: 20px a background-color: #efefef @@ -31,8 +39,3 @@ color: #ffffff color: #ffffff background-color: $clr-turquoise-bright - - input#enterprise_name - padding: 8px - font-size: 105% - margin-bottom: 15px From 843c6ea6a6f947bbdce90b2a89e5e8f74e5d5f90 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 20 Aug 2014 13:27:32 +1000 Subject: [PATCH 037/120] Fix styling on details page --- .../registration/introduction.html.haml | 31 ++++++++----------- .../darkswarm/registration.css.sass | 4 +++ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/templates/registration/introduction.html.haml b/app/assets/javascripts/templates/registration/introduction.html.haml index bca22b7567..4b208afed1 100644 --- a/app/assets/javascripts/templates/registration/introduction.html.haml +++ b/app/assets/javascripts/templates/registration/introduction.html.haml @@ -1,32 +1,27 @@ %div - .row + .row.header %h2 Hi there! - .row %h5 This wizard will step you through creating a Profile on the Open Food Network. .row .small-2.columns   - .small-10.columns{ style: 'line-height: 150%;'} Your profile gives you an online presence on the Open Food Network, allowing you to easily connect with potential customers or partners. You can always choose to update your info later, as well as choose to upgrade your Profile to and Online Store, where you can sell products, track orders and receive payments. + .small-10.columns{ style: 'line-height: 150%;'} Your profile gives you an online presence on the Open Food Network, allowing you to easily connect with potential customers or partners. You can always choose to update your info later, as well as choose to upgrade your Profile to and Online Store, where you can sell products, track orders and receive payments. Creating a profile usually takes about 5-10 minutes. %br - .row - .small-12.columns{ 'data-equalizer' => true } - .small-6.columns{ style: 'font-size: 80%' } - %span Creating a profile usually takes about 5-10 minutes. - %h6 You'll need the following: - %ol{ style: 'font-size: 100%' } + .row{ 'data-equalizer' => true } + .small-6.columns{ 'data-equalizer-watch' => true } + %span{ style: 'font-weight: bold;' } You'll need the following: + .small-12.columns + %ol.numbered-list %li Your enterprise address and contact details %li Your logo image %li A pretty image to serve as your profile header %li Some 'About Us' text - .small-6.columns{ style: 'background-color: #FFFFFF;'} - %h6 Your profile entitles you to: - A searchable listing in Hub / Producer view - %br - A pin on the OFN map to help users find you + .small-6.columns{ 'data-equalizer-watch' => true, style: 'background-color: #ffffff; padding-bottom: 10px;'} + %h6 Your profile entitles you to: + A searchable listing in Hub / Producer view + %br + A pin on the OFN map to help users find you .row .large-12.columns .row - Ready to go? - %br - .row - %input.button.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" } } + %input.button.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" }, style: 'float: right' } \ No newline at end of file diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 58856b4010..33b80157f1 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -14,6 +14,10 @@ font-size: 105% margin-bottom: 15px + ol.numbered-list + font-size: 80% + list-style-type: decimal + #progress-bar margin-bottom: 15px .item From e1400705fe750665d01139b45b85c48332441256 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 20 Aug 2014 13:47:41 +1000 Subject: [PATCH 038/120] Adding contact step to registration process --- .../registration_controller.js.coffee | 8 ++-- .../templates/registration/contact.html.haml | 37 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/templates/registration/contact.html.haml diff --git a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee index 07f85d49c5..e5e8121508 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee @@ -4,7 +4,9 @@ Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, CurrentUs $scope.currentStep = RegistrationService.currentStep $scope.select = RegistrationService.select - $scope.steps = ['details','address'] - # ,'contact','about','images','social' + $scope.steps = ['details','address','contact'] + # ,'about','images','social' - $scope.enterprise = {} \ No newline at end of file + $scope.enterprise = + contact: + email: CurrentUser.email \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml new file mode 100644 index 0000000000..f7d0959590 --- /dev/null +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -0,0 +1,37 @@ +.container#registration-contact + .row.header + %h2 Last step to create your enterprise! + %h5 Who is responsible for managing {{ enterprise.name }}? + %ng-include{ src: "'registration/steps.html'" } + .row.content + .small-8.columns + .row + .small-6.columns + %label{ for: 'contact_first_name' } Primary Contact: + %input.chunky.small-12.columns{ id: 'contact_first_name', placeholder: "First Name", ng: { model: 'enterprise.contact.first_name' } } + .small-6.columns + %label{ for: 'contact_surname' }   + %input.chunky.small-12.columns{ id: 'contact_surname', placeholder: "Surname", ng: { model: 'enterprise.contact.surname' } } + .row + .small-12.columns + %label{ for: 'contact_email' } Email address: + %input.chunky.small-12.columns{ id: 'contact_email', placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.contact.email' } } + .row + .small-12.columns + %label{ for: 'contact_phone' } Phone number: + %input.chunky.small-12.columns{ id: 'contact_phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.contact.phone' } } + .small-4.columns + %h6 Contact display + .row + .small-12.columns + %label{ for: 'contact_display_profile' } + %input{ type: 'checkbox', id: 'contact_name_profile', ng: { model: 'enterprise.contact.name_in_profile' } }   Display name in profile + .small-12.columns + %label{ for: 'contact_display_profile' } + %input{ type: 'checkbox', id: 'contact_email_profile', ng: { model: 'enterprise.contact.email_in_profile' } }   Display email in profile + .small-12.columns + %label{ for: 'contact_display_profile' } + %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.contact.phone_in_profile' } }   Display phone in profile + .row + %input.button.primary{ type: "button", value: "Back", ng: { click: "select('details')" }, style: 'float:left' } + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" }, style: 'float:right' } \ No newline at end of file From 95bfc74b3f18e8c2cfbfafbe540ccbd2796bdcc6 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 20 Aug 2014 14:02:18 +1000 Subject: [PATCH 039/120] No need to deal with locations in registration --- .../services/registration_service.js.coffee | 13 +++++-------- .../templates/registration/contact.html.haml | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/darkswarm/services/registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/registration_service.js.coffee index 903454911d..025c403358 100644 --- a/app/assets/javascripts/darkswarm/services/registration_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/registration_service.js.coffee @@ -1,8 +1,6 @@ -Darkswarm.factory "RegistrationService", (Navigation, $modal, $location)-> +Darkswarm.factory "RegistrationService", (Navigation, $modal, Loading)-> new class RegistrationService - current_step: 'introduction' - constructor: -> @open() @@ -10,17 +8,16 @@ Darkswarm.factory "RegistrationService", (Navigation, $modal, $location)-> @modalInstance = $modal.open templateUrl: 'registration.html' windowClass: "login-modal large" + backdrop: 'static' @modalInstance.result.then @close, @close - @select @current_step + @select 'introduction' select: (step)=> @current_step = step - Navigation.navigate '/' + @current_step - - active: Navigation.active currentStep: => @current_step close: -> - Navigation.navigate "/" \ No newline at end of file + Loading.message = "Taking you back to the home page" + Navigation.go "/" \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index f7d0959590..4a35e8dbef 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -33,5 +33,5 @@ %label{ for: 'contact_display_profile' } %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.contact.phone_in_profile' } }   Display phone in profile .row - %input.button.primary{ type: "button", value: "Back", ng: { click: "select('details')" }, style: 'float:left' } + %input.button.primary{ type: "button", value: "Back", ng: { click: "select('address')" }, style: 'float:left' } %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" }, style: 'float:right' } \ No newline at end of file From 29e78e63ad5eb82d057fadae39d23b717b5b471d Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 20 Aug 2014 14:27:44 +1000 Subject: [PATCH 040/120] Playing with resizing --- .../templates/registration/address.html.haml | 8 ++++---- .../templates/registration/contact.html.haml | 8 ++++---- .../templates/registration/steps.html.haml | 2 +- .../stylesheets/darkswarm/registration.css.sass | 13 ++++++++----- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index e240fd781d..995966b0ab 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -10,17 +10,17 @@ %label{ for: 'enterprise_address' } Address: %input.chunky.small-12.columns{ id: 'enterprise_address', placeholder: "eg. 123 Cranberry Drive", ng: { model: 'enterprise.address' } } .row - .small-8.columns + .small-12.large-8.columns %label{ for: 'enterprise_suburb' } Suburb: %input.chunky.small-12.columns{ id: 'enterprise_suburb', placeholder: "eg. Northcote", ng: { model: 'enterprise.suburb' } } - .small-4.columns + .small-12.large-4.columns %label{ for: 'enterprise_postcode' } Postcode: %input.chunky.small-12.columns{ id: 'enterprise_postcode', placeholder: "eg. 3070", ng: { model: 'enterprise.suburb' } } .row - .small-8.columns + .small-12.large-8.columns %label{ for: 'enterprise_country' } Country: %input.chunky.small-12.columns{ id: 'enterprise_country', placeholder: "eg. Australia", ng: { model: 'enterprise.country' } } - .small-4.columns + .small-12.large-4.columns %label{ for: 'enterprise_state' } State: %input.chunky.small-12.columns{ id: 'enterprise_state', placeholder: "eg. Victoria", ng: { model: 'enterprise.state' } } .small-5.columns diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 4a35e8dbef..7a9b617268 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -4,12 +4,12 @@ %h5 Who is responsible for managing {{ enterprise.name }}? %ng-include{ src: "'registration/steps.html'" } .row.content - .small-8.columns + .small-12.large-8.columns .row - .small-6.columns + .small-12.large-6.columns %label{ for: 'contact_first_name' } Primary Contact: %input.chunky.small-12.columns{ id: 'contact_first_name', placeholder: "First Name", ng: { model: 'enterprise.contact.first_name' } } - .small-6.columns + .small-12.large-6.columns %label{ for: 'contact_surname' }   %input.chunky.small-12.columns{ id: 'contact_surname', placeholder: "Surname", ng: { model: 'enterprise.contact.surname' } } .row @@ -20,7 +20,7 @@ .small-12.columns %label{ for: 'contact_phone' } Phone number: %input.chunky.small-12.columns{ id: 'contact_phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.contact.phone' } } - .small-4.columns + .small-12.large-4.columns %h6 Contact display .row .small-12.columns diff --git a/app/assets/javascripts/templates/registration/steps.html.haml b/app/assets/javascripts/templates/registration/steps.html.haml index 905986816d..ea1e57a306 100644 --- a/app/assets/javascripts/templates/registration/steps.html.haml +++ b/app/assets/javascripts/templates/registration/steps.html.haml @@ -1,5 +1,5 @@ .row#progress-bar - .small-2.columns.item{ ng: { repeat: 'step in steps', class: "{active: currentStep == step}" } } + .small-12.medium-2.columns.item{ ng: { repeat: 'step in steps', class: "{active: (currentStep() == step),'show-for-medium-up': (currentStep() != step)}" } } {{ step }} \ No newline at end of file diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 33b80157f1..6d81233b49 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -14,6 +14,9 @@ font-size: 105% margin-bottom: 15px + label + margin-bottom: 3px + ol.numbered-list font-size: 80% list-style-type: decimal @@ -24,13 +27,13 @@ padding: 12px 0px text-transform: uppercase text-align: center - background-color: #000 - color: #fff + background-color: #000000 + color: #ffffff + .item.active + background-color: #ffffff + color: #000000 #registration-details - label - margin-bottom: 3px - #enterprise-types margin-bottom: 20px a From 07f9dc23e0eaaae134f4dc02f64609536be13c0d Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 20 Aug 2014 14:38:40 +1000 Subject: [PATCH 041/120] Making button styling a bit nicer --- .../templates/registration/address.html.haml | 5 +++-- .../templates/registration/contact.html.haml | 5 +++-- .../templates/registration/details.html.haml | 13 +++++++------ .../templates/registration/introduction.html.haml | 5 ++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index 995966b0ab..8b04675896 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -37,5 +37,6 @@ .small-10.columns %label{ for: 'enterprise_on_map' } Blur my location on the map (show an approximate, not exact pin) .row - %input.button.primary{ type: "button", value: "Back", ng: { click: "select('details')" }, style: 'float:left' } - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" }, style: 'float:right' } + .small-12.columns + %input.button.primary{ type: "button", value: "Back", ng: { click: "select('details')" }, style: 'float:left' } + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" }, style: 'float:right' } diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 7a9b617268..87ed4dfb2e 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -33,5 +33,6 @@ %label{ for: 'contact_display_profile' } %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.contact.phone_in_profile' } }   Display phone in profile .row - %input.button.primary{ type: "button", value: "Back", ng: { click: "select('address')" }, style: 'float:left' } - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" }, style: 'float:right' } \ No newline at end of file + .small-12.columns + %input.button.primary{ type: "button", value: "Back", ng: { click: "select('address')" }, style: 'float:left' } + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" }, style: 'float:right' } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index c6828f4823..167189f4db 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -6,12 +6,12 @@ .row.content .small-12.columns .row - %label{ for: 'enterprise_name' } Enterprise Name: - .row - %input.chunky.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm", ng: { model: 'enterprise.name' } } - .row - Choose One: + .small-12.columns + %label{ for: 'enterprise_name' } Enterprise Name: + %input.chunky.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm", ng: { model: 'enterprise.name' } } .row#enterprise-types{ 'data-equalizer' => true } + .small-12.columns + %label Choose One: .medium-12.large-4.columns{ 'data-equalizer-watch' => true } %a.small-12.columns.panel#producer{ href: "#", ng: { click: "enterprise.type = 'producer'", class: "{selected: enterprise.type == 'producer'}" } } .small-2.columns @@ -33,6 +33,7 @@ %h6 I'm Both %span Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! .row - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" }, style: 'float:right' } + .small-12.columns + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" }, style: 'float:right' } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/introduction.html.haml b/app/assets/javascripts/templates/registration/introduction.html.haml index 4b208afed1..415f3f24fc 100644 --- a/app/assets/javascripts/templates/registration/introduction.html.haml +++ b/app/assets/javascripts/templates/registration/introduction.html.haml @@ -21,7 +21,6 @@ %br A pin on the OFN map to help users find you .row - .large-12.columns - .row - %input.button.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" }, style: 'float: right' } + .small-12.columns + %input.button.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" }, style: 'float: right' } \ No newline at end of file From 10f97fe14b4059cb078a8900c43c5bbc4e170009 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 20 Aug 2014 16:21:30 +1000 Subject: [PATCH 042/120] Adding some icons to registration pages --- .../templates/registration/address.html.haml | 22 +++++++++---------- .../templates/registration/contact.html.haml | 10 +++++---- .../templates/registration/details.html.haml | 9 +++++--- .../registration/introduction.html.haml | 10 ++++----- .../darkswarm/registration.css.sass | 11 +++++++++- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index 8b04675896..3e1b3c174a 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -24,18 +24,18 @@ %label{ for: 'enterprise_state' } State: %input.chunky.small-12.columns{ id: 'enterprise_state', placeholder: "eg. Victoria", ng: { model: 'enterprise.state' } } .small-5.columns - %h6 Location display + %h6 + Location display + %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} .row - .small-2.columns - %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } - .small-10.columns - %label{ for: 'enterpise_suburb_only' } Hide my street name and street number from the public (ie. only show the suburb) - .row   - .row - .small-2.columns - %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } - .small-10.columns - %label{ for: 'enterprise_on_map' } Blur my location on the map (show an approximate, not exact pin) + .small-12.columns + %label.indent-checkbox + %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } + Hide my street name and street number from the public (ie. only show the suburb) + .small-12.columns + %label.indent-checkbox + %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } + Blur my location on the map (show an approximate, not exact pin) .row .small-12.columns %input.button.primary{ type: "button", value: "Back", ng: { click: "select('details')" }, style: 'float:left' } diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 87ed4dfb2e..243d98b601 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -21,16 +21,18 @@ %label{ for: 'contact_phone' } Phone number: %input.chunky.small-12.columns{ id: 'contact_phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.contact.phone' } } .small-12.large-4.columns - %h6 Contact display + %h6 + Contact display + %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your contact details on the Open Food Network."} .row .small-12.columns - %label{ for: 'contact_display_profile' } + %label.indent-checkbox %input{ type: 'checkbox', id: 'contact_name_profile', ng: { model: 'enterprise.contact.name_in_profile' } }   Display name in profile .small-12.columns - %label{ for: 'contact_display_profile' } + %label.indent-checkbox %input{ type: 'checkbox', id: 'contact_email_profile', ng: { model: 'enterprise.contact.email_in_profile' } }   Display email in profile .small-12.columns - %label{ for: 'contact_display_profile' } + %label.indent-checkbox %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.contact.phone_in_profile' } }   Display phone in profile .row .small-12.columns diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index 167189f4db..fb346d6959 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -15,23 +15,26 @@ .medium-12.large-4.columns{ 'data-equalizer-watch' => true } %a.small-12.columns.panel#producer{ href: "#", ng: { click: "enterprise.type = 'producer'", class: "{selected: enterprise.type == 'producer'}" } } .small-2.columns + %i.ofn-i_036-producers .small-10.columns %h6 I'm A Producer - %span Producers are anyone making things to eat & drink - whether you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. + %span{ style: 'font-size: 80%'} Producers are anyone making things to eat & drink - whether you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. .medium-12.large-4.columns{ 'data-equalizer-watch' => true } %a.small-12.columns.panel#hub{ href: "#", ng: { click: "enterprise.type = 'hub'", class: "{selected: enterprise.type == 'hub'}" } } .small-2.columns + %i.ofn-i_040-hub .small-10.columns %h6 I'm A Hub - %span Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, etc... + %span{ style: 'font-size: 80%'} Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, etc... .medium-12.large-4.columns{ 'data-equalizer-watch' => true } %a.small-12.columns.panel#both{ href: "#", ng: { click: "enterprise.type = 'both'", class: "{selected: enterprise.type == 'both'}" } } .small-2.columns + %i.ofn-i_039-delivery .small-10.columns %h6 I'm Both - %span Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! + %span{ style: 'font-size: 80%'} Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! .row .small-12.columns %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" }, style: 'float:right' } diff --git a/app/assets/javascripts/templates/registration/introduction.html.haml b/app/assets/javascripts/templates/registration/introduction.html.haml index 415f3f24fc..4f9bcf0708 100644 --- a/app/assets/javascripts/templates/registration/introduction.html.haml +++ b/app/assets/javascripts/templates/registration/introduction.html.haml @@ -15,11 +15,11 @@ %li Your logo image %li A pretty image to serve as your profile header %li Some 'About Us' text - .small-6.columns{ 'data-equalizer-watch' => true, style: 'background-color: #ffffff; padding-bottom: 10px;'} - %h6 Your profile entitles you to: - A searchable listing in Hub / Producer view - %br - A pin on the OFN map to help users find you + .small-6.columns{ 'data-equalizer-watch' => true, style: 'background-color: #ffffff; padding: 10px;'} + %span{ style: 'font-weight: bold;' } Your profile entitles you to: + %ul{ style: 'margin-top: 10px;' } + %li A searchable listing in Hub / Producer view + %li A pin on the OFN map to help users find you .row .small-12.columns %input.button.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" }, style: 'float: right' } diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 6d81233b49..e12c00f17b 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -9,11 +9,21 @@ .content margin-bottom: 15px + i + font-size: 150% + input.chunky padding: 8px font-size: 105% margin-bottom: 15px + label.indent-checkbox + display: block + padding-left: 20px + text-indent: -17px + input + margin: 0px + label margin-bottom: 3px @@ -35,7 +45,6 @@ #registration-details #enterprise-types - margin-bottom: 20px a background-color: #efefef color: black From a642ad0855bbec429356626e313917f234ca3279 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 17:00:59 +1000 Subject: [PATCH 043/120] More style detail for small view inactive hub small views --- app/assets/stylesheets/darkswarm/hub_node.css.sass | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/hub_node.css.sass b/app/assets/stylesheets/darkswarm/hub_node.css.sass index 19d119f1e5..eb539cc0b5 100644 --- a/app/assets/stylesheets/darkswarm/hub_node.css.sass +++ b/app/assets/stylesheets/darkswarm/hub_node.css.sass @@ -94,9 +94,13 @@ border-color: $disabled-bright &.open .active_table_row, .active_table_row:first-child, .active_table_row:last-child - border-color: $disabled-bright - // & Current hub + // border-color: $disabled-bright + &, &:hover, &:active, &:focus + border-color: $disabled-bright + &.closed, &.open + + // & Current hub &.current .active_table_row, .active_table_row:first-child, .active_table_row:last-child a, a * @@ -105,9 +109,9 @@ background-color: rgba(220,220,220,0.5) &:hover, &:focus, &:active border-color: $disabled-dark + // Small devices @media all and (max-width: 640px) - .active_table_row:first-child .skinny-head background-color: $disabled-bright @@ -117,7 +121,8 @@ border-color: $disabled-bright background-color: transparent &:hover, &:focus, &:active - border-color: $disabled-dark + border-color: $disabled-bright + opacity: 0.85 .active_table_row:first-child .skinny-head background-color: $disabled-light From 3d4e00a03c4d897786caf535a6ef12683a94b209 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 20 Aug 2014 22:00:58 +1000 Subject: [PATCH 044/120] Swtich API key injection over to helper --- .../admin/bulk_order_management.js.coffee | 11 ++++++----- .../javascripts/admin/bulk_product_update.js.coffee | 13 +++++++------ .../spree/admin/orders_controller_decorator.rb | 10 +++------- .../spree/admin/products_controller_decorator.rb | 6 ++++-- app/helpers/admin/injection_helper.rb | 4 +++- .../spree/admin/orders/bulk_management.html.haml | 4 +++- app/views/spree/admin/products/bulk_edit.html.haml | 2 +- .../spree/admin/products/bulk_edit/_data.html.haml | 1 + lib/open_food_network/spree_api_key_loader.rb | 8 ++++++++ 9 files changed, 36 insertions(+), 23 deletions(-) create mode 100644 lib/open_food_network/spree_api_key_loader.rb diff --git a/app/assets/javascripts/admin/bulk_order_management.js.coffee b/app/assets/javascripts/admin/bulk_order_management.js.coffee index d545245eeb..4c1a319c1a 100644 --- a/app/assets/javascripts/admin/bulk_order_management.js.coffee +++ b/app/assets/javascripts/admin/bulk_order_management.js.coffee @@ -1,6 +1,7 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [ - "$scope", "$http", "dataFetcher", "blankOption", "pendingChanges", "VariantUnitManager", "OptionValueNamer", - ($scope, $http, dataFetcher, blankOption, pendingChanges, VariantUnitManager, OptionValueNamer) -> + "$scope", "$http", "dataFetcher", "blankOption", "pendingChanges", "VariantUnitManager", "OptionValueNamer", "SpreeApiKey" + ($scope, $http, dataFetcher, blankOption, pendingChanges, VariantUnitManager, OptionValueNamer, SpreeApiKey) -> + $scope.loading = true $scope.initialiseVariables = -> start = daysFromToday -7 @@ -32,14 +33,14 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [ quantity: { name: "Quantity", visible: true } max: { name: "Max", visible: true } - $scope.initialise = (spree_api_key) -> + $scope.initialise = -> $scope.initialiseVariables() authorise_api_reponse = "" - dataFetcher("/api/users/authorise_api?token=" + spree_api_key).then (data) -> + dataFetcher("/api/users/authorise_api?token=" + SpreeApiKey).then (data) -> authorise_api_reponse = data $scope.spree_api_key_ok = data.hasOwnProperty("success") and data["success"] == "Use of API Authorised" if $scope.spree_api_key_ok - $http.defaults.headers.common["X-Spree-Token"] = spree_api_key + $http.defaults.headers.common["X-Spree-Token"] = SpreeApiKey dataFetcher("/api/enterprises/accessible?template=bulk_index&q[is_primary_producer_eq]=true").then (data) -> $scope.suppliers = data $scope.suppliers.unshift blankOption() diff --git a/app/assets/javascripts/admin/bulk_product_update.js.coffee b/app/assets/javascripts/admin/bulk_product_update.js.coffee index 35ec6e694c..b68e3340e1 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js.coffee +++ b/app/assets/javascripts/admin/bulk_product_update.js.coffee @@ -1,6 +1,8 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", [ - "$scope", "$timeout", "$http", "dataFetcher", "DirtyProducts", "VariantUnitManager", "producers", "Taxons", - ($scope, $timeout, $http, dataFetcher, DirtyProducts, VariantUnitManager, producers, Taxons) -> + "$scope", "$timeout", "$http", "dataFetcher", "DirtyProducts", "VariantUnitManager", "producers", "Taxons", "SpreeApiKey", + ($scope, $timeout, $http, dataFetcher, DirtyProducts, VariantUnitManager, producers, Taxons, SpreeApiKey) -> + $scope.loading = true + $scope.updateStatusMessage = text: "" style: {} @@ -42,14 +44,13 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", [ $scope.limit = 15 $scope.productsWithUnsavedVariants = [] - - $scope.initialise = (spree_api_key) -> + $scope.initialise = -> authorise_api_reponse = "" - dataFetcher("/api/users/authorise_api?token=" + spree_api_key).then (data) -> + dataFetcher("/api/users/authorise_api?token=" + SpreeApiKey).then (data) -> authorise_api_reponse = data $scope.spree_api_key_ok = data.hasOwnProperty("success") and data["success"] == "Use of API Authorised" if $scope.spree_api_key_ok - $http.defaults.headers.common["X-Spree-Token"] = spree_api_key + $http.defaults.headers.common["X-Spree-Token"] = SpreeApiKey $scope.fetchProducts() else if authorise_api_reponse.hasOwnProperty("error") $scope.api_error_msg = authorise_api_reponse("error") diff --git a/app/controllers/spree/admin/orders_controller_decorator.rb b/app/controllers/spree/admin/orders_controller_decorator.rb index 27d9a36943..3e3c255ab3 100644 --- a/app/controllers/spree/admin/orders_controller_decorator.rb +++ b/app/controllers/spree/admin/orders_controller_decorator.rb @@ -1,4 +1,7 @@ +require 'open_food_network/spree_api_key_loader' + Spree::Admin::OrdersController.class_eval do + include OpenFoodNetwork::SpreeApiKeyLoader before_filter :load_spree_api_key, :only => :bulk_management # We need to add expections for collection actions other than :index here @@ -14,11 +17,4 @@ Spree::Admin::OrdersController.class_eval do page(params[:page]). per(params[:per_page] || Spree::Config[:orders_per_page]) } } } - - private - - def load_spree_api_key - current_user.generate_spree_api_key! unless spree_current_user.spree_api_key - @spree_api_key = spree_current_user.spree_api_key - end end diff --git a/app/controllers/spree/admin/products_controller_decorator.rb b/app/controllers/spree/admin/products_controller_decorator.rb index a5b38126e5..dfe5a3d30f 100644 --- a/app/controllers/spree/admin/products_controller_decorator.rb +++ b/app/controllers/spree/admin/products_controller_decorator.rb @@ -1,5 +1,9 @@ +require 'open_food_network/spree_api_key_loader' + Spree::Admin::ProductsController.class_eval do + include OpenFoodNetwork::SpreeApiKeyLoader before_filter :load_bpe_data, :only => :bulk_edit + before_filter :load_spree_api_key, :only => :bulk_edit alias_method :location_after_save_original, :location_after_save @@ -86,8 +90,6 @@ Spree::Admin::ProductsController.class_eval do private def load_bpe_data - current_user.generate_spree_api_key! unless spree_current_user.spree_api_key - @spree_api_key = spree_current_user.spree_api_key @producers = OpenFoodNetwork::Permissions.new(spree_current_user).managed_product_enterprises.is_primary_producer.by_name @taxons = Spree::Taxon.order(:name) end diff --git a/app/helpers/admin/injection_helper.rb b/app/helpers/admin/injection_helper.rb index 9ce62b2719..115bc8d0c5 100644 --- a/app/helpers/admin/injection_helper.rb +++ b/app/helpers/admin/injection_helper.rb @@ -37,7 +37,9 @@ module Admin admin_inject_json_ams_array "ofn.admin", "users", @users, Api::Admin::UserSerializer end - + def admin_inject_spree_api_key + render partial: "admin/json/injection_ams", locals: {ngModule: 'ofn.admin', name: 'SpreeApiKey', json: "'#{@spree_api_key}'"} + end def admin_inject_json_ams(ngModule, name, data, serializer, opts = {}) diff --git a/app/views/spree/admin/orders/bulk_management.html.haml b/app/views/spree/admin/orders/bulk_management.html.haml index 08a05595c5..f701813e9e 100644 --- a/app/views/spree/admin/orders/bulk_management.html.haml +++ b/app/views/spree/admin/orders/bulk_management.html.haml @@ -4,7 +4,9 @@ = render :partial => 'spree/admin/shared/order_sub_menu' -%div{ 'ng-app' => 'ofn.admin', 'ng-controller' => 'AdminOrderMgmtCtrl', 'ng-init' => "initialise('#{@spree_api_key}');loading=true;" } +=admin_inject_spree_api_key + +%div{ ng: { app: 'ofn.admin', controller: 'AdminOrderMgmtCtrl', init: 'initialise()' } } %div{ 'ng-show' => '!spree_api_key_ok' } {{ api_error_msg }} .filters{ :class => "sixteen columns alpha" } diff --git a/app/views/spree/admin/products/bulk_edit.html.haml b/app/views/spree/admin/products/bulk_edit.html.haml index fa322931cd..f230d1c331 100644 --- a/app/views/spree/admin/products/bulk_edit.html.haml +++ b/app/views/spree/admin/products/bulk_edit.html.haml @@ -1,7 +1,7 @@ = render 'spree/admin/products/bulk_edit/header' = render 'spree/admin/products/bulk_edit/data' -%div{ 'ng-app' => 'ofn.admin', 'ng-controller' => 'AdminProductEditCtrl', 'ng-init' => "initialise('#{@spree_api_key}');loading=true;" } +%div{ ng: { app: 'ofn.admin', controller: 'AdminProductEditCtrl', init: 'initialise()' } } = render 'spree/admin/products/bulk_edit/filters' %hr.sixteen.columns.alpha diff --git a/app/views/spree/admin/products/bulk_edit/_data.html.haml b/app/views/spree/admin/products/bulk_edit/_data.html.haml index 25d595bda1..8b727be3eb 100644 --- a/app/views/spree/admin/products/bulk_edit/_data.html.haml +++ b/app/views/spree/admin/products/bulk_edit/_data.html.haml @@ -1,2 +1,3 @@ = admin_inject_producers = admin_inject_taxons += admin_inject_spree_api_key diff --git a/lib/open_food_network/spree_api_key_loader.rb b/lib/open_food_network/spree_api_key_loader.rb new file mode 100644 index 0000000000..0612cb4f3b --- /dev/null +++ b/lib/open_food_network/spree_api_key_loader.rb @@ -0,0 +1,8 @@ +module OpenFoodNetwork + module SpreeApiKeyLoader + def load_spree_api_key + current_user.generate_spree_api_key! unless spree_current_user.spree_api_key + @spree_api_key = spree_current_user.spree_api_key + end + end +end \ No newline at end of file From 7dc42c9e39332e6bdd92a1211c7b3a9ae10ae7da Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 21 Aug 2014 12:47:19 +1000 Subject: [PATCH 045/120] Creating an enterprise works in registration process --- .../registration_controller.js.coffee | 37 ++++++++++++++++--- .../templates/registration/about.html.haml | 1 + .../templates/registration/address.html.haml | 19 ++++++---- .../templates/registration/contact.html.haml | 25 ++++++------- .../templates/registration/details.html.haml | 6 +-- app/controllers/api/enterprises_controller.rb | 11 ++++++ app/controllers/registration_controller.rb | 4 ++ app/helpers/admin/injection_helper.rb | 2 +- app/helpers/injection_helper.rb | 4 ++ app/views/registration/index.html.haml | 1 + lib/open_food_network/spree_api_key_loader.rb | 8 +++- spec/features/consumer/registration_spec.rb | 26 +++++++++++-- 12 files changed, 109 insertions(+), 35 deletions(-) create mode 100644 app/assets/javascripts/templates/registration/about.html.haml diff --git a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee index e5e8121508..7fa8ad0350 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee @@ -1,12 +1,39 @@ -Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, CurrentUser) -> +Darkswarm.controller "RegistrationCtrl", ($scope, $http, RegistrationService, CurrentUser, SpreeApiKey) -> $scope.current_user = CurrentUser $scope.currentStep = RegistrationService.currentStep $scope.select = RegistrationService.select - $scope.steps = ['details','address','contact'] - # ,'about','images','social' + $scope.steps = ['details','address','contact','about'] + # ,'images','social' $scope.enterprise = - contact: - email: CurrentUser.email \ No newline at end of file + user_ids: [CurrentUser.id] + email: CurrentUser.email + address: { + country_id: 12 + state_id: 1061493592 + } + + $scope.createEnterprise = -> + $http( + method: "POST" + url: "/api/enterprises" + data: + enterprise: $scope.prepare($scope.enterprise) + params: + token: SpreeApiKey + ).success((data) -> + $scope.select('about') + ).error((data) -> + console.log angular.toJson(data) + alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') + ) + # $scope.select('about') + + $scope.prepare = (ent_obj) -> + enterprise = {} + for a, v of ent_obj when a isnt 'address' + enterprise[a] = v + enterprise.address_attributes = ent_obj.address + enterprise diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml new file mode 100644 index 0000000000..5dac45cb13 --- /dev/null +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -0,0 +1 @@ +YAY! You created an enterprise! \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index 3e1b3c174a..4b4db863fe 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -8,21 +8,26 @@ .row .small-12.columns %label{ for: 'enterprise_address' } Address: - %input.chunky.small-12.columns{ id: 'enterprise_address', placeholder: "eg. 123 Cranberry Drive", ng: { model: 'enterprise.address' } } + %input.chunky.small-12.columns{ id: 'enterprise_address', placeholder: "eg. 123 Cranberry Drive", ng: { model: 'enterprise.address.address1' } } .row .small-12.large-8.columns - %label{ for: 'enterprise_suburb' } Suburb: - %input.chunky.small-12.columns{ id: 'enterprise_suburb', placeholder: "eg. Northcote", ng: { model: 'enterprise.suburb' } } + %label{ for: 'enterprise_city' } Suburb: + %input.chunky.small-12.columns{ id: 'enterprise_city', placeholder: "eg. Northcote", ng: { model: 'enterprise.address.city' } } .small-12.large-4.columns - %label{ for: 'enterprise_postcode' } Postcode: - %input.chunky.small-12.columns{ id: 'enterprise_postcode', placeholder: "eg. 3070", ng: { model: 'enterprise.suburb' } } + %label{ for: 'enterprise_zipcode' } Postcode: + %input.chunky.small-12.columns{ id: 'enterprise_zipcode', placeholder: "eg. 3070", ng: { model: 'enterprise.address.zipcode' } } .row .small-12.large-8.columns %label{ for: 'enterprise_country' } Country: - %input.chunky.small-12.columns{ id: 'enterprise_country', placeholder: "eg. Australia", ng: { model: 'enterprise.country' } } + -#= select :country_id, available_countries.map{|c|[c.name, c.id]}, {include_blank: false} + %input.chunky.small-12.columns{ id: 'enterprise_country', placeholder: "eg. Australia" } + -# , ng: { model: 'enterprise.country' } } .small-12.large-4.columns %label{ for: 'enterprise_state' } State: - %input.chunky.small-12.columns{ id: 'enterprise_state', placeholder: "eg. Victoria", ng: { model: 'enterprise.state' } } + - binding.pry + -#= select :state_id, available_countries.first.states.map{|c|[c.name, c.id]} + %input.chunky.small-12.columns{ id: 'enterprise_state', placeholder: "eg. Victoria" } + -# , ng: { model: 'enterprise.state' } } .small-5.columns %h6 Location display diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 243d98b601..40c7948767 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -6,20 +6,17 @@ .row.content .small-12.large-8.columns .row - .small-12.large-6.columns - %label{ for: 'contact_first_name' } Primary Contact: - %input.chunky.small-12.columns{ id: 'contact_first_name', placeholder: "First Name", ng: { model: 'enterprise.contact.first_name' } } - .small-12.large-6.columns - %label{ for: 'contact_surname' }   - %input.chunky.small-12.columns{ id: 'contact_surname', placeholder: "Surname", ng: { model: 'enterprise.contact.surname' } } + .small-12.columns + %label{ for: 'enterprise_contact' } Primary Contact: + %input.chunky.small-12.columns{ id: 'enterprise_contact', placeholder: "Contact Name", ng: { model: 'enterprise.contact' } } .row .small-12.columns - %label{ for: 'contact_email' } Email address: - %input.chunky.small-12.columns{ id: 'contact_email', placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.contact.email' } } + %label{ for: 'enterprise_email' } Email address: + %input.chunky.small-12.columns{ id: 'enterprise_email', placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.email' } } .row .small-12.columns - %label{ for: 'contact_phone' } Phone number: - %input.chunky.small-12.columns{ id: 'contact_phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.contact.phone' } } + %label{ for: 'enterprise_phone' } Phone number: + %input.chunky.small-12.columns{ id: 'enterprise_phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.phone' } } .small-12.large-4.columns %h6 Contact display @@ -27,14 +24,14 @@ .row .small-12.columns %label.indent-checkbox - %input{ type: 'checkbox', id: 'contact_name_profile', ng: { model: 'enterprise.contact.name_in_profile' } }   Display name in profile + %input{ type: 'checkbox', id: 'contact_name_profile', ng: { model: 'enterprise.name_in_profile' } }   Display name in profile .small-12.columns %label.indent-checkbox - %input{ type: 'checkbox', id: 'contact_email_profile', ng: { model: 'enterprise.contact.email_in_profile' } }   Display email in profile + %input{ type: 'checkbox', id: 'contact_email_profile', ng: { model: 'enterprise.email_in_profile' } }   Display email in profile .small-12.columns %label.indent-checkbox - %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.contact.phone_in_profile' } }   Display phone in profile + %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.phone_in_profile' } }   Display phone in profile .row .small-12.columns %input.button.primary{ type: "button", value: "Back", ng: { click: "select('address')" }, style: 'float:left' } - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" }, style: 'float:right' } \ No newline at end of file + %input.button.primary{ type: "button", value: "Continue", ng: { click: "createEnterprise()" }, style: 'float:right' } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index fb346d6959..c662f37985 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -13,7 +13,7 @@ .small-12.columns %label Choose One: .medium-12.large-4.columns{ 'data-equalizer-watch' => true } - %a.small-12.columns.panel#producer{ href: "#", ng: { click: "enterprise.type = 'producer'", class: "{selected: enterprise.type == 'producer'}" } } + %a.small-12.columns.panel#producer{ href: "#", ng: { click: "enterprise.is_distributor = false; enterprise.is_primary_producer = true", class: "{selected: (!enterprise.is_distributor && enterprise.is_primary_producer)}" } } .small-2.columns %i.ofn-i_036-producers .small-10.columns @@ -21,7 +21,7 @@ %span{ style: 'font-size: 80%'} Producers are anyone making things to eat & drink - whether you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. .medium-12.large-4.columns{ 'data-equalizer-watch' => true } - %a.small-12.columns.panel#hub{ href: "#", ng: { click: "enterprise.type = 'hub'", class: "{selected: enterprise.type == 'hub'}" } } + %a.small-12.columns.panel#hub{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = false", class: "{selected: (enterprise.is_distributor && !enterprise.is_primary_producer)}" } } .small-2.columns %i.ofn-i_040-hub .small-10.columns @@ -29,7 +29,7 @@ %span{ style: 'font-size: 80%'} Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, etc... .medium-12.large-4.columns{ 'data-equalizer-watch' => true } - %a.small-12.columns.panel#both{ href: "#", ng: { click: "enterprise.type = 'both'", class: "{selected: enterprise.type == 'both'}" } } + %a.small-12.columns.panel#both{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = true", class: "{selected: (enterprise.is_distributor && enterprise.is_primary_producer)}" } } .small-2.columns %i.ofn-i_039-delivery .small-10.columns diff --git a/app/controllers/api/enterprises_controller.rb b/app/controllers/api/enterprises_controller.rb index 3dee7962c4..ed6be3d15b 100644 --- a/app/controllers/api/enterprises_controller.rb +++ b/app/controllers/api/enterprises_controller.rb @@ -11,5 +11,16 @@ module Api @enterprises = Enterprise.ransack(params[:q]).result.accessible_by(current_api_user) render params[:template] || :bulk_index end + + def create + #authorize! :create, Enterprise + + @enterprise = Enterprise.new(params[:enterprise]) + if @enterprise.save + render text: '', :status => 201 + else + invalid_resource!(@enterprise) + end + end end end diff --git a/app/controllers/registration_controller.rb b/app/controllers/registration_controller.rb index c1d79db49c..2915f71639 100644 --- a/app/controllers/registration_controller.rb +++ b/app/controllers/registration_controller.rb @@ -1,4 +1,8 @@ +require 'open_food_network/spree_api_key_loader' + class RegistrationController < BaseController + include OpenFoodNetwork::SpreeApiKeyLoader + before_filter :load_spree_api_key, :only => :index layout 'registration' def index diff --git a/app/helpers/admin/injection_helper.rb b/app/helpers/admin/injection_helper.rb index 115bc8d0c5..7fec829fe7 100644 --- a/app/helpers/admin/injection_helper.rb +++ b/app/helpers/admin/injection_helper.rb @@ -38,7 +38,7 @@ module Admin end def admin_inject_spree_api_key - render partial: "admin/json/injection_ams", locals: {ngModule: 'ofn.admin', name: 'SpreeApiKey', json: "'#{@spree_api_key}'"} + render partial: "admin/json/injection_ams", locals: {ngModule: 'ofn.admin', name: 'SpreeApiKey', json: "'#{@spree_api_key.to_s}'"} end diff --git a/app/helpers/injection_helper.rb b/app/helpers/injection_helper.rb index c639d22104..8ef6b9b43f 100644 --- a/app/helpers/injection_helper.rb +++ b/app/helpers/injection_helper.rb @@ -21,6 +21,10 @@ module InjectionHelper inject_json_ams "taxons", Spree::Taxon.all, Api::TaxonSerializer end + def inject_spree_api_key + render partial: "json/injection_ams", locals: {name: 'SpreeApiKey', json: "'#{@spree_api_key.to_s}'"} + end + def inject_json(name, partial, opts = {}) render partial: "json/injection", locals: {name: name, partial: partial}.merge(opts) end diff --git a/app/views/registration/index.html.haml b/app/views/registration/index.html.haml index a1e8da858d..5d883c43ae 100644 --- a/app/views/registration/index.html.haml +++ b/app/views/registration/index.html.haml @@ -1 +1,2 @@ +=inject_spree_api_key %div{ "ng-controller" => "RegistrationCtrl" } \ No newline at end of file diff --git a/lib/open_food_network/spree_api_key_loader.rb b/lib/open_food_network/spree_api_key_loader.rb index 0612cb4f3b..36fa4b9961 100644 --- a/lib/open_food_network/spree_api_key_loader.rb +++ b/lib/open_food_network/spree_api_key_loader.rb @@ -1,8 +1,12 @@ module OpenFoodNetwork module SpreeApiKeyLoader def load_spree_api_key - current_user.generate_spree_api_key! unless spree_current_user.spree_api_key - @spree_api_key = spree_current_user.spree_api_key + if spree_current_user + spree_current_user.generate_spree_api_key! unless spree_current_user.spree_api_key + @spree_api_key = spree_current_user.spree_api_key + else + @spree_api_key = nil + end end end end \ No newline at end of file diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index c0bdba9810..592ee789e2 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -23,10 +23,30 @@ feature "Registration", js: true do # Filling in details expect(page).to have_content "Woot! First we need to know what sort of enterprise you are:" - fill_in 'enterprise_name', with: "My Awesome Enterprise" - click_link "both" - click_button "Continue" + click_link 'both' + click_button 'Continue' + + # Filling in address + expect(page).to have_content 'My Awesome Enterprise' + fill_in 'enterprise_address', with: '123 Abc Street' + fill_in 'enterprise_city', with: 'Northcote' + fill_in 'enterprise_zipcode', with: '3070' + fill_in 'enterprise_country', with: 'Australia' + fill_in 'enterprise_state', with: 'Victoria' + click_button 'Continue' + + # Filling in Contact Details + expect(page).to have_content 'Who is responsible for managing My Awesome Enterprise?' + fill_in 'enterprise_contact', with: 'Saskia Munroe' + page.should have_field 'enterprise_email', with: user.email + fill_in 'enterprise_phone', with: '12 3456 7890' + click_button 'Continue' + + # Enterprise should be created + sleep 10 + save_screenshot '/Users/rob/Desktop/ss.png' + expect(page).to have_content 'Yay! You created an enterprise!' end end end From ef8f611458aab5e2f21b07ae50ecbb97e4cdb0f7 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 21 Aug 2014 14:06:41 +1000 Subject: [PATCH 046/120] Adding countries and states to registration --- .../registration_controller.js.coffee | 38 +++---------------- .../enterprise_creation_service.js.coffee | 31 +++++++++++++++ .../templates/registration/about.html.haml | 2 +- .../templates/registration/address.html.haml | 9 +---- .../templates/registration/contact.html.haml | 2 +- app/helpers/injection_helper.rb | 4 ++ app/serializers/api/country_serializer.rb | 5 +++ app/serializers/api/state_serializer.rb | 3 ++ app/views/registration/index.html.haml | 1 + spec/features/consumer/registration_spec.rb | 6 +-- 10 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee create mode 100644 app/serializers/api/country_serializer.rb create mode 100644 app/serializers/api/state_serializer.rb diff --git a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee index 7fa8ad0350..dc1bb2a80e 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee @@ -1,39 +1,13 @@ -Darkswarm.controller "RegistrationCtrl", ($scope, $http, RegistrationService, CurrentUser, SpreeApiKey) -> - $scope.current_user = CurrentUser - +Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, EnterpriseCreationService, availableCountries) -> $scope.currentStep = RegistrationService.currentStep $scope.select = RegistrationService.select + $scope.enterprise = EnterpriseCreationService.enterprise + $scope.create = EnterpriseCreationService.create $scope.steps = ['details','address','contact','about'] # ,'images','social' - $scope.enterprise = - user_ids: [CurrentUser.id] - email: CurrentUser.email - address: { - country_id: 12 - state_id: 1061493592 - } + $scope.countries = availableCountries - $scope.createEnterprise = -> - $http( - method: "POST" - url: "/api/enterprises" - data: - enterprise: $scope.prepare($scope.enterprise) - params: - token: SpreeApiKey - ).success((data) -> - $scope.select('about') - ).error((data) -> - console.log angular.toJson(data) - alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') - ) - # $scope.select('about') - - $scope.prepare = (ent_obj) -> - enterprise = {} - for a, v of ent_obj when a isnt 'address' - enterprise[a] = v - enterprise.address_attributes = ent_obj.address - enterprise + $scope.countryHasStates = -> + $scope.enterprise.country.states.length > 0 diff --git a/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee new file mode 100644 index 0000000000..f23f11700a --- /dev/null +++ b/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee @@ -0,0 +1,31 @@ +Darkswarm.factory "EnterpriseCreationService", ($http, RegistrationService, CurrentUser, SpreeApiKey, availableCountries) -> + new class EnterpriseCreationService + enterprise: + user_ids: [CurrentUser.id] + email: CurrentUser.email + address: {} + country: availableCountries[0] + + create: => + $http( + method: "POST" + url: "/api/enterprises" + data: + enterprise: @prepare() + params: + token: SpreeApiKey + ).success((data) -> + RegistrationService.select('about') + ).error((data) -> + console.log angular.toJson(data) + alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') + ) + # RegistrationService.select('about') + + prepare: => + enterprise = {} + for a, v of @enterprise when a isnt 'address' && a isnt 'country' + enterprise[a] = v + enterprise.address_attributes = @enterprise.address + enterprise.address_attributes.country_id = @enterprise.country.id + enterprise \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index 5dac45cb13..ad44ebbf7f 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -1 +1 @@ -YAY! You created an enterprise! \ No newline at end of file +Yay! You created an enterprise! \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index 4b4db863fe..ffea2db77d 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -19,15 +19,10 @@ .row .small-12.large-8.columns %label{ for: 'enterprise_country' } Country: - -#= select :country_id, available_countries.map{|c|[c.name, c.id]}, {include_blank: false} - %input.chunky.small-12.columns{ id: 'enterprise_country', placeholder: "eg. Australia" } - -# , ng: { model: 'enterprise.country' } } + %select.chunky.small-12.columns{ id: 'enterprise_country', ng: { model: 'enterprise.country', options: 'c as c.name for c in countries' } } .small-12.large-4.columns %label{ for: 'enterprise_state' } State: - - binding.pry - -#= select :state_id, available_countries.first.states.map{|c|[c.name, c.id]} - %input.chunky.small-12.columns{ id: 'enterprise_state', placeholder: "eg. Victoria" } - -# , ng: { model: 'enterprise.state' } } + %select.chunky.small-12.columns{ id: 'enterprise_state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()' } } .small-5.columns %h6 Location display diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 40c7948767..4ac93894c0 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -34,4 +34,4 @@ .row .small-12.columns %input.button.primary{ type: "button", value: "Back", ng: { click: "select('address')" }, style: 'float:left' } - %input.button.primary{ type: "button", value: "Continue", ng: { click: "createEnterprise()" }, style: 'float:right' } \ No newline at end of file + %input.button.primary{ type: "button", value: "Continue", ng: { click: "create()" }, style: 'float:right' } \ No newline at end of file diff --git a/app/helpers/injection_helper.rb b/app/helpers/injection_helper.rb index 8ef6b9b43f..a43fab3b4c 100644 --- a/app/helpers/injection_helper.rb +++ b/app/helpers/injection_helper.rb @@ -25,6 +25,10 @@ module InjectionHelper render partial: "json/injection_ams", locals: {name: 'SpreeApiKey', json: "'#{@spree_api_key.to_s}'"} end + def inject_available_countries + inject_json_ams "availableCountries", available_countries, Api::CountrySerializer + end + def inject_json(name, partial, opts = {}) render partial: "json/injection", locals: {name: name, partial: partial}.merge(opts) end diff --git a/app/serializers/api/country_serializer.rb b/app/serializers/api/country_serializer.rb new file mode 100644 index 0000000000..6561692cf6 --- /dev/null +++ b/app/serializers/api/country_serializer.rb @@ -0,0 +1,5 @@ +class Api::CountrySerializer < ActiveModel::Serializer + attributes :id, :name, :states + + has_many :states, serializer: Api::StateSerializer +end \ No newline at end of file diff --git a/app/serializers/api/state_serializer.rb b/app/serializers/api/state_serializer.rb new file mode 100644 index 0000000000..bcf9221ec5 --- /dev/null +++ b/app/serializers/api/state_serializer.rb @@ -0,0 +1,3 @@ +class Api::StateSerializer < ActiveModel::Serializer + attributes :id, :name, :abbr +end \ No newline at end of file diff --git a/app/views/registration/index.html.haml b/app/views/registration/index.html.haml index 5d883c43ae..205b3582bb 100644 --- a/app/views/registration/index.html.haml +++ b/app/views/registration/index.html.haml @@ -1,2 +1,3 @@ =inject_spree_api_key +=inject_available_countries %div{ "ng-controller" => "RegistrationCtrl" } \ No newline at end of file diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 592ee789e2..5041aae1a5 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -32,8 +32,8 @@ feature "Registration", js: true do fill_in 'enterprise_address', with: '123 Abc Street' fill_in 'enterprise_city', with: 'Northcote' fill_in 'enterprise_zipcode', with: '3070' - fill_in 'enterprise_country', with: 'Australia' - fill_in 'enterprise_state', with: 'Victoria' + select 'Australia', from: 'enterprise_country' + select 'Vic', from: 'enterprise_state' click_button 'Continue' # Filling in Contact Details @@ -44,8 +44,6 @@ feature "Registration", js: true do click_button 'Continue' # Enterprise should be created - sleep 10 - save_screenshot '/Users/rob/Desktop/ss.png' expect(page).to have_content 'Yay! You created an enterprise!' end end From 69b1d14cc4e019070d14075ce36a2892a0220229 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 21 Aug 2014 14:16:44 +1000 Subject: [PATCH 047/120] Adding authorize to api enterprise create --- app/controllers/api/enterprises_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/enterprises_controller.rb b/app/controllers/api/enterprises_controller.rb index ed6be3d15b..d80e10849a 100644 --- a/app/controllers/api/enterprises_controller.rb +++ b/app/controllers/api/enterprises_controller.rb @@ -13,7 +13,7 @@ module Api end def create - #authorize! :create, Enterprise + authorize! :create, Enterprise @enterprise = Enterprise.new(params[:enterprise]) if @enterprise.save From 4d106129ee90ae6c7cbd1e39cc385b29b9387f8a Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 21 Aug 2014 15:29:23 +1000 Subject: [PATCH 048/120] Creating an about page including flash boxes for registration --- .../directives/inline_flash.js.coffee | 6 ++++ .../enterprise_creation_service.js.coffee | 28 +++++++-------- .../templates/registration/about.html.haml | 36 ++++++++++++++++++- .../darkswarm/registration.css.sass | 18 ++++++++++ 4 files changed, 73 insertions(+), 15 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/directives/inline_flash.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/inline_flash.js.coffee b/app/assets/javascripts/darkswarm/directives/inline_flash.js.coffee new file mode 100644 index 0000000000..46550b854f --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/inline_flash.js.coffee @@ -0,0 +1,6 @@ +Darkswarm.directive "ofnInlineFlash", -> + restrict: 'E' + controller: ($scope) -> + $scope.visible = true + $scope.closeFlash = -> + $scope.visible = false diff --git a/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee index f23f11700a..5898cdf1c3 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee @@ -7,20 +7,20 @@ Darkswarm.factory "EnterpriseCreationService", ($http, RegistrationService, Curr country: availableCountries[0] create: => - $http( - method: "POST" - url: "/api/enterprises" - data: - enterprise: @prepare() - params: - token: SpreeApiKey - ).success((data) -> - RegistrationService.select('about') - ).error((data) -> - console.log angular.toJson(data) - alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') - ) - # RegistrationService.select('about') + # $http( + # method: "POST" + # url: "/api/enterprises" + # data: + # enterprise: @prepare() + # params: + # token: SpreeApiKey + # ).success((data) -> + # RegistrationService.select('about') + # ).error((data) -> + # console.log angular.toJson(data) + # alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') + # ) + RegistrationService.select('about') prepare: => enterprise = {} diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index ad44ebbf7f..faed853791 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -1 +1,35 @@ -Yay! You created an enterprise! \ No newline at end of file +.container#registration-contact + .row.header + %h2 Nice one! + %h5 Now let's flesh out the details about {{ enterprise.name }}. + %ng-include{ src: "'registration/steps.html'" } + .row.content + %ofn-inline-flash.turquoise.small-12.columns{ ng: { show: 'visible' } } + %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } + {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. + %ofn-inline-flash.brick.small-12.columns{ ng: { show: 'visible' } } + %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } + {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. + + .small-12.large-8.columns + .row + .small-12.columns + %label{ for: 'enterprise_description' } Short Description: + %input.chunky.small-12.columns{ id: 'enterprise_description', placeholder: "A short sentence describing your enterprise", ng: { model: 'enterprise.description' } } + .row + .small-12.columns + %label{ for: 'enterprise_long_desc' } Long Description: + %textarea.chunky.small-12.columns{ id: 'enterprise_long_desc', placeholder: "We recommend keeping you description to under 600 characters or 150 words. Why? Cus people are lazy, and don't like to read too much text online. ;)", ng: { model: 'enterprise.long_description' } } + {{ enterprise.long_description.length }} characters used + .small-12.large-4.columns + .row + .small-12.columns + %label{ for: 'enterprise_abn' } ABN: + %input.chunky.small-12.columns{ id: 'enterprise_abn', placeholder: "eg. 99 123 456 789", ng: { model: 'enterprise.abn' } } + .row + .small-12.columns + %label{ for: 'enterprise_acn' } ACN: + %input.chunky.small-12.columns{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } + .row + .small-12.columns + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('images')" }, style: 'float:right' } \ No newline at end of file diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index e12c00f17b..c48737f7e3 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -12,6 +12,24 @@ i font-size: 150% + ofn-inline-flash + display: block + padding: 15px + position: relative + margin-bottom: 10px + &.brick + background-color: $clr-brick-light + border: 2px solid $clr-brick + color: $clr-brick + &.turquoise + background-color: $clr-turquoise-light + border: 2px solid $clr-turquoise + color: $clr-turquoise + .close-button + position: absolute + top: 0px + right: 0px + input.chunky padding: 8px font-size: 105% From e341b12d3a1dc49bd384ee2d9df6a5b7a6c01eda Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 21 Aug 2014 15:33:25 +1000 Subject: [PATCH 049/120] Adding loading message when creating enterprise --- .../darkswarm/services/enterprise_creation_service.js.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee index 5898cdf1c3..e5400f1b46 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee @@ -7,6 +7,7 @@ Darkswarm.factory "EnterpriseCreationService", ($http, RegistrationService, Curr country: availableCountries[0] create: => + # Loading.message = "Creating " + $scope.enterprise.name # $http( # method: "POST" # url: "/api/enterprises" @@ -15,8 +16,10 @@ Darkswarm.factory "EnterpriseCreationService", ($http, RegistrationService, Curr # params: # token: SpreeApiKey # ).success((data) -> + # Loading.clear() # RegistrationService.select('about') # ).error((data) -> + # Loading.clear() # console.log angular.toJson(data) # alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') # ) From b848d583ff5d773c7b9c568fa9ccf3d65db26268 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 21 Aug 2014 15:57:39 +1000 Subject: [PATCH 050/120] Adding the remainder of pages to registration process --- .../controllers/registration_controller.js.coffee | 3 +-- .../javascripts/templates/registration.html.haml | 2 ++ .../templates/registration/about.html.haml | 6 +++--- .../templates/registration/address.html.haml | 6 +++--- .../templates/registration/contact.html.haml | 6 +++--- .../templates/registration/details.html.haml | 4 ++-- .../templates/registration/finished.html.haml | 14 ++++++++++++++ .../templates/registration/images.html.haml | 11 +++++++++++ .../templates/registration/social.html.haml | 11 +++++++++++ .../stylesheets/darkswarm/registration.css.sass | 6 ++++++ 10 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 app/assets/javascripts/templates/registration/finished.html.haml create mode 100644 app/assets/javascripts/templates/registration/images.html.haml create mode 100644 app/assets/javascripts/templates/registration/social.html.haml diff --git a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee index dc1bb2a80e..3e9dddb2d4 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee @@ -4,8 +4,7 @@ Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, Enterpris $scope.enterprise = EnterpriseCreationService.enterprise $scope.create = EnterpriseCreationService.create - $scope.steps = ['details','address','contact','about'] - # ,'images','social' + $scope.steps = ['details','address','contact','about','images','social'] $scope.countries = availableCountries diff --git a/app/assets/javascripts/templates/registration.html.haml b/app/assets/javascripts/templates/registration.html.haml index dba05f3429..10a12d712e 100644 --- a/app/assets/javascripts/templates/registration.html.haml +++ b/app/assets/javascripts/templates/registration.html.haml @@ -3,6 +3,8 @@ %ng-include{ src: "'registration/introduction.html'" } %div{ ng: { repeat: 'step in steps', show: "currentStep() == step" } } %ng-include{ src: "'registration/'+ step + '.html'" } + %div{ ng: { show: "currentStep() == 'finished'" } } + %ng-include{ src: "'registration/finished.html'" } %a.close-reveal-modal{"ng-click" => "$close()"} %i.ofn-i_009-close diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index faed853791..1d6363c0c8 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -1,4 +1,4 @@ -.container#registration-contact +.container#registration-about .row.header %h2 Nice one! %h5 Now let's flesh out the details about {{ enterprise.name }}. @@ -30,6 +30,6 @@ .small-12.columns %label{ for: 'enterprise_acn' } ACN: %input.chunky.small-12.columns{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } - .row + .row.buttons .small-12.columns - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('images')" }, style: 'float:right' } \ No newline at end of file + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('images')" } } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index ffea2db77d..98a3ccd2a9 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -36,7 +36,7 @@ %label.indent-checkbox %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } Blur my location on the map (show an approximate, not exact pin) - .row + .row.buttons .small-12.columns - %input.button.primary{ type: "button", value: "Back", ng: { click: "select('details')" }, style: 'float:left' } - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" }, style: 'float:right' } + %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('details')" } } + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('contact')" } } diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 4ac93894c0..fe342d73e0 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -31,7 +31,7 @@ .small-12.columns %label.indent-checkbox %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.phone_in_profile' } }   Display phone in profile - .row + .row.buttons .small-12.columns - %input.button.primary{ type: "button", value: "Back", ng: { click: "select('address')" }, style: 'float:left' } - %input.button.primary{ type: "button", value: "Continue", ng: { click: "create()" }, style: 'float:right' } \ No newline at end of file + %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('address')" } } + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "create()" } } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index c662f37985..cad5449e6b 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -35,8 +35,8 @@ .small-10.columns %h6 I'm Both %span{ style: 'font-size: 80%'} Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! - .row + .row.buttons .small-12.columns - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" }, style: 'float:right' } + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('address')" } } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/finished.html.haml b/app/assets/javascripts/templates/registration/finished.html.haml new file mode 100644 index 0000000000..b2150f8f1c --- /dev/null +++ b/app/assets/javascripts/templates/registration/finished.html.haml @@ -0,0 +1,14 @@ +.container#registration-finished + .row.header + %h2 Well done! + %h5 You have successfully completed the profile for {{ enterprise.name }}! + .row.content{ style: 'text-align: center'} + %h3 Why not check it out on the Open Food Network? + %a.button.primary{ type: "button", href: "/map" } Go to Map Page > + + %br + %br + + %h3 Next step - add some products: + %a.button.primary{ type: "button", href: "/admin/products/new" } Add a Product > + \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/images.html.haml b/app/assets/javascripts/templates/registration/images.html.haml new file mode 100644 index 0000000000..92c3c9f703 --- /dev/null +++ b/app/assets/javascripts/templates/registration/images.html.haml @@ -0,0 +1,11 @@ +.container#registration-images + .row.header + %h2 Thanks! + %h5 Let's upload some pretty pictures so your profile looks great! :) + %ng-include{ src: "'registration/steps.html'" } + .row.content + + .row.buttons + .small-12.columns + %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('about')" } } + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('social')" } } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml new file mode 100644 index 0000000000..32ffb75c1a --- /dev/null +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -0,0 +1,11 @@ +.container#registration-social + .row.header + %h2 Last step! + %h5 How can people find {{ enterprise.name }} online? + %ng-include{ src: "'registration/steps.html'" } + .row.content + + .row.buttons + .small-12.columns + %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('images')" } } + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('finished')" } } \ No newline at end of file diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index c48737f7e3..fcc64dbdb2 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -12,6 +12,12 @@ i font-size: 150% + .buttons + .right + float: right + .left + float: left + ofn-inline-flash display: block padding: 15px From bc0c9dd2295a2e3ef2552132a9c6632c41d55ced Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 21 Aug 2014 16:07:39 +1000 Subject: [PATCH 051/120] Adding the social page to registration form --- .../templates/registration/about.html.haml | 2 +- .../templates/registration/social.html.haml | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index 1d6363c0c8..26d0c8e9f5 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -32,4 +32,4 @@ %input.chunky.small-12.columns{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } .row.buttons .small-12.columns - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('images')" } } \ No newline at end of file + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('social')" } } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml index 32ffb75c1a..c66e4422bd 100644 --- a/app/assets/javascripts/templates/registration/social.html.haml +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -4,8 +4,30 @@ %h5 How can people find {{ enterprise.name }} online? %ng-include{ src: "'registration/steps.html'" } .row.content + .small-12.large-7.columns + .row + .small-12.columns + %label{ for: 'enterprise_website' } Website: + %input.chunky.small-12.columns{ id: 'enterprise_website', placeholder: "eg. openfoodnetwork.org.au", ng: { model: 'enterprise.website' } } + .row + .small-12.columns + %label{ for: 'enterprise_facebook' } Facebook: + %input.chunky.small-12.columns{ id: 'enterprise_facebook', placeholder: "eg. www.facebook.com/PageNameHere", ng: { model: 'enterprise.facebook' } } + .row + .small-12.columns + %label{ for: 'enterprise_linkedin' } LinkedIn: + %input.chunky.small-12.columns{ id: 'enterprise_linkedin', placeholder: "eg. www.linkedin.com/YourNameHere", ng: { model: 'enterprise.linkedin' } } + .small-12.large-5.columns + .row + .small-12.columns + %label{ for: 'enterprise_twitter' } Twitter: + %input.chunky.small-12.columns{ id: 'enterprise_twitter', placeholder: "eg. @twitter_handle", ng: { model: 'enterprise.twitter' } } + .row + .small-12.columns + %label{ for: 'enterprise_instagram' } Instagram: + %input.chunky.small-12.columns{ id: 'enterprise_instagram', placeholder: "eg. @instagram_handle", ng: { model: 'enterprise.instagram' } } .row.buttons .small-12.columns - %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('images')" } } + %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('about')" } } %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('finished')" } } \ No newline at end of file From dc43612a04097370283ab57617b9738dde4fec0b Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 21 Aug 2014 16:08:43 +1000 Subject: [PATCH 052/120] Adding an 'r' --- app/assets/javascripts/templates/registration/about.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index 26d0c8e9f5..29ec5282b1 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -19,7 +19,7 @@ .row .small-12.columns %label{ for: 'enterprise_long_desc' } Long Description: - %textarea.chunky.small-12.columns{ id: 'enterprise_long_desc', placeholder: "We recommend keeping you description to under 600 characters or 150 words. Why? Cus people are lazy, and don't like to read too much text online. ;)", ng: { model: 'enterprise.long_description' } } + %textarea.chunky.small-12.columns{ id: 'enterprise_long_desc', placeholder: "We recommend keeping your description to under 600 characters or 150 words. Why? Cus people are lazy, and don't like to read too much text online. ;)", ng: { model: 'enterprise.long_description' } } {{ enterprise.long_description.length }} characters used .small-12.large-4.columns .row From 60d6599f9b30eb90802ce4c15fba27c2d996eba7 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 21 Aug 2014 16:28:13 +1000 Subject: [PATCH 053/120] Tweak chirpy message in view --- app/assets/javascripts/templates/registration/address.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index 98a3ccd2a9..f395703a1b 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -1,6 +1,6 @@ .container#registration-address .row.header - %h2 {{ enterprise.name }} + %h2 Hi there, {{ enterprise.name }} %h5 Now we need to know where you are: %ng-include{ src: "'registration/steps.html'" } .row.content From f1f9a2e7fc506dbf41b6951da0b792136cbdfa1d Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 21 Aug 2014 17:04:40 +1000 Subject: [PATCH 054/120] Updating on later pages of registration process --- .../registration_controller.js.coffee | 7 ++- .../enterprise_creation_service.js.coffee | 60 ++++++++++++------- .../templates/registration/about.html.haml | 2 +- .../templates/registration/social.html.haml | 2 +- app/controllers/api/enterprises_controller.rb | 13 +++- 5 files changed, 58 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee index 3e9dddb2d4..2cf7c50c8d 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee @@ -1,8 +1,9 @@ -Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, EnterpriseCreationService, availableCountries) -> +Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, EnterpriseRegistrationService, availableCountries) -> $scope.currentStep = RegistrationService.currentStep $scope.select = RegistrationService.select - $scope.enterprise = EnterpriseCreationService.enterprise - $scope.create = EnterpriseCreationService.create + $scope.enterprise = EnterpriseRegistrationService.enterprise + $scope.create = EnterpriseRegistrationService.create + $scope.update = EnterpriseRegistrationService.update $scope.steps = ['details','address','contact','about','images','social'] diff --git a/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee index e5400f1b46..52baea146a 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee @@ -1,5 +1,5 @@ -Darkswarm.factory "EnterpriseCreationService", ($http, RegistrationService, CurrentUser, SpreeApiKey, availableCountries) -> - new class EnterpriseCreationService +Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, CurrentUser, SpreeApiKey, Loading, availableCountries) -> + new class EnterpriseRegistrationService enterprise: user_ids: [CurrentUser.id] email: CurrentUser.email @@ -7,27 +7,47 @@ Darkswarm.factory "EnterpriseCreationService", ($http, RegistrationService, Curr country: availableCountries[0] create: => - # Loading.message = "Creating " + $scope.enterprise.name - # $http( - # method: "POST" - # url: "/api/enterprises" - # data: - # enterprise: @prepare() - # params: - # token: SpreeApiKey - # ).success((data) -> - # Loading.clear() - # RegistrationService.select('about') - # ).error((data) -> - # Loading.clear() - # console.log angular.toJson(data) - # alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') - # ) - RegistrationService.select('about') + Loading.message = "Creating " + @enterprise.name + $http( + method: "POST" + url: "/api/enterprises" + data: + enterprise: @prepare() + params: + token: SpreeApiKey + ).success((data) => + Loading.clear() + @enterprise.id = data + RegistrationService.select('about') + ).error((data) => + Loading.clear() + console.log angular.toJson(data) + alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') + ) + #RegistrationService.select('about') + + update: (step) => + Loading.message = "Updating " + @enterprise.name + $http( + method: "PUT" + url: "/api/enterprises/#{@enterprise.id}" + data: + enterprise: @prepare() + params: + 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.') + ) + #RegistrationService.select(step) prepare: => enterprise = {} - for a, v of @enterprise when a isnt 'address' && a isnt 'country' + for a, v of @enterprise when a isnt 'address' && a isnt 'country' && a isnt 'id' enterprise[a] = v enterprise.address_attributes = @enterprise.address enterprise.address_attributes.country_id = @enterprise.country.id diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index 29ec5282b1..e2dad4a66b 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -32,4 +32,4 @@ %input.chunky.small-12.columns{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } .row.buttons .small-12.columns - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('social')" } } \ No newline at end of file + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "update('social')" } } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml index c66e4422bd..40717b6190 100644 --- a/app/assets/javascripts/templates/registration/social.html.haml +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -30,4 +30,4 @@ .row.buttons .small-12.columns %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('about')" } } - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('finished')" } } \ No newline at end of file + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "update('finished')" } } \ No newline at end of file diff --git a/app/controllers/api/enterprises_controller.rb b/app/controllers/api/enterprises_controller.rb index d80e10849a..f2263a600b 100644 --- a/app/controllers/api/enterprises_controller.rb +++ b/app/controllers/api/enterprises_controller.rb @@ -17,7 +17,18 @@ module Api @enterprise = Enterprise.new(params[:enterprise]) if @enterprise.save - render text: '', :status => 201 + render text: @enterprise.id, :status => 201 + else + invalid_resource!(@enterprise) + end + end + + def update + authorize! :update, Enterprise + + @enterprise = Enterprise.find(params[:id]) + if @enterprise.update_attributes(params[:enterprise]) + render text: @enterprise.id, :status => 200 else invalid_resource!(@enterprise) end From db58fb5b0c60bdb3660da3a153e0980e1ac26850 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 12:11:00 +1000 Subject: [PATCH 055/120] Pretty potatoes picture for creating profile wizard --- app/assets/images/potatoes.png | Bin 0 -> 8359 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/assets/images/potatoes.png diff --git a/app/assets/images/potatoes.png b/app/assets/images/potatoes.png new file mode 100644 index 0000000000000000000000000000000000000000..c0be04200eb85384da0773ade028c9ef4a7a4109 GIT binary patch literal 8359 zcmV;YAXwjtP)BH-r+PqIlz==jbc}r($$ozpN_4kvghh8I5jvL z6o|XKDiacCy23*(7eH1?Oj}T-dQ6$c!5t_ibEl?Pla+Uxlsa#3dc)4E&B!)%bY-TU z6*V*g0RdSQ7i1S2p(!+Y9VF_)aoeg)=ek*L868a*8m=unizhSczGOTM4wfl4Z6GJ| z(ufy0H{-KTAq@-h$!ESbNvAGDLKzy0A}5|KJ}eUw_0emAA0^?kUhKeFfg>-JB`#?( zGc_0(1`iMEyGgb&Lv|)GN)8UlI8DI&{O`$g^Vyx;v1{$hf#JJ-<+x|^$X)p3qUp$u z^U{0Wu2(Jx3a$J7%RX4~$50F@DOVgM_}YKaoK%@KKVu;%O(P?-Hci!{N)7}A)=+ZU zL}`IDI&?ZY2pSqHVPN*qTHUEUHg|RzL`3k^md>bf@WE&uPg8&-aF0(+^2b2mypj0bi!f_! z*j{_blvs#iKjX1G^4qKFft}7(Y0f)kwMAaqr(3|2Pnc&tz>G3mEiaX2Eq*dAo%sD@ z!p>5sukWC(wpL`sjYM}%Dfs8I_F{N%RT01CZM6~8tQhDyK{QpUTCO!Oj}MmZ%;XMKN@h= zXG~dzeXC<`o@ZK%!@n{zEAs#U z+`^|vHZJGQD5`qqmauk~Gl#^q2M`2L@T<01#!I|!dqV>dWEFHKZmTdFE z*bjngLyCpq(8Xv^wpwBjs+DQvXhh$7)bCof_aAUC-tW)*-goPMAAVe_88Ek|)v`M7H-z3=@~j!Al=`@k#Qt9&O%Q z#o_!X&Q@|FEz{Y2dWHu{*1YjG!VsW-_-(K+#>?(4GXVr;( z@5`(pqmT?U41zF<)OkV1>U)+i6xeJw843Z`mlU_N;98hb;QZ~Y2%w`vl&{6 zs!#=v;|PK%95R{C*ED4`8Z8z}J{;$ALi7k)RNU%+FF#SWoeey=^Sop zK~a=Y;1Go1N<}~*5M)GF+th6fK>2*eS7oVGOnFW1?ItgUsnz;bfwmNR2GKBWADc@# z>L3DDsT8faBp6h(G6EpO+ilyn8GSaJ^;MaHVGMARNy>{7Vrk84Ko#<$G1DqZjSkH{ z?3k?sh9Ib}P8rlHhZh6_*{!b8=!db`i(8q6vV;Mtp~~bF=gOOQli=>UJxffP)M5H}Cb??+a_eO28h6UyA`d zr`^e9((87+y_8sb&8)v=wM_Mf3p=X*fT}7!nx^?QL)Fc8(Ei+PsTrIHlB(4bkC5)W z8>wf&)sqz0+jL`J=_iNl5jRtTO>RPjY&|tkCkB7tTEt{(=IKPc8;h+(mKs$2H z*K;{OtyF^47_~DZ^z^+@Qv@g%q0qYQHLW;Cedb*6|AL`VsPqgM+S4R;!YwRH*7Ade_N==lUL89k_hz;Kfai0|Sj0 z8XKR+%r!7*97IqQfhojDD})El_U@kX*r;9$2J!L8rpHgfuS`>%OD-<*IN!AT6BX7P z)6^M;({9W$x6EZ(mMq(!E$8%pftFL?&?>#4g;II}Yq>ew6HvZ znJ!Sn>gi`Q-Pf_v%wnaG|M$}ba!QJjOX_W#IN#CtQ#`N|nT0Di zx!o_I)ZD=UY?6Q9-bp%;g`C^WgkCH!kF+}Mb~}N|%t)s*g4NykuMgerF4dqYUNvKM zL{i%eCX1Cqau8s57@3#AW3jlTw$Z-HzKIhRAreKLRVuX__PawNq%&}J?x}A*uLmaW zyLBr!_Xq?%tg#dLs&qS@fQu@iGux*D%H5&v((q^vDi|Ji*_r({j>$9@FFu}^lENZ$ zS>U7hWApY}?b_9bhO6Ie zo5E=*Dsb6xJp~?bTeXtJQYy(pA(u-6Fq7VnH2o!;O(F|YRs$P082}aXuy+FeXmCJ` z&05L5n1wjlg4^@+OD;Sc=j>M-IcVe9n0BlIoV8kQS#7TY#s<&Mz)4;t9C^ zC}WYPNv9hdyVr2<-r88LuBlX0q@tt)v0L!;6&I%|Njbgcy~U%Gp3uZev%>nfL{B8u zJ$|*WkV;L4<&&F9;*b5b`o`)bB=6i5V#m{>W54;M6qKamA9wOK(PcXAy|uM_wT;?Z zt*)$DgSrTnf7TR41$#$+`K6`2xUH>k$LkpwXdT%wfh=Z~k_@lh>k7rX)Np>~;;Q%) zKUUA(Ifo#dQ_tC|qU74|@BT3~zqI6vQBwr8vL@~2hP6grY^=7FR@7alQSmE>YYGY$ zLKnX77@ZiM^mvoLw^|Jb_dxE?0LL%C&+SWH$)C!DBL%d^?XD}|UAgjI!%RA^oyo>) znwoUl-?f?;Bl_>weHwaO#kMTQ0THHB#g()&Q9P3C4_|qk;+MFbsJ`>TngB>zVV_E^vxFsE8c4xumx(R z3XjJx0s#PL2<1~n6grA(!ee#K#+lOYt^3X0r6|WmrvseBP{{+Zwpf4{?JW)2#IWoH zGMS}p*=Q*)H(*-a%PWI(;yK@SDM{R!iXiz%GM!95Tf@PzZC#0p>#H*ba=x|yAwBHcJ)-WY9bac^vRkc$Vz z@A#DSX42dylA4zXJy(lxF#p*LHJ*kxcNd{_pb5B`7(ORF8jsFQKW+>Ur?D9fh6})W zA@2zc5zHnb?3krO9|GbP*icg9A7iTPHd;HDcb60Me>>oJect)9^G5{9LZHJ@A`w;8 z{_XUPplA^VI5BFclNpmPU;x{uQf=q7WDyz-s`v*>D7VZnY z@rKWM=H@!Hko^23P|5MAo}QPlp3DZrY?X?`0QFFVzsQII_lQm)usIw$n@yk-D9jyi z3G}s+6>o}92#b@;Bp_b_oT|@{$-w=z05dlCmq4kTf2{_*=DYR;7Um=Qc@P90PK+4v zJbcnGf(dk^F_I9&go6`9Bh>J5W(=Rervp!-P?$K6C%EKftCAdVv791;g-mkECJ71I z!?JD}#w!4+rNDfU%>&}kd};7y0H8tshY$N_pS=9_MZc3ubyApiBcFo9sbM$~DuLUn zRG7(R;`R>gq{5=$#FADLImjYEWsxgFs%#SQ1#)nRX={C54sZGPt@LzXENbX zC=o}Y3k3W~3IzwlA`uMZ=p4|$#PeJd8H5CRMTJ742SzGUC_*ktK-{rl%=^uC7y6;6 zSnO+lG{|Z_70=D77Yc}NMA#kALWC&zFwmA@3Iz|ehoea@)1Y_)n-;BUE@BAS z!JZ4Gy?7NwlqrCo*^Vk~AlZX4fqw&l_L$2@RvuwL@J((%2Q2?X68-=_yp)856f(KK zzP`AxXJHngK%s<4HZ43kIayabrqy0<)Ly>)P3e3zO#qAPSQqwyK;NuZgK1kti!7SjRQDVaEWYtyp!$aV5z}8vAj9xJDzv{IcB+n*CZC}O!o2Fi7^D}6Q3TcUF|Y_ z8i9d0;tF%(fW#)#sr=>~A_O6zIER>5KqOXn?RP%-=k-_`{QSdHFW|gez+xTx{PRN< zpI2~T?Z75=7TQ;b(g{MUL?Xdl@N~hpXnorJA(yY1Nr_h>NOxS^iM-nC(V52lyheF} znU!m)2j|A2%Q;xHip9L_;Qf=Xh+7?dzC_R^0$<~=!jq9uVEHj;KHc!X(-ivkCdk_4v z(`qm@saZ!3<+1<=TA(0T&L>$&Ci|+>v6x7~L$^?6Kn6IN45h-j=#xqp-zq^$#_Ho* z6uAX-=uWzlmz$e+^%m=(oCtc9Grj)cjaUOe@Z@Q$!P`X61r>x2s5pJr4ADZNgW%|% zSzl3|xe`z5D;EK~si=&K$1`aH0!`ZxHOFU$z_zvU=tN>;BQJ-@A)3u6^5h&jk!{J# zv8;B#8cTzIXi~PfNgds9Kp87eSLB0tQLqh`u9@-im6Gxg8F!yNTEe9<@pv%ZQW`V* z2Y2o9<8PNE&mIpwnBlQWyv|cO%BVEtkzuzm4P|Sz*f(B|?b4q&c1Q}ZT7B^B5#T?( z8n9AMC$rfmyL-HQ3`xdqK1y9I$|9sua5$WRCX}GE=f@XVTU(1f>%KQyNaE=Vb)95B zT@KyXNY6Q?P?!tt-7m({;Nyv>BjQ%Y`yBaMm{$4bgPgombUK?vVvmelt((b6auFn9 z5d)VfDq@tS2!Z6TaM3lL-k<;bgAM1Dz z9DDS1#4A?t`G*e{6da_J56c^sY<`oWYs32Cl{5SI@4s@chLHgCAwiR#T1BPSwTD8X zpx+<#heF}V+L~{9ZE+%QdRnLB(K*qGr*2a7csz?~bys-?2L9OrrRIy9z_=V%tKpH! ze0A&UW06K$Rz}lm8`c^$Z>dxam8u3wq*6m+fEa{+4SM`=t>x(XcF}3+%(0NfWHNjL z;II{)CX;h-thjyC|4J0c+r$R3R*T7O9$8IZ?>nl=B5;}9;^Jaq8dF;)N=8b6#x!c3 z-|z8EZf|dcIt+TCW!sm1KD3YF)R78FY&sqEiw}z@vd-kT?uyxOfAQXo0p!{%7B_jl zO16d6WdBf9PRkIa7>zcg(MS~v@!W-mx1uvb>s!9>@eDrKQ^4|sT$l?*mji*+rTRik zZD%D1m|J<6ty7xp>#y#Pzh5A;fFlMV7(hxxYpYY*@MRU)Dx2-ojuZ)s1_C}GH-)P~ zko2mx$bC<6Y7VZly*;-z3Brv@e33w)ykw%jrI4qfvs?L5&C;1>9=-a%1w7*D95IN+ zq-Y2v8CqvG4Hr5-`lz&{qjdf#&4|e&m+H{s1tIe&Qp3FvsdI&cZG)b{IS-)uLl_8z zFQDy1lC5wfCA*c>sRR`F`p{Qn$YQ967AWbZ9pizWI zz5dcAJ!Y&cW@e~LK8h?GvD==@m!L?up*%ou8CYShARg$y`LM-g(%J2Hx4Ygs_VIz( z^1OZ{`#S`=+gUvVcQTAX($vIrQ#$55U@V`@qEJ!Wa1fN!X0xHp3`%n1^0Ev&_1WJS zTp_x{_46=FchT*aq@?3XnaDNk=;-*kdo#66%jGgJ{M6Bb z8KEi|if7i9+F;|70$Cv~At41t^~0s@80rdx=?Or1$ROZECu+Og>#J_}`e^TjBR%uj zp6lnKJTYSZ&2yZSnVIk{#cXeHucN3Oo^Af}O<3pX!F=d3_*nR5Lt*f6X%rQODsz=$ zKr)!*#X@14AVWaO8neQ>vX-RlT3vPbj@4xT@?-WM(CS##$^IDf;s=>gAjibekRw5) zWpdl6Ze9i>5cEt=28T;a+x?|BNLYYGP$g4nXuA(ZqXdX1A&3;IB{eEWR)VOzOW9Rl z-@Ae!1KDo_t7Fb<{n-P@kALz3thWK^u64puv?$;%Tv)g{xi#mR+yZL|E~+$g36n^u z_^K-K9;qTJ6Ca@BGYAC1MJY{iG(9;17Z2V$i=o+ccDW~DiM=lySiNf~^nbnYWYP!U zCH)8V*Ih?ZLZbHe@08n9ZBx&;2$OIvf20FXEe2I(CP0^@p3_7l${8yzv9B+YQKQ01 z34{zmMm$cV(OAdFAYZ{Y`NiE!#2f#%YCW$_!%-akg$^&Ba|%-waY=hfELo9Y(}qBo zhz<|si(uU)=w=Tdq}|0q54M@J;GqbLKPZA0lnG)zSP_PJ z^Ak`0#EE;99(u^@%lEzS`@GNRb-N4mJ#%5+m1f~-o#xcQz!947R;&FhxBD*vaH{WW z=Yk1uxG?KuBz`){OFU<%%c7#td@{*U7$<-kLITCm1R=gkPG`-zi2VnuirbrJClPtpUuG*YzD(2VFXVhj{$gbBY01NOh|;nMuenaXe=*j zTr8I4(t0#4(u~-0K7Mo@Yh`2^P8paB7sMy?@UNmz_t}N>J4|@WRHMsw*jf!dGgU<_t~c?CiDyQ6nnz%=H zIQS^G2IZE8cSrdS{a*gtv-kLp?z3*AVP-NI`VrMkybVmF0 zWTILN`)U^-l78r{D4GdjbcXm1^2Lu=8KWL)C zH=WPJda2}{C1W({qZH4-t@3=I@F&}*X|}UH_q(0R%_kWGTGZp2wa)WqZLTmJESAC{ zLB2Iup@@n9S|IWqYcIpen@VrF(Obx|G8vhPJbqAUcAi&D^-if)ufdcsG6W@PBeZP{A$95dU{UmF|CjN8=wvxQE* zcFB9n1&k#8$eUx^wIDY(<~eqvXJ$EYixdz@!e#x?-zXAyESufleXp^p6O~U4Lx9}$ z8G;|ICW!k0m&| Date: Fri, 22 Aug 2014 12:11:14 +1000 Subject: [PATCH 056/120] Creating new style of bullet point list --- app/assets/stylesheets/darkswarm/typography.css.sass | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/typography.css.sass b/app/assets/stylesheets/darkswarm/typography.css.sass index b49ce867c1..f3dd1c90a6 100644 --- a/app/assets/stylesheets/darkswarm/typography.css.sass +++ b/app/assets/stylesheets/darkswarm/typography.css.sass @@ -55,7 +55,7 @@ h1, h2, h3, h4, h5, h6, .avenir @include avenir padding: 0px -ul.bullet-list +ul.bullet-list, ul.check-list margin: 0 li list-style: none @@ -69,7 +69,10 @@ ul.bullet-list font-style: normal font-variant: normal text-transform: none - + +ul.check-list + li:before + content: "\e632" .light-grey color: #666666 From 08d3eb6f93fe6605a270402b0ecf6c62c5265e7d Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 12:11:41 +1000 Subject: [PATCH 057/120] Making the modals higher relative to their respective window --- app/assets/stylesheets/darkswarm/modals.css.sass | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/modals.css.sass b/app/assets/stylesheets/darkswarm/modals.css.sass index 0681dd73b4..39a1ffa475 100644 --- a/app/assets/stylesheets/darkswarm/modals.css.sass +++ b/app/assets/stylesheets/darkswarm/modals.css.sass @@ -6,22 +6,26 @@ dialog, .reveal-modal outline: none padding: 1rem overflow-y: scroll + top: 10% + @media all and (max-width: 640px) + top: 0 // Sets up max heights based on device height @media all and (min-height: 1025px) - max-height: 80% + max-height: 70% + top: 15% @media all and (min-height: 700px) and (max-height: 1024px) - max-height: 70% + max-height: 80% @media all and (min-height: 600px) and (max-height: 699px) - max-height: 60% + max-height: 80% @media all and (min-height: 481px) and (max-height: 599px) - max-height: 60% + max-height: 80% @media only screen and (max-height: 480px) and (min-width: 641px) - max-height: 60% + max-height: 80% @media all and (max-height: 480px) overflow-y: scroll From 8b928b5a669ce3419ebb86c7353a36ec47b28a4e Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 12:11:56 +1000 Subject: [PATCH 058/120] Styling on-boarding wizard Introduction step --- .../registration/introduction.html.haml | 52 ++++++++++++------- .../darkswarm/registration.css.sass | 14 ++++- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/templates/registration/introduction.html.haml b/app/assets/javascripts/templates/registration/introduction.html.haml index 4f9bcf0708..43e8e1407a 100644 --- a/app/assets/javascripts/templates/registration/introduction.html.haml +++ b/app/assets/javascripts/templates/registration/introduction.html.haml @@ -1,26 +1,40 @@ %div .row.header %h2 Hi there! - %h5 This wizard will step you through creating a Profile on the Open Food Network. + %h4 This wizard will step you through creating a profile .row - .small-2.columns   - .small-10.columns{ style: 'line-height: 150%;'} Your profile gives you an online presence on the Open Food Network, allowing you to easily connect with potential customers or partners. You can always choose to update your info later, as well as choose to upgrade your Profile to and Online Store, where you can sell products, track orders and receive payments. Creating a profile usually takes about 5-10 minutes. - %br + .small-12.medium-3.large-2.columns.text-right.hide-for-small-only + %img{:src => "/assets/potatoes.png"} + .small-12.medium-9.large-10.columns + %p + Your profile gives you an online presence on the + %strong Open Food Network, + allowing you to easily connect with potential customers or partners. You can always choose to update your info later, as well as choose to upgrade your Profile to and Online Store, where you can sell products, track orders and receive payments. Creating a profile takes about 5-10 minutes. .row{ 'data-equalizer' => true } - .small-6.columns{ 'data-equalizer-watch' => true } - %span{ style: 'font-weight: bold;' } You'll need the following: - .small-12.columns - %ol.numbered-list - %li Your enterprise address and contact details - %li Your logo image - %li A pretty image to serve as your profile header - %li Some 'About Us' text - .small-6.columns{ 'data-equalizer-watch' => true, style: 'background-color: #ffffff; padding: 10px;'} - %span{ style: 'font-weight: bold;' } Your profile entitles you to: - %ul{ style: 'margin-top: 10px;' } - %li A searchable listing in Hub / Producer view - %li A pin on the OFN map to help users find you - .row + .small-12.medium-6.large-6.columns.pad-top{ 'data-equalizer-watch' => true } + %h5 You'll need the following: + %ul.check-list + %li + Your enterprise address and contact details + %li + Your logo image + %li + A pretty picture for your profile header + %li + Some 'About Us' text + + .small-12.medium-6.large-6.columns{ 'data-equalizer-watch' => true} + .highlight-box + %h5 Your profile entitles you to: + %ul.small-block-grid-1 + %li + %i.ofn-i_020-search + A searchable listing + %li + %i.ofn-i_040-hub + A pin on the OFN map + .small-12.columns - %input.button.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" }, style: 'float: right' } + %hr + %input.button.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" } } \ No newline at end of file diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index fcc64dbdb2..9b987d26b4 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -51,10 +51,20 @@ label margin-bottom: 3px - ol.numbered-list - font-size: 80% + ol, ul + // font-size: 80% + font-size: 0.875rem + padding: 0 + margin: 0 + ol list-style-type: decimal + .highlight-box + background: white + padding: 1rem 1.2rem + @media all and (max-width: 640px) + margin-top: 1rem + #progress-bar margin-bottom: 15px .item From f1ef8ba3c78934f655410e333edef4539bf705eb Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 22 Aug 2014 14:26:45 +1000 Subject: [PATCH 059/120] Getting signup to work and authentication to load in reg specific template --- .../authentication/signup_controller.js.coffee | 7 +++++-- .../authentication_controller.js.coffee | 2 +- .../services/authentication_service.js.coffee | 10 ++++++---- .../services/registration_service.js.coffee | 2 +- .../templates/registration/about.html.haml | 6 +++--- .../registration_authentication.html.haml | 17 +++++++++++++++++ .../javascripts/templates/signup.html.haml | 16 ++++++++-------- app/controllers/registration_controller.rb | 2 +- 8 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 app/assets/javascripts/templates/registration_authentication.html.haml diff --git a/app/assets/javascripts/darkswarm/controllers/authentication/signup_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/authentication/signup_controller.js.coffee index d15ef4141d..123079b6b5 100644 --- a/app/assets/javascripts/darkswarm/controllers/authentication/signup_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/authentication/signup_controller.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.controller "SignupCtrl", ($scope, $http, $location, AuthenticationService) -> +Darkswarm.controller "SignupCtrl", ($scope, $http, $window, $location, Redirections, AuthenticationService) -> $scope.path = "/signup" $scope.errors = email: null @@ -6,6 +6,9 @@ Darkswarm.controller "SignupCtrl", ($scope, $http, $location, AuthenticationServ $scope.submit = -> $http.post("/user/spree_user", {spree_user: $scope.spree_user}).success (data)-> - location.href = location.origin + location.pathname # Strips out hash fragments + if Redirections.after_login + $window.location.href = $window.location.origin + Redirections.after_login + else + $window.location.href = $window.location.origin + $window.location.pathname # Strips out hash fragments .error (data) -> $scope.errors = data diff --git a/app/assets/javascripts/darkswarm/controllers/authentication_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/authentication_controller.js.coffee index 7c45fd53d1..1a22f34b0c 100644 --- a/app/assets/javascripts/darkswarm/controllers/authentication_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/authentication_controller.js.coffee @@ -1,7 +1,7 @@ Darkswarm.controller "AuthenticationCtrl", ($scope, AuthenticationService, SpreeUser)-> $scope.open = AuthenticationService.open $scope.toggle = AuthenticationService.toggle - + $scope.spree_user = SpreeUser.spree_user $scope.active = AuthenticationService.active $scope.select = AuthenticationService.select diff --git a/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee b/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee index ff7db62f4a..2dad1bc4f2 100644 --- a/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee @@ -4,12 +4,14 @@ Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redir selectedPath: "/login" constructor: -> - if $location.path() in ["/login", "/signup", "/forgot"] - @open() + if $location.path() in ["/login", "/signup", "/forgot"] && location.pathname is not '/register/auth' + @open $location.path() + else if location.pathname is '/register/auth' + @open '/signup', 'registration_authentication.html' - open: (path = false)=> + open: (path = false, template = 'authentication.html') => @modalInstance = $modal.open - templateUrl: 'authentication.html' + templateUrl: template windowClass: "login-modal medium" @modalInstance.result.then @close, @close @selectedPath = path || @selectedPath diff --git a/app/assets/javascripts/darkswarm/services/registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/registration_service.js.coffee index 025c403358..a2a1fe2dc4 100644 --- a/app/assets/javascripts/darkswarm/services/registration_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/registration_service.js.coffee @@ -14,7 +14,7 @@ Darkswarm.factory "RegistrationService", (Navigation, $modal, Loading)-> select: (step)=> @current_step = step - + currentStep: => @current_step diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index e2dad4a66b..b1065d104c 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -7,9 +7,9 @@ %ofn-inline-flash.turquoise.small-12.columns{ ng: { show: 'visible' } } %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. - %ofn-inline-flash.brick.small-12.columns{ ng: { show: 'visible' } } - %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } - {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. + -# %ofn-inline-flash.brick.small-12.columns{ ng: { show: 'visible' } } + -# %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } + -# {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. .small-12.large-8.columns .row diff --git a/app/assets/javascripts/templates/registration_authentication.html.haml b/app/assets/javascripts/templates/registration_authentication.html.haml new file mode 100644 index 0000000000..c7bfbabeca --- /dev/null +++ b/app/assets/javascripts/templates/registration_authentication.html.haml @@ -0,0 +1,17 @@ +.container + .row.modal-centered + %h2 Welcome to the Open Food Network! + %h5 Start By Signing Up (or logging in): + %div{"ng-controller" => "AuthenticationCtrl"} + %tabset + %ng-include{src: "'signup.html'"} + %ng-include{src: "'login.html'"} + %ng-include{src: "'forgot.html'"} + %div{ ng: { show: "active('/signup')"} } + %hr + Already have an account? + %a{ href: "", ng: { click: "select('/login')"}} + Log in now. + +%a.close-reveal-modal{"ng-click" => "$close()"} + %i.ofn-i_009-close diff --git a/app/assets/javascripts/templates/signup.html.haml b/app/assets/javascripts/templates/signup.html.haml index db066685f1..28bec19b49 100644 --- a/app/assets/javascripts/templates/signup.html.haml +++ b/app/assets/javascripts/templates/signup.html.haml @@ -1,12 +1,12 @@ -%tab#sign-up-content{"ng-controller" => "SignupCtrl", - heading: "Sign up", +%tab#sign-up-content{"ng-controller" => "SignupCtrl", + heading: "Sign up", active: "active(path)", select: "select(path)"} %form{"ng-submit" => "submit()"} .row .large-12.columns %label{for: "email"} Your email - %input.title.input-text{name: "email", + %input.title.input-text{name: "email", type: "email", id: "email", tabindex: 1, @@ -16,7 +16,7 @@ .row .large-12.columns %label{for: "password"} Choose a password - %input.title.input-text{name: "password", + %input.title.input-text{name: "password", type: "password", id: "password", autocomplete: "off", @@ -27,7 +27,7 @@ .row .large-12.columns %label{for: "password_confirmation"} Confirm password - %input.title.input-text{name: "password_confirmation", + %input.title.input-text{name: "password_confirmation", type: "password", id: "password_confirmation", autocomplete: "off", @@ -35,7 +35,7 @@ "ng-model" => "spree_user.password_confirmation"} .row .large-12.columns - %input.button.primary{name: "commit", - tabindex: "3", - type: "submit", + %input.button.primary{name: "commit", + tabindex: "3", + type: "submit", value: "Sign up now"} diff --git a/app/controllers/registration_controller.rb b/app/controllers/registration_controller.rb index 2915f71639..c378d24215 100644 --- a/app/controllers/registration_controller.rb +++ b/app/controllers/registration_controller.rb @@ -7,7 +7,7 @@ class RegistrationController < BaseController def index if spree_current_user.nil? - redirect_to registration_auth_path(anchor: "login?after_login=/register") + redirect_to registration_auth_path(anchor: "signup?after_login=/register") end end end From a16da4eae080b4150127c631aceed934dc17600c Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 22 Aug 2014 15:09:26 +1000 Subject: [PATCH 060/120] Commenting out enterprise creation --- .../enterprise_creation_service.js.coffee | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee index 52baea146a..e52407463a 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee @@ -7,43 +7,43 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, country: availableCountries[0] create: => - Loading.message = "Creating " + @enterprise.name - $http( - method: "POST" - url: "/api/enterprises" - data: - enterprise: @prepare() - params: - token: SpreeApiKey - ).success((data) => - Loading.clear() - @enterprise.id = data - RegistrationService.select('about') - ).error((data) => - Loading.clear() - console.log angular.toJson(data) - alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') - ) - #RegistrationService.select('about') + # Loading.message = "Creating " + @enterprise.name + # $http( + # method: "POST" + # url: "/api/enterprises" + # data: + # enterprise: @prepare() + # params: + # token: SpreeApiKey + # ).success((data) => + # Loading.clear() + # @enterprise.id = data + # RegistrationService.select('about') + # ).error((data) => + # Loading.clear() + # console.log angular.toJson(data) + # alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') + # ) + RegistrationService.select('about') update: (step) => - Loading.message = "Updating " + @enterprise.name - $http( - method: "PUT" - url: "/api/enterprises/#{@enterprise.id}" - data: - enterprise: @prepare() - params: - 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.') - ) - #RegistrationService.select(step) + # Loading.message = "Updating " + @enterprise.name + # $http( + # method: "PUT" + # url: "/api/enterprises/#{@enterprise.id}" + # data: + # enterprise: @prepare() + # params: + # 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.') + # ) + RegistrationService.select(step) prepare: => enterprise = {} From d1b8b12901a5450373fbc1958e606e16e9da5ea9 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 15:38:20 +1000 Subject: [PATCH 061/120] Tweak custom bullet point styles --- app/assets/stylesheets/darkswarm/typography.css.sass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/darkswarm/typography.css.sass b/app/assets/stylesheets/darkswarm/typography.css.sass index f3dd1c90a6..de12103344 100644 --- a/app/assets/stylesheets/darkswarm/typography.css.sass +++ b/app/assets/stylesheets/darkswarm/typography.css.sass @@ -56,7 +56,7 @@ h1, h2, h3, h4, h5, h6, .avenir padding: 0px ul.bullet-list, ul.check-list - margin: 0 + margin: 0 0 0 1.25em !important li list-style: none line-height: 1.5 @@ -64,6 +64,7 @@ ul.bullet-list, ul.check-list li:before content: "\e609" font-family: "OFN" + margin-left: -1.25em display: inline-block font-weight: normal font-style: normal From 500cb65b41922436c22d937a5be976c91bd8baa5 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 15:38:41 +1000 Subject: [PATCH 062/120] Styling for registration steps --- .../darkswarm/registration.css.sass | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 9b987d26b4..f0f898eb4e 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -1,4 +1,5 @@ @import branding +@import mixins #registration-modal .header @@ -7,7 +8,7 @@ .container background-color: #ffffff .content - margin-bottom: 15px + // margin-bottom: 15px i font-size: 150% @@ -71,21 +72,25 @@ padding: 12px 0px text-transform: uppercase text-align: center - background-color: #000000 - color: #ffffff + background-color: #333 + border: 2px solid #333 + color: #fff .item.active - background-color: #ffffff - color: #000000 + background-color: #cccccc + border: 2px solid #333 + color: #333 + @include box-shadow(inset 0 0 1px 0 #fff) #registration-details #enterprise-types - a + a.panel + display: block background-color: #efefef color: black &:hover - background-color: #ffffff + background-color: #fff &.selected - h6 - color: #ffffff - color: #ffffff + &, & * + color: #fff + color: #fff background-color: $clr-turquoise-bright From 8a4dcef7fe71fe2f22e4ef35f682bb19312b7a68 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 15:39:02 +1000 Subject: [PATCH 063/120] Tweak layout and simplify column structures --- .../templates/registration/details.html.haml | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index cad5449e6b..949c634b26 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -1,42 +1,43 @@ .container#registration-details - .row.header + .header %h2 Let's Get Started %h5 Woot! First we need to know what sort of enterprise you are: %ng-include{ src: "'registration/steps.html'" } - .row.content + + .row + .small-12.columns + %label{ for: 'enterprise_name' } Enterprise Name: + %input.chunky.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm", ng: { model: 'enterprise.name' } } + + .row#enterprise-types{ 'data-equalizer' => true } .small-12.columns .row - .small-12.columns - %label{ for: 'enterprise_name' } Enterprise Name: - %input.chunky.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm", ng: { model: 'enterprise.name' } } - .row#enterprise-types{ 'data-equalizer' => true } .small-12.columns %label Choose One: - .medium-12.large-4.columns{ 'data-equalizer-watch' => true } - %a.small-12.columns.panel#producer{ href: "#", ng: { click: "enterprise.is_distributor = false; enterprise.is_primary_producer = true", class: "{selected: (!enterprise.is_distributor && enterprise.is_primary_producer)}" } } - .small-2.columns - %i.ofn-i_036-producers - .small-10.columns - %h6 I'm A Producer - %span{ style: 'font-size: 80%'} Producers are anyone making things to eat & drink - whether you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. - - .medium-12.large-4.columns{ 'data-equalizer-watch' => true } - %a.small-12.columns.panel#hub{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = false", class: "{selected: (enterprise.is_distributor && !enterprise.is_primary_producer)}" } } - .small-2.columns - %i.ofn-i_040-hub - .small-10.columns - %h6 I'm A Hub - %span{ style: 'font-size: 80%'} Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, etc... - - .medium-12.large-4.columns{ 'data-equalizer-watch' => true } - %a.small-12.columns.panel#both{ href: "#", ng: { click: "enterprise.is_distributor = true; enterprise.is_primary_producer = true", class: "{selected: (enterprise.is_distributor && enterprise.is_primary_producer)}" } } - .small-2.columns - %i.ofn-i_039-delivery - .small-10.columns - %h6 I'm Both - %span{ style: 'font-size: 80%'} Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! + .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)}" } } + .left + %render-svg{path: "/assets/map-icon-producer.svg"} + %h4 I'm A Producer + %p.clear + %small Producers are anyone making things to eat & drink - whether 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)}" } } + .left + %render-svg{path: "/assets/map-icon-hub.svg"} + %h4 I'm A Hub + %p + %small Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, 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)}" } } + .left + %render-svg{path: "/assets/map-icon-both.svg"} + %h4 I'm Both + %p + %small Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! .row.buttons .small-12.columns - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('address')" } } + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" } } \ No newline at end of file From c54b18a416d7ba2977d6513ff8bc8ea7ee88f419 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 15:39:40 +1000 Subject: [PATCH 064/120] Cleanupm markup --- .../javascripts/templates/registration/about.html.haml | 2 +- .../javascripts/templates/registration/address.html.haml | 7 ++++--- .../javascripts/templates/registration/contact.html.haml | 2 +- .../javascripts/templates/registration/finished.html.haml | 4 ++-- .../javascripts/templates/registration/images.html.haml | 2 +- .../templates/registration/introduction.html.haml | 4 ++-- .../javascripts/templates/registration/social.html.haml | 2 +- .../javascripts/templates/registration/steps.html.haml | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index b1065d104c..47d9a6012a 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -1,5 +1,5 @@ .container#registration-about - .row.header + .header %h2 Nice one! %h5 Now let's flesh out the details about {{ enterprise.name }}. %ng-include{ src: "'registration/steps.html'" } diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index f395703a1b..4c7736722b 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -1,5 +1,5 @@ .container#registration-address - .row.header + .header %h2 Hi there, {{ enterprise.name }} %h5 Now we need to know where you are: %ng-include{ src: "'registration/steps.html'" } @@ -37,6 +37,7 @@ %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } Blur my location on the map (show an approximate, not exact pin) .row.buttons - .small-12.columns - %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('details')" } } + .small-12.medium-6.columns + %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } } + .small-12.medium-6.columns %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('contact')" } } diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index fe342d73e0..132a4c6543 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -1,5 +1,5 @@ .container#registration-contact - .row.header + .header %h2 Last step to create your enterprise! %h5 Who is responsible for managing {{ enterprise.name }}? %ng-include{ src: "'registration/steps.html'" } diff --git a/app/assets/javascripts/templates/registration/finished.html.haml b/app/assets/javascripts/templates/registration/finished.html.haml index b2150f8f1c..92ec44ab30 100644 --- a/app/assets/javascripts/templates/registration/finished.html.haml +++ b/app/assets/javascripts/templates/registration/finished.html.haml @@ -1,8 +1,8 @@ .container#registration-finished - .row.header + .header %h2 Well done! %h5 You have successfully completed the profile for {{ enterprise.name }}! - .row.content{ style: 'text-align: center'} + .content{ style: 'text-align: center'} %h3 Why not check it out on the Open Food Network? %a.button.primary{ type: "button", href: "/map" } Go to Map Page > diff --git a/app/assets/javascripts/templates/registration/images.html.haml b/app/assets/javascripts/templates/registration/images.html.haml index 92c3c9f703..696a0d7b16 100644 --- a/app/assets/javascripts/templates/registration/images.html.haml +++ b/app/assets/javascripts/templates/registration/images.html.haml @@ -1,5 +1,5 @@ .container#registration-images - .row.header + .header %h2 Thanks! %h5 Let's upload some pretty pictures so your profile looks great! :) %ng-include{ src: "'registration/steps.html'" } diff --git a/app/assets/javascripts/templates/registration/introduction.html.haml b/app/assets/javascripts/templates/registration/introduction.html.haml index 43e8e1407a..8a4f4f7e02 100644 --- a/app/assets/javascripts/templates/registration/introduction.html.haml +++ b/app/assets/javascripts/templates/registration/introduction.html.haml @@ -1,5 +1,5 @@ %div - .row.header + .header %h2 Hi there! %h4 This wizard will step you through creating a profile .row @@ -33,7 +33,7 @@ %li %i.ofn-i_040-hub A pin on the OFN map - + .row .small-12.columns %hr %input.button.primary{ type: "button", value: "Let's get started!", ng: { click: "select('details')" } } diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml index 40717b6190..a5458b2b3e 100644 --- a/app/assets/javascripts/templates/registration/social.html.haml +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -1,5 +1,5 @@ .container#registration-social - .row.header + .header %h2 Last step! %h5 How can people find {{ enterprise.name }} online? %ng-include{ src: "'registration/steps.html'" } diff --git a/app/assets/javascripts/templates/registration/steps.html.haml b/app/assets/javascripts/templates/registration/steps.html.haml index ea1e57a306..65e3cb6b48 100644 --- a/app/assets/javascripts/templates/registration/steps.html.haml +++ b/app/assets/javascripts/templates/registration/steps.html.haml @@ -1,5 +1,5 @@ .row#progress-bar .small-12.medium-2.columns.item{ ng: { repeat: 'step in steps', class: "{active: (currentStep() == step),'show-for-medium-up': (currentStep() != step)}" } } - {{ step }} + {{ $index+1 + ". " + step }} \ No newline at end of file From c93673d78b482f6b3ba39139039039f1ee8ad82f Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 22 Aug 2014 15:45:09 +1000 Subject: [PATCH 065/120] Adding form to each page of registration --- .../templates/registration/about.html.haml | 59 +++++++------- .../templates/registration/address.html.haml | 77 ++++++++++--------- .../templates/registration/contact.html.haml | 65 ++++++++-------- .../templates/registration/details.html.haml | 72 +++++++++-------- .../templates/registration/social.html.haml | 55 ++++++------- 5 files changed, 165 insertions(+), 163 deletions(-) diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index 47d9a6012a..faf40172f4 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -3,33 +3,34 @@ %h2 Nice one! %h5 Now let's flesh out the details about {{ enterprise.name }}. %ng-include{ src: "'registration/steps.html'" } - .row.content - %ofn-inline-flash.turquoise.small-12.columns{ ng: { show: 'visible' } } - %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } - {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. - -# %ofn-inline-flash.brick.small-12.columns{ ng: { show: 'visible' } } - -# %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } - -# {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. + %form + .row.content + %ofn-inline-flash.turquoise.small-12.columns{ ng: { show: 'visible' } } + %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } + {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. + -# %ofn-inline-flash.brick.small-12.columns{ ng: { show: 'visible' } } + -# %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } + -# {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. - .small-12.large-8.columns - .row - .small-12.columns - %label{ for: 'enterprise_description' } Short Description: - %input.chunky.small-12.columns{ id: 'enterprise_description', placeholder: "A short sentence describing your enterprise", ng: { model: 'enterprise.description' } } - .row - .small-12.columns - %label{ for: 'enterprise_long_desc' } Long Description: - %textarea.chunky.small-12.columns{ id: 'enterprise_long_desc', placeholder: "We recommend keeping your description to under 600 characters or 150 words. Why? Cus people are lazy, and don't like to read too much text online. ;)", ng: { model: 'enterprise.long_description' } } - {{ enterprise.long_description.length }} characters used - .small-12.large-4.columns - .row - .small-12.columns - %label{ for: 'enterprise_abn' } ABN: - %input.chunky.small-12.columns{ id: 'enterprise_abn', placeholder: "eg. 99 123 456 789", ng: { model: 'enterprise.abn' } } - .row - .small-12.columns - %label{ for: 'enterprise_acn' } ACN: - %input.chunky.small-12.columns{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } - .row.buttons - .small-12.columns - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "update('social')" } } \ No newline at end of file + .small-12.large-8.columns + .row + .small-12.columns + %label{ for: 'enterprise_description' } Short Description: + %input.chunky.small-12.columns{ id: 'enterprise_description', placeholder: "A short sentence describing your enterprise", ng: { model: 'enterprise.description' } } + .row + .small-12.columns + %label{ for: 'enterprise_long_desc' } Long Description: + %textarea.chunky.small-12.columns{ id: 'enterprise_long_desc', placeholder: "We recommend keeping your description to under 600 characters or 150 words. Why? Cus people are lazy, and don't like to read too much text online. ;)", ng: { model: 'enterprise.long_description' } } + {{ enterprise.long_description.length }} characters used + .small-12.large-4.columns + .row + .small-12.columns + %label{ for: 'enterprise_abn' } ABN: + %input.chunky.small-12.columns{ id: 'enterprise_abn', placeholder: "eg. 99 123 456 789", ng: { model: 'enterprise.abn' } } + .row + .small-12.columns + %label{ for: 'enterprise_acn' } ACN: + %input.chunky.small-12.columns{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } + .row.buttons + .small-12.columns + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "update('social')" } } diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index 4c7736722b..1c3ee071a8 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -3,41 +3,42 @@ %h2 Hi there, {{ enterprise.name }} %h5 Now we need to know where you are: %ng-include{ src: "'registration/steps.html'" } - .row.content - .small-7.columns - .row - .small-12.columns - %label{ for: 'enterprise_address' } Address: - %input.chunky.small-12.columns{ id: 'enterprise_address', placeholder: "eg. 123 Cranberry Drive", ng: { model: 'enterprise.address.address1' } } - .row - .small-12.large-8.columns - %label{ for: 'enterprise_city' } Suburb: - %input.chunky.small-12.columns{ id: 'enterprise_city', placeholder: "eg. Northcote", ng: { model: 'enterprise.address.city' } } - .small-12.large-4.columns - %label{ for: 'enterprise_zipcode' } Postcode: - %input.chunky.small-12.columns{ id: 'enterprise_zipcode', placeholder: "eg. 3070", ng: { model: 'enterprise.address.zipcode' } } - .row - .small-12.large-8.columns - %label{ for: 'enterprise_country' } Country: - %select.chunky.small-12.columns{ id: 'enterprise_country', ng: { model: 'enterprise.country', options: 'c as c.name for c in countries' } } - .small-12.large-4.columns - %label{ for: 'enterprise_state' } State: - %select.chunky.small-12.columns{ id: 'enterprise_state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()' } } - .small-5.columns - %h6 - Location display - %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} - .row - .small-12.columns - %label.indent-checkbox - %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } - Hide my street name and street number from the public (ie. only show the suburb) - .small-12.columns - %label.indent-checkbox - %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } - Blur my location on the map (show an approximate, not exact pin) - .row.buttons - .small-12.medium-6.columns - %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } } - .small-12.medium-6.columns - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('contact')" } } + %form + .row.content + .small-7.columns + .row + .small-12.columns + %label{ for: 'enterprise_address' } Address: + %input.chunky.small-12.columns{ id: 'enterprise_address', placeholder: "eg. 123 Cranberry Drive", ng: { model: 'enterprise.address.address1' } } + .row + .small-12.large-8.columns + %label{ for: 'enterprise_city' } Suburb: + %input.chunky.small-12.columns{ id: 'enterprise_city', placeholder: "eg. Northcote", ng: { model: 'enterprise.address.city' } } + .small-12.large-4.columns + %label{ for: 'enterprise_zipcode' } Postcode: + %input.chunky.small-12.columns{ id: 'enterprise_zipcode', placeholder: "eg. 3070", ng: { model: 'enterprise.address.zipcode' } } + .row + .small-12.large-8.columns + %label{ for: 'enterprise_country' } Country: + %select.chunky.small-12.columns{ id: 'enterprise_country', ng: { model: 'enterprise.country', options: 'c as c.name for c in countries' } } + .small-12.large-4.columns + %label{ for: 'enterprise_state' } State: + %select.chunky.small-12.columns{ id: 'enterprise_state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()' } } + .small-5.columns + %h6 + Location display + %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} + .row + .small-12.columns + %label.indent-checkbox + %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } + Hide my street name and street number from the public (ie. only show the suburb) + .small-12.columns + %label.indent-checkbox + %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } + Blur my location on the map (show an approximate, not exact pin) + .row.buttons + .small-12.medium-6.columns + %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } } + .small-12.medium-6.columns + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('contact')" } } diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 132a4c6543..234ff95c25 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -3,35 +3,36 @@ %h2 Last step to create your enterprise! %h5 Who is responsible for managing {{ enterprise.name }}? %ng-include{ src: "'registration/steps.html'" } - .row.content - .small-12.large-8.columns - .row - .small-12.columns - %label{ for: 'enterprise_contact' } Primary Contact: - %input.chunky.small-12.columns{ id: 'enterprise_contact', placeholder: "Contact Name", ng: { model: 'enterprise.contact' } } - .row - .small-12.columns - %label{ for: 'enterprise_email' } Email address: - %input.chunky.small-12.columns{ id: 'enterprise_email', placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.email' } } - .row - .small-12.columns - %label{ for: 'enterprise_phone' } Phone number: - %input.chunky.small-12.columns{ id: 'enterprise_phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.phone' } } - .small-12.large-4.columns - %h6 - Contact display - %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your contact details on the Open Food Network."} - .row - .small-12.columns - %label.indent-checkbox - %input{ type: 'checkbox', id: 'contact_name_profile', ng: { model: 'enterprise.name_in_profile' } }   Display name in profile - .small-12.columns - %label.indent-checkbox - %input{ type: 'checkbox', id: 'contact_email_profile', ng: { model: 'enterprise.email_in_profile' } }   Display email in profile - .small-12.columns - %label.indent-checkbox - %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.phone_in_profile' } }   Display phone in profile - .row.buttons - .small-12.columns - %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('address')" } } - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "create()" } } \ No newline at end of file + %form + .row.content + .small-12.large-8.columns + .row + .small-12.columns + %label{ for: 'enterprise_contact' } Primary Contact: + %input.chunky.small-12.columns{ id: 'enterprise_contact', placeholder: "Contact Name", ng: { model: 'enterprise.contact' } } + .row + .small-12.columns + %label{ for: 'enterprise_email' } Email address: + %input.chunky.small-12.columns{ id: 'enterprise_email', placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.email' } } + .row + .small-12.columns + %label{ for: 'enterprise_phone' } Phone number: + %input.chunky.small-12.columns{ id: 'enterprise_phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.phone' } } + .small-12.large-4.columns + %h6 + Contact display + %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your contact details on the Open Food Network."} + .row + .small-12.columns + %label.indent-checkbox + %input{ type: 'checkbox', id: 'contact_name_profile', ng: { model: 'enterprise.name_in_profile' } }   Display name in profile + .small-12.columns + %label.indent-checkbox + %input{ type: 'checkbox', id: 'contact_email_profile', ng: { model: 'enterprise.email_in_profile' } }   Display email in profile + .small-12.columns + %label.indent-checkbox + %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.phone_in_profile' } }   Display phone in profile + .row.buttons + .small-12.columns + %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('address')" } } + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "create()" } } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index 949c634b26..74e565c789 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -3,41 +3,39 @@ %h2 Let's Get Started %h5 Woot! First we need to know what sort of enterprise you are: %ng-include{ src: "'registration/steps.html'" } - - .row - .small-12.columns - %label{ for: 'enterprise_name' } Enterprise Name: - %input.chunky.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm", ng: { model: 'enterprise.name' } } + %form + .row + .small-12.columns + %label{ for: 'enterprise_name' } Enterprise Name: + %input.chunky.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm", ng: { model: 'enterprise.name' } } - .row#enterprise-types{ 'data-equalizer' => true } - .small-12.columns - .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)}" } } - .left - %render-svg{path: "/assets/map-icon-producer.svg"} - %h4 I'm A Producer - %p.clear - %small Producers are anyone making things to eat & drink - whether 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)}" } } - .left - %render-svg{path: "/assets/map-icon-hub.svg"} - %h4 I'm A Hub - %p - %small Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, 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)}" } } - .left - %render-svg{path: "/assets/map-icon-both.svg"} - %h4 I'm Both - %p - %small Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! - .row.buttons - .small-12.columns - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" } } - - \ No newline at end of file + .row#enterprise-types{ 'data-equalizer' => true } + .small-12.columns + .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)}" } } + .left + %render-svg{path: "/assets/map-icon-producer.svg"} + %h4 I'm A Producer + %p.clear + %small Producers are anyone making things to eat & drink - whether 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)}" } } + .left + %render-svg{path: "/assets/map-icon-hub.svg"} + %h4 I'm A Hub + %p + %small Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, 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)}" } } + .left + %render-svg{path: "/assets/map-icon-both.svg"} + %h4 I'm Both + %p + %small Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! + .row.buttons + .small-12.columns + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" } } \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml index a5458b2b3e..c89a441157 100644 --- a/app/assets/javascripts/templates/registration/social.html.haml +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -3,31 +3,32 @@ %h2 Last step! %h5 How can people find {{ enterprise.name }} online? %ng-include{ src: "'registration/steps.html'" } - .row.content - .small-12.large-7.columns - .row - .small-12.columns - %label{ for: 'enterprise_website' } Website: - %input.chunky.small-12.columns{ id: 'enterprise_website', placeholder: "eg. openfoodnetwork.org.au", ng: { model: 'enterprise.website' } } - .row - .small-12.columns - %label{ for: 'enterprise_facebook' } Facebook: - %input.chunky.small-12.columns{ id: 'enterprise_facebook', placeholder: "eg. www.facebook.com/PageNameHere", ng: { model: 'enterprise.facebook' } } - .row - .small-12.columns - %label{ for: 'enterprise_linkedin' } LinkedIn: - %input.chunky.small-12.columns{ id: 'enterprise_linkedin', placeholder: "eg. www.linkedin.com/YourNameHere", ng: { model: 'enterprise.linkedin' } } - .small-12.large-5.columns - .row - .small-12.columns - %label{ for: 'enterprise_twitter' } Twitter: - %input.chunky.small-12.columns{ id: 'enterprise_twitter', placeholder: "eg. @twitter_handle", ng: { model: 'enterprise.twitter' } } - .row - .small-12.columns - %label{ for: 'enterprise_instagram' } Instagram: - %input.chunky.small-12.columns{ id: 'enterprise_instagram', placeholder: "eg. @instagram_handle", ng: { model: 'enterprise.instagram' } } + %form + .row.content + .small-12.large-7.columns + .row + .small-12.columns + %label{ for: 'enterprise_website' } Website: + %input.chunky.small-12.columns{ id: 'enterprise_website', placeholder: "eg. openfoodnetwork.org.au", ng: { model: 'enterprise.website' } } + .row + .small-12.columns + %label{ for: 'enterprise_facebook' } Facebook: + %input.chunky.small-12.columns{ id: 'enterprise_facebook', placeholder: "eg. www.facebook.com/PageNameHere", ng: { model: 'enterprise.facebook' } } + .row + .small-12.columns + %label{ for: 'enterprise_linkedin' } LinkedIn: + %input.chunky.small-12.columns{ id: 'enterprise_linkedin', placeholder: "eg. www.linkedin.com/YourNameHere", ng: { model: 'enterprise.linkedin' } } + .small-12.large-5.columns + .row + .small-12.columns + %label{ for: 'enterprise_twitter' } Twitter: + %input.chunky.small-12.columns{ id: 'enterprise_twitter', placeholder: "eg. @twitter_handle", ng: { model: 'enterprise.twitter' } } + .row + .small-12.columns + %label{ for: 'enterprise_instagram' } Instagram: + %input.chunky.small-12.columns{ id: 'enterprise_instagram', placeholder: "eg. @instagram_handle", ng: { model: 'enterprise.instagram' } } - .row.buttons - .small-12.columns - %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('about')" } } - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "update('finished')" } } \ No newline at end of file + .row.buttons + .small-12.columns + %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('about')" } } + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "update('finished')" } } \ No newline at end of file From 2917c0fa441ab5000b6810092a95864d7e5c547d Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 16:27:58 +1000 Subject: [PATCH 066/120] More styling and work on step 1 - DETAILS --- .../templates/registration/details.html.haml | 11 ++++----- .../darkswarm/registration.css.sass | 24 +++++++++++++++++-- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index 74e565c789..aeb9427d0b 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -13,29 +13,26 @@ .small-12.columns .row .small-12.columns - %label Choose One: + %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)}" } } .left %render-svg{path: "/assets/map-icon-producer.svg"} %h4 I'm A Producer - %p.clear - %small Producers are anyone making things to eat & drink - whether you grow it, raise it, brew it, bake it, ferment it, milk it or mould it. + %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)}" } } .left %render-svg{path: "/assets/map-icon-hub.svg"} %h4 I'm A Hub - %p - %small Hubs are anyone connecting the producer to the eater. Hubs may be a co-op, and independent retailer, a buying group, a CSA box scheme, a farm-gate stall, a wholesaler, etc... + %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)}" } } .left %render-svg{path: "/assets/map-icon-both.svg"} %h4 I'm Both - %p - %small Hey there, Jack-of-all-trades! Not only do you produce yummy things to eat and/or drink, you also want to connect directly to those who love buying your products! + %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 .small-12.columns %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" } } \ No newline at end of file diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index f0f898eb4e..4d2b0157dd 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -87,10 +87,30 @@ display: block background-color: #efefef color: black + @media all and (min-width: 768px) + min-height: 200px &:hover background-color: #fff + &.producer-panel:hover + &, & * + color: $clr-turquoise + &.hub-panel:hover, &.both-panel:hover + &, & * + color: $clr-brick &.selected &, & * color: #fff - color: #fff - background-color: $clr-turquoise-bright + &.hub-panel, &.both-panel + background-color: $clr-brick-bright + &:hover + &, & * + color: white + &.producer-panel + background-color: $clr-turquoise-bright + &:hover + &, & * + color: white + p + clear: both + font-size: 0.875rem + From 75c62a7cb834d96a6b9bc9628f476d69dea48ebb Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 16:49:19 +1000 Subject: [PATCH 067/120] Markup changes to step 2 address --- .../templates/registration/address.html.haml | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index 1c3ee071a8..39c459f0e0 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -1,11 +1,17 @@ .container#registration-address .header - %h2 Hi there, {{ enterprise.name }} + %h2 + Hi there, + %span.brick{"ng-show" => "enterprise.is_distributor"} + {{ enterprise.name }} + %span.turquoise{"ng-show" => "!enterprise.is_distributor" } + {{ enterprise.name }} + %h5 Now we need to know where you are: %ng-include{ src: "'registration/steps.html'" } %form .row.content - .small-7.columns + .small-12.medium-12.large-7.columns .row .small-12.columns %label{ for: 'enterprise_address' } Address: @@ -24,19 +30,20 @@ .small-12.large-4.columns %label{ for: 'enterprise_state' } State: %select.chunky.small-12.columns{ id: 'enterprise_state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()' } } - .small-5.columns - %h6 - Location display - %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} - .row - .small-12.columns - %label.indent-checkbox - %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } - Hide my street name and street number from the public (ie. only show the suburb) - .small-12.columns - %label.indent-checkbox - %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } - Blur my location on the map (show an approximate, not exact pin) + .small-12.medium-12.large-5.hide-for-small-only + // This is the location area + / %h6 + / Location display + / %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} + / .row + / .small-12.columns + / %label.indent-checkbox + / %input{ type: 'checkbox', id: 'enterpise_suburb_only', ng: { model: 'enterprise.suburb_only' } } + / Hide my street name and street number from the public (ie. only show the suburb) + / .small-12.columns + / %label.indent-checkbox + / %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } + / Blur my location on the map (show an approximate, not exact pin) .row.buttons .small-12.medium-6.columns %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } } From 912b7a8f9527f3ff87e813adb6d03f73109a70bd Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 16:49:40 +1000 Subject: [PATCH 068/120] Add a color class for global use --- app/assets/stylesheets/darkswarm/typography.css.sass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/stylesheets/darkswarm/typography.css.sass b/app/assets/stylesheets/darkswarm/typography.css.sass index de12103344..eb1885d361 100644 --- a/app/assets/stylesheets/darkswarm/typography.css.sass +++ b/app/assets/stylesheets/darkswarm/typography.css.sass @@ -48,6 +48,9 @@ small, .small .turquoise color: $clr-turquoise +.brick + color: $clr-brick + @mixin avenir font-family: "AvenirBla_IE", "AvenirBla" From a5fefbe6bb31a59aa5a0f6c7bfef7a7bcfef3352 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 16:49:57 +1000 Subject: [PATCH 069/120] More styling for register form --- app/assets/stylesheets/darkswarm/registration.css.sass | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 4d2b0157dd..6de8e00ed0 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -5,6 +5,7 @@ .header text-align: center background-color: #efefef + padding-bottom: 1rem .container background-color: #ffffff .content From 6486e41576470d1af13f1398742602386adf054b Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 17:50:22 +1000 Subject: [PATCH 070/120] More styling for registration --- app/assets/stylesheets/darkswarm/registration.css.sass | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 6de8e00ed0..70e6ef9a79 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -15,10 +15,6 @@ font-size: 150% .buttons - .right - float: right - .left - float: left ofn-inline-flash display: block From 100d672eef594aaeabdcb4f1d9d789f628ea8c19 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 17:50:41 +1000 Subject: [PATCH 071/120] Adjust button layout at bottom of page --- .../javascripts/templates/registration/social.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml index c89a441157..b217ebcc60 100644 --- a/app/assets/javascripts/templates/registration/social.html.haml +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -30,5 +30,6 @@ .row.buttons .small-12.columns - %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('about')" } } - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "update('finished')" } } \ No newline at end of file + %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('about')" } } +   + %input.button.primary{ type: "button", value: "Continue", ng: { click: "update('finished')" } } \ No newline at end of file From dc5506d06b9ea8dc7d7409bda06da88a4f3f1a03 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 17:51:03 +1000 Subject: [PATCH 072/120] Adjust button layout at bottom of page --- .../javascripts/templates/registration/images.html.haml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/templates/registration/images.html.haml b/app/assets/javascripts/templates/registration/images.html.haml index 696a0d7b16..efd3688076 100644 --- a/app/assets/javascripts/templates/registration/images.html.haml +++ b/app/assets/javascripts/templates/registration/images.html.haml @@ -8,4 +8,7 @@ .row.buttons .small-12.columns %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('about')" } } - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('social')" } } \ No newline at end of file +   + %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('social')" } } + + \ No newline at end of file From 4d8796669b78e0c804b93b3aa88b3f998a84e48a Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 17:51:25 +1000 Subject: [PATCH 073/120] Adding in pretty alert boxes, yay! --- .../templates/registration/about.html.haml | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index faf40172f4..3058843aa5 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -1,13 +1,29 @@ .container#registration-about .header %h2 Nice one! - %h5 Now let's flesh out the details about {{ enterprise.name }}. + %h5 + Now let's flesh out the details about + %span.brick{"ng-show" => "enterprise.is_distributor"} + {{ enterprise.name }} + %span.turquoise{"ng-show" => "!enterprise.is_distributor" } + {{ enterprise.name }} + %ng-include{ src: "'registration/steps.html'" } %form + .row + .small-12.columns + .alert-box.alert{"data-alert" => ""} + {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. + %a.close{:href => "#"} X + + .alert-box.info{"data-alert" => ""} + {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. + %a.close{:href => "#"} X + .row.content %ofn-inline-flash.turquoise.small-12.columns{ ng: { show: 'visible' } } - %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } - {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. + / %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } + / {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. -# %ofn-inline-flash.brick.small-12.columns{ ng: { show: 'visible' } } -# %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } -# {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. @@ -21,7 +37,7 @@ .small-12.columns %label{ for: 'enterprise_long_desc' } Long Description: %textarea.chunky.small-12.columns{ id: 'enterprise_long_desc', placeholder: "We recommend keeping your description to under 600 characters or 150 words. Why? Cus people are lazy, and don't like to read too much text online. ;)", ng: { model: 'enterprise.long_description' } } - {{ enterprise.long_description.length }} characters used + %small {{ enterprise.long_description.length }} characters used .small-12.large-4.columns .row .small-12.columns @@ -31,6 +47,6 @@ .small-12.columns %label{ for: 'enterprise_acn' } ACN: %input.chunky.small-12.columns{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } - .row.buttons + .row.buttons.pad-top .small-12.columns - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "update('social')" } } + %input.button.primary{ type: "button", value: "Continue", ng: { click: "update('social')" } } From e0fff552f96502ac90a2d545d4e9b4e0acb11068 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 17:51:49 +1000 Subject: [PATCH 074/120] Adjust button layout at bottom of page --- .../templates/registration/address.html.haml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index 39c459f0e0..d36274d856 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -1,13 +1,13 @@ .container#registration-address .header %h2 - Hi there, + Greetings %span.brick{"ng-show" => "enterprise.is_distributor"} {{ enterprise.name }} %span.turquoise{"ng-show" => "!enterprise.is_distributor" } {{ enterprise.name }} - %h5 Now we need to know where you are: + %h5 Now we need to know where you are %ng-include{ src: "'registration/steps.html'" } %form .row.content @@ -44,8 +44,9 @@ / %label.indent-checkbox / %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } / Blur my location on the map (show an approximate, not exact pin) + .row.buttons - .small-12.medium-6.columns - %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } } - .small-12.medium-6.columns - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "select('contact')" } } + .small-12.columns + %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } } +   + %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" } } From f8c761f4920fda209af750bbc5763c67fbd56fd7 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 17:52:33 +1000 Subject: [PATCH 075/120] Comment out unused section, set column layout to match previous step --- .../templates/registration/contact.html.haml | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 234ff95c25..dac16c5771 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -1,11 +1,16 @@ .container#registration-contact .header %h2 Last step to create your enterprise! - %h5 Who is responsible for managing {{ enterprise.name }}? + %h5 + Who is responsible for managing + %span.brick{"ng-show" => "enterprise.is_distributor"} + {{ enterprise.name }} + %span.turquoise{"ng-show" => "!enterprise.is_distributor" } + {{ enterprise.name }} %ng-include{ src: "'registration/steps.html'" } %form .row.content - .small-12.large-8.columns + .small-12.medium-12.large-7.columns .row .small-12.columns %label{ for: 'enterprise_contact' } Primary Contact: @@ -18,21 +23,25 @@ .small-12.columns %label{ for: 'enterprise_phone' } Phone number: %input.chunky.small-12.columns{ id: 'enterprise_phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.phone' } } - .small-12.large-4.columns - %h6 - Contact display - %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your contact details on the Open Food Network."} - .row - .small-12.columns - %label.indent-checkbox - %input{ type: 'checkbox', id: 'contact_name_profile', ng: { model: 'enterprise.name_in_profile' } }   Display name in profile - .small-12.columns - %label.indent-checkbox - %input{ type: 'checkbox', id: 'contact_email_profile', ng: { model: 'enterprise.email_in_profile' } }   Display email in profile - .small-12.columns - %label.indent-checkbox - %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.phone_in_profile' } }   Display phone in profile + .small-12.medium-12.large-5.hide-for-small-only + / %h6 + / Contact display + / %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your contact details on the Open Food Network."} + / .row + / .small-12.columns + / %label.indent-checkbox + / %input{ type: 'checkbox', id: 'contact_name_profile', ng: { model: 'enterprise.name_in_profile' } }   Display name in profile + / .small-12.columns + / %label.indent-checkbox + / %input{ type: 'checkbox', id: 'contact_email_profile', ng: { model: 'enterprise.email_in_profile' } }   Display email in profile + / .small-12.columns + / %label.indent-checkbox + / %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.phone_in_profile' } }   Display phone in profile + .row.buttons .small-12.columns - %input.button.primary.left{ type: "button", value: "Back", ng: { click: "select('address')" } } - %input.button.primary.right{ type: "button", value: "Continue", ng: { click: "create()" } } \ No newline at end of file + %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('address')" } } +   + %input.button.primary{ type: "button", value: "Continue", ng: { click: "create()" } } + + \ No newline at end of file From 8d570286a1d7be27c211ab820d81c1335a65ce8f Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 22 Aug 2014 17:53:05 +1000 Subject: [PATCH 076/120] Adding in sexy logic to add color to name depending on type --- .../javascripts/templates/registration/finished.html.haml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/templates/registration/finished.html.haml b/app/assets/javascripts/templates/registration/finished.html.haml index 92ec44ab30..8e99ac1870 100644 --- a/app/assets/javascripts/templates/registration/finished.html.haml +++ b/app/assets/javascripts/templates/registration/finished.html.haml @@ -1,7 +1,12 @@ .container#registration-finished .header %h2 Well done! - %h5 You have successfully completed the profile for {{ enterprise.name }}! + %h5 + You have successfully completed the profile for + %span.brick{"ng-show" => "enterprise.is_distributor"} + {{ enterprise.name }} + %span.turquoise{"ng-show" => "!enterprise.is_distributor" } + {{ enterprise.name }} .content{ style: 'text-align: center'} %h3 Why not check it out on the Open Food Network? %a.button.primary{ type: "button", href: "/map" } Go to Map Page > From 800eecea33b26b0e83c2ade943b6c2c10dc96122 Mon Sep 17 00:00:00 2001 From: Rob H Date: Sun, 24 Aug 2014 10:08:50 +1000 Subject: [PATCH 077/120] Fix failing bulk specs --- .../javascripts/unit/bulk_order_management_spec.js.coffee | 8 +++++--- spec/javascripts/unit/bulk_product_update_spec.js.coffee | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/spec/javascripts/unit/bulk_order_management_spec.js.coffee b/spec/javascripts/unit/bulk_order_management_spec.js.coffee index 80884b855d..35b9e13d61 100644 --- a/spec/javascripts/unit/bulk_order_management_spec.js.coffee +++ b/spec/javascripts/unit/bulk_order_management_spec.js.coffee @@ -2,7 +2,9 @@ describe "AdminOrderMgmtCtrl", -> ctrl = scope = httpBackend = VariantUnitManager = null beforeEach -> - module "ofn.admin" + module "ofn.admin", ($provide) -> + $provide.value 'SpreeApiKey', 'API_KEY' + return beforeEach inject(($controller, $rootScope, $httpBackend, _VariantUnitManager_) -> scope = $rootScope.$new() ctrl = $controller @@ -18,7 +20,7 @@ describe "AdminOrderMgmtCtrl", -> returnedSuppliers = ["list of suppliers"] returnedDistributors = ["list of distributors"] returnedOrderCycles = [ "oc1", "oc2", "oc3" ] - httpBackend.expectGET("/api/users/authorise_api?token=api_key").respond success: "Use of API Authorised" + httpBackend.expectGET("/api/users/authorise_api?token=API_KEY").respond success: "Use of API Authorised" httpBackend.expectGET("/api/enterprises/accessible?template=bulk_index&q[is_primary_producer_eq]=true").respond returnedSuppliers httpBackend.expectGET("/api/enterprises/accessible?template=bulk_index&q[is_distributor_eq]=true").respond returnedDistributors httpBackend.expectGET("/api/order_cycles/accessible").respond returnedOrderCycles @@ -27,7 +29,7 @@ describe "AdminOrderMgmtCtrl", -> #spyOn(returnedSuppliers, "unshift") #spyOn(returnedDistributors, "unshift") #spyOn(returnedOrderCycles, "unshift") - scope.initialise "api_key" + scope.initialise() httpBackend.flush() expect(scope.suppliers).toEqual [{ id : '0', name : 'All' }, 'list of suppliers'] diff --git a/spec/javascripts/unit/bulk_product_update_spec.js.coffee b/spec/javascripts/unit/bulk_product_update_spec.js.coffee index b9081a1882..649ab99f52 100644 --- a/spec/javascripts/unit/bulk_product_update_spec.js.coffee +++ b/spec/javascripts/unit/bulk_product_update_spec.js.coffee @@ -165,7 +165,7 @@ describe "filtering products for submission to database", -> variant_unit: 'weight' variant_unit_scale: 1 ] - + # TODO Not an exhaustive test, is there a better way to do this? it "only returns the properties of products which ought to be updated", -> available_on = new Date() @@ -238,6 +238,7 @@ describe "AdminProductEditCtrl", -> module ($provide)-> $provide.value "producers", [] $provide.value "taxons", [] + $provide.value 'SpreeApiKey', 'API_KEY' null beforeEach inject((_$controller_, _$timeout_, $rootScope, _$httpBackend_, _DirtyProducts_) -> @@ -252,9 +253,9 @@ describe "AdminProductEditCtrl", -> describe "loading data upon initialisation", -> it "gets a list of producers and then resets products with a list of data", -> - $httpBackend.expectGET("/api/users/authorise_api?token=api_key").respond success: "Use of API Authorised" + $httpBackend.expectGET("/api/users/authorise_api?token=API_KEY").respond success: "Use of API Authorised" spyOn($scope, "fetchProducts").andReturn "nothing" - $scope.initialise "api_key" + $scope.initialise() $httpBackend.flush() expect($scope.fetchProducts.calls.length).toEqual 1 expect($scope.spree_api_key_ok).toEqual true From 412e906ed3ccefd2d85256357a29e90aebe5edfc Mon Sep 17 00:00:00 2001 From: Rob H Date: Sun, 24 Aug 2014 11:20:00 +1000 Subject: [PATCH 078/120] Adding basic validation to reg process --- .../registration_controller.js.coffee | 4 +--- .../registration_form_controller.js.coffee | 20 +++++++++++++++++++ .../templates/registration/details.html.haml | 9 ++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee diff --git a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee index 2cf7c50c8d..2fcc0f32fd 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration_controller.js.coffee @@ -1,9 +1,7 @@ Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, EnterpriseRegistrationService, availableCountries) -> $scope.currentStep = RegistrationService.currentStep - $scope.select = RegistrationService.select $scope.enterprise = EnterpriseRegistrationService.enterprise - $scope.create = EnterpriseRegistrationService.create - $scope.update = EnterpriseRegistrationService.update + $scope.select = RegistrationService.select $scope.steps = ['details','address','contact','about','images','social'] diff --git a/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee new file mode 100644 index 0000000000..dc48bac9c5 --- /dev/null +++ b/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee @@ -0,0 +1,20 @@ +Darkswarm.controller "RegistrationFormCtrl", ($scope, RegistrationService, EnterpriseRegistrationService) -> + $scope.submitted = false + + $scope.create = (form) -> + $scope.submitted = true + if form.$valid + EnterpriseRegistrationService.create() + $scope.submitted = false + + $scope.update = (nextStep, form) -> + $scope.submitted = true + if form.$valid + EnterpriseRegistrationService.update(nextStep) + $scope.submitted = false + + $scope.select = (nextStep, form) -> + $scope.submitted = true + if form.$valid + RegistrationService.select(nextStep) + $scope.submitted = false \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index aeb9427d0b..7991d0e01c 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -3,11 +3,14 @@ %h2 Let's Get Started %h5 Woot! First we need to know what sort of enterprise you are: %ng-include{ src: "'registration/steps.html'" } - %form + %form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "select('address',details)" } } .row .small-12.columns %label{ for: 'enterprise_name' } Enterprise Name: - %input.chunky.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm", ng: { model: 'enterprise.name' } } + %input.chunky.small-12.columns{ id: 'enterprise_name', name: 'name', placeholder: "eg. Charlie's Awesome Farm", required: true, ng: { model: 'enterprise.name' } } + {{ submitted + " " + details.name.$error.required }} + %span.error.small-12.columns{ ng: { show: "details.name.$error.required && submitted" } } + You need to enter a name for you enterprise! .row#enterprise-types{ 'data-equalizer' => true } .small-12.columns @@ -35,4 +38,4 @@ %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 .small-12.columns - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" } } \ No newline at end of file + %input.button.primary.right{ type: "submit", value: "Continue" } From 34841f85438526318f88b77bc5f0cead0c248a01 Mon Sep 17 00:00:00 2001 From: Rob H Date: Sun, 24 Aug 2014 12:24:16 +1000 Subject: [PATCH 079/120] Refactoring registration form controller --- .../registration_form_controller.js.coffee | 19 +++++++------------ .../templates/registration/details.html.haml | 7 +++---- .../darkswarm/registration.css.sass | 4 +++- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee index dc48bac9c5..e9073b8c1b 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee @@ -1,20 +1,15 @@ Darkswarm.controller "RegistrationFormCtrl", ($scope, RegistrationService, EnterpriseRegistrationService) -> $scope.submitted = false + $scope.valid = (form) -> + $scope.submitted = !form.$valid + form.$valid + $scope.create = (form) -> - $scope.submitted = true - if form.$valid - EnterpriseRegistrationService.create() - $scope.submitted = false + EnterpriseRegistrationService.create() if $scope.valid(form) $scope.update = (nextStep, form) -> - $scope.submitted = true - if form.$valid - EnterpriseRegistrationService.update(nextStep) - $scope.submitted = false + EnterpriseRegistrationService.update(nextStep) if $scope.valid(form) $scope.select = (nextStep, form) -> - $scope.submitted = true - if form.$valid - RegistrationService.select(nextStep) - $scope.submitted = false \ No newline at end of file + RegistrationService.select(nextStep) if $scope.valid(form) \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index 7991d0e01c..fc3a3a7798 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -5,15 +5,14 @@ %ng-include{ src: "'registration/steps.html'" } %form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "select('address',details)" } } .row - .small-12.columns + .small-12.columns.field %label{ for: 'enterprise_name' } Enterprise Name: %input.chunky.small-12.columns{ id: 'enterprise_name', name: 'name', placeholder: "eg. Charlie's Awesome Farm", required: true, ng: { model: 'enterprise.name' } } - {{ submitted + " " + details.name.$error.required }} %span.error.small-12.columns{ ng: { show: "details.name.$error.required && submitted" } } - You need to enter a name for you enterprise! + You need to enter a name for your enterprise! .row#enterprise-types{ 'data-equalizer' => true } - .small-12.columns + .small-12.columns.field .row .small-12.columns %label Choose one: diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 70e6ef9a79..42db8f4aa1 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -34,10 +34,12 @@ top: 0px right: 0px + .field + margin-bottom: 15px + input.chunky padding: 8px font-size: 105% - margin-bottom: 15px label.indent-checkbox display: block From 454e4c971a9233738661db0501858c749f010e5b Mon Sep 17 00:00:00 2001 From: Rob H Date: Sun, 24 Aug 2014 16:43:10 +1000 Subject: [PATCH 080/120] Adding validation to address page --- .../registration_form_controller.js.coffee | 2 +- .../templates/registration/address.html.haml | 42 ++++++++++++------- .../templates/registration/contact.html.haml | 15 +++---- .../templates/registration/details.html.haml | 6 +-- .../darkswarm/registration.css.sass | 4 +- 5 files changed, 38 insertions(+), 31 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee index e9073b8c1b..84f133da54 100644 --- a/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/registration_form_controller.js.coffee @@ -11,5 +11,5 @@ Darkswarm.controller "RegistrationFormCtrl", ($scope, RegistrationService, Enter $scope.update = (nextStep, form) -> EnterpriseRegistrationService.update(nextStep) if $scope.valid(form) - $scope.select = (nextStep, form) -> + $scope.selectIfValid = (nextStep, form) -> RegistrationService.select(nextStep) if $scope.valid(form) \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index d36274d856..0d6fdb90a0 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -1,40 +1,50 @@ .container#registration-address .header - %h2 + %h2 Greetings - %span.brick{"ng-show" => "enterprise.is_distributor"} + %span.brick{ ng: { show: "enterprise.is_distributor" } } {{ enterprise.name }} - %span.turquoise{"ng-show" => "!enterprise.is_distributor" } + %span.turquoise{ ng: { show: "!enterprise.is_distributor" } } {{ enterprise.name }} - + %h5 Now we need to know where you are %ng-include{ src: "'registration/steps.html'" } - %form + %form{ name: 'address', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('contact',address)" } } .row.content .small-12.medium-12.large-7.columns .row - .small-12.columns + .small-12.columns.field %label{ for: 'enterprise_address' } Address: - %input.chunky.small-12.columns{ id: 'enterprise_address', placeholder: "eg. 123 Cranberry Drive", ng: { model: 'enterprise.address.address1' } } + %input.chunky.small-12.columns{ id: 'enterprise_address', name: 'address1', required: true, placeholder: "eg. 123 Cranberry Drive", required: true, ng: { model: 'enterprise.address.address1' } } + %span.error.small-12.columns{ ng: { show: "address.address1.$error.required && submitted" } } + You need to enter an address. .row - .small-12.large-8.columns + .small-12.large-8.columns.field %label{ for: 'enterprise_city' } Suburb: - %input.chunky.small-12.columns{ id: 'enterprise_city', placeholder: "eg. Northcote", ng: { model: 'enterprise.address.city' } } + %input.chunky.small-12.columns{ id: 'enterprise_city', name: 'city', required: true, placeholder: "eg. Northcote", ng: { model: 'enterprise.address.city' } } + %span.error.small-12.columns{ ng: { show: "address.city.$error.required && submitted" } } + You need to enter a suburb. .small-12.large-4.columns %label{ for: 'enterprise_zipcode' } Postcode: - %input.chunky.small-12.columns{ id: 'enterprise_zipcode', placeholder: "eg. 3070", ng: { model: 'enterprise.address.zipcode' } } + %input.chunky.small-12.columns{ id: 'enterprise_zipcode', name: 'zipcode', required: true, placeholder: "eg. 3070", ng: { model: 'enterprise.address.zipcode' } } + %span.error.small-12.columns{ ng: { show: "address.zipcode.$error.required && submitted" } } + You need to enter a postcode. .row .small-12.large-8.columns %label{ for: 'enterprise_country' } Country: - %select.chunky.small-12.columns{ id: 'enterprise_country', ng: { model: 'enterprise.country', options: 'c as c.name for c in countries' } } + %select.chunky.small-12.columns{ id: 'enterprise_country', name: 'country', required: true, ng: { model: 'enterprise.country', options: 'c as c.name for c in countries' } } + %span.error.small-12.columns{ ng: { show: "address.country.$error.required && submitted" } } + You need to enter a country. .small-12.large-4.columns %label{ for: 'enterprise_state' } State: - %select.chunky.small-12.columns{ id: 'enterprise_state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()' } } + %select.chunky.small-12.columns{ id: 'enterprise_state', name: 'state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()', required: 'countryHasStates()' } } + %span.error.small-12.columns{ ng: { show: "address.state.$error.required && submitted" } } + You need to enter a state. .small-12.medium-12.large-5.hide-for-small-only // This is the location area / %h6 / Location display - / %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} + / %i.ofn-i_013-help.has-tip{ 'data-tooltip' => true, title: "Choose how you want to display your enterprise's address on the Open Food Network. By default, full location is shown everywhere including street name and number."} / .row / .small-12.columns / %label.indent-checkbox @@ -44,9 +54,9 @@ / %label.indent-checkbox / %input{ type: 'checkbox', id: 'enterprise_on_map', ng: { model: 'enterprise.on_map' } } / Blur my location on the map (show an approximate, not exact pin) - + .row.buttons .small-12.columns - %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } } + %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('details')" } }   - %input.button.primary{ type: "button", value: "Continue", ng: { click: "select('contact')" } } + %input.button.primary{ type: "submit", value: "Continue" } diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index dac16c5771..8d45501d4a 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -1,8 +1,8 @@ .container#registration-contact .header %h2 Last step to create your enterprise! - %h5 - Who is responsible for managing + %h5 + Who is responsible for managing %span.brick{"ng-show" => "enterprise.is_distributor"} {{ enterprise.name }} %span.turquoise{"ng-show" => "!enterprise.is_distributor" } @@ -12,15 +12,15 @@ .row.content .small-12.medium-12.large-7.columns .row - .small-12.columns + .small-12.columns.field %label{ for: 'enterprise_contact' } Primary Contact: %input.chunky.small-12.columns{ id: 'enterprise_contact', placeholder: "Contact Name", ng: { model: 'enterprise.contact' } } .row - .small-12.columns + .small-12.columns.field %label{ for: 'enterprise_email' } Email address: %input.chunky.small-12.columns{ id: 'enterprise_email', placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.email' } } .row - .small-12.columns + .small-12.columns.field %label{ for: 'enterprise_phone' } Phone number: %input.chunky.small-12.columns{ id: 'enterprise_phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.phone' } } .small-12.medium-12.large-5.hide-for-small-only @@ -37,11 +37,8 @@ / .small-12.columns / %label.indent-checkbox / %input{ type: 'checkbox', id: 'contact_phone_profile', ng: { model: 'enterprise.phone_in_profile' } }   Display phone in profile - .row.buttons .small-12.columns - %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('address')" } } + %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('address')" } }   %input.button.primary{ type: "button", value: "Continue", ng: { click: "create()" } } - - \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index fc3a3a7798..dc2c3cc76d 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -3,7 +3,7 @@ %h2 Let's Get Started %h5 Woot! First we need to know what sort of enterprise you are: %ng-include{ src: "'registration/steps.html'" } - %form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "select('address',details)" } } + %form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('address',details)" } } .row .small-12.columns.field %label{ for: 'enterprise_name' } Enterprise Name: @@ -20,13 +20,13 @@ .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)}" } } .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)}" } } .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 } diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index 42db8f4aa1..be3fdda994 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -62,7 +62,7 @@ .highlight-box background: white padding: 1rem 1.2rem - @media all and (max-width: 640px) + @media all and (max-width: 640px) margin-top: 1rem #progress-bar @@ -86,7 +86,7 @@ display: block background-color: #efefef color: black - @media all and (min-width: 768px) + @media all and (min-width: 768px) min-height: 200px &:hover background-color: #fff From fc0afae51c27f80e1f99bc292170b0aea5baa22a Mon Sep 17 00:00:00 2001 From: Rob H Date: Sun, 24 Aug 2014 18:46:14 +1000 Subject: [PATCH 081/120] Adding form validation to contact page --- .../templates/registration/address.html.haml | 10 ++++------ .../templates/registration/contact.html.haml | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/templates/registration/address.html.haml b/app/assets/javascripts/templates/registration/address.html.haml index 0d6fdb90a0..6fe39e9285 100644 --- a/app/assets/javascripts/templates/registration/address.html.haml +++ b/app/assets/javascripts/templates/registration/address.html.haml @@ -2,9 +2,7 @@ .header %h2 Greetings - %span.brick{ ng: { show: "enterprise.is_distributor" } } - {{ enterprise.name }} - %span.turquoise{ ng: { show: "!enterprise.is_distributor" } } + %span{ ng: { class: "{brick: enterprise.is_distributor, turquoise: !enterprise.is_distributor}" } } {{ enterprise.name }} %h5 Now we need to know where you are @@ -24,18 +22,18 @@ %input.chunky.small-12.columns{ id: 'enterprise_city', name: 'city', required: true, placeholder: "eg. Northcote", ng: { model: 'enterprise.address.city' } } %span.error.small-12.columns{ ng: { show: "address.city.$error.required && submitted" } } You need to enter a suburb. - .small-12.large-4.columns + .small-12.large-4.columns.field %label{ for: 'enterprise_zipcode' } Postcode: %input.chunky.small-12.columns{ id: 'enterprise_zipcode', name: 'zipcode', required: true, placeholder: "eg. 3070", ng: { model: 'enterprise.address.zipcode' } } %span.error.small-12.columns{ ng: { show: "address.zipcode.$error.required && submitted" } } You need to enter a postcode. .row - .small-12.large-8.columns + .small-12.large-8.columns.field %label{ for: 'enterprise_country' } Country: %select.chunky.small-12.columns{ id: 'enterprise_country', name: 'country', required: true, ng: { model: 'enterprise.country', options: 'c as c.name for c in countries' } } %span.error.small-12.columns{ ng: { show: "address.country.$error.required && submitted" } } You need to enter a country. - .small-12.large-4.columns + .small-12.large-4.columns.field %label{ for: 'enterprise_state' } State: %select.chunky.small-12.columns{ id: 'enterprise_state', name: 'state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()', required: 'countryHasStates()' } } %span.error.small-12.columns{ ng: { show: "address.state.$error.required && submitted" } } diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index 8d45501d4a..ea2c51263a 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -3,26 +3,28 @@ %h2 Last step to create your enterprise! %h5 Who is responsible for managing - %span.brick{"ng-show" => "enterprise.is_distributor"} - {{ enterprise.name }} - %span.turquoise{"ng-show" => "!enterprise.is_distributor" } + %span{ ng: { class: "{brick: enterprise.is_distributor, turquoise: !enterprise.is_distributor}" } } {{ enterprise.name }} %ng-include{ src: "'registration/steps.html'" } - %form + %form{ name: 'contact', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "create(contact)" } } .row.content .small-12.medium-12.large-7.columns .row .small-12.columns.field %label{ for: 'enterprise_contact' } Primary Contact: - %input.chunky.small-12.columns{ id: 'enterprise_contact', placeholder: "Contact Name", ng: { model: 'enterprise.contact' } } + %input.chunky.small-12.columns{ id: 'enterprise_contact', name: 'contact', required: true, placeholder: "Contact Name", ng: { model: 'enterprise.contact' } } + %span.error.small-12.columns{ ng: { show: "contact.contact.$error.required && submitted" } } + You need to enter a primary contact. .row .small-12.columns.field %label{ for: 'enterprise_email' } Email address: - %input.chunky.small-12.columns{ id: 'enterprise_email', placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.email' } } + %input.chunky.small-12.columns{ id: 'enterprise_email', name: 'email', type: 'email', required: true, placeholder: "eg. charlie@thefarm.com", ng: { model: 'enterprise.email' } } + %span.error.small-12.columns{ ng: { show: "(contact.email.$error.email || contact.email.$error.required) && submitted" } } + You need to enter valid email address. .row .small-12.columns.field %label{ for: 'enterprise_phone' } Phone number: - %input.chunky.small-12.columns{ id: 'enterprise_phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.phone' } } + %input.chunky.small-12.columns{ id: 'enterprise_phone', name: 'phone', placeholder: "eg. (03) 1234 5678", ng: { model: 'enterprise.phone' } } .small-12.medium-12.large-5.hide-for-small-only / %h6 / Contact display @@ -41,4 +43,4 @@ .small-12.columns %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('address')" } }   - %input.button.primary{ type: "button", value: "Continue", ng: { click: "create()" } } + %input.button.primary{ type: "submit", value: "Continue" } From 19565a5f3b4786aaf35f6b842be336fb721c0c3b Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 27 Aug 2014 11:50:46 +1000 Subject: [PATCH 082/120] Rename service --- ...ervice.js.coffee => enterprise_registration_service.js.coffee} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/assets/javascripts/darkswarm/services/{enterprise_creation_service.js.coffee => enterprise_registration_service.js.coffee} (100%) diff --git a/app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee similarity index 100% rename from app/assets/javascripts/darkswarm/services/enterprise_creation_service.js.coffee rename to app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee From 048a741a2cf41d6ae028e4b6694d7d0e0ea0c897 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 27 Aug 2014 11:51:13 +1000 Subject: [PATCH 083/120] Plugging final two registration pages into validation --- .../templates/registration/about.html.haml | 18 +++++------------- .../templates/registration/social.html.haml | 4 ++-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index 3058843aa5..07e631345f 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -1,7 +1,7 @@ .container#registration-about .header %h2 Nice one! - %h5 + %h5 Now let's flesh out the details about %span.brick{"ng-show" => "enterprise.is_distributor"} {{ enterprise.name }} @@ -9,24 +9,16 @@ {{ enterprise.name }} %ng-include{ src: "'registration/steps.html'" } - %form + %form{ name: 'about', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "update('social',about)" } } .row .small-12.columns .alert-box.alert{"data-alert" => ""} {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. - %a.close{:href => "#"} X + %a.close{:href => "#"} × .alert-box.info{"data-alert" => ""} {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. - %a.close{:href => "#"} X - - .row.content - %ofn-inline-flash.turquoise.small-12.columns{ ng: { show: 'visible' } } - / %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } - / {{ enterprise.name }} has been created on the Open Food Network. If you leave at any point from here onwards, your enterprise will be saved, and you can always login to the admin section to update or continue filling out your enterprise details. - -# %ofn-inline-flash.brick.small-12.columns{ ng: { show: 'visible' } } - -# %i.ofn-i_009-close.close-button{ ng: { click: 'closeFlash()' } } - -# {{ enterprise.name }} won't be visible on the Open Food Network until you enter a long and short description. + %a.close{:href => "#"} × .small-12.large-8.columns .row @@ -49,4 +41,4 @@ %input.chunky.small-12.columns{ id: 'enterprise_acn', placeholder: "eg. 123 456 789", ng: { model: 'enterprise.acn' } } .row.buttons.pad-top .small-12.columns - %input.button.primary{ type: "button", value: "Continue", ng: { click: "update('social')" } } + %input.button.primary{ type: "submit", value: "Continue" } diff --git a/app/assets/javascripts/templates/registration/social.html.haml b/app/assets/javascripts/templates/registration/social.html.haml index b217ebcc60..2aa12bd08b 100644 --- a/app/assets/javascripts/templates/registration/social.html.haml +++ b/app/assets/javascripts/templates/registration/social.html.haml @@ -3,7 +3,7 @@ %h2 Last step! %h5 How can people find {{ enterprise.name }} online? %ng-include{ src: "'registration/steps.html'" } - %form + %form{ name: 'social', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "update('finished',social)" } } .row.content .small-12.large-7.columns .row @@ -32,4 +32,4 @@ .small-12.columns %input.button.secondary{ type: "button", value: "Back", ng: { click: "select('about')" } }   - %input.button.primary{ type: "button", value: "Continue", ng: { click: "update('finished')" } } \ No newline at end of file + %input.button.primary{ type: "submit", value: "Continue" } \ No newline at end of file From de64a5154bc42e8d6c0d8c419df5f2179bc63a78 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 11 Sep 2014 17:13:07 +1000 Subject: [PATCH 084/120] Fixing markup icon class name was incorrect --- .../templates/price_breakdown_button.html.haml | 2 +- .../stylesheets/darkswarm/_shop-popovers.css.sass | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/templates/price_breakdown_button.html.haml b/app/assets/javascripts/templates/price_breakdown_button.html.haml index 8a86ed2618..e5dbbe7123 100644 --- a/app/assets/javascripts/templates/price_breakdown_button.html.haml +++ b/app/assets/javascripts/templates/price_breakdown_button.html.haml @@ -1,2 +1,2 @@ %button.graph-button{"ng-class" => "{open: tt_isOpen}"} - %i.ofn-i-058-graph + %i.ofn-i_058-graph diff --git a/app/assets/stylesheets/darkswarm/_shop-popovers.css.sass b/app/assets/stylesheets/darkswarm/_shop-popovers.css.sass index 6fa8a72c1b..e1eb2cd448 100644 --- a/app/assets/stylesheets/darkswarm/_shop-popovers.css.sass +++ b/app/assets/stylesheets/darkswarm/_shop-popovers.css.sass @@ -87,10 +87,10 @@ button.graph-button &:hover, &:active, &:focus background-color: rgba(255,255,255,1) - i.ofn-i-058-graph + i.ofn-i_058-graph color: $clr-brick-bright - i.ofn-i-058-graph + i.ofn-i_058-graph color: #999 margin: 0 padding: 0 @@ -98,7 +98,7 @@ button.graph-button @media all and (max-width: 640px) padding: 3px - i.ofn-i-058-graph + i.ofn-i_058-graph font-size: 0.75rem button.graph-button.open @@ -107,10 +107,10 @@ button.graph-button.open &:hover, &:active, &:focus background-color: rgba(255,255,255,1) - i.ofn-i-058-graph + i.ofn-i_058-graph color: $clr-brick-bright - i.ofn-i-058-graph + i.ofn-i_058-graph color: $clr-brick From 98f7e58f9d3d182926c6be3ed3a9f7a98894d156 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 11 Sep 2014 17:58:05 +1000 Subject: [PATCH 085/120] Registration spec expects the correct url --- spec/controllers/registration_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/registration_controller_spec.rb b/spec/controllers/registration_controller_spec.rb index 458a5fc33d..0240dc6de0 100644 --- a/spec/controllers/registration_controller_spec.rb +++ b/spec/controllers/registration_controller_spec.rb @@ -3,6 +3,6 @@ require 'spec_helper' describe RegistrationController do it "redirects to authentication page when user not logged in" do get :index - response.should redirect_to registration_auth_path(anchor: "login?after_login=/register") + response.should redirect_to registration_auth_path(anchor: "signup?after_login=/register") end end From 12f5e484793c8a7542fda401cf8bddfe04508fef Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 11 Sep 2014 17:58:38 +1000 Subject: [PATCH 086/120] Replace is not with isnt - damn you CoffeeScript --- .../darkswarm/services/authentication_service.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee b/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee index 2dad1bc4f2..5f5ae520e3 100644 --- a/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/authentication_service.js.coffee @@ -4,7 +4,7 @@ Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redir selectedPath: "/login" constructor: -> - if $location.path() in ["/login", "/signup", "/forgot"] && location.pathname is not '/register/auth' + if $location.path() in ["/login", "/signup", "/forgot"] && location.pathname isnt '/register/auth' @open $location.path() else if location.pathname is '/register/auth' @open '/signup', 'registration_authentication.html' From a7a99b50482896ab7f2b324189de716d566526f5 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 11 Sep 2014 18:15:33 +1000 Subject: [PATCH 087/120] Pending registration spec --- spec/features/consumer/registration_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 5041aae1a5..0c706b1a13 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -4,18 +4,19 @@ feature "Registration", js: true do describe "Registering a Profile" do let(:user) { create(:user, password: "password", password_confirmation: "password") } - it "Allows a logged in user to register a profile" do + pending "Allows a logged in user to register a profile" do visit registration_path expect(URI.parse(current_url).path).to eq registration_auth_path # Logging in + click_link "Log in" fill_in "Email", with: user.email fill_in "Password", with: user.password click_button 'Log in' # Log in was successful, introduction shown - expect(page).to have_content "This wizard will step you through creating a Profile on the Open Food Network." + expect(page).to have_content "This wizard will step you through creating a profile" expect(URI.parse(current_url).path).to eq registration_path # Done reading introduction From 5007fd8ec364474e92503bacb7bfdc4a0677b520 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 11 Sep 2014 22:27:05 +1000 Subject: [PATCH 088/120] Shipping method 1 is used, so shipping method amount is zero --- spec/features/consumer/shopping/checkout_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index ab53befda5..7dae7a54e2 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -188,7 +188,7 @@ feature "As a consumer I want to check out my cart", js: true do # Order should have a payment with the correct amount o = Spree::Order.complete.first - o.payments.first.amount.should == 15.79 + o.payments.first.amount.should == 11.23 end it "shows the payment processing failed message when submitted with an invalid credit card" do From 043cc915e7ca1cc7b86baaf61431176c14d269a6 Mon Sep 17 00:00:00 2001 From: Rob H Date: Thu, 11 Sep 2014 22:40:03 +1000 Subject: [PATCH 089/120] Removing save_screenshot calls --- spec/features/admin/bulk_product_update_spec.rb | 1 - spec/features/consumer/authentication_spec.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index 9f530f860c..b2d5e41718 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -305,7 +305,6 @@ feature %q{ expect(page).to have_select "producer", selected: s1.name expect(page).to have_field "available_on", with: p.available_on.strftime("%F %T") expect(page).to have_field "price", with: "10.0" - save_screenshot '/Users/rob/Desktop/ss.png' expect(page).to have_selector "div#s2id_p#{p.id}_category a.select2-choice" expect(page).to have_select "variant_unit_with_scale", selected: "Volume (L)" expect(page).to have_field "on_hand", with: "6" diff --git a/spec/features/consumer/authentication_spec.rb b/spec/features/consumer/authentication_spec.rb index cf0bc658bd..f8b405374e 100644 --- a/spec/features/consumer/authentication_spec.rb +++ b/spec/features/consumer/authentication_spec.rb @@ -10,7 +10,6 @@ feature "Authentication", js: true do visit groups_path(anchor: "login?after_login=#{producers_path}") fill_in "Email", with: user.email fill_in "Password", with: user.password - save_screenshot "/Users/willmarshall/Desktop/wtf.png" click_login_button page.should have_content "Find local producers" current_path.should == producers_path From 6d7fd6dc941a710da862dea47fa806424a0140ef Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 10:48:33 +1000 Subject: [PATCH 090/120] Add in logic to change right hand label if this is the current hub --- app/views/home/_skinny.html.haml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/home/_skinny.html.haml b/app/views/home/_skinny.html.haml index 3c5654437c..da9709479b 100644 --- a/app/views/home/_skinny.html.haml +++ b/app/views/home/_skinny.html.haml @@ -15,12 +15,16 @@ .columns.small-6.medium-3.large-4.text-right{"bo-if" => "hub.active"} %a.hub.open_closed{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"} %i.ofn-i_033-open-sign - %span.margin-top {{ hub.orders_close_at | sensible_timeframe }} + %span.margin-top{ bo: { if: "current()" } } + %em Shopping here + %span.margin-top{ bo: { if: "!current()" } } {{ hub.orders_close_at | sensible_timeframe }} .columns.small-6.medium-3.large-4.text-right{"bo-if" => "!hub.active"} %a.hub.open_closed{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"} %i.ofn-i_032-closed-sign - %span.margin-top Orders closed + %span.margin-top{ bo: { if: "current()" } } + %em Shopping here + %span.margin-top{ bo: { if: "!current()" } } Orders closed From 9c33be911c401fb4c055d82c5d0c8b9ecd4eeffe Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 10:49:59 +1000 Subject: [PATCH 091/120] Update placeholder label --- app/views/home/_hubs.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/_hubs.html.haml b/app/views/home/_hubs.html.haml index ede6750b83..ff90a45d48 100644 --- a/app/views/home/_hubs.html.haml +++ b/app/views/home/_hubs.html.haml @@ -14,7 +14,7 @@ / %i.ofn-i_020-search %input{type: :text, "ng-model" => "query", - placeholder: "Search by Name or Suburb...", + placeholder: "Search by name or suburb...", "ng-debounce" => "150", "ofn-disable-enter" => true} From 126e9e82a6553f2e1f56ae39ae527b492d6ccb83 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 10:58:51 +1000 Subject: [PATCH 092/120] Add in blues for use --- app/assets/stylesheets/darkswarm/branding.css.sass | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/darkswarm/branding.css.sass b/app/assets/stylesheets/darkswarm/branding.css.sass index 9fa27dcc96..011ef2ff68 100644 --- a/app/assets/stylesheets/darkswarm/branding.css.sass +++ b/app/assets/stylesheets/darkswarm/branding.css.sass @@ -11,8 +11,13 @@ $clr-turquoise-light: #ceefe4 $clr-turquoise-ultra-light: #e8f9f4 $clr-turquoise-bright: #23a877 +$clr-blue: #0096ad +$clr-blue-light: #85d9e5 +$clr-blue-bright: #14b6cc + $disabled-light: #e5e5e5 $disabled-bright: #ccc $disabled-dark: #999 $med-grey: #666 -$dark-grey: #333 \ No newline at end of file +$dark-grey: #333 + From ecacde41dd798e461de4c18d074309b0aec89062 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 11:00:10 +1000 Subject: [PATCH 093/120] Tweaks to big input for small screens --- app/assets/stylesheets/darkswarm/big-input.sass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/big-input.sass b/app/assets/stylesheets/darkswarm/big-input.sass index 20c87d6a6b..15bf937f39 100644 --- a/app/assets/stylesheets/darkswarm/big-input.sass +++ b/app/assets/stylesheets/darkswarm/big-input.sass @@ -9,8 +9,6 @@ @include avenir @include csstrans @include border-radius(0.5rem) - - // transition: all 0.5s ease background: rgba(255,255,255,0.1) border: 2px solid $input font-size: 2rem @@ -21,6 +19,8 @@ margin-bottom: 0.5rem box-shadow: none color: $inputactv + @media all and (max-width: 640px) + font-size: 1.25rem &:hover @include box-shadow(0 1px 1px 0 rgba(255,255,255,0.25)) From 6ee3010fa7e25e6ec130ca1106faf33b9308e7ca Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 12 Sep 2014 11:00:34 +1000 Subject: [PATCH 094/120] Differentiation of on-boarding process by url --- .../enterprise_registration_service.js.coffee | 17 ++-- .../templates/registration/contact.html.haml | 2 +- .../templates/registration/details.html.haml | 22 ++--- .../darkswarm/registration.css.sass | 8 +- app/controllers/registration_controller.rb | 16 +++- app/helpers/injection_helper.rb | 12 ++- app/views/registration/index.html.haml | 1 + config/routes.rb | 1 + .../registration_controller_spec.rb | 13 ++- spec/features/consumer/registration_spec.rb | 81 ++++++++++++++++--- .../enterprise_registration_spec.js.coffee | 24 ++++++ 11 files changed, 158 insertions(+), 39 deletions(-) create mode 100644 spec/javascripts/unit/darkswarm/services/enterprise_registration_spec.js.coffee diff --git a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee index e52407463a..a248bc278b 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee @@ -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 \ No newline at end of file diff --git a/app/assets/javascripts/templates/registration/contact.html.haml b/app/assets/javascripts/templates/registration/contact.html.haml index ea2c51263a..c7262248d0 100644 --- a/app/assets/javascripts/templates/registration/contact.html.haml +++ b/app/assets/javascripts/templates/registration/contact.html.haml @@ -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 diff --git a/app/assets/javascripts/templates/registration/details.html.haml b/app/assets/javascripts/templates/registration/details.html.haml index dc2c3cc76d..bb358a1864 100644 --- a/app/assets/javascripts/templates/registration/details.html.haml +++ b/app/assets/javascripts/templates/registration/details.html.haml @@ -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 diff --git a/app/assets/stylesheets/darkswarm/registration.css.sass b/app/assets/stylesheets/darkswarm/registration.css.sass index be3fdda994..3e851709bc 100644 --- a/app/assets/stylesheets/darkswarm/registration.css.sass +++ b/app/assets/stylesheets/darkswarm/registration.css.sass @@ -90,21 +90,21 @@ min-height: 200px &:hover background-color: #fff - &.producer-panel:hover + &#producer-panel:hover &, & * color: $clr-turquoise - &.hub-panel:hover, &.both-panel:hover + &#hub-panel:hover, &#both-panel:hover &, & * color: $clr-brick &.selected &, & * color: #fff - &.hub-panel, &.both-panel + &#hub-panel, &#both-panel background-color: $clr-brick-bright &:hover &, & * color: white - &.producer-panel + &#producer-panel background-color: $clr-turquoise-bright &:hover &, & * diff --git a/app/controllers/registration_controller.rb b/app/controllers/registration_controller.rb index c378d24215..d58b10bd0b 100644 --- a/app/controllers/registration_controller.rb +++ b/app/controllers/registration_controller.rb @@ -2,12 +2,24 @@ require 'open_food_network/spree_api_key_loader' class RegistrationController < BaseController include OpenFoodNetwork::SpreeApiKeyLoader - before_filter :load_spree_api_key, :only => :index + before_filter :load_spree_api_key, only: :index + before_filter :check_user, except: :authenticate layout 'registration' def index + @enterprise_attributes = { type: 'profile' } + end + + def store + @enterprise_attributes = { is_distributor: true, is_primary_producer: true, type: 'single' } + render :index + end + + private + + def check_user if spree_current_user.nil? - redirect_to registration_auth_path(anchor: "signup?after_login=/register") + redirect_to registration_auth_path(anchor: "signup?after_login=#{request.env['PATH_INFO']}") end end end diff --git a/app/helpers/injection_helper.rb b/app/helpers/injection_helper.rb index a43fab3b4c..795dcb6a5c 100644 --- a/app/helpers/injection_helper.rb +++ b/app/helpers/injection_helper.rb @@ -2,18 +2,18 @@ module InjectionHelper def inject_enterprises inject_json_ams "enterprises", Enterprise.all, Api::EnterpriseSerializer, active_distributors: @active_distributors end - + def inject_current_order inject_json_ams "currentOrder", current_order, Api::CurrentOrderSerializer, current_distributor: current_distributor, current_order_cycle: current_order_cycle end def inject_available_shipping_methods - inject_json_ams "shippingMethods", available_shipping_methods, + inject_json_ams "shippingMethods", available_shipping_methods, Api::ShippingMethodSerializer, current_order: current_order end def inject_available_payment_methods - inject_json_ams "paymentMethods", current_order.available_payment_methods, + inject_json_ams "paymentMethods", current_order.available_payment_methods, Api::PaymentMethodSerializer end @@ -22,13 +22,17 @@ module InjectionHelper end def inject_spree_api_key - render partial: "json/injection_ams", locals: {name: 'SpreeApiKey', json: "'#{@spree_api_key.to_s}'"} + render partial: "json/injection_ams", locals: {name: 'spreeApiKey', json: "'#{@spree_api_key.to_s}'"} end def inject_available_countries inject_json_ams "availableCountries", available_countries, Api::CountrySerializer end + def inject_enterprise_attributes + render partial: "json/injection_ams", locals: {name: 'enterpriseAttributes', json: "#{@enterprise_attributes.to_json}"} + end + def inject_json(name, partial, opts = {}) render partial: "json/injection", locals: {name: name, partial: partial}.merge(opts) end diff --git a/app/views/registration/index.html.haml b/app/views/registration/index.html.haml index 205b3582bb..de09d9494f 100644 --- a/app/views/registration/index.html.haml +++ b/app/views/registration/index.html.haml @@ -1,3 +1,4 @@ =inject_spree_api_key =inject_available_countries +=inject_enterprise_attributes %div{ "ng-controller" => "RegistrationCtrl" } \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6447715926..f95b0c07df 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,7 @@ Openfoodnetwork::Application.routes.draw do get "/map", to: "map#index", as: :map get "/register", to: "registration#index", as: :registration + get "/register/store", to: "registration#store", as: :store_registration get "/register/auth", to: "registration#authenticate", as: :registration_auth resource :shop, controller: "shop" do diff --git a/spec/controllers/registration_controller_spec.rb b/spec/controllers/registration_controller_spec.rb index 0240dc6de0..49efc005f6 100644 --- a/spec/controllers/registration_controller_spec.rb +++ b/spec/controllers/registration_controller_spec.rb @@ -1,8 +1,15 @@ require 'spec_helper' describe RegistrationController do - it "redirects to authentication page when user not logged in" do - get :index - response.should redirect_to registration_auth_path(anchor: "signup?after_login=/register") + describe "redirecting when user not logged in" do + it "index" do + get :index + response.should redirect_to registration_auth_path(anchor: "signup?after_login=/register") + end + + it "store" do + get :store + response.should redirect_to registration_auth_path(anchor: "signup?after_login=/register/store") + end end end diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 0c706b1a13..ce5adc776e 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -1,10 +1,12 @@ require 'spec_helper' feature "Registration", js: true do - describe "Registering a Profile" do + include WebHelper + + describe "Registering a Profile", use_short_wait do let(:user) { create(:user, password: "password", password_confirmation: "password") } - pending "Allows a logged in user to register a profile" do + it "Allows a logged in user to register a profile" do visit registration_path expect(URI.parse(current_url).path).to eq registration_auth_path @@ -14,22 +16,22 @@ feature "Registration", js: true do fill_in "Email", with: user.email fill_in "Password", with: user.password click_button 'Log in' - + # Log in was successful, introduction shown expect(page).to have_content "This wizard will step you through creating a profile" expect(URI.parse(current_url).path).to eq registration_path # Done reading introduction click_button "Let's get started!" - + # Filling in details expect(page).to have_content "Woot! First we need to know what sort of enterprise you are:" fill_in 'enterprise_name', with: "My Awesome Enterprise" - click_link 'both' + click_link 'both-panel' click_button 'Continue' # Filling in address - expect(page).to have_content 'My Awesome Enterprise' + expect(page).to have_content 'Greetings My Awesome Enterprise' fill_in 'enterprise_address', with: '123 Abc Street' fill_in 'enterprise_city', with: 'Northcote' fill_in 'enterprise_zipcode', with: '3070' @@ -45,8 +47,69 @@ feature "Registration", js: true do click_button 'Continue' # Enterprise should be created - expect(page).to have_content 'Yay! You created an enterprise!' + expect(page).to have_content 'Nice one!' + # e = Enterprise.find_by_name('My Awesome Enterprise') + # expect(e.address.address1).to eq "123 Abc Street" + # expect(e.is_distributor).to eq true + # expect(e.is_primary_producer).to eq true + # expect(e.contact).to eq "Saskia Munroe" + + # Filling in about + fill_in 'enterprise_description', with: 'Short description' + fill_in 'enterprise_long_desc', with: 'Long description' + fill_in 'enterprise_abn', with: '12345' + fill_in 'enterprise_acn', with: '54321' + click_button 'Continue' + + # Enterprise should be updated + expect(page).to have_content 'Last step!' + # e.reload + # expect(e.description).to eq "Short description" + # expect(e.long_description).to eq "Long description" + # expect(e.abn).to eq '12345' + # expect(e.acn).to eq '54321' + + # Filling in social + fill_in 'enterprise_website', with: 'www.shop.com' + fill_in 'enterprise_facebook', with: 'FaCeBoOk' + fill_in 'enterprise_linkedin', with: 'LiNkEdIn' + fill_in 'enterprise_twitter', with: '@TwItTeR' + fill_in 'enterprise_instagram', with: '@InStAgRaM' + click_button 'Continue' + + # Done + expect(page).to have_content "You have successfully completed the profile for My Awesome Enterprise" + # e.reload + # expect(e.website).to eq "www.shop.com" + # expect(e.facebook).to eq "FaCeBoOk" + # expect(e.linkedin).to eq "LiNkEdIn" + # expect(e.twitter).to eq "@TwItTeR" + # expect(e.instagram).to eq "@InStAgRaM" + end + + it "Allows a logged in user to register a store" do + visit store_registration_path + + expect(URI.parse(current_url).path).to eq registration_auth_path + + # Logging in + click_link "Log in" + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_button 'Log in' + + # Log in was successful, introduction shown + expect(page).to have_content "This wizard will step you through creating a profile" + expect(URI.parse(current_url).path).to eq store_registration_path + + # Done reading introduction + click_button "Let's get started!" + + # Details Page + expect(page).to have_content "Woot! First we need to know the name of your farm:" + expect(page).to_not have_selector '#enterprise-types' + + # Everything from here should be covered in 'profile' spec end end -end - \ No newline at end of file +end \ No newline at end of file diff --git a/spec/javascripts/unit/darkswarm/services/enterprise_registration_spec.js.coffee b/spec/javascripts/unit/darkswarm/services/enterprise_registration_spec.js.coffee new file mode 100644 index 0000000000..121c4132a4 --- /dev/null +++ b/spec/javascripts/unit/darkswarm/services/enterprise_registration_spec.js.coffee @@ -0,0 +1,24 @@ +describe "EnterpriseRegistrationService", -> + EnterpriseRegistrationService = null + availableCountries = [] + enterpriseAttributes = + name: "Enterprise 1" + something: true + spreeApiKey = "keykeykeykey" + CurrentUser = + id: 2 + email: 'lalala@email.com' + + beforeEach -> + module('Darkswarm') + angular.module('Darkswarm').value 'availableCountries', availableCountries + angular.module('Darkswarm').value 'enterpriseAttributes', enterpriseAttributes + angular.module('Darkswarm').value 'spreeApiKey', spreeApiKey + angular.module('Darkswarm').value 'CurrentUser', CurrentUser + + inject ($injector)-> + EnterpriseRegistrationService = $injector.get("EnterpriseRegistrationService") + + it "adds the specified attributes to the ERS enterprise object", -> + expect(EnterpriseRegistrationService.enterprise.name).toBe "Enterprise 1" + expect(EnterpriseRegistrationService.enterprise.something).toBe true \ No newline at end of file From 01397b2e49a5000a3d25eaf3531e7c19fe654341 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 11:01:35 +1000 Subject: [PATCH 095/120] Tweaks to filter box --- .../stylesheets/darkswarm/active_table_search.css.sass | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/darkswarm/active_table_search.css.sass b/app/assets/stylesheets/darkswarm/active_table_search.css.sass index 417b0d9996..0503e30d0f 100644 --- a/app/assets/stylesheets/darkswarm/active_table_search.css.sass +++ b/app/assets/stylesheets/darkswarm/active_table_search.css.sass @@ -9,7 +9,13 @@ margin-right: 0 .row.filter-box:first-child - // border-top: 1px solid $clr-brick + border: 1px solid $clr-blue-light + @include border-radius(0.25em) + margin-top: 2px + +.row.filter-box:last-child + background: transparent + margin-top: 1em products .filter-box background: #f7f7f7 @@ -20,6 +26,8 @@ products .filter-box .tdhead padding: 0.25rem 0.5rem margin-top: 0.9rem + color: $clr-blue + border-bottom: 1px solid $clr-blue-light // OVERRIDES [class*="block-grid-"] From bfa71942fe8a29c36e76ee44cd336d8dfdc0cf04 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 11:02:28 +1000 Subject: [PATCH 096/120] Tweaks to input placeholder label --- app/views/producers/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/producers/index.html.haml b/app/views/producers/index.html.haml index b8645f936a..76dc60a7e6 100644 --- a/app/views/producers/index.html.haml +++ b/app/views/producers/index.html.haml @@ -13,7 +13,7 @@ .small-12.columns %input.animate-show{type: :text, "ng-model" => "query", - placeholder: "Search by Producer or Suburb...", + placeholder: "Search by producer or suburb...", "ng-debounce" => "150", "ofn-disable-enter" => true} From 033fe885135745a20b170033ef13d749f4e21402 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 12 Sep 2014 11:07:59 +1000 Subject: [PATCH 097/120] New product form shows permitted suppliers --- .../admin/products_controller_decorator.rb | 12 ++++++---- .../new/replace_form.html.haml.deface | 2 +- .../admin/bulk_product_update_spec.rb | 24 +++++++++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/app/controllers/spree/admin/products_controller_decorator.rb b/app/controllers/spree/admin/products_controller_decorator.rb index a5b38126e5..75c946ad0f 100644 --- a/app/controllers/spree/admin/products_controller_decorator.rb +++ b/app/controllers/spree/admin/products_controller_decorator.rb @@ -1,5 +1,6 @@ Spree::Admin::ProductsController.class_eval do - before_filter :load_bpe_data, :only => :bulk_edit + before_filter :load_form_data, only: [:bulk_edit, :new] + before_filter :load_bpe_data, only: :bulk_edit alias_method :location_after_save_original, :location_after_save @@ -85,10 +86,13 @@ Spree::Admin::ProductsController.class_eval do private - def load_bpe_data - current_user.generate_spree_api_key! unless spree_current_user.spree_api_key - @spree_api_key = spree_current_user.spree_api_key + def load_form_data @producers = OpenFoodNetwork::Permissions.new(spree_current_user).managed_product_enterprises.is_primary_producer.by_name @taxons = Spree::Taxon.order(:name) end + + def load_bpe_data + current_user.generate_spree_api_key! unless spree_current_user.spree_api_key + @spree_api_key = spree_current_user.spree_api_key + end end diff --git a/app/overrides/spree/admin/products/new/replace_form.html.haml.deface b/app/overrides/spree/admin/products/new/replace_form.html.haml.deface index 334739a4c2..7c627eec4e 100644 --- a/app/overrides/spree/admin/products/new/replace_form.html.haml.deface +++ b/app/overrides/spree/admin/products/new/replace_form.html.haml.deface @@ -7,7 +7,7 @@ = f.field_container :supplier do = f.label :supplier_id, t(:supplier) %span.required * - = f.collection_select(:supplier_id, Enterprise.is_primary_producer.managed_by(spree_current_user).by_name, :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"}) + = f.collection_select(:supplier_id, @producers, :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"}) = f.error_message_on :supplier .six.columns.omega = f.field_container :name do diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index 9f530f860c..1fd20266e0 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -745,8 +745,6 @@ feature %q{ permissions_list: [:manage_products]) end - use_short_wait - before do @enterprise_user = create_enterprise_user @enterprise_user.enterprise_roles.build(enterprise: supplier_managed1).save @@ -779,6 +777,28 @@ feature %q{ expect(page).to have_field 'product_name', with: product_supplied_inactive.name end + it "allows me to create a product" do + taxon = create(:taxon, name: 'Fruit') + + visit '/admin/products/bulk_edit' + + find("a", text: "NEW PRODUCT").click + expect(page).to have_content 'NEW PRODUCT' + expect(page).to have_select 'product_supplier_id', with_options: [supplier_managed1.name, supplier_managed2.name, supplier_permitted.name] + + within 'fieldset#new_product' do + fill_in 'product_name', with: 'Big Bag Of Apples' + select supplier_permitted.name, from: 'product_supplier_id' + fill_in 'product_price', with: '10.00' + select taxon.name, from: 'product_primary_taxon_id' + end + click_button 'Create' + + expect(URI.parse(current_url).path).to eq '/admin/products/bulk_edit' + expect(flash_message).to eq 'Product "Big Bag Of Apples" has been successfully created!' + expect(page).to have_field "product_name", with: 'Big Bag Of Apples' + end + it "allows me to update a product" do p = product_supplied_permitted From a6556f3a4f8a383d7e741a7735441b7655487bbd Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 12 Sep 2014 11:12:35 +1000 Subject: [PATCH 098/120] Fix broken JS specs --- .../admin/services/enterprise_relationships_spec.js.coffee | 4 ++-- spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/javascripts/unit/admin/services/enterprise_relationships_spec.js.coffee b/spec/javascripts/unit/admin/services/enterprise_relationships_spec.js.coffee index 9701377a73..d179f6857c 100644 --- a/spec/javascripts/unit/admin/services/enterprise_relationships_spec.js.coffee +++ b/spec/javascripts/unit/admin/services/enterprise_relationships_spec.js.coffee @@ -12,5 +12,5 @@ describe "enterprise relationships", -> EnterpriseRelationships = _EnterpriseRelationships_ it "presents permission names", -> - expect(EnterpriseRelationships.permission_presentation("add_to_order_cycle")).toEqual "can add to order cycle" - expect(EnterpriseRelationships.permission_presentation("manage_products")).toEqual "can manage the products of" + expect(EnterpriseRelationships.permission_presentation("add_to_order_cycle")).toEqual "to add to order cycle" + expect(EnterpriseRelationships.permission_presentation("manage_products")).toEqual "to manage products" diff --git a/spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee b/spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee index 6b1238d1d1..f8ae8230bc 100644 --- a/spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee +++ b/spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee @@ -8,18 +8,21 @@ describe "Hubs service", -> active: false orders_close_at: new Date() is_distributor: true + has_shopfront: true } { id: 3 active: false orders_close_at: new Date() is_distributor: true + has_shopfront: true } { id: 1 active: true orders_close_at: new Date() is_distributor: true + has_shopfront: true } ] From 1c5a495d5cc7d31a0ac148477a78856c3c8a42fb Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 11:29:41 +1000 Subject: [PATCH 099/120] Making icons smaller, adding a bit of background shadow to pop them out --- app/assets/images/map_001-producer-only.svg | 84 +++++++++--------- .../images/map_002-producer-only-profile.svg | 88 ++++++++++--------- app/assets/images/map_003-producer-shop.svg | 84 +++++++++--------- .../images/map_004-producer-shop-profile.svg | 88 ++++++++++--------- app/assets/images/map_005-hub.svg | 51 ++++++----- app/assets/images/map_006-hub-profile.svg | 53 +++++------ app/assets/images/map_007-shop.svg | 53 ++++++----- app/assets/images/map_008-shop-profile.svg | 79 +++++++++-------- 8 files changed, 307 insertions(+), 273 deletions(-) diff --git a/app/assets/images/map_001-producer-only.svg b/app/assets/images/map_001-producer-only.svg index b34c01f1ed..423442a68f 100644 --- a/app/assets/images/map_001-producer-only.svg +++ b/app/assets/images/map_001-producer-only.svg @@ -11,53 +11,57 @@ ]> + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="33px" + viewBox="0 0 28 33" enable-background="new 0 0 28 33" xml:space="preserve"> - + - + - - - - - - + + + + + + + + + diff --git a/app/assets/images/map_002-producer-only-profile.svg b/app/assets/images/map_002-producer-only-profile.svg index 0522f91257..f84834f6c6 100644 --- a/app/assets/images/map_002-producer-only-profile.svg +++ b/app/assets/images/map_002-producer-only-profile.svg @@ -11,55 +11,59 @@ ]> + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="33px" + viewBox="0 0 28 33" enable-background="new 0 0 28 33" xml:space="preserve"> - + - + - - - - - + + + + + + + + diff --git a/app/assets/images/map_003-producer-shop.svg b/app/assets/images/map_003-producer-shop.svg index 84c324ac4e..82ca2ce55c 100644 --- a/app/assets/images/map_003-producer-shop.svg +++ b/app/assets/images/map_003-producer-shop.svg @@ -11,53 +11,57 @@ ]> + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="33px" + viewBox="0 0 28 33" enable-background="new 0 0 28 33" xml:space="preserve"> - + - + - - - - - - + + + + + + + + + diff --git a/app/assets/images/map_004-producer-shop-profile.svg b/app/assets/images/map_004-producer-shop-profile.svg index 4d35236813..06316e61a3 100644 --- a/app/assets/images/map_004-producer-shop-profile.svg +++ b/app/assets/images/map_004-producer-shop-profile.svg @@ -11,55 +11,59 @@ ]> + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="33px" + viewBox="0 0 28 33" enable-background="new 0 0 28 33" xml:space="preserve"> - + - + - - - - - + + + + + + + + diff --git a/app/assets/images/map_005-hub.svg b/app/assets/images/map_005-hub.svg index be2d292c20..13c0b99779 100644 --- a/app/assets/images/map_005-hub.svg +++ b/app/assets/images/map_005-hub.svg @@ -11,36 +11,41 @@ ]> + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="33px" + viewBox="0 0 28 33" enable-background="new 0 0 28 33" xml:space="preserve"> - + - + - - - - + + + + + + + diff --git a/app/assets/images/map_006-hub-profile.svg b/app/assets/images/map_006-hub-profile.svg index b284ea34f3..57347a38e3 100644 --- a/app/assets/images/map_006-hub-profile.svg +++ b/app/assets/images/map_006-hub-profile.svg @@ -11,38 +11,41 @@ ]> + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="33px" + viewBox="0 0 28 33" enable-background="new 0 0 28 33" xml:space="preserve"> - + - + - - - + + + + + + diff --git a/app/assets/images/map_007-shop.svg b/app/assets/images/map_007-shop.svg index e2ebe118ce..5007c75e5f 100644 --- a/app/assets/images/map_007-shop.svg +++ b/app/assets/images/map_007-shop.svg @@ -11,37 +11,42 @@ ]> + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="33px" + viewBox="0 0 28 33" enable-background="new 0 0 28 33" xml:space="preserve"> - + - + - - - + + + + + + diff --git a/app/assets/images/map_008-shop-profile.svg b/app/assets/images/map_008-shop-profile.svg index 635602b7bf..cab4e2e01f 100644 --- a/app/assets/images/map_008-shop-profile.svg +++ b/app/assets/images/map_008-shop-profile.svg @@ -11,56 +11,61 @@ ]> + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="33px" + viewBox="0 0 28 33" enable-background="new 0 0 28 33" xml:space="preserve"> - + - - + - - - - - - + + - + - + - - - - + + + + + + + + + + + + From e50bbeaefbbbf6dd053e7e207f0d1c98be70d5d4 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 12 Sep 2014 11:33:47 +1000 Subject: [PATCH 100/120] Edit product form shows permitted suppliers --- .../admin/products_controller_decorator.rb | 2 +- .../add_supplier_to_admin_product.rb | 5 ----- .../_form/add_supplier.html.haml.deface | 7 ++++++ .../admin/products/_supplier_form.html.haml | 5 ----- spec/features/admin/products_spec.rb | 22 +++++++++++++++---- 5 files changed, 26 insertions(+), 15 deletions(-) delete mode 100644 app/overrides/add_supplier_to_admin_product.rb create mode 100644 app/overrides/spree/admin/products/_form/add_supplier.html.haml.deface delete mode 100644 app/views/spree/admin/products/_supplier_form.html.haml diff --git a/app/controllers/spree/admin/products_controller_decorator.rb b/app/controllers/spree/admin/products_controller_decorator.rb index 75c946ad0f..e06053588c 100644 --- a/app/controllers/spree/admin/products_controller_decorator.rb +++ b/app/controllers/spree/admin/products_controller_decorator.rb @@ -1,5 +1,5 @@ Spree::Admin::ProductsController.class_eval do - before_filter :load_form_data, only: [:bulk_edit, :new] + before_filter :load_form_data, only: [:bulk_edit, :new, :edit] before_filter :load_bpe_data, only: :bulk_edit alias_method :location_after_save_original, :location_after_save diff --git a/app/overrides/add_supplier_to_admin_product.rb b/app/overrides/add_supplier_to_admin_product.rb deleted file mode 100644 index a608f4e282..0000000000 --- a/app/overrides/add_supplier_to_admin_product.rb +++ /dev/null @@ -1,5 +0,0 @@ -Deface::Override.new(:virtual_path => "spree/admin/products/_form", - :insert_top => "[data-hook='admin_product_form_right']", - :partial => "spree/admin/products/supplier_form", - :name => "add_supplier_to_admin_product", - :original => '18bd94de3eb8bdf8b669932bf04fc59e2e85288b') \ No newline at end of file diff --git a/app/overrides/spree/admin/products/_form/add_supplier.html.haml.deface b/app/overrides/spree/admin/products/_form/add_supplier.html.haml.deface new file mode 100644 index 0000000000..1cc609bef4 --- /dev/null +++ b/app/overrides/spree/admin/products/_form/add_supplier.html.haml.deface @@ -0,0 +1,7 @@ +/ insert_top "[data-hook='admin_product_form_right']" + += f.field_container :supplier do + = f.label :supplier + %br + = f.collection_select(:supplier_id, @producers, :id, :name, {:include_blank => true}, {:class => "select2"}) + = f.error_message_on :supplier diff --git a/app/views/spree/admin/products/_supplier_form.html.haml b/app/views/spree/admin/products/_supplier_form.html.haml deleted file mode 100644 index 3e5c01c2a3..0000000000 --- a/app/views/spree/admin/products/_supplier_form.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -= f.field_container :supplier do - = f.label :supplier - %br - = f.collection_select(:supplier_id, Enterprise.is_primary_producer.managed_by(spree_current_user).by_name, :id, :name, {:include_blank => true}, {:class => "select2"}) - = f.error_message_on :supplier diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 201381f852..1f61b07d2a 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -86,11 +86,14 @@ feature %q{ context "as an enterprise user" do - before(:each) do + before do @new_user = create_enterprise_user @supplier2 = create(:supplier_enterprise, name: 'Another Supplier') + @supplier_permitted = create(:supplier_enterprise, name: 'Permitted Supplier') @new_user.enterprise_roles.build(enterprise: @supplier2).save @new_user.enterprise_roles.build(enterprise: @distributors[0]).save + create(:enterprise_relationship, parent: @supplier_permitted, child: @supplier2, + permissions_list: [:manage_products]) login_to_admin_as @new_user end @@ -116,9 +119,8 @@ feature %q{ select taxon.name, from: "product_primary_taxon_id" # Should only have suppliers listed which the user can manage - within "#product_supplier_id" do - page.should_not have_content @supplier.name - end + page.should have_select 'product_supplier_id', with_options: [@supplier2.name, @supplier_permitted.name] + page.should_not have_select 'product_supplier_id', with_options: [@supplier.name] click_button 'Create' @@ -127,6 +129,18 @@ feature %q{ product.supplier.should == @supplier2 end + scenario "editing a product" do + product = create(:simple_product, name: 'a product', supplier: @supplier2) + + visit spree.edit_admin_product_path product + + select 'Permitted Supplier', from: 'product_supplier_id' + click_button 'Update' + flash_message.should == 'Product "a product" has been successfully updated!' + product.reload + product.supplier.should == @supplier_permitted + end + scenario "editing product distributions" do product = create(:simple_product, supplier: @supplier2) From a28eaba31a2c6355b51914e7da57eca5c8e73b6d Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 11:45:13 +1000 Subject: [PATCH 101/120] Turn off price graph pop overs for small devices --- app/assets/stylesheets/darkswarm/_shop-popovers.css.sass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/stylesheets/darkswarm/_shop-popovers.css.sass b/app/assets/stylesheets/darkswarm/_shop-popovers.css.sass index e1eb2cd448..feb6529fa2 100644 --- a/app/assets/stylesheets/darkswarm/_shop-popovers.css.sass +++ b/app/assets/stylesheets/darkswarm/_shop-popovers.css.sass @@ -84,6 +84,9 @@ button.graph-button display: inline background-color: rgba(255,255,255,0.5) padding: 5px + @media all and (max-width: 768px) + display: none + // Hide for small &:hover, &:active, &:focus background-color: rgba(255,255,255,1) From cc65faadd0f47bf0946fca8dce1ed269ee87e19c Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 12 Sep 2014 11:48:17 +1000 Subject: [PATCH 102/120] Specing out enterprise registration service properly --- .../enterprise_registration_service.js.coffee | 72 +++++++++---------- .../enterprise_registration_spec.js.coffee | 65 ++++++++++++++++- 2 files changed, 98 insertions(+), 39 deletions(-) diff --git a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee index a248bc278b..68915193ee 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee @@ -11,49 +11,47 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService, @enterprise[key] = value create: => - # Loading.message = "Creating " + @enterprise.name - # $http( - # method: "POST" - # url: "/api/enterprises" - # data: - # enterprise: @prepare() - # params: - # token: spreeApiKey - # ).success((data) => - # Loading.clear() - # @enterprise.id = data - # RegistrationService.select('about') - # ).error((data) => - # Loading.clear() - # console.log angular.toJson(data) - # alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') - # ) - RegistrationService.select('about') + Loading.message = "Creating " + @enterprise.name + $http( + method: "POST" + url: "/api/enterprises" + data: + enterprise: @prepare() + params: + token: spreeApiKey + ).success((data) => + Loading.clear() + @enterprise.id = data + RegistrationService.select('about') + ).error((data) => + Loading.clear() + alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.') + ) + # RegistrationService.select('about') update: (step) => - # Loading.message = "Updating " + @enterprise.name - # $http( - # method: "PUT" - # url: "/api/enterprises/#{@enterprise.id}" - # data: - # enterprise: @prepare() - # params: - # token: spreeApiKey - # ).success((data) -> - # Loading.clear() - # RegistrationService.select(step) - # ).error((data) -> - # Loading.clear() - # console.log angular.toJson(data) - # alert('Failed to update your enterprise.\nPlease ensure all fields are completely filled out.') - # ) - RegistrationService.select(step) + Loading.message = "Updating " + @enterprise.name + $http( + method: "PUT" + url: "/api/enterprises/#{@enterprise.id}" + data: + enterprise: @prepare() + params: + token: spreeApiKey + ).success((data) -> + Loading.clear() + RegistrationService.select(step) + ).error((data) -> + Loading.clear() + alert('Failed to update your enterprise.\nPlease ensure all fields are completely filled out.') + ) + # RegistrationService.select(step) prepare: => enterprise = {} 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.address_attributes = @enterprise.address if @enterprise.address? + enterprise.address_attributes.country_id = @enterprise.country.id if @enterprise.country? enterprise \ No newline at end of file diff --git a/spec/javascripts/unit/darkswarm/services/enterprise_registration_spec.js.coffee b/spec/javascripts/unit/darkswarm/services/enterprise_registration_spec.js.coffee index 121c4132a4..1852dbd16c 100644 --- a/spec/javascripts/unit/darkswarm/services/enterprise_registration_spec.js.coffee +++ b/spec/javascripts/unit/darkswarm/services/enterprise_registration_spec.js.coffee @@ -1,5 +1,6 @@ describe "EnterpriseRegistrationService", -> EnterpriseRegistrationService = null + $httpBackend = null availableCountries = [] enterpriseAttributes = name: "Enterprise 1" @@ -8,6 +9,8 @@ describe "EnterpriseRegistrationService", -> CurrentUser = id: 2 email: 'lalala@email.com' + RegistrationServiceMock = + select: -> null beforeEach -> module('Darkswarm') @@ -15,10 +18,68 @@ describe "EnterpriseRegistrationService", -> angular.module('Darkswarm').value 'enterpriseAttributes', enterpriseAttributes angular.module('Darkswarm').value 'spreeApiKey', spreeApiKey angular.module('Darkswarm').value 'CurrentUser', CurrentUser + angular.module('Darkswarm').value 'RegistrationService', RegistrationServiceMock - inject ($injector)-> + inject ($injector, _$httpBackend_) -> + $httpBackend = _$httpBackend_ EnterpriseRegistrationService = $injector.get("EnterpriseRegistrationService") it "adds the specified attributes to the ERS enterprise object", -> expect(EnterpriseRegistrationService.enterprise.name).toBe "Enterprise 1" - expect(EnterpriseRegistrationService.enterprise.something).toBe true \ No newline at end of file + expect(EnterpriseRegistrationService.enterprise.something).toBe true + + describe "creating an enterprise", -> + describe "success", -> + beforeEach -> + spyOn(RegistrationServiceMock, "select") + $httpBackend.expectPOST("/api/enterprises?token=keykeykeykey").respond 200, 6 + EnterpriseRegistrationService.create() + $httpBackend.flush() + + it "stores the id of the created enterprise", -> + expect(EnterpriseRegistrationService.enterprise.id).toBe 6 + + it "moves the user to the about page", -> + expect(RegistrationServiceMock.select).toHaveBeenCalledWith 'about' + + describe "failure", -> + beforeEach -> + spyOn(RegistrationServiceMock, "select") + spyOn(window, "alert") + $httpBackend.expectPOST("/api/enterprises?token=keykeykeykey").respond 400, 6 + EnterpriseRegistrationService.create() + $httpBackend.flush() + + it "alerts the user to failure", -> + expect(window.alert).toHaveBeenCalledWith 'Failed to create your enterprise.\nPlease ensure all fields are completely filled out.' + + it "does not move the user to the about page", -> + expect(RegistrationServiceMock.select).not.toHaveBeenCalled + + + describe "updating an enterprise", -> + beforeEach -> + EnterpriseRegistrationService.enterprise.id = 78 + spyOn(RegistrationServiceMock, "select") + + describe "success", -> + beforeEach -> + $httpBackend.expectPUT("/api/enterprises/78?token=keykeykeykey").respond 200, 6 + EnterpriseRegistrationService.update('step') + $httpBackend.flush() + + it "moves the user to the about page", -> + expect(RegistrationServiceMock.select).toHaveBeenCalledWith 'step' + + describe "failure", -> + beforeEach -> + spyOn(window, "alert") + $httpBackend.expectPUT("/api/enterprises/78?token=keykeykeykey").respond 400, 6 + EnterpriseRegistrationService.update('step') + $httpBackend.flush() + + it "alerts the user to failure", -> + expect(window.alert).toHaveBeenCalledWith 'Failed to update your enterprise.\nPlease ensure all fields are completely filled out.' + + it "does not move the user to the about page", -> + expect(RegistrationServiceMock.select).not.toHaveBeenCalled From 5c7ab2efa30493d2fe8f6cbdd1306bc511b33421 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 12 Sep 2014 12:47:16 +1000 Subject: [PATCH 103/120] Restrict editing of ownership and type in enterprise api controller --- app/controllers/api/enterprises_controller.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/controllers/api/enterprises_controller.rb b/app/controllers/api/enterprises_controller.rb index f2263a600b..9a3b715093 100644 --- a/app/controllers/api/enterprises_controller.rb +++ b/app/controllers/api/enterprises_controller.rb @@ -1,5 +1,8 @@ module Api class EnterprisesController < Spree::Api::BaseController + + before_filter :override_owner, only: [:create, :update] + before_filter :check_type, only: :update respond_to :json def managed @@ -33,5 +36,15 @@ module Api invalid_resource!(@enterprise) end end + + private + + def override_owner + params[:enterprise][:owner_id] = current_api_user.id + end + + def check_type + params[:enterprise].delete :type unless current_api_user.admin? + end end end From 4fb30f294265a7fcaf5c08258d3d18cd10013995 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 12 Sep 2014 12:50:04 +1000 Subject: [PATCH 104/120] When removing outgoing exchanges, do not removing variants from other outgoing exchanges --- .../admin/order_cycle.js.erb.coffee | 13 ++--- .../unit/order_cycle_spec.js.coffee | 48 ++++++++++++------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/admin/order_cycle.js.erb.coffee b/app/assets/javascripts/admin/order_cycle.js.erb.coffee index b8068681ca..64f2550466 100644 --- a/app/assets/javascripts/admin/order_cycle.js.erb.coffee +++ b/app/assets/javascripts/admin/order_cycle.js.erb.coffee @@ -197,12 +197,13 @@ angular.module('order_cycle', ['ngResource']) this.order_cycle.outgoing_exchanges.push({enterprise_id: new_distributor_id, incoming: false, active: true, variants: {}, enterprise_fees: []}) removeExchange: (exchange) -> - incoming_index = this.order_cycle.incoming_exchanges.indexOf exchange - this.order_cycle.incoming_exchanges.splice(incoming_index, 1) if incoming_index > -1 - outgoing_index = this.order_cycle.outgoing_exchanges.indexOf exchange - this.order_cycle.outgoing_exchanges.splice(outgoing_index, 1) if outgoing_index > -1 - - this.removeDistributionOfVariant(variant_id) for variant_id, active of exchange.variants when active + if exchange.incoming + incoming_index = this.order_cycle.incoming_exchanges.indexOf exchange + this.order_cycle.incoming_exchanges.splice(incoming_index, 1) + this.removeDistributionOfVariant(variant_id) for variant_id, active of exchange.variants when active + else + outgoing_index = this.order_cycle.outgoing_exchanges.indexOf exchange + this.order_cycle.outgoing_exchanges.splice(outgoing_index, 1) if outgoing_index > -1 addCoordinatorFee: -> this.order_cycle.coordinator_fees.push({}) diff --git a/spec/javascripts/unit/order_cycle_spec.js.coffee b/spec/javascripts/unit/order_cycle_spec.js.coffee index 0d5127314a..2a8d001804 100644 --- a/spec/javascripts/unit/order_cycle_spec.js.coffee +++ b/spec/javascripts/unit/order_cycle_spec.js.coffee @@ -516,30 +516,44 @@ describe 'OrderCycle services', -> ] describe 'removing exchanges', -> - it 'removes incoming exchanges', -> - exchange = {enterprise_id: '123', active: true, variants: {}, enterprise_fees: []} - OrderCycle.order_cycle.incoming_exchanges = [exchange] - OrderCycle.removeExchange(exchange) - expect(OrderCycle.order_cycle.incoming_exchanges).toEqual [] + exchange = null - it 'removes outgoing exchanges', -> - exchange = {enterprise_id: '123', active: true, variants: {}, enterprise_fees: []} - OrderCycle.order_cycle.outgoing_exchanges = [exchange] - OrderCycle.removeExchange(exchange) - expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual [] - - it 'removes distribution of all exchange variants', -> + beforeEach -> spyOn(OrderCycle, 'removeDistributionOfVariant') exchange = enterprise_id: '123' active: true + incoming: false variants: {1: true, 2: false, 3: true} enterprise_fees: [] - OrderCycle.order_cycle.incoming_exchanges = [exchange] - OrderCycle.removeExchange(exchange) - expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('1') - expect(OrderCycle.removeDistributionOfVariant).not.toHaveBeenCalledWith('2') - expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('3') + + describe "removing incoming exchanges", -> + beforeEach -> + exchange.incoming = true + OrderCycle.order_cycle.incoming_exchanges = [exchange] + + it 'removes the exchange', -> + OrderCycle.removeExchange(exchange) + expect(OrderCycle.order_cycle.incoming_exchanges).toEqual [] + + it 'removes distribution of all exchange variants', -> + OrderCycle.removeExchange(exchange) + expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('1') + expect(OrderCycle.removeDistributionOfVariant).not.toHaveBeenCalledWith('2') + expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('3') + + describe "removing outgoing exchanges", -> + beforeEach -> + exchange.incoming = false + OrderCycle.order_cycle.outgoing_exchanges = [exchange] + + it 'removes the exchange', -> + OrderCycle.removeExchange(exchange) + expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual [] + + it "does not remove distribution of any variants", -> + OrderCycle.removeExchange(exchange) + expect(OrderCycle.removeDistributionOfVariant).not.toHaveBeenCalled() it 'adds coordinator fees', -> OrderCycle.addCoordinatorFee() From f5048ecf7cf1ae3c903e76278aceb9d5f4f69ef6 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 12 Sep 2014 13:24:17 +1000 Subject: [PATCH 105/120] Sends confirmation email when Enterprise is created --- .../templates/registration/finished.html.haml | 9 ++++----- app/mailers/enterprise_mailer.rb | 12 ++++++++++++ app/models/enterprise.rb | 6 ++++++ .../creation_confirmation.html.haml | 9 +++++++++ spec/mailers/enterprise_mailer_spec.rb | 13 +++++++++++++ 5 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 app/mailers/enterprise_mailer.rb create mode 100644 app/views/enterprise_mailer/creation_confirmation.html.haml create mode 100644 spec/mailers/enterprise_mailer_spec.rb diff --git a/app/assets/javascripts/templates/registration/finished.html.haml b/app/assets/javascripts/templates/registration/finished.html.haml index 8e99ac1870..75489c607a 100644 --- a/app/assets/javascripts/templates/registration/finished.html.haml +++ b/app/assets/javascripts/templates/registration/finished.html.haml @@ -1,8 +1,8 @@ .container#registration-finished .header %h2 Well done! - %h5 - You have successfully completed the profile for + %h5 + You have successfully completed the profile for %span.brick{"ng-show" => "enterprise.is_distributor"} {{ enterprise.name }} %span.turquoise{"ng-show" => "!enterprise.is_distributor" } @@ -10,10 +10,9 @@ .content{ style: 'text-align: center'} %h3 Why not check it out on the Open Food Network? %a.button.primary{ type: "button", href: "/map" } Go to Map Page > - + %br %br - + %h3 Next step - add some products: %a.button.primary{ type: "button", href: "/admin/products/new" } Add a Product > - \ No newline at end of file diff --git a/app/mailers/enterprise_mailer.rb b/app/mailers/enterprise_mailer.rb new file mode 100644 index 0000000000..73c09e1e56 --- /dev/null +++ b/app/mailers/enterprise_mailer.rb @@ -0,0 +1,12 @@ +class EnterpriseMailer < Spree::BaseMailer + def creation_confirmation(enterprise) + find_enterprise(enterprise) + subject = "#{@enterprise.name} is now on #{Spree::Config[:site_name]}" + mail(:to => @enterprise.owner.email, :from => from_address, :subject => subject) + end + + private + def find_enterprise(enterprise) + @enterprise = enterprise.is_a?(Enterprise) ? enterprise : Enterprise.find(enterprise) + end +end diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index ccca96ab26..537ac78295 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -6,6 +6,8 @@ class Enterprise < ActiveRecord::Base acts_as_gmappable :process_geocoding => false + after_create :send_creation_email + has_and_belongs_to_many :groups, class_name: 'EnterpriseGroup' has_many :producer_properties, foreign_key: 'producer_id' has_many :supplied_products, :class_name => 'Spree::Product', :foreign_key => 'supplier_id', :dependent => :destroy @@ -227,6 +229,10 @@ class Enterprise < ActiveRecord::Base private + def send_creation_email + EnterpriseMailer.creation_confirmation(self).deliver + end + def strip_url(url) url.andand.sub /(https?:\/\/)?/, '' end diff --git a/app/views/enterprise_mailer/creation_confirmation.html.haml b/app/views/enterprise_mailer/creation_confirmation.html.haml new file mode 100644 index 0000000000..0df3bf06a0 --- /dev/null +++ b/app/views/enterprise_mailer/creation_confirmation.html.haml @@ -0,0 +1,9 @@ +%h1 + = @enterprise.name + " has been created" + +%h3 + Why not check it out on + %a{ href: "#{map_url}" } + = Spree::Config[:site_name] + "?" + +If you have any questions, please get in touch with us at: hello@openfoodnetwork.org diff --git a/spec/mailers/enterprise_mailer_spec.rb b/spec/mailers/enterprise_mailer_spec.rb new file mode 100644 index 0000000000..412870bad7 --- /dev/null +++ b/spec/mailers/enterprise_mailer_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe EnterpriseMailer do + before do + @enterprise = create(:enterprise) + ActionMailer::Base.deliveries = [] + end + + it "should send an email when given an enterprise" do + EnterpriseMailer.creation_confirmation(@enterprise).deliver + ActionMailer::Base.deliveries.count.should == 1 + end +end \ No newline at end of file From 0dd33e6635604e80598ec9662417852d71f18d10 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 13:40:00 +1000 Subject: [PATCH 106/120] Modal styling updates ated trying to fix mobile scrolling issue. getting there. --- .../stylesheets/darkswarm/modals.css.sass | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/modals.css.sass b/app/assets/stylesheets/darkswarm/modals.css.sass index 0681dd73b4..0d33841286 100644 --- a/app/assets/stylesheets/darkswarm/modals.css.sass +++ b/app/assets/stylesheets/darkswarm/modals.css.sass @@ -6,25 +6,21 @@ dialog, .reveal-modal outline: none padding: 1rem overflow-y: scroll - - // Sets up max heights based on device height - @media all and (min-height: 1025px) + + // Reveal.js + // @media only screen and (max-width: 40.063em) + + @media only screen and (max-width: 640px) + max-height: auto + position: absolute !important + top: 0 + left: 0 + + // Medium and up - when modal is NOT full screen + @media only screen and (min-width: 641px) + top: 10% max-height: 80% - @media all and (min-height: 700px) and (max-height: 1024px) - max-height: 70% - - @media all and (min-height: 600px) and (max-height: 699px) - max-height: 60% - - @media all and (min-height: 481px) and (max-height: 599px) - max-height: 60% - - @media only screen and (max-height: 480px) and (min-width: 641px) - max-height: 60% - - @media all and (max-height: 480px) - overflow-y: scroll .reveal-modal-bg From 05d8c825c710a2e57a173f8251d1a4b31942396e Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 12 Sep 2014 13:40:47 +1000 Subject: [PATCH 107/120] Enterprise User should NOT see form elements for changing type --- spec/features/admin/enterprises_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 8d5f6bfee6..abaab5cd2d 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -277,14 +277,14 @@ feature %q{ expect(page).to have_content distributor1.name expect(page).to have_checked_field "enterprise_set_collection_attributes_0_is_distributor" expect(page).to have_unchecked_field "enterprise_set_collection_attributes_0_is_primary_producer" - expect(page).to have_select "enterprise_set_collection_attributes_0_type" + expect(page).to_not have_select "enterprise_set_collection_attributes_0_type" end within("tr.enterprise-#{supplier1.id}") do expect(page).to have_content supplier1.name expect(page).to have_unchecked_field "enterprise_set_collection_attributes_1_is_distributor" expect(page).to have_checked_field "enterprise_set_collection_attributes_1_is_primary_producer" - expect(page).to have_select "enterprise_set_collection_attributes_1_type" + expect(page).to_not have_select "enterprise_set_collection_attributes_1_type" end expect(page).to_not have_content "supplier2.name" From 3cff83b7a5c6af03dfd3db8e533a2c5849aa0729 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 14:42:58 +1000 Subject: [PATCH 108/120] Kill the outside modal close button styling once and for all --- .../templates/partials/close.html.haml | 2 +- .../stylesheets/darkswarm/modals.css.sass | 33 ++----------------- app/views/modals/_producer.html.haml | 2 +- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/app/assets/javascripts/templates/partials/close.html.haml b/app/assets/javascripts/templates/partials/close.html.haml index 1facd8edeb..a02ae410a8 100644 --- a/app/assets/javascripts/templates/partials/close.html.haml +++ b/app/assets/javascripts/templates/partials/close.html.haml @@ -1,2 +1,2 @@ -%a.close-reveal-modal.outside{"ng-click" => "$close()"} +%a.close-reveal-modal{"ng-click" => "$close()"} %i.ofn-i_009-close diff --git a/app/assets/stylesheets/darkswarm/modals.css.sass b/app/assets/stylesheets/darkswarm/modals.css.sass index 0d33841286..c9c3d4e8c8 100644 --- a/app/assets/stylesheets/darkswarm/modals.css.sass +++ b/app/assets/stylesheets/darkswarm/modals.css.sass @@ -7,16 +7,17 @@ dialog, .reveal-modal padding: 1rem overflow-y: scroll - // Reveal.js + // Reveal.js break point: // @media only screen and (max-width: 40.063em) + // Small - when modal IS full screen @media only screen and (max-width: 640px) max-height: auto position: absolute !important top: 0 left: 0 - // Medium and up - when modal is NOT full screen + // Medium and up - when modal IS NOT full screen @media only screen and (min-width: 641px) top: 10% max-height: 80% @@ -35,31 +36,3 @@ dialog .close-reveal-modal, .reveal-modal .close-reveal-modal &:hover, &:active, &:focus background-color: rgba(235,235,235,1) color: #333 - -// dialog .close-reveal-modal.outside, .reveal-modal .close-reveal-modal.outside -// top: -2.5rem -// right: -2.5rem -// font-size: 2rem -// color: white -// text-shadow: none -// padding: 0.25rem -// @include border-radius(999999) -// border: 1px solid transparent -// &:hover, &:active, &:focus -// text-shadow: 0 1px 3px #333 -// border: 1px solid white - -// @media all and (max-width: 640px) -// top: 0.5rem -// right: 0.5rem -// font-size: 2rem -// color: white -// text-shadow: none -// padding: 0.25rem -// background-color: rgba(150,150,150,0.85) -// @include border-radius(999999) -// border: 1px solid transparent -// &:hover, &:active, &:focus -// text-shadow: 0 1px 3px #333 -// border: 1px solid white - diff --git a/app/views/modals/_producer.html.haml b/app/views/modals/_producer.html.haml index 5d2d342f6d..51a45cfe5f 100644 --- a/app/views/modals/_producer.html.haml +++ b/app/views/modals/_producer.html.haml @@ -50,7 +50,7 @@ %a{"ng-href" => "http://instagram.com/{{enterprise.instagram}}", target: "_blank"} %i.ofn-i_043-instagram - %a.close-reveal-modal.outside{"ng-click" => "$close()"} + %a.close-reveal-modal{"ng-click" => "$close()"} %i.ofn-i_009-close From 85076908650111b59ac36f88e2b2b61f862a1a38 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 12 Sep 2014 15:23:13 +1000 Subject: [PATCH 109/120] Fixing enterprise owner migration --- db/migrate/20140828023619_add_owner_to_enterprise.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/migrate/20140828023619_add_owner_to_enterprise.rb b/db/migrate/20140828023619_add_owner_to_enterprise.rb index 0d859ff84b..8491e9c599 100644 --- a/db/migrate/20140828023619_add_owner_to_enterprise.rb +++ b/db/migrate/20140828023619_add_owner_to_enterprise.rb @@ -7,7 +7,8 @@ class AddOwnerToEnterprise < ActiveRecord::Migration owner = e.users.find{ |u| !u.admin? } admin_owner = e.users.find &:admin? any_admin = Spree::User.admin.first - e.update_column :owner_id, (owner || admin_owner || any_admin ) + any_user = Spree::User.first + e.update_column :owner_id, (owner || admin_owner || any_admin || any_user ) end add_foreign_key :enterprises, :spree_users, column: :owner_id From dbefd43f07c6a0dc6f0da6ad1d79e7f8f5acb6e4 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 12 Sep 2014 15:33:02 +1000 Subject: [PATCH 110/120] Add commented-out scrolling code. Return false from click handlers. --- .../javascripts/darkswarm/directives/hub_modal.js.coffee | 4 +++- app/assets/javascripts/darkswarm/directives/modal.js.coffee | 4 +++- .../darkswarm/directives/producer_modal.js.coffee | 5 +++-- .../javascripts/darkswarm/services/map_modal.js.coffee | 5 ++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/hub_modal.js.coffee b/app/assets/javascripts/darkswarm/directives/hub_modal.js.coffee index 6eb0299ab4..8e42d0c835 100644 --- a/app/assets/javascripts/darkswarm/directives/hub_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/hub_modal.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.directive "hubModal", ($modal)-> +Darkswarm.directive "hubModal", ($modal, $document)-> restrict: 'E' replace: true template: "{{enterprise.name}}" @@ -6,3 +6,5 @@ Darkswarm.directive "hubModal", ($modal)-> elem.on "click", (ev)=> ev.stopPropagation() scope.modalInstance = $modal.open(controller: ctrl, templateUrl: 'hub_modal.html', scope: scope) + #$document.scrollTo 0, 0 + false diff --git a/app/assets/javascripts/darkswarm/directives/modal.js.coffee b/app/assets/javascripts/darkswarm/directives/modal.js.coffee index 7c1babe215..f45388cca3 100644 --- a/app/assets/javascripts/darkswarm/directives/modal.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/modal.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.directive "ofnModal", ($modal)-> +Darkswarm.directive "ofnModal", ($modal, $document)-> # Generic modal! Uses transclusion so designer-types can do stuff like: # %ofn-modal # CONTENT @@ -17,3 +17,5 @@ Darkswarm.directive "ofnModal", ($modal)-> elem.on "click", => transclude scope, (clone)-> scope.modalInstance = $modal.open(controller: ctrl, template: clone, scope: scope) + #$document.scrollTo 0, 0 + false diff --git a/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee b/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee index af2b13f157..d30a807655 100644 --- a/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.directive "producerModal", ($modal)-> +Darkswarm.directive "producerModal", ($modal, $document)-> restrict: 'E' replace: true template: "" @@ -7,4 +7,5 @@ Darkswarm.directive "producerModal", ($modal)-> elem.on "click", (ev)=> ev.stopPropagation() scope.modalInstance = $modal.open(controller: ctrl, templateUrl: 'producer_modal.html', scope: scope) - + #$document.scrollTo 0, 0 + false diff --git a/app/assets/javascripts/darkswarm/services/map_modal.js.coffee b/app/assets/javascripts/darkswarm/services/map_modal.js.coffee index c9ed30f558..30e9563d7e 100644 --- a/app/assets/javascripts/darkswarm/services/map_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/services/map_modal.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.factory "MapModal", ($modal, $rootScope)-> +Darkswarm.factory "MapModal", ($modal, $rootScope, $document)-> new class MapModal open: (enterprise)-> scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise @@ -7,6 +7,9 @@ Darkswarm.factory "MapModal", ($modal, $rootScope)-> if enterprise.is_distributor scope.hub = enterprise $modal.open(templateUrl: "hub_modal.html", scope: scope) + #$document.scrollTo 0, 0 + else scope.producer = enterprise $modal.open(templateUrl: "map_modal_producer.html", scope: scope) + #$document.scrollTo 0, 0 From c365047d0cfe3f551cd16ebe6743f73c1a98c0b4 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 15:40:12 +1000 Subject: [PATCH 111/120] Short description goes back in producer fat view until we can clean up the HTML formatting --- app/views/producers/_fat.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/producers/_fat.html.haml b/app/views/producers/_fat.html.haml index a8512c9a22..f420b33386 100644 --- a/app/views/producers/_fat.html.haml +++ b/app/views/producers/_fat.html.haml @@ -1,13 +1,13 @@ .row.active_table_row{"ng-show" => "open()", "ng-click" => "toggle()", "ng-class" => "{'open' : !ofn-i_032-closed-sign()}"} .columns.small-12.medium-7.large-7.fat - / No long description available because it spits out HTML formatting producer.long_description - %div{"bo-if" => "producer.long_description"} + / Will add in long description available once clean up HTML formatting producer.long_description + %div{"bo-if" => "producer.description"} %label About us %img.right.show-for-medium-up{src: "{{ producer.logo }}" } %p.text-small - {{ producer.long_description }} - %div.show-for-medium-up{"bo-if" => "producer.long_description.length==0"} + {{ producer.description }} + %div.show-for-medium-up{"bo-if" => "producer.description.length==0"} %label   .columns.small-12.medium-5.large-5.fat From 799bfae6e4751d441393b917540eb122805b249f Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 15:51:20 +1000 Subject: [PATCH 112/120] Revert "Add commented-out scrolling code. Return false from click handlers." This reverts commit dbefd43f07c6a0dc6f0da6ad1d79e7f8f5acb6e4. --- .../javascripts/darkswarm/directives/hub_modal.js.coffee | 4 +--- app/assets/javascripts/darkswarm/directives/modal.js.coffee | 4 +--- .../darkswarm/directives/producer_modal.js.coffee | 5 ++--- .../javascripts/darkswarm/services/map_modal.js.coffee | 5 +---- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/hub_modal.js.coffee b/app/assets/javascripts/darkswarm/directives/hub_modal.js.coffee index 8e42d0c835..6eb0299ab4 100644 --- a/app/assets/javascripts/darkswarm/directives/hub_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/hub_modal.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.directive "hubModal", ($modal, $document)-> +Darkswarm.directive "hubModal", ($modal)-> restrict: 'E' replace: true template: "{{enterprise.name}}" @@ -6,5 +6,3 @@ Darkswarm.directive "hubModal", ($modal, $document)-> elem.on "click", (ev)=> ev.stopPropagation() scope.modalInstance = $modal.open(controller: ctrl, templateUrl: 'hub_modal.html', scope: scope) - #$document.scrollTo 0, 0 - false diff --git a/app/assets/javascripts/darkswarm/directives/modal.js.coffee b/app/assets/javascripts/darkswarm/directives/modal.js.coffee index f45388cca3..7c1babe215 100644 --- a/app/assets/javascripts/darkswarm/directives/modal.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/modal.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.directive "ofnModal", ($modal, $document)-> +Darkswarm.directive "ofnModal", ($modal)-> # Generic modal! Uses transclusion so designer-types can do stuff like: # %ofn-modal # CONTENT @@ -17,5 +17,3 @@ Darkswarm.directive "ofnModal", ($modal, $document)-> elem.on "click", => transclude scope, (clone)-> scope.modalInstance = $modal.open(controller: ctrl, template: clone, scope: scope) - #$document.scrollTo 0, 0 - false diff --git a/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee b/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee index d30a807655..af2b13f157 100644 --- a/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.directive "producerModal", ($modal, $document)-> +Darkswarm.directive "producerModal", ($modal)-> restrict: 'E' replace: true template: "" @@ -7,5 +7,4 @@ Darkswarm.directive "producerModal", ($modal, $document)-> elem.on "click", (ev)=> ev.stopPropagation() scope.modalInstance = $modal.open(controller: ctrl, templateUrl: 'producer_modal.html', scope: scope) - #$document.scrollTo 0, 0 - false + diff --git a/app/assets/javascripts/darkswarm/services/map_modal.js.coffee b/app/assets/javascripts/darkswarm/services/map_modal.js.coffee index 30e9563d7e..c9ed30f558 100644 --- a/app/assets/javascripts/darkswarm/services/map_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/services/map_modal.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.factory "MapModal", ($modal, $rootScope, $document)-> +Darkswarm.factory "MapModal", ($modal, $rootScope)-> new class MapModal open: (enterprise)-> scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise @@ -7,9 +7,6 @@ Darkswarm.factory "MapModal", ($modal, $rootScope, $document)-> if enterprise.is_distributor scope.hub = enterprise $modal.open(templateUrl: "hub_modal.html", scope: scope) - #$document.scrollTo 0, 0 - else scope.producer = enterprise $modal.open(templateUrl: "map_modal_producer.html", scope: scope) - #$document.scrollTo 0, 0 From cc9d2ebbacf333ad261783967adb8199c22aee46 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 12 Sep 2014 16:01:25 +1000 Subject: [PATCH 113/120] Modal styling fixes for scrolling on mobile view --- app/assets/stylesheets/darkswarm/modals.css.sass | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/darkswarm/modals.css.sass b/app/assets/stylesheets/darkswarm/modals.css.sass index 5e6c06dcfd..e6303a4cd7 100644 --- a/app/assets/stylesheets/darkswarm/modals.css.sass +++ b/app/assets/stylesheets/darkswarm/modals.css.sass @@ -12,7 +12,9 @@ dialog, .reveal-modal // Small - when modal IS full screen @media only screen and (max-width: 640px) - max-height: auto + max-height: initial + // This is needed to make the height not the height of whole content page + min-height: 100% position: absolute !important top: 0 left: 0 From d2c5533549781fa99a424418a94485f3fa2d1625 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 12 Sep 2014 16:10:38 +1000 Subject: [PATCH 114/120] Remove use_short_wait --- spec/features/consumer/registration_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index ce5adc776e..0befe45182 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature "Registration", js: true do include WebHelper - describe "Registering a Profile", use_short_wait do + describe "Registering a Profile" do let(:user) { create(:user, password: "password", password_confirmation: "password") } it "Allows a logged in user to register a profile" do From b41029d5d0c90dc12c8829d56e8a5a2ede6b423c Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 12 Sep 2014 16:10:32 +1000 Subject: [PATCH 115/120] Spec reliability: Explicitly set a $0 calculator for shipping method --- spec/features/consumer/shopping/checkout_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 7dae7a54e2..f9c05651a2 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -28,7 +28,7 @@ feature "As a consumer I want to check out my cart", js: true do end describe "with shipping methods" do - let(:sm1) { create(:shipping_method, require_ship_address: true, name: "Frogs", description: "yellow") } + let(:sm1) { create(:shipping_method, require_ship_address: true, name: "Frogs", description: "yellow", calculator: Spree::Calculator::FlatRate.new(preferred_amount: 0.00)) } let(:sm2) { create(:shipping_method, require_ship_address: false, name: "Donkeys", description: "blue", calculator: Spree::Calculator::FlatRate.new(preferred_amount: 4.56)) } before do distributor.shipping_methods << sm1 From 25a889375c94d939fd3ef2b82dfb0279c6ee90a5 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 12 Sep 2014 16:38:32 +1000 Subject: [PATCH 116/120] Fix unreliable spec --- spec/features/consumer/registration_spec.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 0befe45182..bd12e34d80 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -10,11 +10,22 @@ feature "Registration", js: true do visit registration_path expect(URI.parse(current_url).path).to eq registration_auth_path + # Prevent race condition - "Log in" link is visible, but early click events are lost + # without some delay here + page.should have_link "Log in" # Logging in click_link "Log in" + #page.should have_button 'Log in' + fill_in "Email", with: user.email fill_in "Password", with: user.password + + # unless page.has_button? 'Log in' + # save_screenshot('/home/rohan/ss.png', full: true) + # binding.pry + # end + click_button 'Log in' # Log in was successful, introduction shown @@ -112,4 +123,4 @@ feature "Registration", js: true do # Everything from here should be covered in 'profile' spec end end -end \ No newline at end of file +end From cb7033eea08f1af762e09f5b3113edf4b6da5eeb Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 12 Sep 2014 16:42:10 +1000 Subject: [PATCH 117/120] Registration spec checks enterprise created and updated --- spec/features/consumer/registration_spec.rb | 40 +++++++++------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index bd12e34d80..9723422f8c 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -16,16 +16,8 @@ feature "Registration", js: true do # Logging in click_link "Log in" - #page.should have_button 'Log in' - fill_in "Email", with: user.email fill_in "Password", with: user.password - - # unless page.has_button? 'Log in' - # save_screenshot('/home/rohan/ss.png', full: true) - # binding.pry - # end - click_button 'Log in' # Log in was successful, introduction shown @@ -59,11 +51,11 @@ feature "Registration", js: true do # Enterprise should be created expect(page).to have_content 'Nice one!' - # e = Enterprise.find_by_name('My Awesome Enterprise') - # expect(e.address.address1).to eq "123 Abc Street" - # expect(e.is_distributor).to eq true - # expect(e.is_primary_producer).to eq true - # expect(e.contact).to eq "Saskia Munroe" + e = Enterprise.find_by_name('My Awesome Enterprise') + expect(e.address.address1).to eq "123 Abc Street" + expect(e.is_distributor).to eq true + expect(e.is_primary_producer).to eq true + expect(e.contact).to eq "Saskia Munroe" # Filling in about fill_in 'enterprise_description', with: 'Short description' @@ -74,11 +66,11 @@ feature "Registration", js: true do # Enterprise should be updated expect(page).to have_content 'Last step!' - # e.reload - # expect(e.description).to eq "Short description" - # expect(e.long_description).to eq "Long description" - # expect(e.abn).to eq '12345' - # expect(e.acn).to eq '54321' + e.reload + expect(e.description).to eq "Short description" + expect(e.long_description).to eq "Long description" + expect(e.abn).to eq '12345' + expect(e.acn).to eq '54321' # Filling in social fill_in 'enterprise_website', with: 'www.shop.com' @@ -90,12 +82,12 @@ feature "Registration", js: true do # Done expect(page).to have_content "You have successfully completed the profile for My Awesome Enterprise" - # e.reload - # expect(e.website).to eq "www.shop.com" - # expect(e.facebook).to eq "FaCeBoOk" - # expect(e.linkedin).to eq "LiNkEdIn" - # expect(e.twitter).to eq "@TwItTeR" - # expect(e.instagram).to eq "@InStAgRaM" + e.reload + expect(e.website).to eq "www.shop.com" + expect(e.facebook).to eq "FaCeBoOk" + expect(e.linkedin).to eq "LiNkEdIn" + expect(e.twitter).to eq "@TwItTeR" + expect(e.instagram).to eq "@InStAgRaM" end it "Allows a logged in user to register a store" do From 0815775bc314eea4a536250d74bb463481acb972 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 12 Sep 2014 17:22:54 +1000 Subject: [PATCH 118/120] Temporary fix for race condition in registration spec --- spec/features/consumer/registration_spec.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 9723422f8c..04e244e205 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -10,9 +10,8 @@ feature "Registration", js: true do visit registration_path expect(URI.parse(current_url).path).to eq registration_auth_path - # Prevent race condition - "Log in" link is visible, but early click events are lost - # without some delay here - page.should have_link "Log in" + + sleep 0.5 # TOTO: DEAL WITH ME # Logging in click_link "Log in" @@ -21,6 +20,8 @@ feature "Registration", js: true do click_button 'Log in' # Log in was successful, introduction shown + sleep 0.5 # TOTO: DEAL WITH ME + expect(page).to have_content "This wizard will step you through creating a profile" expect(URI.parse(current_url).path).to eq registration_path @@ -95,6 +96,8 @@ feature "Registration", js: true do expect(URI.parse(current_url).path).to eq registration_auth_path + sleep 0.5 # TOTO: DEAL WITH ME + # Logging in click_link "Log in" fill_in "Email", with: user.email @@ -102,6 +105,8 @@ feature "Registration", js: true do click_button 'Log in' # Log in was successful, introduction shown + sleep 0.5 # TOTO: DEAL WITH ME + expect(page).to have_content "This wizard will step you through creating a profile" expect(URI.parse(current_url).path).to eq store_registration_path From 143545da0d295f6de4e69120200d1f931d964be2 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 12 Sep 2014 23:41:26 +1000 Subject: [PATCH 119/120] Try newer syntax to fix spec failing on CI --- spec/features/admin/orders_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/features/admin/orders_spec.rb b/spec/features/admin/orders_spec.rb index dd733a7009..dd4a2113e8 100644 --- a/spec/features/admin/orders_spec.rb +++ b/spec/features/admin/orders_spec.rb @@ -129,26 +129,26 @@ feature %q{ visit '/admin/orders' click_link 'New Order' - page.should have_content 'ADD PRODUCT' + expect(page).to have_content 'ADD PRODUCT' targetted_select2_search product.name, from: '#add_variant_id', dropdown_css: '.select2-drop' click_link 'Add' page.has_selector? "table.index tbody[data-hook='admin_order_form_line_items'] tr" # Wait for JS - page.should have_selector 'td', text: product.name + expect(page).to have_selector 'td', text: product.name - page.should have_select 'order_distributor_id', with_options: [distributor1.name] - page.should have_no_select 'order_distributor_id', with_options: [distributor2.name] + expect(page).to have_select 'order_distributor_id', with_options: [distributor1.name] + expect(page).to_not have_select 'order_distributor_id', with_options: [distributor2.name] - page.should have_select 'order_order_cycle_id', with_options: [order_cycle1.name] - page.should have_no_select 'order_order_cycle_id', with_options: [order_cycle2.name] + expect(page).to have_select 'order_order_cycle_id', with_options: [order_cycle1.name] + expect(page).to_not have_select 'order_order_cycle_id', with_options: [order_cycle2.name] select distributor1.name, from: 'order_distributor_id' select order_cycle1.name, from: 'order_order_cycle_id' click_button 'Update' - page.should have_selector 'h1', text: 'Customer Details' + expect(page).to have_selector 'h1', text: 'Customer Details' o = Spree::Order.last - o.distributor.should == distributor1 - o.order_cycle.should == order_cycle1 + expect(o.distributor).to eq distributor1 + expect(o.order_cycle).to eq order_cycle1 end end From 5cf09d264c761fb53a56fa33003443de6cff7c0e Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Sun, 14 Sep 2014 12:27:02 +1000 Subject: [PATCH 120/120] fix suburb typo --- db/suburb_seeds.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/suburb_seeds.rb b/db/suburb_seeds.rb index ea3ee531db..cd07f46ed3 100644 --- a/db/suburb_seeds.rb +++ b/db/suburb_seeds.rb @@ -15762,8 +15762,8 @@ module SuburbSeeder ($$6770$$,$$STURT CREEK$$,#{state_id_wa},-18.224393,127.66743), ($$6770$$,$$TANAMI$$,#{state_id_wa},-18.224393,127.66743), ($$6798$$,$$CHRISTMAS ISLAND$$,#{state_id_wa},-10.487053,105.64067), - ($$6799$$,$$HOME ISLAND COCOS ($$KEELING) ISLANDS$$,#{state_id_wa},-12.169719,96.83152), - ($$6799$$,$$WEST ISLAND COCOS ($$KEELING) ISLANDS$$,#{state_id_wa},-12.169719,96.83152), + ($$6799$$,$$HOME ISLAND COCOS (KEELING) ISLANDS$$,#{state_id_wa},-12.169719,96.83152), + ($$6799$$,$$WEST ISLAND COCOS (KEELING) ISLANDS$$,#{state_id_wa},-12.169719,96.83152), ($$6800$$,$$PERTH$$,#{state_id_wa},-31.99212,115.763228), ($$6803$$,$$NORTHBRIDGE$$,#{state_id_wa},0.0,0.0), ($$6809$$,$$PERTH$$,#{state_id_wa},-31.99212,115.763228),