mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 11:54:33 +03:00
9d67980a7e
refs #5798, closes #5018 - adds new `gh-fullscreen-modal` component - modals are now specified in-context so that they can have deeper interaction with their surrounding components/controller/route, i.e. a modal component can be a thin confirm/deny wrapper over the underlying controller action keeping all context-sensitive logic in one place - adds spin-buttons to all modals with async behaviour - adds/improves behaviour of inline-validation in modals - improves re-authenticate modal to properly handle validation and authentication errors
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
import Ember from 'ember';
|
|
import ModalComponent from 'ghost/components/modals/base';
|
|
|
|
const {computed, inject} = Ember;
|
|
const {alias} = computed;
|
|
|
|
export default ModalComponent.extend({
|
|
|
|
submitting: false,
|
|
|
|
post: alias('model'),
|
|
|
|
notifications: inject.service(),
|
|
routing: inject.service('-routing'),
|
|
|
|
_deletePost() {
|
|
let post = this.get('post');
|
|
|
|
// definitely want to clear the data store and post of any unsaved,
|
|
// client-generated tags
|
|
post.updateTags();
|
|
|
|
return post.destroyRecord();
|
|
},
|
|
|
|
_success() {
|
|
// clear any previous error messages
|
|
this.get('notifications').closeAlerts('post.delete');
|
|
|
|
// redirect to content screen
|
|
this.get('routing').transitionTo('posts');
|
|
},
|
|
|
|
_failure() {
|
|
this.get('notifications').showAlert('Your post could not be deleted. Please try again.', {type: 'error', key: 'post.delete.failed'});
|
|
},
|
|
|
|
actions: {
|
|
confirm() {
|
|
this.set('submitting', true);
|
|
|
|
this._deletePost().then(() => {
|
|
this._success();
|
|
}, () => {
|
|
this._failure();
|
|
}).finally(() => {
|
|
this.send('closeModal');
|
|
});
|
|
}
|
|
}
|
|
});
|