Adrià Vilanova Martínez | c6e1ce3 | 2024-02-26 03:34:13 +0100 | [diff] [blame] | 1 | import '@material/web/dialog/dialog.js'; |
Adrià Vilanova Martínez | ca25b68 | 2022-10-24 00:11:03 +0200 | [diff] [blame] | 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` |
Adrià Vilanova Martínez | c6e1ce3 | 2024-02-26 03:34:13 +0100 | [diff] [blame] | 37 | <md-dialog |
Adrià Vilanova Martínez | ca25b68 | 2022-10-24 00:11:03 +0200 | [diff] [blame] | 38 | ?open=${this.open} |
Adrià Vilanova Martínez | c6e1ce3 | 2024-02-26 03:34:13 +0100 | [diff] [blame] | 39 | @open=${this._openingDialog} |
| 40 | @close=${this._closingDialog}> |
| 41 | <div slot="content"> |
Adrià Vilanova Martínez | ca25b68 | 2022-10-24 00:11:03 +0200 | [diff] [blame] | 42 | Are you sure you want to run workflow |
| 43 | <span class="workflow">${this.workflow?.getName?.()}</span> for all |
| 44 | the selected threads? |
Adrià Vilanova Martínez | c6e1ce3 | 2024-02-26 03:34:13 +0100 | [diff] [blame] | 45 | </div> |
| 46 | <div slot="actions"> |
Adrià Vilanova Martínez | c6e1ce3 | 2024-02-26 03:34:13 +0100 | [diff] [blame] | 47 | <md-text-button |
| 48 | @click=${() => this.open = false}> |
| 49 | Cancel |
| 50 | </md-text-button> |
Adrià Vilanova Martínez | 2d4ffe6 | 2024-02-26 04:12:20 +0100 | [diff] [blame] | 51 | <md-filled-button |
| 52 | @click=${this._dispatchConfirmEvent}> |
| 53 | Run workflow |
| 54 | </md-filled-button> |
Adrià Vilanova Martínez | c6e1ce3 | 2024-02-26 03:34:13 +0100 | [diff] [blame] | 55 | </div> |
| 56 | </md-dialog> |
Adrià Vilanova Martínez | ca25b68 | 2022-10-24 00:11:03 +0200 | [diff] [blame] | 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); |