feat: loading data from clipboard; error detection

This commit is contained in:
2025-03-07 14:04:58 +01:00
parent c9459eb8f4
commit ff6622bc29
12 changed files with 147 additions and 65 deletions
+11 -1
View File
@@ -53,6 +53,7 @@ export default defineComponent({
loadStockFromString(stockString: string) {
const stockArray = stockString.trim().split(';');
let failureCount = 0;
this.store.stockList.length = 0;
this.store.chosenVehicle = null;
@@ -85,10 +86,19 @@ export default defineComponent({
if (cargo) vehicleCargo = vehicle?.cargoTypes.find((c) => c.id == cargo) || null;
}
if (!vehicle) console.warn('Brak pojazdu / rodzaj pojazdu źle wczytany:', type);
if (!vehicle && type) {
failureCount++;
console.warn(`Wystąpił błąd - nie wczytano pojazdu o nazwie: ${type}`);
return;
}
this.addVehicle(vehicle, vehicleCargo);
});
if (failureCount != 0 && failureCount == stockArray.length) {
console.warn('Wystąpił błąd - niepoprawny format');
throw 'stock-loading-error';
}
},
},
});