From 36a16641a8efe13d8c7df438a91eb6dd42e9b980 Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Tue, 19 Sep 2023 12:05:47 +0200 Subject: [PATCH] #2638 fixed remove one data point from context script in meta data point - Added while() which checks if the specified id has already occurred and provides a new one. - Changed removeDatapoint() function, now it checks for key of datapoint.pointLocator.context when deleting context points --- .../components/datasources/MetaDataSource/point.vue | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index fc2077d6fa..fd6109820f 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -309,7 +309,7 @@ mdi-close @@ -476,14 +476,21 @@ export default { }, methods: { - removeDatapoint(dataPointXid) { + removeDatapoint(key) { this.datapoint.pointLocator.context = this.datapoint.pointLocator.context.filter( - (p) => p.dataPointXid != dataPointXid, + (p) => p.key !== key, ); }, addDatapoint() { const p = this.datapoints.find((x) => x.id === this.selectedDatapointId); if (!this.datapoint.pointLocator.context.find((x) => p.xid === x.dataPointXid)) { + if (this.datapoint.pointLocator.context.find((x) => p.id === x.key)) { + let newId = p.id; + while (this.datapoint.pointLocator.context.find((x) => newId === x.key)) { + newId++; + } + p.id = newId; + } this.datapoint.pointLocator.context.push({ key: p.id, value: `p${p.id}`,