diff --git a/README.md b/README.md index af03256e..51b2572c 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,30 @@ In order to add a new page you need to go along the following steps: } ``` +### Dialogs + +![Example dialog](doc/images/dialog.png) + +The basic dialog component is `src/components/CscDialog.vue`. + +#### How to create a new custom dialog + +Check the example implementation in `src/components/CscDialogChangePassword.vue`. + +#### How to call custom dialogs from within a Vue.js Component method + +To reduce the boilerplate code of dialog components, we call Dialogs +via [Quasar Dialog Plugin](https://quasar.dev/quasar-plugins/dialog). + +```javascript +this.$q.dialog({ + component: CscDialogChangePassword, + parent: this +}).onOk((password) => { + this.changeWebPassword(password) +}) +``` + ### NGCP API All API functions are located in `src/api`. The file `src/api/common.js` diff --git a/doc/images/dialog.png b/doc/images/dialog.png new file mode 100644 index 00000000..856945e0 Binary files /dev/null and b/doc/images/dialog.png differ diff --git a/src/components/CscDialog.vue b/src/components/CscDialog.vue index 0d854533..df2108bb 100644 --- a/src/components/CscDialog.vue +++ b/src/components/CscDialog.vue @@ -1,46 +1,58 @@ @@ -50,25 +62,25 @@ export default { props: { title: { type: String, - default: '' + default: undefined, + required: true }, titleIcon: { type: String, - default: '' + default: undefined + }, + titleIconColor: { + type: String, + default: 'primary' }, opened: { type: Boolean, default: false } }, - data () { - return { - - } - }, watch: { opened (opened) { - if (opened) { + if (opened === true) { this.open() } else { this.close() @@ -82,12 +94,20 @@ export default { }, methods: { open () { - this.$refs.modal.show() + this.show() + }, + show () { + this.$refs.dialog.show() + this.$emit('show') }, close () { - this.$refs.modal.hide() + this.hide() this.$emit('close') }, + hide () { + this.$refs.dialog.hide() + this.$emit('hide') + }, cancel () { this.close() this.$emit('cancel') @@ -95,24 +115,3 @@ export default { } } - - diff --git a/src/components/CscDialogBase.vue b/src/components/CscDialogBase.vue deleted file mode 100644 index e982dbee..00000000 --- a/src/components/CscDialogBase.vue +++ /dev/null @@ -1,91 +0,0 @@ - - - diff --git a/src/components/CscDialogChangePassword.vue b/src/components/CscDialogChangePassword.vue index c8cb2a4f..c2d84928 100644 --- a/src/components/CscDialogChangePassword.vue +++ b/src/components/CscDialogChangePassword.vue @@ -1,18 +1,21 @@