Merge branch 'master' of https://github.com/travis-ci/travis-web
This commit is contained in:
commit
75ae8d7d14
|
@ -119,14 +119,12 @@ unless window.TravisApplication
|
||||||
loadOrMerge: (type, hash, options) ->
|
loadOrMerge: (type, hash, options) ->
|
||||||
options ||= {}
|
options ||= {}
|
||||||
|
|
||||||
if !type._idToReference
|
reference = type._getReferenceById(hash.id)
|
||||||
type._idToReference = {}
|
|
||||||
reference = type._idToReference[hash.id]
|
|
||||||
|
|
||||||
if reference && options.skipIfExists
|
if reference && options.skipIfExists
|
||||||
return
|
return
|
||||||
|
|
||||||
reference = type._referenceForId(hash.id)
|
reference = type._getOrCreateReferenceForId(hash.id)
|
||||||
if reference.record
|
if reference.record
|
||||||
reference.record.merge(hash)
|
reference.record.merge(hash)
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,7 +9,7 @@ Travis.FlashController = Ember.ArrayController.extend
|
||||||
@set('flashes', Ember.A())
|
@set('flashes', Ember.A())
|
||||||
|
|
||||||
content: (->
|
content: (->
|
||||||
@get('unseenBroadcasts').concat(@get('flashes'))
|
@get('unseenBroadcasts').concat(@get('flashes')).filter (o) -> o
|
||||||
).property('unseenBroadcasts.length', 'flashes.length')
|
).property('unseenBroadcasts.length', 'flashes.length')
|
||||||
|
|
||||||
unseenBroadcasts: (->
|
unseenBroadcasts: (->
|
||||||
|
|
|
@ -15,6 +15,7 @@ Travis.Adapter = Ember.RESTAdapter.extend
|
||||||
|
|
||||||
@sideload(klass, data)
|
@sideload(klass, data)
|
||||||
records.load(klass, dataToLoad)
|
records.load(klass, dataToLoad)
|
||||||
|
@addToRecordArrays(records.get('content'))
|
||||||
|
|
||||||
buildURL: ->
|
buildURL: ->
|
||||||
@_super.apply(this, arguments).replace(/\.json$/, '')
|
@_super.apply(this, arguments).replace(/\.json$/, '')
|
||||||
|
@ -22,26 +23,38 @@ Travis.Adapter = Ember.RESTAdapter.extend
|
||||||
didFind: (record, id, data) ->
|
didFind: (record, id, data) ->
|
||||||
@sideload(record.constructor, data)
|
@sideload(record.constructor, data)
|
||||||
@_super(record, id, data)
|
@_super(record, id, data)
|
||||||
|
@addToRecordArrays(record)
|
||||||
|
|
||||||
didFindAll: (klass, records, data) ->
|
didFindAll: (klass, records, data) ->
|
||||||
@sideload(klass, data)
|
@sideload(klass, data)
|
||||||
@_super(klass, records, data)
|
@_super(klass, records, data)
|
||||||
|
@addToRecordArrays(records.get('content'))
|
||||||
|
|
||||||
didFindQuery: (klass, records, params, data) ->
|
didFindQuery: (klass, records, params, data) ->
|
||||||
@sideload(klass, data)
|
@sideload(klass, data)
|
||||||
@_super(klass, records, params, data)
|
@_super(klass, records, params, data)
|
||||||
|
@addToRecordArrays(records.get('content'))
|
||||||
|
|
||||||
didCreateRecord: (record, data) ->
|
didCreateRecord: (record, data) ->
|
||||||
@sideload(record.constructor, data)
|
@sideload(record.constructor, data)
|
||||||
@_super(record, data)
|
@_super(record, data)
|
||||||
|
@addToRecordArrays(record)
|
||||||
|
|
||||||
didSaveRecord: (record, data) ->
|
didSaveRecord: (record, data) ->
|
||||||
@sideload(record.constructor, data)
|
@sideload(record.constructor, data)
|
||||||
@_super(record, data)
|
@_super(record, data)
|
||||||
|
@addToRecordArrays(record)
|
||||||
|
|
||||||
didDeleteRecord: (record, data) ->
|
didDeleteRecord: (record, data) ->
|
||||||
@sideload(record.constructor, data)
|
@sideload(record.constructor, data)
|
||||||
@_super(record, 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) ->
|
sideload: (klass, data) ->
|
||||||
for name, records of data
|
for name, records of data
|
||||||
|
|
|
@ -38,9 +38,10 @@ Array.prototype.diff = (a) ->
|
||||||
@loadedAttributes = []
|
@loadedAttributes = []
|
||||||
@loadedRelationships = []
|
@loadedRelationships = []
|
||||||
|
|
||||||
attributes = this.attributes || []
|
attributes = this.constructor.getAttributes() || []
|
||||||
relationships = this.relationships || []
|
relationships = this.constructor.getRelationships() || []
|
||||||
|
|
||||||
|
if hash
|
||||||
for key in attributes
|
for key in attributes
|
||||||
dataKey = @dataKey(key)
|
dataKey = @dataKey(key)
|
||||||
if hash.hasOwnProperty(dataKey)
|
if hash.hasOwnProperty(dataKey)
|
||||||
|
@ -86,10 +87,10 @@ Array.prototype.diff = (a) ->
|
||||||
@loadTheRest(key)
|
@loadTheRest(key)
|
||||||
|
|
||||||
isAttribute: (name) ->
|
isAttribute: (name) ->
|
||||||
this.attributes.contains(name)
|
this.constructor.getAttributes().contains(name)
|
||||||
|
|
||||||
isRelationship: (name) ->
|
isRelationship: (name) ->
|
||||||
this.relationships.contains(name)
|
this.constructor.getRelationships().contains(name)
|
||||||
|
|
||||||
loadTheRest: (key) ->
|
loadTheRest: (key) ->
|
||||||
# for some weird reason key comes changed to a string and for some weird reason it even is called with
|
# 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()
|
).property()
|
||||||
|
|
||||||
isRecordLoaded: (id) ->
|
isRecordLoaded: (id) ->
|
||||||
!!@_referenceForId(id).record
|
reference = @_getReferenceById(id)
|
||||||
|
reference && reference.record
|
||||||
|
|
||||||
camelizeKeys: true
|
camelizeKeys: true
|
||||||
|
|
||||||
# TODO: the functions below will be added to Ember Model, remove them when that
|
# TODO: the functions below will be added to Ember Model, remove them when that
|
||||||
# happens
|
# happens
|
||||||
resetData: ->
|
resetData: ->
|
||||||
@_idToReference = null
|
@_referenceCache = {}
|
||||||
@sideloadedData = null
|
@sideloadedData = {}
|
||||||
@recordCache = null
|
@recordArrays = []
|
||||||
@recordArrays = null
|
@_currentBatchIds = []
|
||||||
@_currentBatchIds = null
|
@_hasManyArrays = []
|
||||||
@_hasManyArrays = null
|
|
||||||
@_findAllRecordArray = null
|
@_findAllRecordArray = null
|
||||||
|
|
||||||
unload: (record) ->
|
unload: (record) ->
|
||||||
|
@ -172,10 +173,8 @@ Array.prototype.diff = (a) ->
|
||||||
delete this.recordCache[key]
|
delete this.recordCache[key]
|
||||||
|
|
||||||
loadRecordForReference: (reference) ->
|
loadRecordForReference: (reference) ->
|
||||||
record = @create({ _reference: reference })
|
record = @create({ _reference: reference, id: reference.id })
|
||||||
@recordCache = {} unless @recordCache
|
|
||||||
@sideloadedData = {} unless @sideloadedData
|
@sideloadedData = {} unless @sideloadedData
|
||||||
@recordCache[reference.id] = record
|
|
||||||
reference.record = record
|
reference.record = record
|
||||||
record.load(reference.id, @sideloadedData[reference.id])
|
record.load(reference.id, @sideloadedData[reference.id])
|
||||||
# TODO: find a nicer way to not add record to record arrays twice
|
# TODO: find a nicer way to not add record to record arrays twice
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
@displaysTabs = (tabs) ->
|
@displaysTabs = (tabs) ->
|
||||||
for name, tab of 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} 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']
|
equal($("#tab_#{name}").hasClass('display-inline'), !tab.hidden, "#{name} tab should has class display-inline") if name in ['build', 'job']
|
||||||
|
|
||||||
@displaysSummaryBuildLink = (link, number) ->
|
@displaysSummaryBuildLink = (link, number) ->
|
||||||
|
|
|
@ -3,9 +3,9 @@ minispade.require 'ext/jquery'
|
||||||
responseTime = 0
|
responseTime = 0
|
||||||
|
|
||||||
repos = [
|
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: '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'},
|
{ 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'},
|
{ 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) ->
|
reposByName = (name) ->
|
||||||
|
|
810
assets/scripts/vendor/ember-model.js
vendored
810
assets/scripts/vendor/ember-model.js
vendored
File diff suppressed because it is too large
Load Diff
9613
assets/scripts/vendor/ember.js
vendored
9613
assets/scripts/vendor/ember.js
vendored
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user