Merge branch 'ember-cli' of github.com:travis-ci/travis-web into ember-cli

This commit is contained in:
Lisa Passing 2015-02-10 14:45:56 +01:00
commit c00b5492f9
5 changed files with 39 additions and 19 deletions

View File

@ -4,11 +4,21 @@
Adapter = ApplicationAdapter.extend
namespace: 'settings'
find: (store, type, id, record) ->
@ajax(this.urlPrefix() + '/ssh_key/' + id, 'GET')
deleteRecord: (store, type, record) ->
id = Ember.get(record, 'id')
@ajax(this.urlPrefix() + '/ssh_key/' + id, "DELETE");
createRecord: (store, type, record) ->
data = {};
serializer = store.serializerFor(type.typeKey);
serializer.serializeIntoHash(data, type, record, { includeId: true });
this.ajax(this.buildURL(type.typeKey, null, record), "POST", { data: data })
id = Ember.get(record, 'id')
this.ajax(this.urlPrefix() + '/ssh_key/' + id, "PATCH", { data: data })
`export default Adapter`

View File

@ -18,7 +18,12 @@ Controller = Ember.ObjectController.extend Validations,
actions:
add: ->
model = Travis.SshKey.create(id: @get('repo.id'))
id = @get('repo.id')
model = @store.recordForId('sshKey', id)
if model.get('currentState.stateName') == 'root.empty'
@store.dematerializeRecord(model)
model = @store.createRecord('sshKey', id: id)
@set('model', model)
@set('isEditing', true)
@ -30,10 +35,10 @@ Controller = Ember.ObjectController.extend Validations,
@get('model').save().then =>
@set('isEditing', false)
@set('isSaving', false)
, (xhr) =>
, (error) =>
@set('isSaving', false)
if xhr.status == 422
@addErrorsFromResponse(JSON.parse(xhr.response)['errors'])
if error.errors
@addErrorsFromResponse(error.errors)
else
@set('isSaving', false)
@ -43,18 +48,18 @@ Controller = Ember.ObjectController.extend Validations,
deletingDone = => @set('isDeleting', false)
# because of the bug in ember model reference is not cleared after
# deleting the record, so I'm doing it manually here
delete @get('model').constructor._referenceCache[parseInt(@get('model.id'))]
@get('model').deleteRecord().then(deletingDone, deletingDone).then =>
@get('model').deleteRecord()
@get('model').save().then(deletingDone, deletingDone).then =>
@set('model', null)
cancel: ->
if model = @get('model')
if model.get('isNew')
@set('model', null)
@set('isEditing', false)
if model.get('currentState.stateName') == 'root.empty' ||
model.get('currentState.stateName').indexOf('root.loaded.created') != -1
@store.dematerializeRecord(model)
@set('model', null)
@set('isEditing', false)
edit: ->
@set('isEditing', true)

View File

@ -7,11 +7,12 @@ ErrorsView = Ember.View.extend
classNameBindings: ['codes', 'show']
codes: (->
@get('errors').mapBy('code')
).property('@errors')
).property('@errors', 'errors.length')
show: Ember.computed.notEmpty('errors.[]')
fn = (name, options) ->
errors = @get('errors').for(name)
window[name + 'Errors'] = errors
view = ErrorsView.create(
controller: this
errors: errors

View File

@ -1 +1 @@
{{#each erorr in view.errors}}{{error.message}}{{/each}}
{{#each error in view.errors}}{{error.message}}{{/each}}

View File

@ -2,12 +2,14 @@
<ul>
{{#if view.displayCancelBuild}}
<li class="icon cancel-build" title="Cancel Build">
<a href="#" {{action "cancelBuild" target=view}}></a>
<a href="#" {{action "cancelBuild" target=view}}
{{bind-attr class="view.canCancelBuild::disabled"}}></a>
</li>
{{/if}}
{{#if view.displayCancelJob}}
<li class="icon cancel-job" title="Cancel Job">
<a href="#" {{action "cancelJob" target=view}}></a>
<a href="#" {{action "cancelJob" target=view}}
{{bind-attr class="view.canCancelJob::disabled"}}></a>
</li>
{{/if}}
{{#if view.displayRequeueBuild}}
@ -15,7 +17,8 @@
{{#if view.requeueing}}
<span class="icon loading"></span>
{{else}}
<a href="#" {{action "requeueBuild" target=view}}></a>
<a href="#" {{action "requeueBuild" target=view}}
{{bind-attr class="view.canRequeueBuild::disabled"}}></a>
{{/if}}
</li>
{{/if}}
@ -24,7 +27,8 @@
{{#if view.requeueing}}
<span class="icon loading"></span>
{{else}}
<a href="#" {{action "requeueJob" target=view}}></a>
<a href="#" {{action "requeueJob" target=view}}
{{bind-attr class="view.canRequeueJob::disabled"}}></a>
{{/if}}
</li>
{{/if}}