@@ -120,20 +120,36 @@ limitations under the License.
120
120
/>
121
121
</q-card-actions >
122
122
</q-card >
123
+ <q-dialog v-model =" showWarningDialog" persistent >
124
+ <zcl-warning-dialog
125
+ title =" Do you want to proceed?"
126
+ message =" ZCL device type is being modified which can cause all the configuration on the endpoint to be cleared and re-adjusted."
127
+ cancel-label =" No"
128
+ ok-label =" Yes"
129
+ @ok ="
130
+ () => {
131
+ warningDialogReturnValue = 'ok'
132
+ saveOrCreateHandler()
133
+ }
134
+ "
135
+ />
136
+ </q-dialog >
123
137
</div >
124
138
</template >
125
139
126
140
<script >
127
141
import * as RestApi from ' ../../src-shared/rest-api'
128
142
import * as DbEnum from ' ../../src-shared/db-enum'
129
143
import CommonMixin from ' ../util/common-mixin'
144
+ import ZclWarningDialog from ' ./ZclWarningDialog.vue'
130
145
const _ = require (' lodash' )
131
146
132
147
export default {
133
148
name: ' ZclCreateModifyEndpoint' ,
134
149
props: [' endpointReference' ],
135
150
emits: [' saveOrCreateValidated' , ' updateData' ],
136
151
mixins: [CommonMixin],
152
+ components: { ZclWarningDialog },
137
153
watch: {
138
154
deviceTypeRefAndDeviceIdPair (val ) {
139
155
this .setDeviceTypeCallback (val)
@@ -175,6 +191,7 @@ export default {
175
191
176
192
// Set device types only in edit mode
177
193
this .deviceTypeTmp = deviceTypes
194
+ this .deviceTypeMountSnapshot = JSON .parse (JSON .stringify (deviceTypes))
178
195
this .primaryDeviceTypeTmp = deviceTypes[0 ] ?? null // First item is the primary device type
179
196
} else {
180
197
this .shownEndpoint .endpointIdentifier = this .getSmallestUnusedEndpointId ()
@@ -198,8 +215,11 @@ export default {
198
215
saveOrCreateCloseFlag: false ,
199
216
deviceTypeTmp: [], // Temp store for the selected device types
200
217
primaryDeviceTypeTmp: null , // Temp store for the selected primary device type
201
- enableMultipleDevice: false , // TODO make it data driven
202
- enablePrimaryDevice: false , // TODO make it data driven
218
+ enableMultipleDevice: false ,
219
+ enablePrimaryDevice: false ,
220
+ showWarningDialog: false ,
221
+ warningDialogReturnValue: null ,
222
+ deviceTypeMountSnapshot: null ,
203
223
}
204
224
},
205
225
computed: {
@@ -361,6 +381,21 @@ export default {
361
381
}
362
382
},
363
383
saveOrCreateHandler () {
384
+ // Check if warning dialog available for the given situation
385
+ if (
386
+ this .endpointReference &&
387
+ this .warningDialogReturnValue == null &&
388
+ this .deviceType ? .length > 1
389
+ ) {
390
+ // Check if warning dialog should be shown
391
+ let deviceTypeChanged = true
392
+ // this.deviceTypeMountSnapshot
393
+ if (deviceTypeChanged) {
394
+ this .showWarningDialog = true
395
+ return
396
+ }
397
+ }
398
+ this .warningDialogReturnValue = null
364
399
let profile = this .$store .state .zap .isProfileIdShown
365
400
? this .$refs .profile .validate ()
366
401
: true
0 commit comments