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