Changed parts: the list is the car's, not the app's
The Changed parts section offered all three parts to every car. An EV changes no
oil, and a checkbox nobody will ever tick is one more thing to read past on every
service — so which parts a car records now belongs to the car, the same way its
tabs, its Information rows and its Service history columns already do.
It works the way those three do because a fourth mechanism for the same idea
would be a fourth to keep in step: hidden_service_parts on the car, validated by
the endpoint that already does this, stored as the hidden set so a part added in
a later release is on by default, and needing write access because the choice
belongs to the car and everyone it is shared with sees it.
There is no order beside it, which is the one place this departs from the other
three. Those arrange things whose position means something — a tab bar reads left
to right, a table's columns are read across. The parts are a checkbox list inside
a single column, and moving Cabin air filter above Oil says nothing. Adding one
later is the same shape as the others if that turns out to be wrong.
A part switched off leaves the form and the history together — the chips on the
phone's cards, the web column's summary and the panel it opens. "I don't record
this" means it stops taking up room, not that it takes up room saying nothing,
which is the rule a hidden column already follows. That is the judgment call
here: a car with five years of oil changes hides them all by switching the part
off. Nothing is written to the records, so switching it back on brings every one
of those chips back, which is what makes the call safe to reverse.
The part that would have been a silent data bug: the API rewrites all three
booleans from the body of a service update, so a form that simply stopped
sending a hidden part would set it false on the next edit of any old record.
Both forms therefore keep every part in their state and submit every one — only
the checkboxes are filtered. The mirror of that is a *new* record, where a hidden
part starts false rather than at its `initial`, since ticking a box nobody was
shown is not a default, it's a guess. Oil is the only part with initial: true, so
that case is live the moment anyone hides it.
Verified: go vet and go test ./... pass, with a new test covering that every part
is hideable (unlike the tabs and the columns — a service that changed nothing is
a real service), that the "parts" column key is refused as a part key and a part
key as a column key, and that no part is also a column. flutter analyze is clean
and flutter test passes 32 to 35, the new ones covering visibleParts, that a
hidden part's chips go while its stored boolean stays, and the picker's fourth
section. npm run build is clean.
Both apps were driven against throwaway stub APIs. Web: the picker saved
{"hiddenServiceParts":["oil"]}, the table's parts cell went from "Oil & Oil
filter +2" to "Engine air filter, Cabin air filter", the record whose only part
was oil went to an empty cell, the panel dropped to two rows, the add form
offered two unticked boxes where oil's initial: true would have ticked one, and
editing the three-part record sent changedOil:true back with a box that was never
on screen. Phone: the same car rendered chips "Engine air, Cabin air", "Changed
parts —" for the oil-only record, and an add sheet with exactly two unticked
boxes.
Not verified: no automated test guards the web behaviour — the web app still has
no test runner, so the above was read out of the live DOM and the outgoing
request bodies by hand. The phone's picker was checked by widget test and by
rendering, but its Save was not driven end to end. Neither app was run against
the real API Server: bootstrap appends the new field on the next start, and until
that start a client sending hiddenServiceParts takes a 400 — they deploy together
from this repo, but the server must go first.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
7718b32013
commit
35e6c511b7
@@ -194,9 +194,10 @@ POST /api/vehicle-providers/{provider}/import
|
||||
# which PATCH /api/me {carOrder} sets)
|
||||
GET /api/cars POST /api/cars
|
||||
GET /api/cars/{id} PATCH /api/cars/{id} DELETE /api/cars/{id}
|
||||
PUT /api/cars/{id}/view # which tabs, Information rows and service-history
|
||||
# columns this car shows, and the order of the tabs,
|
||||
# the rows, the columns and the provider readings
|
||||
PUT /api/cars/{id}/view # which tabs, Information rows, service-history
|
||||
# columns and service parts this car shows, and the
|
||||
# order of the tabs, the rows, the columns and the
|
||||
# provider readings
|
||||
GET /api/cars/{id}/provider POST /api/cars/{id}/provider
|
||||
POST /api/cars/{id}/provider/sync
|
||||
GET /api/cars/{id}/service-records GET /api/cars/{id}/technical-checks
|
||||
|
||||
@@ -295,6 +295,20 @@ var hideableServiceColumns = map[string]bool{
|
||||
"notes": true, "file": true,
|
||||
}
|
||||
|
||||
// hideableServiceParts are the parts a service record can say were changed, and
|
||||
// so the ones a car can take off its list: an EV changes no oil, and offering it
|
||||
// on every service form is a checkbox nobody there will ever tick. Keys mirror
|
||||
// SERVICE_PARTS in the web app's lib/serviceParts.js and kServiceParts in the
|
||||
// phone's service_parts.dart — one per boolean on the service_records
|
||||
// collection.
|
||||
//
|
||||
// Every part is hideable, unlike the tabs and the columns: there is no part the
|
||||
// form needs, because a service that changed nothing at all is a service with an
|
||||
// empty Changed parts section, which is a thing that happens.
|
||||
var hideableServiceParts = map[string]bool{
|
||||
"oil": true, "engineFilter": true, "cabinFilter": true,
|
||||
}
|
||||
|
||||
// arrangeableServiceColumns are the columns that table can be rearranged into:
|
||||
// the hideable ones plus Date, which cannot be switched off but has no reason to
|
||||
// be stuck at the left. Derived from hideableServiceColumns so the two sets
|
||||
@@ -346,10 +360,11 @@ func normalizeKeys(in []string, allowed map[string]bool, what string) ([]string,
|
||||
}
|
||||
|
||||
// PUT /api/cars/{id}/view — choose what this car's page shows: which tabs, which
|
||||
// rows of the Information tab, which columns of the Service history table, and
|
||||
// the order the tabs, the Information rows, those columns and the connected
|
||||
// service's headline readings are laid out in. Body: {hiddenTabs?: [...],
|
||||
// hiddenFields?: [...], hiddenServiceColumns?: [...], tabOrder?: [...],
|
||||
// rows of the Information tab, which columns of the Service history table, which
|
||||
// parts its service form offers, and the order the tabs, the Information rows,
|
||||
// those columns and the connected service's headline readings are laid out in.
|
||||
// Body: {hiddenTabs?: [...], hiddenFields?: [...], hiddenServiceColumns?: [...],
|
||||
// hiddenServiceParts?: [...], tabOrder?: [...],
|
||||
// fieldOrder?: [...], serviceColumnOrder?: [...], metricOrder?: [...]}; only the
|
||||
// lists present are written, so a client can rearrange one group without
|
||||
// resending the others. Its own endpoint rather than fields on the car edit, so an ordinary
|
||||
@@ -361,6 +376,7 @@ func (s *Server) updateCarView(w http.ResponseWriter, r *http.Request) {
|
||||
HiddenTabs *[]string `json:"hiddenTabs"`
|
||||
HiddenFields *[]string `json:"hiddenFields"`
|
||||
HiddenServiceColumns *[]string `json:"hiddenServiceColumns"`
|
||||
HiddenServiceParts *[]string `json:"hiddenServiceParts"`
|
||||
TabOrder *[]string `json:"tabOrder"`
|
||||
FieldOrder *[]string `json:"fieldOrder"`
|
||||
ServiceColumnOrder *[]string `json:"serviceColumnOrder"`
|
||||
@@ -405,6 +421,14 @@ func (s *Server) updateCarView(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
payload["hidden_service_columns"] = columns
|
||||
}
|
||||
if in.HiddenServiceParts != nil {
|
||||
parts, err := normalizeKeys(*in.HiddenServiceParts, hideableServiceParts, "service part")
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
payload["hidden_service_parts"] = parts
|
||||
}
|
||||
if in.TabOrder != nil {
|
||||
// A wider set than the hidden tabs: Information is arrangeable although it
|
||||
// cannot be switched off. A partial list is accepted, and the tabs it
|
||||
|
||||
@@ -200,6 +200,49 @@ func TestNormalizeHiddenServiceColumns(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The parts a service can change hide against their own set — one key per
|
||||
// boolean on the service_records collection, and no order beside it, because
|
||||
// they are a checkbox list inside a single column.
|
||||
func TestNormalizeHiddenServiceParts(t *testing.T) {
|
||||
got, err := normalizeKeys([]string{" oil ", "cabinFilter", "oil", ""}, hideableServiceParts, "service part")
|
||||
if err != nil {
|
||||
t.Fatalf("normalizeKeys: %v", err)
|
||||
}
|
||||
assertKeys(t, got, []string{"oil", "cabinFilter"}) // trimmed, blanks dropped, deduped
|
||||
|
||||
// Every part is hideable, unlike the tabs and the columns: a service that
|
||||
// changed nothing is a real service, so there is no part the form must keep.
|
||||
for _, key := range []string{"oil", "engineFilter", "cabinFilter"} {
|
||||
if !hideableServiceParts[key] {
|
||||
t.Errorf("service part %q should be hideable", key)
|
||||
}
|
||||
}
|
||||
if len(hideableServiceParts) != 3 {
|
||||
t.Errorf("hideableServiceParts has %d entries, want the 3 booleans on a service record", len(hideableServiceParts))
|
||||
}
|
||||
|
||||
// "parts" is the column those three share; it is not one of them. Sending
|
||||
// the column key here would hide nothing and quietly succeed if the two sets
|
||||
// were not kept apart.
|
||||
if _, err := normalizeKeys([]string{"parts"}, hideableServiceParts, "service part"); err == nil {
|
||||
t.Error("normalizeKeys accepted the parts column as a part, want an error")
|
||||
}
|
||||
if _, err := normalizeKeys([]string{"notes"}, hideableServiceParts, "service part"); err == nil {
|
||||
t.Error("normalizeKeys accepted a column key as a service part, want an error")
|
||||
}
|
||||
if _, err := normalizeKeys([]string{"oil", "nonsense"}, hideableServiceParts, "service part"); err == nil {
|
||||
t.Error("normalizeKeys accepted an unknown service part, want an error")
|
||||
}
|
||||
|
||||
// And no part is a column, which is what keeps the table from widening as
|
||||
// parts are added.
|
||||
for key := range hideableServiceParts {
|
||||
if arrangeableServiceColumns[key] {
|
||||
t.Errorf("service part %q must not also be a column", key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The columns arrange against a wider set than they hide against, the way the
|
||||
// tabs do: the date cannot be switched off, but it can be moved off the left.
|
||||
func TestNormalizeServiceColumnOrder(t *testing.T) {
|
||||
|
||||
@@ -68,7 +68,8 @@ type carRecord struct {
|
||||
Created string `json:"created"`
|
||||
Updated string `json:"updated"`
|
||||
|
||||
// Switched-off tabs, Information fields and Service history columns, plus
|
||||
// Switched-off tabs, Information fields, Service history columns and service
|
||||
// parts, plus
|
||||
// the arrangements of the tabs, the Information rows, those columns and the
|
||||
// connected service's readings. Raw
|
||||
// because PocketBase hands back whatever a json field holds — null on a car
|
||||
@@ -76,6 +77,7 @@ type carRecord struct {
|
||||
HiddenTabs json.RawMessage `json:"hidden_tabs"`
|
||||
HiddenFields json.RawMessage `json:"hidden_fields"`
|
||||
HiddenServiceColumns json.RawMessage `json:"hidden_service_columns"`
|
||||
HiddenServiceParts json.RawMessage `json:"hidden_service_parts"`
|
||||
TabOrder json.RawMessage `json:"tab_order"`
|
||||
FieldOrder json.RawMessage `json:"field_order"`
|
||||
ServiceColumnOrder json.RawMessage `json:"service_column_order"`
|
||||
@@ -109,6 +111,7 @@ func (rec carRecord) toModel() models.Car {
|
||||
HiddenTabs: decodeStringList(rec.HiddenTabs),
|
||||
HiddenFields: decodeStringList(rec.HiddenFields),
|
||||
HiddenServiceColumns: decodeStringList(rec.HiddenServiceColumns),
|
||||
HiddenServiceParts: decodeStringList(rec.HiddenServiceParts),
|
||||
TabOrder: decodeStringList(rec.TabOrder),
|
||||
FieldOrder: decodeStringList(rec.FieldOrder),
|
||||
ServiceColumnOrder: decodeStringList(rec.ServiceColumnOrder),
|
||||
|
||||
@@ -52,6 +52,9 @@ var collectionsSchema = map[string][]fieldDef{
|
||||
// never records what was changed). Date is not hideable and so never
|
||||
// appears here.
|
||||
fJSON("hidden_service_columns", 2000),
|
||||
// And the parts its services never change (["oil"] on an EV), which come
|
||||
// off the service form and out of that column together.
|
||||
fJSON("hidden_service_parts", 2000),
|
||||
// The order the tabs are laid out in, as tab keys, the same for the
|
||||
// Information rows, the Service history columns, and the connected
|
||||
// service's headline readings. Empty means the page's own default order.
|
||||
|
||||
@@ -91,6 +91,16 @@ type Car struct {
|
||||
// nothing.
|
||||
HiddenServiceColumns []string `json:"hiddenServiceColumns"`
|
||||
|
||||
// HiddenServiceParts is the parts this car's services never change, as part
|
||||
// keys (["oil"] on an EV, which has none to change). They come off the
|
||||
// Changed parts section of the service form and out of the history's parts
|
||||
// column together: a part nobody records is one nobody wants offered either.
|
||||
// The hidden set like the ones above, so a part added later is on by
|
||||
// default, and there is no order beside it — the parts are a checkbox list
|
||||
// inside one column, and their position says nothing a tab's or a column's
|
||||
// does.
|
||||
HiddenServiceParts []string `json:"hiddenServiceParts"`
|
||||
|
||||
// ServiceColumnOrder is the arrangement of those columns, covering the
|
||||
// hidden ones so a column switched back on returns to where it was. It does
|
||||
// include "date", which cannot be switched off but can be moved off the
|
||||
|
||||
+9
-4
@@ -27,9 +27,11 @@ navigation bar** — Garage, Charging, Settings, and Users for admins — in an
|
||||
|
||||
**Which tabs a car shows, and in what order, belongs to the car** — the same
|
||||
arrangement the web app reads, so everyone it is shared with sees the same
|
||||
page. Edit it under the **tune** icon: switch tabs, Information rows and
|
||||
Service history columns on or off, and drag any of the three lists by its
|
||||
handle to reorder it. (The web rearranges by dragging the tab bar and the
|
||||
page. Edit it under the **tune** icon: switch tabs, Information rows, Service
|
||||
history columns and the parts a service can change on or off, and drag any of
|
||||
the first three lists by its handle to reorder it. (The parts have no order —
|
||||
they are a checkbox list inside one column, and their position says nothing a
|
||||
tab's or a column's does.) (The web rearranges by dragging the tab bar and the
|
||||
column headings themselves; on a touch screen those gestures belong to the tab
|
||||
bar and the scroll, so every arrangement is made in the picker instead.) Two
|
||||
things cannot be switched off: Information — a page with no tabs left would be
|
||||
@@ -57,7 +59,10 @@ navigation bar** — Garage, Charging, Settings, and Users for admins — in an
|
||||
have changed shares the one **parts** column — they are a growing list, and a
|
||||
column apiece would widen the web's table without end — and both that column
|
||||
and the form's Changed parts section come from `lib/service_parts.dart`, the
|
||||
twin of the web's `lib/serviceParts.js`.
|
||||
twin of the web's `lib/serviceParts.js`. Which of them this car records is
|
||||
the car's own choice as well: a part switched off leaves the form's
|
||||
checkboxes and the cards' chips together, and nothing is written to the
|
||||
records, so switching it back on brings the old chips back.
|
||||
- **Technical check history** — the mandatory roadworthiness inspections
|
||||
(przegląd techniczny, MOT, TÜV). Result, cost, station, and the certificate's
|
||||
valid-until, which overrides the car's interval when present. A failed check
|
||||
|
||||
@@ -377,6 +377,8 @@
|
||||
"fieldsOrderHint": "Træk felterne på fanen Oplysninger for at ændre deres rækkefølge.",
|
||||
"serviceColumnsHeading": "Kolonner i servicehistorik",
|
||||
"columnAlwaysOn": "{column} vises altid.",
|
||||
"servicePartsHeading": "Udskiftede dele",
|
||||
"servicePartsHint": "En fravalgt del forsvinder fra serviceformularen og fra historikken. Det, der allerede er registreret, bevares og kommer tilbage med den.",
|
||||
"reorderHint": "Træk en række i håndtaget for at ændre rækkefølgen.",
|
||||
"tabsReorder": "Faneblade",
|
||||
"fieldsReorder": "Informationsfelter"
|
||||
|
||||
@@ -377,6 +377,8 @@
|
||||
"fieldsOrderHint": "Drag the fields on the Information tab to change the order they appear in.",
|
||||
"serviceColumnsHeading": "Service history columns",
|
||||
"columnAlwaysOn": "{column} is always shown.",
|
||||
"servicePartsHeading": "Changed parts",
|
||||
"servicePartsHint": "A part switched off comes off the service form and out of the history. What is already recorded is kept, and comes back with it.",
|
||||
"reorderHint": "Drag a row by its handle to change the order.",
|
||||
"tabsReorder": "Tabs",
|
||||
"fieldsReorder": "Information fields"
|
||||
|
||||
@@ -381,6 +381,8 @@
|
||||
"fieldsOrderHint": "Przeciągnij pola na zakładce Informacje, aby zmienić ich kolejność.",
|
||||
"serviceColumnsHeading": "Kolumny historii serwisowej",
|
||||
"columnAlwaysOn": "Kolumna {column} jest zawsze widoczna.",
|
||||
"servicePartsHeading": "Wymienione części",
|
||||
"servicePartsHint": "Wyłączona część znika z formularza serwisu i z historii. Zapisane dane pozostają i wracają razem z nią.",
|
||||
"reorderHint": "Przeciągnij wiersz za uchwyt, aby zmienić kolejność.",
|
||||
"tabsReorder": "Zakładki",
|
||||
"fieldsReorder": "Pola informacyjne"
|
||||
|
||||
@@ -146,6 +146,7 @@ class ApiClient {
|
||||
List<String>? metricOrder,
|
||||
List<String>? hiddenServiceColumns,
|
||||
List<String>? serviceColumnOrder,
|
||||
List<String>? hiddenServiceParts,
|
||||
}) async {
|
||||
final body = <String, dynamic>{
|
||||
if (hiddenTabs != null) "hiddenTabs": hiddenTabs,
|
||||
@@ -155,6 +156,7 @@ class ApiClient {
|
||||
if (metricOrder != null) "metricOrder": metricOrder,
|
||||
if (hiddenServiceColumns != null) "hiddenServiceColumns": hiddenServiceColumns,
|
||||
if (serviceColumnOrder != null) "serviceColumnOrder": serviceColumnOrder,
|
||||
if (hiddenServiceParts != null) "hiddenServiceParts": hiddenServiceParts,
|
||||
};
|
||||
final data = await _send("PUT", "/cars/$id/view", body: body);
|
||||
return Car.fromJson(Map<String, dynamic>.from(data));
|
||||
|
||||
@@ -107,6 +107,12 @@ class Car {
|
||||
final List<String> hiddenServiceColumns;
|
||||
final List<String> serviceColumnOrder;
|
||||
|
||||
/// The parts this car's services never change, as part keys. They come off
|
||||
/// the service form and out of the history's chips together — a part nobody
|
||||
/// records is one nobody wants offered. No order beside it: the parts are a
|
||||
/// checkbox list inside one column, and their position says nothing.
|
||||
final List<String> hiddenServiceParts;
|
||||
|
||||
Car({
|
||||
required this.id,
|
||||
required this.name,
|
||||
@@ -138,6 +144,7 @@ class Car {
|
||||
this.metricOrder = const [],
|
||||
this.hiddenServiceColumns = const [],
|
||||
this.serviceColumnOrder = const [],
|
||||
this.hiddenServiceParts = const [],
|
||||
});
|
||||
|
||||
factory Car.fromJson(Map<String, dynamic> j) => Car(
|
||||
@@ -171,6 +178,7 @@ class Car {
|
||||
metricOrder: _asStrList(j["metricOrder"]),
|
||||
hiddenServiceColumns: _asStrList(j["hiddenServiceColumns"]),
|
||||
serviceColumnOrder: _asStrList(j["serviceColumnOrder"]),
|
||||
hiddenServiceParts: _asStrList(j["hiddenServiceParts"]),
|
||||
);
|
||||
|
||||
bool get isOwner => access == "owner";
|
||||
|
||||
@@ -470,6 +470,7 @@ class _CarDetailScreenState extends State<CarDetailScreen> {
|
||||
final columns = arrangeKeys(kServiceColumnKeys, car.serviceColumnOrder)
|
||||
.where((key) => !car.hiddenServiceColumns.contains(key))
|
||||
.toList();
|
||||
final parts = visibleParts(car);
|
||||
return _TabList(
|
||||
empty: data.services.isEmpty ? t("car.services.empty") : null,
|
||||
onAdd: car.canWrite ? () => _addService(car) : null,
|
||||
@@ -478,6 +479,7 @@ class _CarDetailScreenState extends State<CarDetailScreen> {
|
||||
.map((s) => _ServiceTile(
|
||||
record: s,
|
||||
columns: columns,
|
||||
parts: parts,
|
||||
onEdit: car.canWrite ? () => _editService(car, s) : null,
|
||||
onDelete: car.canWrite ? () => _deleteService(s) : null,
|
||||
))
|
||||
@@ -825,11 +827,16 @@ class _ServiceTile extends StatelessWidget {
|
||||
/// The visible column keys, already arranged. Never empty: date cannot be
|
||||
/// hidden.
|
||||
final List<String> columns;
|
||||
|
||||
/// The parts this car still records. Passed in rather than read off the car
|
||||
/// for the same reason the columns are: every row shows the same ones.
|
||||
final List<ServicePart> parts;
|
||||
final VoidCallback? onEdit;
|
||||
final VoidCallback? onDelete;
|
||||
const _ServiceTile({
|
||||
required this.record,
|
||||
required this.columns,
|
||||
required this.parts,
|
||||
this.onEdit,
|
||||
this.onDelete,
|
||||
});
|
||||
@@ -912,7 +919,7 @@ class _ServiceTile extends StatelessWidget {
|
||||
/// them in one table cell and so names the first and counts the rest behind a
|
||||
/// panel; a card has the width to simply show them all.
|
||||
Widget _parts(BuildContext context) {
|
||||
final changed = changedParts(record);
|
||||
final changed = changedParts(record, parts);
|
||||
if (changed.isEmpty) return _empty(context, "parts");
|
||||
return Wrap(
|
||||
spacing: 6,
|
||||
@@ -1976,7 +1983,14 @@ class _ServiceSheetState extends State<_ServiceSheet> {
|
||||
/// Which parts this record says were changed, keyed the way [kServiceParts]
|
||||
/// keys them, so a part added to that list turns up in this sheet without a
|
||||
/// second edit here.
|
||||
///
|
||||
/// Every part, not only the shown ones: an edit has to send back what a part
|
||||
/// this car has switched off already said, because the API rewrites all of the
|
||||
/// booleans from the body and an omitted one would come back false.
|
||||
late final Map<String, bool> _changed;
|
||||
|
||||
/// The parts this car still records, and so the only ones with a checkbox.
|
||||
late final List<ServicePart> _parts;
|
||||
final _pending = PendingAttachment();
|
||||
bool _saving = false;
|
||||
String? _error;
|
||||
@@ -1990,11 +2004,14 @@ class _ServiceSheetState extends State<_ServiceSheet> {
|
||||
_date = r?.date ?? DateTime.now();
|
||||
_km = TextEditingController(text: r == null ? "" : "${r.km}");
|
||||
_notes = TextEditingController(text: r?.notes ?? "");
|
||||
_parts = visibleParts(widget.car);
|
||||
// An existing record is read through the part's own accessor; a new one
|
||||
// starts from the part's default, which is why an oil change comes ticked.
|
||||
// starts from the part's default, which is why an oil change comes ticked —
|
||||
// unless this car has switched that part off, since ticking a box nobody was
|
||||
// shown is not a default, it's a guess.
|
||||
_changed = {
|
||||
for (final part in kServiceParts)
|
||||
part.key: r == null ? part.initial : part.changed(r),
|
||||
part.key: r == null ? part.initial && _parts.contains(part) : part.changed(r),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2092,7 +2109,7 @@ class _ServiceSheetState extends State<_ServiceSheet> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
for (final part in kServiceParts)
|
||||
for (final part in _parts)
|
||||
CheckboxListTile(
|
||||
value: _changed[part.key] ?? false,
|
||||
onChanged: (v) => setState(() => _changed[part.key] = v ?? false),
|
||||
|
||||
@@ -3,6 +3,7 @@ import "package:flutter/material.dart";
|
||||
import "../i18n.dart";
|
||||
import "../main.dart";
|
||||
import "../models.dart";
|
||||
import "../service_parts.dart";
|
||||
import "../theme.dart";
|
||||
|
||||
/// Every tab a car's page can show, in the order they appear when the car has no
|
||||
@@ -179,6 +180,7 @@ class _CarViewSheetState extends State<CarViewSheet> {
|
||||
late Set<String> _visibleTabs;
|
||||
late Set<String> _visibleFields;
|
||||
late Set<String> _visibleColumns;
|
||||
late Set<String> _visibleServiceParts;
|
||||
bool _saving = false;
|
||||
String? _error;
|
||||
|
||||
@@ -194,6 +196,7 @@ class _CarViewSheetState extends State<CarViewSheet> {
|
||||
_visibleColumns = kHideableServiceColumnKeys
|
||||
.where((k) => !car.hiddenServiceColumns.contains(k))
|
||||
.toSet();
|
||||
_visibleServiceParts = visibleParts(car).map((p) => p.key).toSet();
|
||||
}
|
||||
|
||||
/// Whether [key] is one of the rows on offer below: Information never is
|
||||
@@ -253,6 +256,10 @@ class _CarViewSheetState extends State<CarViewSheet> {
|
||||
tabOrder: _tabOrder,
|
||||
fieldOrder: _fieldOrder,
|
||||
serviceColumnOrder: _columnOrder,
|
||||
hiddenServiceParts: kServiceParts
|
||||
.where((p) => !_visibleServiceParts.contains(p.key))
|
||||
.map((p) => p.key)
|
||||
.toList(),
|
||||
);
|
||||
if (mounted) Navigator.pop(context, car);
|
||||
} catch (e) {
|
||||
@@ -381,6 +388,35 @@ class _CarViewSheetState extends State<CarViewSheet> {
|
||||
style: TextStyle(fontSize: 11, color: DriverVault.muted(context)),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_heading(context, t("car.viewPicker.servicePartsHeading")),
|
||||
// No drag handle here, and no stored order: the parts are a
|
||||
// checkbox list inside one column, so their position carries
|
||||
// nothing a tab's or a column's does.
|
||||
for (final part in kServiceParts)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||
child: Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: _visibleServiceParts.contains(part.key),
|
||||
onChanged: (v) => setState(() => (v ?? false)
|
||||
? _visibleServiceParts.add(part.key)
|
||||
: _visibleServiceParts.remove(part.key)),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(t(part.label), style: const TextStyle(fontSize: 14)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
t("car.viewPicker.servicePartsHint"),
|
||||
style: TextStyle(fontSize: 11, color: DriverVault.muted(context)),
|
||||
),
|
||||
),
|
||||
if (_error != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
|
||||
@@ -76,9 +76,22 @@ final List<ServicePart> kServiceParts = [
|
||||
),
|
||||
];
|
||||
|
||||
/// The parts this record says were changed. A record written before a part
|
||||
/// existed simply doesn't carry its field, which the model reads as false —
|
||||
/// "not changed" rather than "unknown", because that service genuinely didn't
|
||||
/// change it.
|
||||
List<ServicePart> changedParts(ServiceRecord service) =>
|
||||
kServiceParts.where((part) => part.changed(service)).toList();
|
||||
/// The parts a car actually records, which is every one it hasn't switched off.
|
||||
/// An EV changes no oil, and a checkbox nobody will ever tick is one more thing
|
||||
/// to read past on every service. The hidden set rather than the visible one, so
|
||||
/// a part added in a later release is on by default.
|
||||
List<ServicePart> visibleParts(Car car) =>
|
||||
kServiceParts.where((part) => !car.hiddenServiceParts.contains(part.key)).toList();
|
||||
|
||||
/// The parts this record says were changed, among the ones [parts] still shows.
|
||||
/// A record written before a part existed simply doesn't carry its field, which
|
||||
/// the model reads as false — "not changed" rather than "unknown", because that
|
||||
/// service genuinely didn't change it.
|
||||
///
|
||||
/// A part switched off disappears from the history as well as from the form, the
|
||||
/// same way a hidden column does: what "I don't record this" means is that it
|
||||
/// stops taking up room, not that it takes up room saying nothing. Its stored
|
||||
/// boolean is left alone, so switching it back on brings the old records' chips
|
||||
/// back with it.
|
||||
List<ServicePart> changedParts(ServiceRecord service, List<ServicePart> parts) =>
|
||||
parts.where((part) => part.changed(service)).toList();
|
||||
|
||||
@@ -12,6 +12,7 @@ import "package:drivervault_phone/i18n.dart";
|
||||
import "package:drivervault_phone/main.dart";
|
||||
import "package:drivervault_phone/models.dart";
|
||||
import "package:drivervault_phone/screens/car_view_sheet.dart";
|
||||
import "package:drivervault_phone/service_parts.dart";
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -83,14 +84,37 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Car car({List<String> hiddenColumns = const [], List<String> columnOrder = const []}) =>
|
||||
Car car({
|
||||
List<String> hiddenColumns = const [],
|
||||
List<String> columnOrder = const [],
|
||||
List<String> hiddenParts = const [],
|
||||
}) =>
|
||||
Car.fromJson({
|
||||
"id": "car1",
|
||||
"name": "bZ4X",
|
||||
"hiddenServiceColumns": hiddenColumns,
|
||||
"serviceColumnOrder": columnOrder,
|
||||
"hiddenServiceParts": hiddenParts,
|
||||
});
|
||||
|
||||
// The sheet stacks its sections in one list: tabs, Information rows, the
|
||||
// Service history columns, then the parts. Counted from the end rather than
|
||||
// the start so the tab rows — whose number depends on showProvider — don't
|
||||
// have to be worked out here.
|
||||
List<bool> ticks(WidgetTester tester) => tester
|
||||
.widgetList<Checkbox>(find.byType(Checkbox))
|
||||
.map((b) => b.value ?? false)
|
||||
.toList();
|
||||
List<bool> columnTicks(WidgetTester tester) {
|
||||
final all = ticks(tester);
|
||||
final end = all.length - kServiceParts.length;
|
||||
return all.sublist(end - kServiceColumnKeys.length, end);
|
||||
}
|
||||
List<bool> partTicks(WidgetTester tester) {
|
||||
final all = ticks(tester);
|
||||
return all.sublist(all.length - kServiceParts.length);
|
||||
}
|
||||
|
||||
testWidgets("offers every column, with the date locked on", (tester) async {
|
||||
await pump(tester, car());
|
||||
|
||||
@@ -114,15 +138,33 @@ void main() {
|
||||
testWidgets("a switched-off column comes back unticked", (tester) async {
|
||||
await pump(tester, car(hiddenColumns: ["parts", "file"]));
|
||||
|
||||
// Read the ticks in the order the rows are laid out — the sheet lists the
|
||||
// tabs and the Information rows above the columns, so the columns are the
|
||||
// last seven.
|
||||
final ticks = tester
|
||||
expect(columnTicks(tester), [true, true, true, true, false, true, false]);
|
||||
});
|
||||
|
||||
testWidgets("offers every part, none of them locked", (tester) async {
|
||||
await pump(tester, car());
|
||||
|
||||
expect(find.text(t("car.viewPicker.servicePartsHeading").toUpperCase()),
|
||||
findsOneWidget);
|
||||
for (final part in kServiceParts) {
|
||||
expect(find.text(t(part.label)), findsWidgets,
|
||||
reason: "the ${part.key} part is not on offer");
|
||||
}
|
||||
expect(partTicks(tester), List.filled(kServiceParts.length, true));
|
||||
|
||||
// Only the date is locked. Every part can be switched off: a service that
|
||||
// changed nothing is a real service, so the form needs none of them.
|
||||
final locked = tester
|
||||
.widgetList<Checkbox>(find.byType(Checkbox))
|
||||
.map((b) => b.value ?? false)
|
||||
.toList();
|
||||
final columns = ticks.sublist(ticks.length - kServiceColumnKeys.length);
|
||||
expect(columns, [true, true, true, true, false, true, false]);
|
||||
.where((b) => b.onChanged == null);
|
||||
expect(locked, hasLength(1));
|
||||
});
|
||||
|
||||
testWidgets("a switched-off part comes back unticked", (tester) async {
|
||||
await pump(tester, car(hiddenParts: ["oil", "cabinFilter"]));
|
||||
expect(partTicks(tester), [false, true, false]);
|
||||
// And it changes nothing about the columns, which are their own set.
|
||||
expect(columnTicks(tester), List.filled(kServiceColumnKeys.length, true));
|
||||
});
|
||||
|
||||
testWidgets("the rows follow the car's arrangement", (tester) async {
|
||||
|
||||
@@ -299,18 +299,40 @@ void main() {
|
||||
"changedCabinAirFilter": cabin,
|
||||
});
|
||||
|
||||
expect(changedParts(record()).isEmpty, isTrue);
|
||||
expect(changedParts(record(oil: true)).map((p) => p.key), ["oil"]);
|
||||
final all = kServiceParts;
|
||||
expect(changedParts(record(), all).isEmpty, isTrue);
|
||||
expect(changedParts(record(oil: true), all).map((p) => p.key), ["oil"]);
|
||||
// Catalogue order, not the order the fields happen to be read in.
|
||||
expect(
|
||||
changedParts(record(cabin: true, oil: true)).map((p) => p.key),
|
||||
changedParts(record(cabin: true, oil: true), all).map((p) => p.key),
|
||||
["oil", "cabinFilter"],
|
||||
);
|
||||
|
||||
// A record written before a part existed carries no field for it, which
|
||||
// reads as "not changed" rather than as a missing value.
|
||||
final old = ServiceRecord.fromJson({"id": "s", "car": "c", "km": 0});
|
||||
expect(changedParts(old).isEmpty, isTrue);
|
||||
expect(changedParts(old, all).isEmpty, isTrue);
|
||||
});
|
||||
|
||||
test("a part a car has switched off leaves its records alone", () {
|
||||
final car = Car.fromJson({"id": "c", "name": "bZ4X", "hiddenServiceParts": ["oil"]});
|
||||
expect(car.hiddenServiceParts, ["oil"]);
|
||||
expect(visibleParts(car).map((p) => p.key), ["engineFilter", "cabinFilter"]);
|
||||
|
||||
// A car nobody has configured offers every part — the hidden set, so one
|
||||
// added in a later release is on by default.
|
||||
expect(visibleParts(Car.fromJson({"id": "d", "name": "Yaris"})).length, kServiceParts.length);
|
||||
|
||||
// The chips follow the car, so an oil change recorded before the part was
|
||||
// switched off stops being shown...
|
||||
final oiled = ServiceRecord.fromJson({
|
||||
"id": "s", "car": "c", "km": 90000,
|
||||
"changedOil": true, "changedCabinAirFilter": true,
|
||||
});
|
||||
expect(changedParts(oiled, visibleParts(car)).map((p) => p.key), ["cabinFilter"]);
|
||||
// ...but the record still says so, which is what brings the chip back if the
|
||||
// part is switched on again. Nothing here writes to the record.
|
||||
expect(oiled.changedOil, isTrue);
|
||||
});
|
||||
|
||||
test("arrangeKeys: partial orders keep every key, unknown ones are dropped", () {
|
||||
|
||||
@@ -141,6 +141,15 @@ Config (`server/.env`, copy from `.env.example`):
|
||||
the column and the form's Changed parts section are driven by one list in
|
||||
`lib/serviceParts.js`, so adding a part is one entry there plus its boolean on
|
||||
the API's `service_records` collection.
|
||||
|
||||
**Which parts a car records is the car's** too, under the same picker. An EV
|
||||
changes no oil, and a checkbox nobody will ever tick is one more thing to read
|
||||
past on every service. A part switched off leaves the form, the column's
|
||||
summary and the panel together — "I don't record this" means it stops taking
|
||||
up room, not that it takes up room saying nothing. Nothing is written to the
|
||||
records: an edit sends a hidden part's stored boolean straight back, because
|
||||
the API rewrites all of them from the body, so switching the part on again
|
||||
brings the old services' chips back with it.
|
||||
- **Arranging the Service history columns** — the column headings on that tab
|
||||
drag into any order, saved on drop, and it covers the hidden columns too. Date
|
||||
is arrangeable although it can't be switched off, the same rule Information
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ref } from "vue";
|
||||
import { api } from "../api";
|
||||
import { formatKm } from "../lib/format.js";
|
||||
import { applyAttachment } from "../lib/attachment.js";
|
||||
import { SERVICE_PARTS } from "../lib/serviceParts.js";
|
||||
import { SERVICE_PARTS, visibleParts } from "../lib/serviceParts.js";
|
||||
import { t } from "../i18n";
|
||||
import AttachmentField from "./AttachmentField.vue";
|
||||
import DateField from "./DateField.vue";
|
||||
@@ -19,6 +19,11 @@ const emit = defineEmits(["saved", "close"]);
|
||||
const isEdit = !!props.service;
|
||||
const saving = ref(false);
|
||||
const error = ref("");
|
||||
// The parts this car records. Read once rather than as a computed: the dialog is
|
||||
// mounted per open, and a part switching off under an open form would rearrange
|
||||
// it mid-edit.
|
||||
const shown = visibleParts(props.car);
|
||||
const hidden = SERVICE_PARTS.filter((part) => !shown.includes(part)).map((part) => part.key);
|
||||
const form = ref({
|
||||
date: props.service ? toDateInput(props.service.date) : new Date().toISOString().slice(0, 10),
|
||||
km: props.service?.km ?? "",
|
||||
@@ -26,8 +31,19 @@ const form = ref({
|
||||
// part added to it turns up in this dialog without a second edit. An existing
|
||||
// record written before a part existed has no field for it, which reads as
|
||||
// unchecked.
|
||||
//
|
||||
// Every part, not only the shown ones: an edit has to send back what a hidden
|
||||
// part already said, because the API rewrites all three booleans from the body
|
||||
// and an omitted one would come back false. A *new* record starts a hidden
|
||||
// part at false rather than its `initial`, since ticking a box nobody was
|
||||
// shown is not a default, it's a guess.
|
||||
...Object.fromEntries(
|
||||
SERVICE_PARTS.map((part) => [part.field, props.service ? !!props.service[part.field] : part.initial])
|
||||
SERVICE_PARTS.map((part) => [
|
||||
part.field,
|
||||
props.service
|
||||
? !!props.service[part.field]
|
||||
: part.initial && !hidden.includes(part.key),
|
||||
])
|
||||
),
|
||||
notes: props.service?.notes ?? "",
|
||||
});
|
||||
@@ -82,10 +98,10 @@ async function submit() {
|
||||
<input v-model="form.km" type="number" min="0" required placeholder="16138" class="dh-input data" />
|
||||
</div>
|
||||
</div>
|
||||
<fieldset class="rounded-control border border-subtle p-3">
|
||||
<fieldset v-if="shown.length" class="rounded-control border border-subtle p-3">
|
||||
<legend class="eyebrow px-1">{{ t("forms.service.changedParts") }}</legend>
|
||||
<label
|
||||
v-for="part in SERVICE_PARTS"
|
||||
v-for="part in shown"
|
||||
:key="part.key"
|
||||
class="flex items-center gap-2 py-1 text-sm text-body"
|
||||
>
|
||||
|
||||
@@ -384,7 +384,9 @@
|
||||
"fieldsOrderHint": "Træk felterne på fanen Oplysninger for at ændre deres rækkefølge.",
|
||||
"serviceColumnsHeading": "Kolonner i servicehistorik",
|
||||
"columnAlwaysOn": "{column} vises altid.",
|
||||
"serviceColumnsOrderHint": "Træk kolonneoverskrifterne på fanen Servicehistorik for at ændre deres rækkefølge."
|
||||
"serviceColumnsOrderHint": "Træk kolonneoverskrifterne på fanen Servicehistorik for at ændre deres rækkefølge.",
|
||||
"servicePartsHeading": "Udskiftede dele",
|
||||
"servicePartsHint": "En fravalgt del forsvinder fra serviceformularen og fra historikken. Det, der allerede er registreret, bevares og kommer tilbage med den."
|
||||
},
|
||||
|
||||
"provider": {
|
||||
|
||||
@@ -383,7 +383,9 @@
|
||||
"fieldsOrderHint": "Drag the fields on the Information tab to change the order they appear in.",
|
||||
"serviceColumnsHeading": "Service history columns",
|
||||
"columnAlwaysOn": "{column} is always shown.",
|
||||
"serviceColumnsOrderHint": "Drag the column headings on the Service history tab to change the order they appear in."
|
||||
"serviceColumnsOrderHint": "Drag the column headings on the Service history tab to change the order they appear in.",
|
||||
"servicePartsHeading": "Changed parts",
|
||||
"servicePartsHint": "A part switched off comes off the service form and out of the history. What is already recorded is kept, and comes back with it."
|
||||
},
|
||||
|
||||
"provider": {
|
||||
|
||||
@@ -388,7 +388,9 @@
|
||||
"fieldsOrderHint": "Przeciągnij pola na zakładce Informacje, aby zmienić ich kolejność.",
|
||||
"serviceColumnsHeading": "Kolumny historii serwisowej",
|
||||
"columnAlwaysOn": "Kolumna {column} jest zawsze widoczna.",
|
||||
"serviceColumnsOrderHint": "Przeciągnij nagłówki kolumn na zakładce Historia serwisowa, aby zmienić ich kolejność."
|
||||
"serviceColumnsOrderHint": "Przeciągnij nagłówki kolumn na zakładce Historia serwisowa, aby zmienić ich kolejność.",
|
||||
"servicePartsHeading": "Wymienione części",
|
||||
"servicePartsHint": "Wyłączona część znika z formularza serwisu i z historii. Zapisane dane pozostają i wracają razem z nią."
|
||||
},
|
||||
|
||||
"provider": {
|
||||
|
||||
@@ -16,9 +16,25 @@ export const SERVICE_PARTS = [
|
||||
{ key: "cabinFilter", field: "changedCabinAirFilter", label: "forms.service.cabinFilter", initial: false },
|
||||
];
|
||||
|
||||
// The parts this record says were changed. A record written before a part
|
||||
// existed simply doesn't carry its field, which reads as "not changed" rather
|
||||
// than as a missing value — that service genuinely didn't change it.
|
||||
export function changedParts(service) {
|
||||
return SERVICE_PARTS.filter((part) => !!service?.[part.field]);
|
||||
// The parts a car actually records, which is every one it hasn't switched off.
|
||||
// An EV changes no oil, and a checkbox nobody will ever tick is one more thing
|
||||
// to read past on every service. The hidden set rather than the visible one, so
|
||||
// a part added in a later release is on by default.
|
||||
export function visibleParts(car) {
|
||||
const hidden = car?.hiddenServiceParts || [];
|
||||
return SERVICE_PARTS.filter((part) => !hidden.includes(part.key));
|
||||
}
|
||||
|
||||
// The parts this record says were changed, among the ones the car still shows.
|
||||
// A record written before a part existed simply doesn't carry its field, which
|
||||
// reads as "not changed" rather than as a missing value — that service genuinely
|
||||
// didn't change it.
|
||||
//
|
||||
// A part switched off disappears from the history as well as from the form, the
|
||||
// same way a hidden column does: what "I don't record this" means is that it
|
||||
// stops taking up room, not that it takes up room saying nothing. Its stored
|
||||
// boolean is left alone, so switching it back on brings the old records' chips
|
||||
// back with it.
|
||||
export function changedParts(service, car) {
|
||||
return visibleParts(car).filter((part) => !!service?.[part.field]);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
expiryStatus,
|
||||
reminderStatus,
|
||||
} from "../lib/format.js";
|
||||
import { SERVICE_PARTS, changedParts } from "../lib/serviceParts.js";
|
||||
import { SERVICE_PARTS, changedParts, visibleParts } from "../lib/serviceParts.js";
|
||||
import { t, tSplit } from "../i18n";
|
||||
import CarFormModal from "../components/CarFormModal.vue";
|
||||
import ServiceFormModal from "../components/ServiceFormModal.vue";
|
||||
@@ -255,6 +255,7 @@ const HIDEABLE_SERVICE_COLUMNS = ALL_SERVICE_COLUMN_KEYS.filter((key) => key !==
|
||||
const tabDraft = ref([]); // tab keys that stay visible
|
||||
const fieldDraft = ref([]); // Information keys that stay visible
|
||||
const columnDraft = ref([]); // Service history columns that stay visible
|
||||
const partDraft = ref([]); // parts the service form keeps offering
|
||||
const viewSaving = ref(false);
|
||||
const viewError = ref("");
|
||||
|
||||
@@ -264,6 +265,7 @@ function openViewPicker() {
|
||||
columnDraft.value = serviceColumnKeys.value.filter(
|
||||
(key) => key !== "date" && !hiddenServiceColumns.value.includes(key)
|
||||
);
|
||||
partDraft.value = visibleParts(car.value).map((part) => part.key);
|
||||
viewError.value = "";
|
||||
showViewPicker.value = true;
|
||||
}
|
||||
@@ -280,6 +282,9 @@ function toggleFieldDraft(key, on) {
|
||||
function toggleColumnDraft(key, on) {
|
||||
columnDraft.value = on ? [...columnDraft.value, key] : columnDraft.value.filter((k) => k !== key);
|
||||
}
|
||||
function togglePartDraft(key, on) {
|
||||
partDraft.value = on ? [...partDraft.value, key] : partDraft.value.filter((k) => k !== key);
|
||||
}
|
||||
|
||||
async function saveView() {
|
||||
viewSaving.value = true;
|
||||
@@ -289,6 +294,7 @@ async function saveView() {
|
||||
hiddenTabs: HIDEABLE_TABS.filter((key) => !tabDraft.value.includes(key)),
|
||||
hiddenFields: INFO_FIELD_KEYS.filter((key) => !fieldDraft.value.includes(key)),
|
||||
hiddenServiceColumns: HIDEABLE_SERVICE_COLUMNS.filter((key) => !columnDraft.value.includes(key)),
|
||||
hiddenServiceParts: SERVICE_PARTS.filter((part) => !partDraft.value.includes(part.key)).map((part) => part.key),
|
||||
});
|
||||
car.value = { ...updated, access: car.value.access };
|
||||
showViewPicker.value = false;
|
||||
@@ -515,7 +521,7 @@ function serviceCell(s, key) {
|
||||
// has to stay one line wide, and it is going to grow, so past two it becomes the
|
||||
// first part and a tally. The panel behind it has the full picture either way.
|
||||
function partsSummary(s) {
|
||||
const changed = changedParts(s);
|
||||
const changed = changedParts(s, car.value);
|
||||
if (!changed.length) return { text: t("common.empty"), muted: true, count: 0 };
|
||||
const labels = changed.map((part) => t(part.label));
|
||||
return {
|
||||
@@ -1221,7 +1227,7 @@ onMounted(load);
|
||||
>
|
||||
<p class="eyebrow mb-2">{{ t("forms.service.changedParts") }}</p>
|
||||
<div
|
||||
v-for="part in SERVICE_PARTS"
|
||||
v-for="part in visibleParts(car)"
|
||||
:key="part.key"
|
||||
class="flex items-center justify-between gap-4 py-0.5 text-sm"
|
||||
>
|
||||
@@ -1879,6 +1885,24 @@ onMounted(load);
|
||||
{{ t("car.viewPicker.serviceColumnsOrderHint") }}
|
||||
</p>
|
||||
|
||||
<p class="eyebrow mb-2 mt-5">{{ t("car.viewPicker.servicePartsHeading") }}</p>
|
||||
<div class="grid gap-2 sm:grid-cols-2">
|
||||
<label
|
||||
v-for="part in SERVICE_PARTS"
|
||||
:key="part.key"
|
||||
class="flex items-center gap-2 text-sm font-medium text-body"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded border-subtle text-accent focus:ring-accent"
|
||||
:checked="partDraft.includes(part.key)"
|
||||
@change="togglePartDraft(part.key, $event.target.checked)"
|
||||
/>
|
||||
<span>{{ t(part.label) }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="mt-2 text-xs text-muted">{{ t("car.viewPicker.servicePartsHint") }}</p>
|
||||
|
||||
<p v-if="viewError" class="mt-3 text-sm text-danger">{{ viewError }}</p>
|
||||
|
||||
<div class="mt-5 flex justify-end gap-2">
|
||||
|
||||
Reference in New Issue
Block a user