mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 03:12:46 +08:00
Add deleteRecord
API to store to support deleting a tag
This commit is contained in:
parent
e63a24a08a
commit
34294ca748
|
@ -15,6 +15,11 @@ const RestModel = Ember.Object.extend({
|
|||
self.setProperties(attrs);
|
||||
return result;
|
||||
});
|
||||
},
|
||||
|
||||
destroyRecord() {
|
||||
const type = this.get('__type');
|
||||
return this.store.destroyRecord(type, this.get('id'));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -60,6 +65,13 @@ export default Ember.Object.extend({
|
|||
});
|
||||
},
|
||||
|
||||
destroyRecord(type, id) {
|
||||
return Discourse.ajax(this.pathFor(type, id), { method: 'DELETE' }).then(function(result) {
|
||||
delete _identityMap[type][id];
|
||||
return result;
|
||||
});
|
||||
},
|
||||
|
||||
createRecord(type, attrs) {
|
||||
return this._hydrate(type, attrs);
|
||||
},
|
||||
|
|
|
@ -12,5 +12,10 @@ export default Ember.Object.extend({
|
|||
createRecord(type, attrs) {
|
||||
const adapter = this.container.lookup('adapter:' + type) || this.container.lookup('adapter:rest');
|
||||
return adapter.createRecord(type, attrs);
|
||||
},
|
||||
|
||||
destroyRecord(type, id) {
|
||||
const adapter = this.container.lookup('adapter:' + type) || this.container.lookup('adapter:rest');
|
||||
return adapter.destroyRecord(type, id);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user