|
@@ -1,7 +1,7 @@
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import { useStore } from '@/store'
|
|
import { useStore } from '@/store'
|
|
const store = useStore()
|
|
const store = useStore()
|
|
-import { computed, shallowRef } from 'vue'
|
|
|
|
|
|
+import { ref, shallowRef, watch } from 'vue'
|
|
import VCollaps from './VCollaps.vue';
|
|
import VCollaps from './VCollaps.vue';
|
|
|
|
|
|
//see https://github.com/imguolao/monaco-vue#vite
|
|
//see https://github.com/imguolao/monaco-vue#vite
|
|
@@ -37,25 +37,23 @@ const MONACO_EDITOR_OPTIONS = {
|
|
formatOnType: true,
|
|
formatOnType: true,
|
|
formatOnPaste: true,
|
|
formatOnPaste: true,
|
|
}
|
|
}
|
|
-
|
|
|
|
const { selectedNode } = storeToRefs(store)
|
|
const { selectedNode } = storeToRefs(store)
|
|
|
|
+const code=ref("");
|
|
|
|
+let dirty=false;
|
|
|
|
|
|
-
|
|
|
|
-const code = computed(():string => {
|
|
|
|
- if(!selectedNode.value)
|
|
|
|
- return "";
|
|
|
|
- if(!selectedNode.value.nodeId.value)
|
|
|
|
- return "";
|
|
|
|
- const m=store.addressSpace?.mapping.get(selectedNode.value.nodeId.toString());
|
|
|
|
- if(m)
|
|
|
|
- return m.read;
|
|
|
|
- return "";
|
|
|
|
|
|
+watch(selectedNode, () => {
|
|
|
|
+ if (!selectedNode.value)
|
|
|
|
+ return;
|
|
|
|
+ if (!selectedNode.value.nodeId.value)
|
|
|
|
+ return;
|
|
|
|
+ const m = store.addressSpace?.mapping.get(selectedNode.value.nodeId.toString());
|
|
|
|
+ code.value = m?.read || "";
|
|
|
|
+ dirty=false;
|
|
});
|
|
});
|
|
|
|
|
|
const editorRef = shallowRef()
|
|
const editorRef = shallowRef()
|
|
const handleMount = (editor: any) => {
|
|
const handleMount = (editor: any) => {
|
|
- editorRef.value = editor
|
|
|
|
-
|
|
|
|
|
|
+ editorRef.value = editor;
|
|
}
|
|
}
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -64,17 +62,26 @@ const onChange = (value: string | undefined, event: monaco.editor.IModelContentC
|
|
return;
|
|
return;
|
|
if(!value)
|
|
if(!value)
|
|
return;
|
|
return;
|
|
- store.addressSpace?.mapping.set(store.selectedNode.nodeId.value.toString(), {path: store.selectedNode.nodeId.toString(), read: value, write: ""} as IMappingValue)
|
|
|
|
|
|
+ code.value=value;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function formChanged(){
|
|
|
|
+ dirty=true;
|
|
}
|
|
}
|
|
|
|
|
|
function okPressed() {
|
|
function okPressed() {
|
|
- console.log('TODO: Handle OK Button');
|
|
|
|
|
|
+ if(!dirty)
|
|
|
|
+ return;
|
|
|
|
+ if(!selectedNode.value)
|
|
|
|
+ return;
|
|
|
|
+ store.addressSpace?.mapping.set(selectedNode.value.nodeId.toString(), {path: selectedNode.value.nodeId.toString(), read: code.value, write: ""} as IMappingValue)
|
|
|
|
+ dirty=false;
|
|
}
|
|
}
|
|
defineExpose({ okPressed })
|
|
defineExpose({ okPressed })
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
- <VCollaps :selected=false name="Mapping">
|
|
|
|
|
|
+ <VCollaps :selected=false name="Mapping" @change="formChanged()">
|
|
<div class="card-text" v-if="selectedNode">
|
|
<div class="card-text" v-if="selectedNode">
|
|
<vue-monaco-editor
|
|
<vue-monaco-editor
|
|
v-model:value="code"
|
|
v-model:value="code"
|