Esempio n. 1
0
import ModalComponent from 'ghost/components/modals/base';
import {invokeAction} from 'ember-invoke-action';

export default ModalComponent.extend({
    user: null,
    submitting: false,

    actions: {
        confirm() {
            this.set('submitting', true);

            invokeAction(this, 'confirm').finally(() => {
                this.send('closeModal');
            });
        }
    }
});
export default ModalComponent.extend({
    labelText: 'Select or drag-and-drop a CSV File',

    response: null,
    closeDisabled: false,

    uploadUrl: computed(function () {
        return `${ghostPaths().apiRoot}/subscribers/csv/`;
    }),

    actions: {
        uploadStarted() {
            this.set('closeDisabled', true);
        },

        uploadFinished() {
            this.set('closeDisabled', false);
        },

        uploadSuccess(response) {
            this.set('response', response.meta.stats);
            // invoke the passed in confirm action
            invokeAction(this, 'confirm');
        },

        confirm() {
            // noop - we don't want the enter key doing anything
        },

        closeModal() {
            if (!this.get('closeDisabled')) {
                this._super(...arguments);
            }
        }
    }
});
Esempio n. 3
0
import Ember from 'ember';
import ModalComponent from 'ghost/components/modals/base';

const {computed} = Ember;
const {alias} = computed;

export default ModalComponent.extend({

    submitting: false,

    tag: alias('model'),

    postInflection: computed('tag.count.posts', function () {
        return this.get('tag.count.posts') > 1 ? 'posts' : 'post';
    }),

    actions: {
        confirm() {
            this.set('submitting', true);

            this.get('confirm')().finally(() => {
                this.send('closeModal');
            });
        }
    }
});
Esempio n. 4
0
export default ModalComponent.extend({

    submitting: false,

    ghostPaths: service(),
    notifications: service(),
    store: service(),
    ajax: service(),

    _deleteAll() {
        let deleteUrl = this.get('ghostPaths.url').api('db');
        return this.get('ajax').del(deleteUrl);
    },

    _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');
            });
        }
    }
});
Esempio n. 5
0
import ModalComponent from 'ghost/components/modals/base';

export default ModalComponent.extend({
    actions: {
        confirm() {
            this.attrs.confirm().finally(() => {
                this.send('closeModal');
            });
        }
    }
});
Esempio n. 6
0
import ModalComponent from 'ghost/components/modals/base';

export default ModalComponent.extend({

    submitting: false,

    user: null,

    actions: {
        confirm() {
            this.set('submitting', true);

            this.attrs.confirm().finally(() => {
                this.send('closeModal');
            });
        }
    }
});