blob: 8b778e623036a8f32a930dccdc14903c9cb3c9ef [file] [log] [blame]
Adrià Vilanova Martínezca25b682022-10-24 00:11:03 +02001import '@material/mwc-dialog/mwc-dialog.js';
2import '@material/web/button/filled-button.js';
3import '@material/web/button/text-button.js';
4
5import {css, html, LitElement} from 'lit';
6import {createRef, ref} from 'lit/directives/ref.js';
7
8export default class TwptConfirmDialog extends LitElement {
9 static properties = {
10 open: {type: Boolean},
11 workflow: {type: Object},
12 };
13
14 static styles = css`
15 :host {
16 --mdc-dialog-content-ink-color: var(--mdc-theme-on-surface, #000);
17 --mdc-dialog-z-index: 200;
18 }
19
20 .workflow {
21 font-weight: 500;
22 }
23 `;
24
25 constructor() {
26 super();
27 this.open = false;
28 }
29
30 render() {
31 return html`
32 <mwc-dialog
33 ?open=${this.open}
34 @opening=${this._openingDialog}
35 @closing=${this._closingDialog}>
36 <p>
37 Are you sure you want to run workflow
38 <span class="workflow">${this.workflow?.getName?.()}</span> for all
39 the selected threads?
40 </p>
41 <md-filled-button
42 slot="primaryAction"
43 label="Run workflow"
44 @click=${this._dispatchConfirmEvent}>
45 </md-filled-button>
46 <md-text-button
47 slot="secondaryAction"
48 dialogAction="cancel"
49 label="Cancel">
50 </md-text-button>
51 </mwc-dialog>
52 `;
53 }
54
55 _openingDialog() {
56 this.open = true;
57 }
58
59 _closingDialog() {
60 this.open = false;
61 }
62
63 _dispatchConfirmEvent() {
64 const e = new Event('confirm');
65 this.dispatchEvent(e);
66 this.open = false;
67 }
68}
69window.customElements.define('twpt-confirm-dialog', TwptConfirmDialog);