summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/ConfiguratorModuleConfig.vue
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/src/components/ConfiguratorModuleConfig.vue')
-rw-r--r--webapp/src/components/ConfiguratorModuleConfig.vue37
1 files changed, 32 insertions, 5 deletions
diff --git a/webapp/src/components/ConfiguratorModuleConfig.vue b/webapp/src/components/ConfiguratorModuleConfig.vue
index 5253086..b8bb793 100644
--- a/webapp/src/components/ConfiguratorModuleConfig.vue
+++ b/webapp/src/components/ConfiguratorModuleConfig.vue
@@ -53,7 +53,10 @@
</v-flex>
</v-layout>
<v-textarea prepend-icon="description" rows="1" :label="$t('description')" color="primary" v-model="description"></v-textarea>
- <v-textarea v-if="expertMode" prepend-icon="code" rows="20" :label="$t('script')" color="primary" v-model="script"></v-textarea>
+ <div v-if="expertMode">
+ <div class="body-1 script-heading"><v-icon>code</v-icon><span>{{ $t('script') }}</span></div>
+ <codemirror class="script-editor" ref="editor" v-model="script"></codemirror>
+ </div>
<div v-else class="text-xs-right">
<v-subheader>{{ $t('entries') }}</v-subheader>
<v-list>
@@ -113,7 +116,11 @@ export default {
timeout: '',
script: '',
expertMode: false,
- items: []
+ items: [],
+ interval: {
+ id: null,
+ counter: 0
+ }
}
},
computed: {
@@ -129,11 +136,11 @@ export default {
deep: true,
async handler (value) {
if (value.type === 'config' && value.show) {
- this.name = value.info.name
- this.description = value.info.description
+ this.name = value.info.name || ''
+ this.description = value.info.description || ''
this.defaultEntry = value.info.defaultEntry
this.timeout = value.info.timeout
- this.script = value.info.script
+ this.script = value.info.script || ''
if (this.script) this.expertMode = true
else this.expertMode = false
this.items = []
@@ -143,6 +150,8 @@ export default {
customName: x.config_x_entry.customName,
keyBind: x.config_x_entry.keyBind
}))
+ this.interval.id = setInterval(this.refreshEditor, 50)
+ this.interval.counter = 0
}
}
}
@@ -172,6 +181,11 @@ export default {
})
this.$store.dispatch('configurator/loadData')
this.setDialog({ show: false })
+ },
+ refreshEditor () {
+ this.interval.counter++
+ if (this.$refs.editor) this.$refs.editor.codemirror.refresh()
+ if (this.interval.counter >= 15) clearInterval(this.interval.id)
}
}
}
@@ -191,4 +205,17 @@ export default {
margin-left: 20px;
margin-right: 20px;
}
+
+.script-heading {
+ display: flex;
+ align-items: center;
+}
+
+.script-heading > span {
+ margin-left: 9px;
+}
+
+.script-editor {
+ margin-top: 8px;
+}
</style>