webapp: avoid undefined serial for InputSerial

if variables are set with 'const foo = {} as Inverter', then
'foo.serial' will be undefined, causing warnings and errors
when using InputSerial.
This commit is contained in:
Bernhard Kirchen 2024-12-01 18:05:57 +01:00 committed by Thomas Basler
parent b2dcac549c
commit 1c5a3cf6fe

View File

@ -383,8 +383,8 @@ export default defineComponent({
return {
modal: {} as bootstrap.Modal,
modalDelete: {} as bootstrap.Modal,
newInverterData: {} as Inverter,
selectedInverterData: {} as Inverter,
newInverterData: { serial: '' } as Inverter,
selectedInverterData: { serial: '' } as Inverter,
inverters: [] as Inverter[],
dataLoading: true,
alert: {} as AlertResponse,
@ -440,7 +440,7 @@ export default defineComponent({
},
onSubmit() {
this.callInverterApiEndpoint('add', JSON.stringify(this.newInverterData));
this.newInverterData = {} as Inverter;
this.newInverterData = { serial: '' } as Inverter;
},
onDelete() {
this.callInverterApiEndpoint('del', JSON.stringify({ id: this.selectedInverterData.id }));