Shared Data in Widget Component and Widget Config Component

This commit is contained in:
cgfhtw
2024-07-31 13:13:16 +02:00
parent c2be0a4790
commit cf440ffb43
2 changed files with 16 additions and 5 deletions
+4 -3
View File
@@ -12,7 +12,8 @@ export default {
widget: null,
tmpConfig: {},
isLoading: false,
hasConfig: true
hasConfig: true,
sharedData: null
}),
emits: [
"change",
@@ -120,7 +121,7 @@ export default {
</div>
</div>
<div v-if="ready" class="card-body overflow-hidden">
<component :is="component" :config="arguments" :width="width" :height="height" @setConfig="setConfig" @change="changeConfigManually"></component>
<component :is="component" v-model:shared-data="sharedData" :config="arguments" :width="width" :height="height" @setConfig="setConfig" @change="changeConfigManually"></component>
</div>
<div v-else class="card-body overflow-hidden text-center d-flex flex-column justify-content-center"><i class="fa-solid fa-spinner fa-pulse fa-3x"></i></div>
<bs-modal ref="config">
@@ -128,7 +129,7 @@ export default {
{{ widget ? 'Config for ' + widget.setup.name : '' }}
</template>
<template v-slot:default>
<component v-if="ready && !isLoading" :is="component" :config="tmpConfig" @change="changeConfig" :configMode="true"></component>
<component v-if="ready && !isLoading" :is="component" v-model:shared-data="sharedData" :config="tmpConfig" @change="changeConfig" :configMode="true"></component>
<div v-else class="text-center"><i class="fa-solid fa-spinner fa-pulse fa-3x"></i></div>
</template>
<template v-if="widgetHasFooter" v-slot:footer>
@@ -3,17 +3,27 @@ export default {
"config",
"width",
"height",
"configMode"
"configMode",
"sharedData"
],
emits: [
"setConfig",
"change" // TODO(chris): do we need this?
"change", // TODO(chris): do we need this?
"update:sharedData"
],
computed: {
apiurl() {
const app_root = FHC_JS_DATA_STORAGE_OBJECT.app_root;
const ci_router = FHC_JS_DATA_STORAGE_OBJECT.ci_router;
return app_root + ci_router;
},
shared: {
get() {
return this.sharedData;
},
set(value) {
this.$emit('update:sharedData', value);
}
}
},
methods: {