travis-web/app/components/caches-item.js
2016-01-04 13:15:14 +01:00

34 lines
884 B
JavaScript

import Ember from 'ember';
export default Ember.Component.extend({
ajax: Ember.inject.service(),
tagName: 'li',
classNames: ['cache-item'],
classNameBindings: ['cache.type'],
isDeleting: false,
actions: {
"delete": function() {
var data, deletingDone, repo;
if (this.get('isDeleting')) {
return;
}
if (confirm('Are you sure?')) {
this.set('isDeleting', true);
data = {
branch: this.get('cache.branch')
};
deletingDone = () => {
return this.set('isDeleting', false);
};
repo = this.get('repo');
return this.get('ajax').ajax("/repos/" + (repo.get('id')) + "/caches", "DELETE", {
data: data
}).then(deletingDone, deletingDone).then(() => {
return this.get('caches').removeObject(this.get('cache'));
});
}
}
}
});