Vue.component("vv-notice", {
template: '<template> </template>',
data :function () {
    return {};
},
methods :{
    to_message(object) {
        let message = 'UNKNOWN MESSAGE';
        if (typeof object === 'string') {
            message = vvs.toHtml(object);
        } else if (Array.isArray(object) && object.length === 1) {
            message = vvs.toHtml(vvs.toString(object[0]));
        } else if (Array.isArray(object) && object.length > 1) {
            message = '<ul>'.concat(object.map(m => {
                return '<li>'.concat(vvs.toHtml(vvs.toString(m)), '</li>');
            }).join('\n'), '</ul>');
        } else if (!Array.isArray(object)) {
            message = vvs.toHtml(object.toString() + (object.response && object.response.data ? ': '.concat(object.response.data) : ''));
        }
        return message;
    },
    message: function (error) {
        if (!error)
            return;
        this.$q.notify({
            icon: 'icon-fa-ok-circled',
            type: 'positive',
            html: true,
            message: this.to_message(error)
        });
    },
    warning: function (error) {
        if (!error)
            return;
        this.$q.notify({
            icon: 'icon-fa-attention',
            type: 'warning',
            html: true,
            message: this.to_message(error)
        });
    },
    error: function (error) {
        if (!error)
            return;
        this.$q.notify({
            icon: 'icon-fa-attention-circled',
            type: 'negative',
            html: true,
            message: this.to_message(error)
        });
    },
    question: function (message, title, callback) {
        if (!message)
            return;
        this.$q.dialog({
            title: title,
            message: message,
            noBackdropDismiss: true,
            cancel: {
                unelevated: true,
                color: 'negative',
                label: 'no'
            },
            ok: {
                unelevated: true,
                color: 'primary',
                label: 'yes'
            }
        }).onOk(() => {
            if (vvs.isFunction(callback)) {
                callback(true);
            }
        }).onCancel(() => {
            if (vvs.isFunction(callback)) {
                callback(false);
            }
        }).onDismiss(() => {
        });
    }
}
})