0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/client/app/components/modals/delete-all.js
Kevin Ansfield 1c6b208047 Refactor modals
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
2016-01-12 20:53:08 +00:00

48 lines
1.2 KiB
JavaScript

import Ember from 'ember';
import ModalComponent from 'ghost/components/modals/base';
import {request as ajax} from 'ic-ajax';
const {inject} = Ember;
export default ModalComponent.extend({
submitting: false,
ghostPaths: inject.service('ghost-paths'),
notifications: inject.service(),
store: inject.service(),
_deleteAll() {
return ajax(this.get('ghostPaths.url').api('db'), {
type: 'DELETE'
});
},
_unloadData() {
this.get('store').unloadAll('post');
this.get('store').unloadAll('tag');
},
_showSuccess() {
this.get('notifications').showAlert('All content deleted from database.', {type: 'success', key: 'all-content.delete.success'});
},
_showFailure(error) {
this.get('notifications').showAPIError(error, {key: 'all-content.delete'});
},
actions: {
confirm() {
this.set('submitting', true);
this._deleteAll().then(() => {
this._unloadData();
this._showSuccess();
}).catch((error) => {
this._showFailure(error);
}).finally(() => {
this.send('closeModal');
});
}
}
});