This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/queued-post.js.es6

40 lines
923 B
JavaScript

import BufferedContent from 'discourse/mixins/buffered-content';
import { popupAjaxError } from 'discourse/lib/ajax-error';
function updateState(state) {
return function() {
const post = this.get('post');
post.update({ state }).then(() => {
this.get('controllers.queued-posts.model').removeObject(post);
}).catch(popupAjaxError);
};
}
export default Ember.Controller.extend(BufferedContent, {
needs: ['queued-posts'],
post: Ember.computed.alias('model'),
editing: false,
actions: {
approve: updateState('approved'),
reject: updateState('rejected'),
edit() {
this.set('editing', true);
},
confirmEdit() {
this.get('post').update({ raw: this.get('buffered.raw') }).then(() => {
this.commitBuffer();
this.set('editing', false);
});
},
cancelEdit() {
this.rollbackBuffer();
this.set('editing', false);
}
}
});