From dc17ef0ad09b36a03f73bac8ce7e15af690860be Mon Sep 17 00:00:00 2001 From: Gergely Kiss Date: Fri, 2 Jun 2023 18:20:36 +0200 Subject: [PATCH] Add multi device type modification warning dialog --- src/components/ZclCreateModifyEndpoint.vue | 39 +++++++++++++++- src/components/ZclWarningDialog.vue | 52 ++++++++++++++++++++++ 2 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 src/components/ZclWarningDialog.vue diff --git a/src/components/ZclCreateModifyEndpoint.vue b/src/components/ZclCreateModifyEndpoint.vue index 227e8eac96..5818e9cd25 100644 --- a/src/components/ZclCreateModifyEndpoint.vue +++ b/src/components/ZclCreateModifyEndpoint.vue @@ -120,6 +120,20 @@ limitations under the License. /> + + + @@ -127,6 +141,7 @@ limitations under the License. import * as RestApi from '../../src-shared/rest-api' import * as DbEnum from '../../src-shared/db-enum' import CommonMixin from '../util/common-mixin' +import ZclWarningDialog from './ZclWarningDialog.vue' const _ = require('lodash') export default { @@ -134,6 +149,7 @@ export default { props: ['endpointReference'], emits: ['saveOrCreateValidated', 'updateData'], mixins: [CommonMixin], + components: { ZclWarningDialog }, watch: { deviceTypeRefAndDeviceIdPair(val) { this.setDeviceTypeCallback(val) @@ -175,6 +191,7 @@ export default { // Set device types only in edit mode this.deviceTypeTmp = deviceTypes + this.deviceTypeMountSnapshot = JSON.parse(JSON.stringify(deviceTypes)) this.primaryDeviceTypeTmp = deviceTypes[0] ?? null // First item is the primary device type } else { this.shownEndpoint.endpointIdentifier = this.getSmallestUnusedEndpointId() @@ -198,8 +215,11 @@ export default { saveOrCreateCloseFlag: false, deviceTypeTmp: [], // Temp store for the selected device types primaryDeviceTypeTmp: null, // Temp store for the selected primary device type - enableMultipleDevice: false, // TODO make it data driven - enablePrimaryDevice: false, // TODO make it data driven + enableMultipleDevice: false, + enablePrimaryDevice: false, + showWarningDialog: false, + warningDialogReturnValue: null, + deviceTypeMountSnapshot: null, } }, computed: { @@ -361,6 +381,21 @@ export default { } }, saveOrCreateHandler() { + // Check if warning dialog available for the given situation + if ( + this.endpointReference && + this.warningDialogReturnValue == null && + this.deviceType?.length > 1 + ) { + // Check if warning dialog should be shown + let deviceTypeChanged = true + // this.deviceTypeMountSnapshot + if (deviceTypeChanged) { + this.showWarningDialog = true + return + } + } + this.warningDialogReturnValue = null let profile = this.$store.state.zap.isProfileIdShown ? this.$refs.profile.validate() : true diff --git a/src/components/ZclWarningDialog.vue b/src/components/ZclWarningDialog.vue new file mode 100644 index 0000000000..d7038a131e --- /dev/null +++ b/src/components/ZclWarningDialog.vue @@ -0,0 +1,52 @@ + + +