Sha256: bb674606b5337639c2dd54bcb06feda7650a33053bc7996b841bb8a1ab55708a

Contents?: true

Size: 1.17 KB

Versions: 18

Compression:

Stored size: 1.17 KB

Contents

export class VDialog {
    constructor(options, params, event, root) {
        this.dialogId = options.target;
        this.params = params;
        this.event = event;
        this.root = root;
    }

    call(results) {
        const dialog = this.root.querySelector('#' + this.dialogId);

        if (!(dialog && dialog.vComponent)) {
            const err = new Error(
                `Unable to find dialog ${this.dialogId}. `
                + 'Did you forget to attach it?'
            );

            results.push({
                action: 'dialog',
                contentType: 'v/errors',
                content: {exception: err.message},
            });

            return new Promise((_, reject) => reject(results));
        }

        return new Promise(function(resolve, reject) {
            const comp = dialog.vComponent.mdcComponent;

            comp.listen('MDCDialog:closed', (event) => {
                results.push({
                    action: 'dialog',
                    statusCode: 200,
                    dialogAction: event.detail.action,
                });

                resolve(results);
            });

            dialog.vComponent.open();
        });
    }
}

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
coprl-3.0.0.beta.12 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.11 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.10 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.9 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.8 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.7 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.6 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.5 views/mdc/assets/js/components/events/dialog.js
voom-presenters-2.1.2 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.4 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.3 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.2 views/mdc/assets/js/components/events/dialog.js
coprl-3.0.0.beta.1 views/mdc/assets/js/components/events/dialog.js
voom-presenters-2.1.0 views/mdc/assets/js/components/events/dialog.js
voom-presenters-2.0.3 views/mdc/assets/js/components/events/dialog.js
voom-presenters-2.0.2 views/mdc/assets/js/components/events/dialog.js
voom-presenters-2.0.1 views/mdc/assets/js/components/events/dialog.js
voom-presenters-2.0.0 views/mdc/assets/js/components/events/dialog.js