Update plot-indicator to properly work on v3

This commit is contained in:
Matthias 2022-11-18 16:10:44 +01:00
parent 847c0be579
commit 86dcd212e1

View File

@ -92,11 +92,11 @@ export default defineComponent({
Reset, Reset,
}, },
props: { props: {
value: { required: true, type: Object as () => Record<string, IndicatorConfig> }, modelValue: { required: true, type: Object as () => Record<string, IndicatorConfig> },
columns: { required: true, type: Array as () => string[] }, columns: { required: true, type: Array as () => string[] },
addNew: { required: true, type: Boolean }, addNew: { required: true, type: Boolean },
}, },
emits: ['input'], emits: ['update:modelValue'],
setup(props, { emit }) { setup(props, { emit }) {
const selColor = ref(randomColor()); const selColor = ref(randomColor());
const graphType = ref<ChartType>(ChartType.line); const graphType = ref<ChartType>(ChartType.line);
@ -127,7 +127,7 @@ export default defineComponent({
}; };
}); });
const emitIndicator = () => { const emitIndicator = () => {
emit('input', combinedIndicator.value); emit('update:modelValue', combinedIndicator.value);
}; };
const clickCancel = () => { const clickCancel = () => {
@ -136,13 +136,13 @@ export default defineComponent({
}; };
watch( watch(
() => props.value, () => props.modelValue,
() => { () => {
[selAvailableIndicator.value] = Object.keys(props.value); [selAvailableIndicator.value] = Object.keys(props.modelValue);
cancelled.value = false; cancelled.value = false;
if (selAvailableIndicator.value && props.value) { if (selAvailableIndicator.value && props.modelValue) {
selColor.value = props.value[selAvailableIndicator.value].color || randomColor(); selColor.value = props.modelValue[selAvailableIndicator.value].color || randomColor();
graphType.value = props.value[selAvailableIndicator.value].type || ChartType.line; graphType.value = props.modelValue[selAvailableIndicator.value].type || ChartType.line;
} }
}, },
); );