Skip to content

Commit d443649

Browse files
committed
Input-widgets: Label: Flag component as 'no variable element'
Signed-off-by: Arturo Manzoli <[email protected]>
1 parent fdeecb2 commit d443649

File tree

3 files changed

+16
-34
lines changed

3 files changed

+16
-34
lines changed

src/components/InputElementConfig.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
</template>
232232
</ExpansiblePanel>
233233
<ExpansiblePanel
234-
v-if="currentElement"
234+
v-if="currentElement && currentElement.options.variableType"
235235
:key="currentElement.hash"
236236
no-bottom-divider
237237
no-top-divider

src/components/custom-widget-elements/Label.vue

+4-22
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
margin: '1px',
2020
}"
2121
>
22-
{{ miniWidget.options.text || 'Label' }}
22+
{{ miniWidget.options.layout?.text || 'Label' }}
2323
</div>
2424
</div>
2525
</template>
2626

2727
<script setup lang="ts">
28-
import { onMounted, onUnmounted, toRefs, watch } from 'vue'
28+
import { onMounted, toRefs, watch } from 'vue'
2929
30-
import { deleteDataLakeVariable, listenDataLakeVariable, unlistenDataLakeVariable } from '@/libs/actions/data-lake'
3130
import { useWidgetManagerStore } from '@/stores/widgetManager'
3231
import { CustomWidgetElementOptions, CustomWidgetElementType } from '@/types/widgets'
3332
@@ -41,7 +40,6 @@ const props = defineProps<{
4140
}>()
4241
4342
const miniWidget = toRefs(props).miniWidget
44-
let listenerId: string | undefined
4543
4644
watch(
4745
() => widgetStore.miniWidgetManagerVars(miniWidget.value.hash).configMenuOpen,
@@ -60,33 +58,17 @@ onMounted(() => {
6058
if (!props.miniWidget.options || Object.keys(props.miniWidget.options).length === 0) {
6159
miniWidget.value.isCustomElement = true
6260
widgetStore.updateElementOptions(props.miniWidget.hash, {
63-
text: 'Label',
6461
layout: {
62+
text: 'Label',
6563
textSize: 20,
6664
weight: 'normal',
6765
decoration: 'none',
6866
color: '#FFFFFF',
6967
align: 'center',
7068
},
71-
variableType: 'string',
72-
dataLakeVariable: undefined,
69+
variableType: null,
7370
})
7471
}
75-
if (props.miniWidget.options.dataLakeVariable) {
76-
listenerId = listenDataLakeVariable(props.miniWidget.options.dataLakeVariable?.name, (value) => {
77-
miniWidget.value.options.text = value as string
78-
})
79-
miniWidget.value.options.text = widgetStore.getMiniWidgetLastValue(miniWidget.value.hash) as string
80-
}
81-
})
82-
83-
onUnmounted(() => {
84-
if (miniWidget.value.options.dataLakeVariable) {
85-
deleteDataLakeVariable(miniWidget.value.options.dataLakeVariable.id)
86-
if (listenerId) {
87-
unlistenDataLakeVariable(miniWidget.value.options.dataLakeVariable.name, listenerId)
88-
}
89-
}
9072
})
9173
</script>
9274

src/types/widgets.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,19 @@ export type CustomWidgetElementOptions = {
186186
/**
187187
* Variable type
188188
*/
189-
variableType: 'string' | 'boolean' | 'number'
189+
variableType: DataLakeVariable | null
190190
/**
191191
* Action parameter
192192
*/
193193
dataLakeVariable: DataLakeVariable
194-
/**
195-
* The label text
196-
*/
197-
text: string
198194
/**
199195
* Layout options
200196
*/
201197
layout: {
198+
/**
199+
* The label text
200+
*/
201+
text: string
202202
/**
203203
* The size of the label's font (in pixels)
204204
*/
@@ -245,7 +245,7 @@ export type CustomWidgetElementOptions = {
245245
/**
246246
* Variable type
247247
*/
248-
variableType: 'string' | 'boolean' | 'number'
248+
variableType: DataLakeVariable['type'] | null
249249
/**
250250
* Action parameter
251251
*/
@@ -304,7 +304,7 @@ export type CustomWidgetElementOptions = {
304304
/**
305305
* Variable type
306306
*/
307-
variableType: 'string' | 'boolean' | 'number'
307+
variableType: DataLakeVariable['type'] | null
308308
/**
309309
* Action parameter
310310
*/
@@ -351,7 +351,7 @@ export type CustomWidgetElementOptions = {
351351
/**
352352
* Variable type
353353
*/
354-
variableType: 'string' | 'boolean' | 'number'
354+
variableType: DataLakeVariable['type'] | null
355355
/**
356356
* Action parameter
357357
*/
@@ -414,7 +414,7 @@ export type CustomWidgetElementOptions = {
414414
/**
415415
* Variable type
416416
*/
417-
variableType: 'string' | 'boolean' | 'number'
417+
variableType: DataLakeVariable['type'] | null
418418
/**
419419
* Action parameter
420420
*/
@@ -465,7 +465,7 @@ export type CustomWidgetElementOptions = {
465465
/**
466466
* Variable type
467467
*/
468-
variableType: 'string' | 'boolean' | 'number'
468+
variableType: DataLakeVariable['type'] | null
469469
/**
470470
* Action parameter
471471
*/
@@ -532,7 +532,7 @@ export type CustomWidgetElementOptions = {
532532
/**
533533
* Variable type
534534
*/
535-
variableType: 'string' | 'boolean' | 'number'
535+
variableType: DataLakeVariable['type'] | null
536536
/**
537537
* Action parameter
538538
*/

0 commit comments

Comments
 (0)