[New] Close of confirmation dialog also possible with closeable=true

This commit is contained in:
Robert von Burg 2021-11-24 11:50:54 +01:00
parent f3579ae0f9
commit 91714eb8b3
2 changed files with 15 additions and 3 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "strolch-wc-information-dialog", "name": "strolch-wc-information-dialog",
"description": "Strolch WebComponent Information Dialog", "description": "Strolch WebComponent Information Dialog",
"version": "0.1.3", "version": "0.1.4",
"authors": [ "authors": [
"Robert von Burg" "Robert von Burg"
], ],

View File

@ -34,9 +34,12 @@
<div class="buttons"> <div class="buttons">
<template is="dom-if" if="[[confirmation]]"> <template is="dom-if" if="[[confirmation]]">
<template is="dom-if" if="[[cancelable]]"> <template is="dom-if" if="[[cancelable]]">
<paper-button on-tap="_onClose">[[cancelLbl]]</paper-button> <paper-button on-tap="_onCancel">[[cancelLbl]]</paper-button>
</template> </template>
<paper-button autofocus on-tap="_onOk">[[okLbl]]</paper-button> <paper-button autofocus on-tap="_onOk">[[okLbl]]</paper-button>
<template is="dom-if" if="[[closeable]]">
<paper-button autofocus on-tap="_onClose">[[closeLbl]]</paper-button>
</template>
</template> </template>
<template is="dom-if" if="[[!confirmation]]"> <template is="dom-if" if="[[!confirmation]]">
<paper-button autofocus on-tap="_onClose">[[closeLbl]]</paper-button> <paper-button autofocus on-tap="_onClose">[[closeLbl]]</paper-button>
@ -87,6 +90,10 @@
type: Boolean, type: Boolean,
value: true value: true
}, },
closeable: {
type: Boolean,
value: false
},
callback: { callback: {
type: Function, type: Function,
value: null value: null
@ -100,6 +107,10 @@
observers: [], observers: [],
_onClose: function () { _onClose: function () {
this.close();
},
_onCancel: function () {
if (this.confirmation) { if (this.confirmation) {
this._confirm(false); this._confirm(false);
} else { } else {
@ -181,7 +192,8 @@
this.confirmation = true; this.confirmation = true;
} }
this.cancelable = typeof data.cancelable === "boolean" ? data.cancelable : true; this.cancelable = typeof data.cancelable === "boolean" && data.cancelable;
this.closeable = typeof data.closeable === "boolean" && data.closeable;
console.log("Message: " + this.title + ': ' + this.line1); console.log("Message: " + this.title + ': ' + this.line1);
this.$.dlg.notifyResize(); this.$.dlg.notifyResize();