Update code for newest ember-model
This commit is contained in:
parent
b3ce14cc22
commit
b5297d7800
|
@ -119,14 +119,12 @@ unless window.TravisApplication
|
|||
loadOrMerge: (type, hash, options) ->
|
||||
options ||= {}
|
||||
|
||||
if !type._idToReference
|
||||
type._idToReference = {}
|
||||
reference = type._idToReference[hash.id]
|
||||
reference = type._getReferenceById(hash.id)
|
||||
|
||||
if reference && options.skipIfExists
|
||||
return
|
||||
|
||||
reference = type._referenceForId(hash.id)
|
||||
reference = type._getOrCreateReferenceForId(hash.id)
|
||||
if reference.record
|
||||
reference.record.merge(hash)
|
||||
else
|
||||
|
|
|
@ -9,7 +9,7 @@ Travis.FlashController = Ember.ArrayController.extend
|
|||
@set('flashes', Ember.A())
|
||||
|
||||
content: (->
|
||||
@get('unseenBroadcasts').concat(@get('flashes'))
|
||||
@get('unseenBroadcasts').concat(@get('flashes')).filter (o) -> o
|
||||
).property('unseenBroadcasts.length', 'flashes.length')
|
||||
|
||||
unseenBroadcasts: (->
|
||||
|
|
|
@ -38,18 +38,19 @@ Array.prototype.diff = (a) ->
|
|||
@loadedAttributes = []
|
||||
@loadedRelationships = []
|
||||
|
||||
attributes = this.attributes || []
|
||||
relationships = this.relationships || []
|
||||
attributes = this.constructor.getAttributes() || []
|
||||
relationships = this.constructor.getRelationships() || []
|
||||
|
||||
for key in attributes
|
||||
dataKey = @dataKey(key)
|
||||
if hash.hasOwnProperty(dataKey)
|
||||
@loadedAttributes.pushObject(key)
|
||||
if hash
|
||||
for key in attributes
|
||||
dataKey = @dataKey(key)
|
||||
if hash.hasOwnProperty(dataKey)
|
||||
@loadedAttributes.pushObject(key)
|
||||
|
||||
for key in relationships
|
||||
dataKey = @dataKey(key)
|
||||
if hash.hasOwnProperty(dataKey)
|
||||
@loadedRelationships.pushObject(key)
|
||||
for key in relationships
|
||||
dataKey = @dataKey(key)
|
||||
if hash.hasOwnProperty(dataKey)
|
||||
@loadedRelationships.pushObject(key)
|
||||
|
||||
incomplete = Ember.EnumerableUtils.intersection(@loadedAttributes, attributes).length != attributes.length ||
|
||||
Ember.EnumerableUtils.intersection(@loadedRelationships, relationships).length != relationships.length
|
||||
|
@ -86,10 +87,10 @@ Array.prototype.diff = (a) ->
|
|||
@loadTheRest(key)
|
||||
|
||||
isAttribute: (name) ->
|
||||
this.attributes.contains(name)
|
||||
this.constructor.getAttributes().contains(name)
|
||||
|
||||
isRelationship: (name) ->
|
||||
this.relationships.contains(name)
|
||||
this.constructor.getRelationships().contains(name)
|
||||
|
||||
loadTheRest: (key) ->
|
||||
# for some weird reason key comes changed to a string and for some weird reason it even is called with
|
||||
|
@ -145,19 +146,19 @@ Array.prototype.diff = (a) ->
|
|||
).property()
|
||||
|
||||
isRecordLoaded: (id) ->
|
||||
!!@_referenceForId(id).record
|
||||
reference = @_getReferenceById(id)
|
||||
reference && reference.record
|
||||
|
||||
camelizeKeys: true
|
||||
|
||||
# TODO: the functions below will be added to Ember Model, remove them when that
|
||||
# happens
|
||||
resetData: ->
|
||||
@_idToReference = null
|
||||
@sideloadedData = null
|
||||
@recordCache = null
|
||||
@recordArrays = null
|
||||
@_currentBatchIds = null
|
||||
@_hasManyArrays = null
|
||||
@_referenceCache = {}
|
||||
@sideloadedData = {}
|
||||
@recordArrays = []
|
||||
@_currentBatchIds = []
|
||||
@_hasManyArrays = []
|
||||
@_findAllRecordArray = null
|
||||
|
||||
unload: (record) ->
|
||||
|
@ -172,10 +173,8 @@ Array.prototype.diff = (a) ->
|
|||
delete this.recordCache[key]
|
||||
|
||||
loadRecordForReference: (reference) ->
|
||||
record = @create({ _reference: reference })
|
||||
@recordCache = {} unless @recordCache
|
||||
record = @create({ _reference: reference, id: reference.id })
|
||||
@sideloadedData = {} unless @sideloadedData
|
||||
@recordCache[reference.id] = record
|
||||
reference.record = record
|
||||
record.load(reference.id, @sideloadedData[reference.id])
|
||||
# TODO: find a nicer way to not add record to record arrays twice
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
@displaysTabs = (tabs) ->
|
||||
for name, tab of tabs
|
||||
equal($("#tab_#{name} a").attr('href'), tab.href, "#{name} tab should link to #{tab.href}") unless tab.hidden
|
||||
equal($("#tab_#{name}").hasClass('active'), !!tab.active, "#{name} tab should be active")
|
||||
equal($("#tab_#{name}").hasClass('active'), !!tab.active, "#{name} tab should #{'not' unless tab.active} be active")
|
||||
equal($("#tab_#{name}").hasClass('display-inline'), !tab.hidden, "#{name} tab should has class display-inline") if name in ['build', 'job']
|
||||
|
||||
@displaysSummaryBuildLink = (link, number) ->
|
||||
|
|
|
@ -3,9 +3,9 @@ minispade.require 'ext/jquery'
|
|||
responseTime = 0
|
||||
|
||||
repos = [
|
||||
{ id: '1', owner: 'travis-ci', name: 'travis-core', slug: 'travis-ci/travis-core', build_ids: [1, 2], last_build_id: 1, last_build_number: 1, last_build_state: 'passed', last_build_duration: 30, last_build_started_at: '2012-07-02T00:00:00Z', last_build_finished_at: '2012-07-02T00:00:30Z', description: 'Description of travis-core' },
|
||||
{ id: '2', owner: 'travis-ci', name: 'travis-assets', slug: 'travis-ci/travis-assets', build_ids: [3], last_build_id: 3, last_build_number: 3, last_build_state: 'failed', last_build_duration: 30, last_build_started_at: '2012-07-02T00:01:00Z', last_build_finished_at: '2012-07-01T00:01:30Z', description: 'Description of travis-assets'},
|
||||
{ id: '3', owner: 'travis-ci', name: 'travis-hub', slug: 'travis-ci/travis-hub', build_ids: [4], last_build_id: 4, last_build_number: 4, last_build_state: null, last_build_duration: null, last_build_started_at: '2012-07-02T00:02:00Z', last_build_finished_at: null, description: 'Description of travis-hub'},
|
||||
{ id: '1', owner: 'travis-ci', name: 'travis-core', slug: 'travis-ci/travis-core', build_ids: [1, 2], last_build_id: 1, last_build_number: 1, last_build_state: 'passed', last_build_duration: 30, last_build_started_at: '2012-07-02T00:00:00Z', last_build_finished_at: '2012-07-02T00:00:30Z', description: 'Description of travis-core', github_language: 'ruby' },
|
||||
{ id: '2', owner: 'travis-ci', name: 'travis-assets', slug: 'travis-ci/travis-assets', build_ids: [3], last_build_id: 3, last_build_number: 3, last_build_state: 'failed', last_build_duration: 30, last_build_started_at: '2012-07-02T00:01:00Z', last_build_finished_at: '2012-07-01T00:01:30Z', description: 'Description of travis-assets', github_language: 'ruby'},
|
||||
{ id: '3', owner: 'travis-ci', name: 'travis-hub', slug: 'travis-ci/travis-hub', build_ids: [4], last_build_id: 4, last_build_number: 4, last_build_state: null, last_build_duration: null, last_build_started_at: '2012-07-02T00:02:00Z', last_build_finished_at: null, description: 'Description of travis-hub', github_language: 'ruby' },
|
||||
]
|
||||
|
||||
reposByName = (name) ->
|
||||
|
|
Loading…
Reference in New Issue
Block a user