OK address no longer being lazy-loaded

This commit is contained in:
Will Marshall
2014-07-03 11:40:33 +10:00
committed by Rohan Mitchell
parent 0177a56408
commit 6d4dfad336
4 changed files with 32 additions and 39 deletions

View File

@@ -1,4 +1,5 @@
Darkswarm.factory 'Enterprises', (enterprises, CurrentHub, Taxons, Dereferencer)->
console.log enterprises[0].address
new class Enterprises
enterprises_by_id: {} # id/object pairs for lookup
constructor: ->

View File

@@ -30,7 +30,6 @@ class Enterprise < ActiveRecord::Base
validates_presence_of :address
validates_associated :address
after_initialize :initialize_country
before_validation :set_unused_address_fields
after_validation :geocode_address
@@ -207,11 +206,6 @@ class Enterprise < ActiveRecord::Base
url.andand.sub /(https?:\/\/)?(www\.)?/, ''
end
def initialize_country
self.address ||= Spree::Address.new
self.address.country = Spree::Country.find_by_id(Spree::Config[:default_country_id]) if self.address.new_record?
end
def set_unused_address_fields
address.firstname = address.lastname = address.phone = 'unused' if address.present?
end

View File

@@ -1,6 +1,4 @@
class Api::EnterpriseSerializer < ActiveModel::Serializer
# To improve this: http://hawkins.io/2013/06/caching_object_graphs_with_active_model_serializers/
def serializable_hash
cached_serializer_hash.merge uncached_serializer_hash
end
@@ -43,7 +41,7 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer
has_many :distributors, key: :hubs, serializer: Api::IdSerializer
has_many :suppliers, key: :producers, serializer: Api::IdSerializer
#has_one :address, serializer: Api::AddressSerializer
has_one :address, serializer: Api::AddressSerializer
def pickup
object.shipping_methods.where(:require_ship_address => false).present?

View File

@@ -1,35 +1,35 @@
= inject_enterprises
.producers{"ng-controller" => "ProducersCtrl"}
.row
.small-12.columns.text-center.pad-top
%h1 Producers
%div
Select a
%ofn-modal{title: "producer"}
= render partial: "modals/producers"
from the list below:
-#.producers{"ng-controller" => "ProducersCtrl"}
-#.row
-#.small-12.columns.text-center.pad-top
-#%h1 Producers
-#%div
-#Select a
-#%ofn-modal{title: "producer"}
-#= render partial: "modals/producers"
-#from the list below:
#active-table-search.row.pad-top
.small-12.columns
%i.ofn-i_020-search
%input{type: :text,
"ng-model" => "query",
placeholder: "Search postcode, suburb or producer name...",
"ng-debounce" => "150",
"ofn-disable-enter" => true}
-##active-table-search.row.pad-top
-#.small-12.columns
-#%i.ofn-i_020-search
-#%input{type: :text,
-#"ng-model" => "query",
-#placeholder: "Search postcode, suburb or producer name...",
-#"ng-debounce" => "150",
-#"ofn-disable-enter" => true}
.row{bindonce: true}
.small-12.columns
.active_table
%producer.active_table_node.row.animate-repeat{id: "{{producer.path}}",
"scroll-after-load" => true,
"ng-repeat" => "producer in filteredProducers = (Producers.visible | filterProducers:query)",
"ng-controller" => "ProducerNodeCtrl",
"ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !producer.active}",
id: "{{producer.hash}}"}
-#.row{bindonce: true}
-#.small-12.columns
-#.active_table
-#%producer.active_table_node.row.animate-repeat{id: "{{producer.path}}",
-#"scroll-after-load" => true,
-#"ng-repeat" => "producer in filteredProducers = (Producers.visible | filterProducers:query)",
-#"ng-controller" => "ProducerNodeCtrl",
-#"ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !producer.active}",
-#id: "{{producer.hash}}"}
.small-12.columns
= render partial: 'producers/skinny'
= render partial: 'producers/fat'
-#.small-12.columns
-#= render partial: 'producers/skinny'
-#= render partial: 'producers/fat'
= render partial: "shared/footer"
-#= render partial: "shared/footer"