diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index d2f93d409b..7add6873d3 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -11,9 +11,9 @@ - + @@ -316,31 +316,31 @@ - - + + {{ $t('script.runScript') }} - - + + - Script results: {{this.resultMessage}} + Script results: {{ this.resultMessage }} - - - - Script error: {{this.resultMessage}} + + + + Script error: {{ this.resultMessage }} - + !!v || this.$t('validation.rule.notNull'), - ruleValidScript: () => this.validScript || this.resultMessage, + ruleValidScript: () => this.validScript || this.resultMessage, }; }, @@ -530,11 +530,12 @@ export default { this.$emit('canceled'); }, - save() { + async save() { console.debug('VirtualDataSource.point.vue::save()'); - if (this.validScript) - this.$emit('saved', this.datapoint); - }, + await this.validateScript(); + if (this.validScript) + this.$emit('saved', this.datapoint); + }, addMsValue(array) { array.push(this.multistateValue); @@ -555,24 +556,24 @@ export default { return; } }, - async validateScript() { - try { - if (this.datapoint.pointLocator.script === ""){ - this.validScript = false; - this.resultMessage = this.$t('validation.rule.notNull'); - } - else { - let resp = await this.$store.dispatch('requestPost', { - url: `/datapoint/meta/test`, - data: this.datapoint.pointLocator - }); - this.validScript = resp.success; - this.resultMessage = resp.message; - } - } catch (e) { - console.log('error:' + e); - } - }, + async validateScript() { + try { + if (this.datapoint.pointLocator.script === "") { + this.validScript = false; + this.resultMessage = this.$t('validation.rule.notNull'); + } else { + let resp = await this.$store.dispatch('requestPost', { + url: `/datapoint/meta/test`, + data: this.datapoint.pointLocator + }); + this.validScript = resp.success; + this.resultMessage = resp.message; + this.$refs.scriptBodyTextarea.validate(); + } + } catch (e) { + console.log('error:' + e); + } + }, }, };