FIX: wasn't able to recover a post

This commit is contained in:
Régis Hanol 2017-12-16 13:04:20 +01:00
parent e73556f48f
commit 50487d6122
2 changed files with 9 additions and 11 deletions

View File

@ -305,7 +305,7 @@ export default Ember.Controller.extend(BufferedContent, {
},
recoverPost(post) {
post.get("post_number") === 1 ? this.recoverTopic() : this.recover();
post.get("post_number") === 1 ? this.recoverTopic() : post.recover();
},
deletePost(post) {

View File

@ -125,35 +125,33 @@ const Post = RestModel.extend({
// Expands the first post's content, if embedded and shortened.
expand() {
const self = this;
return ajax("/posts/" + this.get('id') + "/expand-embed").then(function(post) {
self.set('cooked', "<section class='expanded-embed'>" + post.cooked + "</section>" );
return ajax(`/posts/${this.get('id')}/expand-embed`).then(post => {
this.set('cooked', `<section class="expanded-embed">${post.cooked}</section>`);
});
},
// Recover a deleted post
recover() {
const post = this,
initProperties = post.getProperties('deleted_at', 'deleted_by', 'user_deleted', 'can_delete');
const initProperties = this.getProperties('deleted_at', 'deleted_by', 'user_deleted', 'can_delete');
post.setProperties({
this.setProperties({
deleted_at: null,
deleted_by: null,
user_deleted: false,
can_delete: false
});
return ajax("/posts/" + (this.get('id')) + "/recover", { type: 'PUT', cache: false }).then(function(data){
post.setProperties({
return ajax(`/posts/${this.get('id')}/recover`, { type: 'PUT', cache: false }).then(data => {
this.setProperties({
cooked: data.cooked,
raw: data.raw,
user_deleted: false,
can_delete: true,
version: data.version
});
}).catch(function(error) {
}).catch(error => {
popupAjaxError(error);
post.setProperties(initProperties);
this.setProperties(initProperties);
});
},