Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inability to change the text of a Label input widget #1556

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/InputElementConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
</template>
</ExpansiblePanel>
<ExpansiblePanel
v-if="currentElement"
v-if="currentElement && currentElement.options.variableType"
:key="currentElement.hash"
no-bottom-divider
no-top-divider
Expand Down
26 changes: 4 additions & 22 deletions src/components/custom-widget-elements/Label.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
margin: '1px',
}"
>
{{ miniWidget.options.text || 'Label' }}
{{ miniWidget.options.layout?.text || 'Label' }}
</div>
</div>
</template>

<script setup lang="ts">
import { onMounted, onUnmounted, toRefs, watch } from 'vue'
import { onMounted, toRefs, watch } from 'vue'

import { deleteDataLakeVariable, listenDataLakeVariable, unlistenDataLakeVariable } from '@/libs/actions/data-lake'
import { useWidgetManagerStore } from '@/stores/widgetManager'
import { CustomWidgetElementOptions, CustomWidgetElementType } from '@/types/widgets'

Expand All @@ -41,7 +40,6 @@ const props = defineProps<{
}>()

const miniWidget = toRefs(props).miniWidget
let listenerId: string | undefined

watch(
() => widgetStore.miniWidgetManagerVars(miniWidget.value.hash).configMenuOpen,
Expand All @@ -60,33 +58,17 @@ onMounted(() => {
if (!props.miniWidget.options || Object.keys(props.miniWidget.options).length === 0) {
miniWidget.value.isCustomElement = true
widgetStore.updateElementOptions(props.miniWidget.hash, {
text: 'Label',
layout: {
text: 'Label',
textSize: 20,
weight: 'normal',
decoration: 'none',
color: '#FFFFFF',
align: 'center',
},
variableType: 'string',
dataLakeVariable: undefined,
variableType: null,
})
}
if (props.miniWidget.options.dataLakeVariable) {
listenerId = listenDataLakeVariable(props.miniWidget.options.dataLakeVariable?.name, (value) => {
miniWidget.value.options.text = value as string
})
miniWidget.value.options.text = widgetStore.getMiniWidgetLastValue(miniWidget.value.hash) as string
}
})

onUnmounted(() => {
if (miniWidget.value.options.dataLakeVariable) {
deleteDataLakeVariable(miniWidget.value.options.dataLakeVariable.id)
if (listenerId) {
unlistenDataLakeVariable(miniWidget.value.options.dataLakeVariable.name, listenerId)
}
}
})
</script>

Expand Down
22 changes: 11 additions & 11 deletions src/types/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,19 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable | null
/**
* Action parameter
*/
dataLakeVariable: DataLakeVariable
/**
* The label text
*/
text: string
/**
* Layout options
*/
layout: {
/**
* The label text
*/
text: string
/**
* The size of the label's font (in pixels)
*/
Expand Down Expand Up @@ -245,7 +245,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down Expand Up @@ -304,7 +304,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down Expand Up @@ -351,7 +351,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down Expand Up @@ -414,7 +414,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down Expand Up @@ -465,7 +465,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down Expand Up @@ -532,7 +532,7 @@ export type CustomWidgetElementOptions = {
/**
* Variable type
*/
variableType: 'string' | 'boolean' | 'number'
variableType: DataLakeVariable['type'] | null
/**
* Action parameter
*/
Expand Down
Loading