This commit is contained in:
Justine Arreche 2013-10-21 20:04:30 -04:00
commit 75ae8d7d14
8 changed files with 7383 additions and 3232 deletions

View File

@ -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

View File

@ -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: (->

View File

@ -15,6 +15,7 @@ Travis.Adapter = Ember.RESTAdapter.extend
@sideload(klass, data)
records.load(klass, dataToLoad)
@addToRecordArrays(records.get('content'))
buildURL: ->
@_super.apply(this, arguments).replace(/\.json$/, '')
@ -22,26 +23,38 @@ Travis.Adapter = Ember.RESTAdapter.extend
didFind: (record, id, data) ->
@sideload(record.constructor, data)
@_super(record, id, data)
@addToRecordArrays(record)
didFindAll: (klass, records, data) ->
@sideload(klass, data)
@_super(klass, records, data)
@addToRecordArrays(records.get('content'))
didFindQuery: (klass, records, params, data) ->
@sideload(klass, data)
@_super(klass, records, params, data)
@addToRecordArrays(records.get('content'))
didCreateRecord: (record, data) ->
@sideload(record.constructor, data)
@_super(record, data)
@addToRecordArrays(record)
didSaveRecord: (record, data) ->
@sideload(record.constructor, data)
@_super(record, data)
@addToRecordArrays(record)
didDeleteRecord: (record, data) ->
@sideload(record.constructor, data)
@_super(record, data)
@addToRecordArrays(record)
addToRecordArrays: (records) ->
records = [records] unless Ember.isArray(records)
for record in records
record.constructor.addToRecordArrays(record)
sideload: (klass, data) ->
for name, records of data

View File

@ -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

View File

@ -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) ->

View File

@ -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) ->

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff