diff --git a/assets/scripts/lib/travis/model.coffee b/assets/scripts/lib/travis/model.coffee index 099e515b..fa5722e2 100644 --- a/assets/scripts/lib/travis/model.coffee +++ b/assets/scripts/lib/travis/model.coffee @@ -6,13 +6,6 @@ @loadedAttributes = [] @_super.apply this, arguments - get: (name) -> - if @constructor.isAttribute(name) && @get('incomplete') && !@isAttributeLoaded(name) - console.log 'Loading rest of', @constructor, @get('clientId'), 'for key: ', name - @loadTheRest() - - @_super.apply this, arguments - refresh: -> if id = @get('id') store = @get('store') diff --git a/assets/scripts/spec/unit/incomplete_spec.coffee b/assets/scripts/spec/unit/incomplete_spec.coffee index 4ac494e9..676752c3 100644 --- a/assets/scripts/spec/unit/incomplete_spec.coffee +++ b/assets/scripts/spec/unit/incomplete_spec.coffee @@ -89,6 +89,15 @@ describe 'Travis.Model', -> runs -> expect( record.get('complete') ).toBeFalsy() + it 'loads missing data if getPath is used', -> + other = Em.Object.create(record: record) + expect( other.get('record.description') ).toBeNull() + + waits 50 + runs -> + expect( other.get('record.description') ).toEqual 'bar' + expect( record.get('isComplete') ).toBeTruthy() + it 'loads missing data on try to get it', -> expect( record.get('name') ).toEqual 'foo' expect( record.get('description') ).toBeNull() diff --git a/assets/scripts/vendor/ember-data.js b/assets/scripts/vendor/ember-data.js index e86afd5d..8e09d046 100644 --- a/assets/scripts/vendor/ember-data.js +++ b/assets/scripts/vendor/ember-data.js @@ -3255,6 +3255,12 @@ DS.attr = function(type, options) { return Ember.computed(function(key, value) { var data; + if(arguments.length === 1 && this.constructor.isAttribute(key) && get(this, 'incomplete') && !this.isAttributeLoaded(key)) { + if(this.loadTheRest) { + this.loadTheRest(key); + } + } + key = meta.key(this.constructor); if (arguments.length === 2) { @@ -3389,6 +3395,12 @@ var hasAssociation = function(type, options, one) { var data = get(this, 'data'), ids, id, association, store = get(this, 'store'); + if(arguments.length === 1 && this.constructor.isAttribute(key) && get(this, 'incomplete') && !this.isAttributeLoaded(key)) { + if(this.loadTheRest) { + this.loadTheRest(key); + } + } + if (typeof type === 'string') { type = get(this, type, false) || get(window, type); } @@ -3451,6 +3463,12 @@ var hasAssociation = function(type, options) { store = get(this, 'store'), ids, id, association; + if(arguments.length === 1 && this.constructor.isAttribute(key) && get(this, 'incomplete') && !this.isAttributeLoaded(key)) { + if(this.loadTheRest) { + this.loadTheRest(key); + } + } + if (typeof type === 'string') { type = get(this, type, false) || get(window, type); }