From f77cbf0e731d8a605cfc42c543e2881ef0378f19 Mon Sep 17 00:00:00 2001 From: tajniak81 <13187254+tajniak81@users.noreply.github.com> Date: Fri, 17 Jul 2026 12:53:33 +0200 Subject: [PATCH] Add LPG bi-fuel and hydrogen fuel types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add petrol_lpg, diesel_lpg and hydrogen to the fuel_type choices, across the six places that define them: the PocketBase schema, the car form and detail view in both the Web App and the Phone App, and the two doc comments that enumerate the values. The Go API needed no change — it passes fuel_type through as a free string, so PocketBase is the only validator. Model the LPG conversions as their own choices rather than a separate "has LPG" flag: the car runs on either tank, so "petrol + LPG" is what an owner picks it out as. Order each variant next to its base fuel so the dropdowns read naturally. Purely additive — existing rows keep their values and need no migration. The live PocketBase schema does still need scripts/setup-pocketbase.mjs re-run before the new choices will save, since its select field allows only the old four; the script reconciles select values on existing fields, so re-running migrates it in place. Co-Authored-By: Claude Opus 4.8 --- API Server/internal/models/models.go | 2 +- API Server/scripts/setup-pocketbase.mjs | 12 +++++++++++- Phone App/lib/models.dart | 2 +- Phone App/lib/screens/car_detail_screen.dart | 3 +++ Phone App/lib/screens/car_form_sheet.dart | 3 +++ Web App/web/src/components/CarFormModal.vue | 3 +++ Web App/web/src/views/CarDetail.vue | 3 +++ 7 files changed, 25 insertions(+), 3 deletions(-) diff --git a/API Server/internal/models/models.go b/API Server/internal/models/models.go index 00b7b02..e9c8eb2 100644 --- a/API Server/internal/models/models.go +++ b/API Server/internal/models/models.go @@ -54,7 +54,7 @@ type Car struct { BrakeFluidSpec string `json:"brakeFluidSpec"` // e.g. "DOT 4" CoolantSpec string `json:"coolantSpec"` // e.g. "Toyota Super Long Life Coolant" - FuelType string `json:"fuelType"` // petrol | diesel | hybrid | electric + FuelType string `json:"fuelType"` // petrol | petrol_lpg | diesel | diesel_lpg | hybrid | electric | hydrogen BuildDate string `json:"buildDate"` // ISO YYYY-MM-DD (date-only) FirstRegistrationDate string `json:"firstRegistrationDate"` // ISO YYYY-MM-DD (date-only) diff --git a/API Server/scripts/setup-pocketbase.mjs b/API Server/scripts/setup-pocketbase.mjs index 791049a..c3b212a 100644 --- a/API Server/scripts/setup-pocketbase.mjs +++ b/API Server/scripts/setup-pocketbase.mjs @@ -245,7 +245,17 @@ const DESIRED = { F.text("brake_fluid_spec"), F.text("coolant_spec"), F.number("current_km"), - F.select("fuel_type", ["petrol", "diesel", "hybrid", "electric"]), + // Bi-fuel LPG conversions are their own choice rather than a flag: the car + // runs on either tank, so "petrol + LPG" is what an owner picks it out as. + F.select("fuel_type", [ + "petrol", + "petrol_lpg", + "diesel", + "diesel_lpg", + "hybrid", + "electric", + "hydrogen", + ]), F.text("build_date"), // ISO YYYY-MM-DD (date-only; VIN 10th digit ≈ model year) F.text("first_registration_date"), // ISO YYYY-MM-DD // Owner of this car. Non-cascading on purpose: deleting a user must not diff --git a/Phone App/lib/models.dart b/Phone App/lib/models.dart index 5738f41..165ae17 100644 --- a/Phone App/lib/models.dart +++ b/Phone App/lib/models.dart @@ -18,7 +18,7 @@ class Car { final String differentialOilSpec; final String brakeFluidSpec; final String coolantSpec; - final String fuelType; // petrol | diesel | hybrid | electric + final String fuelType; // petrol | petrol_lpg | diesel | diesel_lpg | hybrid | electric | hydrogen final String buildDate; // ISO YYYY-MM-DD (date-only) final String firstRegistrationDate; // ISO YYYY-MM-DD (date-only) final int serviceIntervalDays; diff --git a/Phone App/lib/screens/car_detail_screen.dart b/Phone App/lib/screens/car_detail_screen.dart index 93f3068..84c355c 100644 --- a/Phone App/lib/screens/car_detail_screen.dart +++ b/Phone App/lib/screens/car_detail_screen.dart @@ -456,9 +456,12 @@ class _InfoTab extends StatelessWidget { static const Map _fuelLabels = { "petrol": "Petrol (gasoline)", + "petrol_lpg": "Petrol (gasoline) + LPG", "diesel": "Diesel", + "diesel_lpg": "Diesel + LPG", "hybrid": "Hybrid", "electric": "Electric", + "hydrogen": "Hydrogen", }; static String _fuelLabel(String v) => _fuelLabels[v] ?? "—"; diff --git a/Phone App/lib/screens/car_form_sheet.dart b/Phone App/lib/screens/car_form_sheet.dart index 19d4041..7058855 100644 --- a/Phone App/lib/screens/car_form_sheet.dart +++ b/Phone App/lib/screens/car_form_sheet.dart @@ -198,9 +198,12 @@ class _CarFormSheetState extends State { labelText: "Fuel type", border: OutlineInputBorder(), isDense: true), items: const [ DropdownMenuItem(value: "petrol", child: Text("Petrol (gasoline)")), + DropdownMenuItem(value: "petrol_lpg", child: Text("Petrol (gasoline) + LPG")), DropdownMenuItem(value: "diesel", child: Text("Diesel")), + DropdownMenuItem(value: "diesel_lpg", child: Text("Diesel + LPG")), DropdownMenuItem(value: "hybrid", child: Text("Hybrid")), DropdownMenuItem(value: "electric", child: Text("Electric")), + DropdownMenuItem(value: "hydrogen", child: Text("Hydrogen")), ], onChanged: (v) => setState(() => _fuelType = v ?? ""), ), diff --git a/Web App/web/src/components/CarFormModal.vue b/Web App/web/src/components/CarFormModal.vue index 229016c..c34b40c 100644 --- a/Web App/web/src/components/CarFormModal.vue +++ b/Web App/web/src/components/CarFormModal.vue @@ -110,9 +110,12 @@ async function submit() {
diff --git a/Web App/web/src/views/CarDetail.vue b/Web App/web/src/views/CarDetail.vue index 1e9f9fa..da2a304 100644 --- a/Web App/web/src/views/CarDetail.vue +++ b/Web App/web/src/views/CarDetail.vue @@ -390,9 +390,12 @@ function yn(v) { const FUEL_LABELS = { petrol: "Petrol (gasoline)", + petrol_lpg: "Petrol (gasoline) + LPG", diesel: "Diesel", + diesel_lpg: "Diesel + LPG", hybrid: "Hybrid", electric: "Electric", + hydrogen: "Hydrogen", }; function fuelLabel(v) { return FUEL_LABELS[v] || "—";