Env vars now work with Ember Data
This commit is contained in:
parent
5c5ed6e408
commit
6b177d2238
|
@ -8,7 +8,7 @@ Travis.EnvVarAdapter = Travis.ApplicationAdapter.extend
|
|||
|
||||
if record && (repoId = get(record, 'repo.id'))
|
||||
delimiter = if url.indexOf('?') != -1 then '&' else '?'
|
||||
url = "#{url}#{delimiter}repository_id=#{repo_id}"
|
||||
url = "#{url}#{delimiter}repository_id=#{repoId}"
|
||||
|
||||
url
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@ Travis.EnvVarController = Ember.ObjectController.extend Travis.Validations,
|
|||
return if @get('isDeleting')
|
||||
@set('isDeleting', true)
|
||||
|
||||
deletingDone = => @set('isDeleting', false)
|
||||
@get('model').deleteRecord().then deletingDone, deletingDone
|
||||
@get('model').destroyRecord()
|
||||
|
||||
edit: ->
|
||||
@set('isEditing', true)
|
||||
|
@ -37,7 +36,6 @@ Travis.EnvVarController = Ember.ObjectController.extend Travis.Validations,
|
|||
|
||||
save: ->
|
||||
return if @get('isSaving')
|
||||
@set('isSaving', true)
|
||||
|
||||
if @isValid()
|
||||
env_var = @get('model')
|
||||
|
@ -45,8 +43,3 @@ Travis.EnvVarController = Ember.ObjectController.extend Travis.Validations,
|
|||
# TODO: handle errors
|
||||
env_var.save().then =>
|
||||
@set('isEditing', false)
|
||||
@set('isSaving', false)
|
||||
, =>
|
||||
@set('isSaving', false)
|
||||
else
|
||||
@set('isSaving', false)
|
||||
|
|
|
@ -7,6 +7,8 @@ Travis.EnvVarsNewController = Ember.Controller.extend Validations,
|
|||
needs: ['repo']
|
||||
repo: Ember.computed.alias('controllers.repo.repo')
|
||||
|
||||
isSaving: false
|
||||
|
||||
validates:
|
||||
name: ['presence']
|
||||
|
||||
|
@ -26,7 +28,7 @@ Travis.EnvVarsNewController = Ember.Controller.extend Validations,
|
|||
@set('isSaving', true)
|
||||
|
||||
if @isValid()
|
||||
env_var = EnvVar.create(
|
||||
env_var = @store.createRecord('env_var',
|
||||
name: @get('name')
|
||||
value: @get('value')
|
||||
public: @get('public')
|
||||
|
@ -40,5 +42,3 @@ Travis.EnvVarsNewController = Ember.Controller.extend Validations,
|
|||
self.transitionToRoute('env_vars')
|
||||
, =>
|
||||
@set('isSaving', false)
|
||||
else
|
||||
@set('isSaving', false)
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
Travis.EnvVarsController = Ember.ArrayController.extend()
|
||||
Travis.EnvVarsController = Ember.ArrayController.extend
|
||||
vars: Ember.computed.filterBy('model', 'isNew', false)
|
||||
|
|
|
@ -47,25 +47,9 @@ Travis.Repo = Travis.Model.extend
|
|||
|
||||
envVars: (->
|
||||
id = @get('id')
|
||||
envVars = @store.filter('env_var', { repository_id: id }, (envVar) ->
|
||||
# envVar.get('
|
||||
@store.filter('env_var', { repository_id: id }, (v) ->
|
||||
v.get('repo.id') == id
|
||||
)
|
||||
|
||||
EnvVar.find repository_id: id
|
||||
|
||||
# TODO: move to controller
|
||||
array = ExpandableRecordArray.create
|
||||
type: EnvVar
|
||||
content: Ember.A([])
|
||||
|
||||
array.load(envVars)
|
||||
|
||||
globalEnvVars = Ember.RecordArray.create({ modelClass: EnvVar, content: Ember.A([]) })
|
||||
EnvVar.registerRecordArray(globalEnvVars)
|
||||
|
||||
array.observe(globalEnvVars, (envVar) -> envVar.get('isLoaded') && envVar.get('repo.id') == id )
|
||||
|
||||
array
|
||||
).property()
|
||||
|
||||
builds: (->
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{{outlet}}
|
||||
|
||||
<ul class="env-vars">
|
||||
{{#each controller itemController="envVar"}}
|
||||
{{#each vars itemController="envVar"}}
|
||||
<li class="env-var">
|
||||
{{#if isEditing}}
|
||||
{{partial 'env_vars/form'}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user