Adrià Vilanova Martínez | 8803b6c | 2022-10-17 00:36:38 +0200 | [diff] [blame] | 1 | import '@material/mwc-dialog/mwc-dialog.js'; |
| 2 | import '@material/web/button/text-button.js'; |
| 3 | import '@material/web/button/filled-button.js'; |
| 4 | import './WorkflowEditor.js'; |
| 5 | |
| 6 | import {css, html, LitElement} from 'lit'; |
| 7 | import {createRef, ref} from 'lit/directives/ref.js'; |
| 8 | |
| 9 | import * as pb from '../../proto/main_pb.js'; |
| 10 | |
| 11 | export default class WFWorkflowDialog extends LitElement { |
| 12 | static properties = { |
| 13 | open: {type: Boolean}, |
| 14 | uuid: {type: String}, |
| 15 | workflow: {type: Object}, |
| 16 | }; |
| 17 | |
| 18 | static styles = css` |
| 19 | :host { |
| 20 | --mdc-dialog-content-ink-color: var(--mdc-theme-on-surface, #000); |
| 21 | } |
| 22 | `; |
| 23 | |
| 24 | workflowEditorRef = createRef(); |
| 25 | |
| 26 | constructor() { |
| 27 | super(); |
| 28 | this.open = false; |
| 29 | this.workflow = new pb.workflows.Workflow(); |
| 30 | } |
| 31 | |
| 32 | render() { |
| 33 | return html` |
| 34 | <mwc-dialog |
| 35 | ?open=${this.open} |
| 36 | @opening=${this._openingDialog} |
| 37 | @closing=${this._closingDialog}> |
| 38 | <wf-workflow-editor ${ref(this.workflowEditorRef)} |
| 39 | .workflow=${this.workflow}> |
| 40 | </wf-workflow-editor> |
| 41 | <md-filled-button |
| 42 | slot="primaryAction" |
Adrià Vilanova Martínez | 8803b6c | 2022-10-17 00:36:38 +0200 | [diff] [blame] | 43 | @click=${this._save}> |
Renovate bot | aa5fb8e | 2024-02-25 18:10:09 +0000 | [diff] [blame] | 44 | Save |
Adrià Vilanova Martínez | 8803b6c | 2022-10-17 00:36:38 +0200 | [diff] [blame] | 45 | </md-filled-button> |
| 46 | <md-text-button |
| 47 | slot="secondaryAction" |
Renovate bot | aa5fb8e | 2024-02-25 18:10:09 +0000 | [diff] [blame] | 48 | dialogAction="cancel"> |
| 49 | Cancel |
Adrià Vilanova Martínez | 8803b6c | 2022-10-17 00:36:38 +0200 | [diff] [blame] | 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 | _save() { |
| 64 | const success = this.workflowEditorRef.value.save(this.uuid); |
| 65 | if (success) this.open = false; |
| 66 | } |
| 67 | } |
| 68 | window.customElements.define('wf-workflow-dialog', WFWorkflowDialog); |