Sha256: e4dbb908368c891dfe527510f81cb8169b2ad1dcaf87c450995b91bf4ea8559e

Contents?: true

Size: 1.61 KB

Versions: 18

Compression:

Stored size: 1.61 KB

Contents

import {VBase} from './base';


export class VCloseDialog extends VBase {
    constructor(options, params, event, root) {
        super(options, root);
        this.elementId = options.target;
    }

    call(results) {
        return new Promise((resolve) => {
            const elem = this.root.getElementById(this.elementId);
            if (!elem) {
                const err = new Error(
                    `Unable to locate node ${this.elementId}!`
                    + ' Did you forget to attach it?');

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

                return new Promise((_, reject) => reject(results));
            }
            if (!elem.vComponent || !elem.vComponent.respondTo('closeDialog')) {
                const err = new Error(
                    `Element at node ${this.elementId} does not contain a component that reponds to `
                    + 'the closeDialog() method. Are you targeting the correct element.');

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

                return new Promise((_, reject) => reject(results));
            }
            elem.vComponent.closeDialog();

            results.push({
                action: 'close_dialog',
                statusCode: 200,
            });

            // Otherwise, proceed with the next action:
            return resolve(results);
        });
    }
}

Version data entries

18 entries across 18 versions & 2 rubygems

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