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