feat(roadtrip): let one stop say how full it fills

The fill level was one figure for the whole trip, and a trip does not have one.
A motorway rapid charger is worth about 80 % because the last fifth costs as
long again; the charger at the hotel is worth all of it because the car stands
there all night. Between those two the difference is a whole leg, and a single
setting has to be wrong about one of them.

So the badge on a refuelling stop is now the way in: it shows what that stop
will actually fill to, its own figure or the traveller's, and opens a panel of
the six answers people actually give. Under them it says what the choice buys in
kilometres, because 80 % is an abstraction and "about 290 km from here" is the
thing being decided. Picking the figure a stop already has hands it back to the
setting, the same gesture the kind picker uses to un-pick a kind.

The value lives in places.fill_percent, beside stop_type, because it is a
property of the stop rather than of the person. Null means "follow the setting",
which is every stop that predates the column and every stop nobody has an
opinion about, so nothing changes for a trip that never touches it.

Two pieces of shared machinery came out of it rather than being copied. The
popover chrome — measure before showing, flip when the window is short, close on
an outside click, Escape or a scroll — is one component now, used by the kind
picker and this one. So is the assembly of the range from seven settings, which
the routes hook and the rail both need and which would have drifted the first
time a field was added.
This commit is contained in:
Maurice
2026-09-09 23:05:35 +02:00
committed by Maurice
parent aaf6559d5d
commit 96ab748f34
46 changed files with 783 additions and 144 deletions
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} خلال {time}',
'roadtrip.day.stopCount': '{count} محطات',
'roadtrip.stop.stayShort': 'مدة',
'roadtrip.stop.fillTitle': 'يملأ حتى',
'roadtrip.stop.fillGives': 'نحو {distance} من هنا',
'roadtrip.stop.fillNoRange': 'أدخل المدى لترى ما الذي يمنحه ذلك.',
'roadtrip.stop.fillDefault': 'استخدام الإعداد الافتراضي الخاص بي',
'roadtrip.stop.fillSet': 'حدد مقدار التعبئة في هذه المحطة',
'roadtrip.leg.pending': 'لا يوجد مسار',
'roadtrip.stop.addTitle': 'إضافة كمحطة توقف',
'roadtrip.stop.kind': 'نوع المحطة',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} em {time}',
'roadtrip.day.stopCount': '{count} paradas',
'roadtrip.stop.stayShort': 'Parada',
'roadtrip.stop.fillTitle': 'Abastece até',
'roadtrip.stop.fillGives': 'cerca de {distance} a partir daqui',
'roadtrip.stop.fillNoRange': 'Informe uma autonomia para ver o que isso rende.',
'roadtrip.stop.fillDefault': 'Usar meu padrão',
'roadtrip.stop.fillSet': 'Definir quanto abastecer nesta parada',
'roadtrip.leg.pending': 'Sem rota',
'roadtrip.stop.addTitle': 'Adicionar como parada',
'roadtrip.stop.kind': 'Tipo de parada',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} en {time}',
'roadtrip.day.stopCount': '{count} parades',
'roadtrip.stop.stayShort': 'Parada',
'roadtrip.stop.fillTitle': 'Omple al',
'roadtrip.stop.fillGives': 'uns {distance} des d’aquí',
'roadtrip.stop.fillNoRange': 'Indica una autonomia per veure què dona.',
'roadtrip.stop.fillDefault': 'Usa el meu valor per defecte',
'roadtrip.stop.fillSet': 'Defineix quant s’omple en aquesta parada',
'roadtrip.leg.pending': 'Sense ruta',
'roadtrip.stop.addTitle': 'Afegeix com a parada',
'roadtrip.stop.kind': 'Tipus de parada',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} za {time}',
'roadtrip.day.stopCount': 'zastávek: {count}',
'roadtrip.stop.stayShort': 'Pobyt',
'roadtrip.stop.fillTitle': 'Natankuje na',
'roadtrip.stop.fillGives': 'asi {distance} odsud',
'roadtrip.stop.fillNoRange': 'Zadej dojezd, ať je vidět, co to vynese.',
'roadtrip.stop.fillDefault': 'Použít moji výchozí hodnotu',
'roadtrip.stop.fillSet': 'Nastavit, na kolik se tady tankuje',
'roadtrip.leg.pending': 'Bez trasy',
'roadtrip.stop.addTitle': 'Přidat jako zastávku',
'roadtrip.stop.kind': 'Druh zastávky',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} in {time}',
'roadtrip.day.stopCount': '{count} Stopps',
'roadtrip.stop.stayShort': 'Dauer',
'roadtrip.stop.fillTitle': 'Tankt auf',
'roadtrip.stop.fillGives': 'etwa {distance} ab hier',
'roadtrip.stop.fillNoRange': 'Trag eine Reichweite ein, dann steht hier, was das bringt.',
'roadtrip.stop.fillDefault': 'Meinen Standard nehmen',
'roadtrip.stop.fillSet': 'Festlegen, wie voll hier getankt wird',
'roadtrip.leg.pending': 'Keine Route',
'roadtrip.stop.addTitle': 'Als Stopp hinzufügen',
'roadtrip.stop.kind': 'Art des Stopps',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} in {time}',
'roadtrip.day.stopCount': '{count} stops',
'roadtrip.stop.stayShort': 'Stay',
'roadtrip.stop.fillTitle': 'Fills to',
'roadtrip.stop.fillGives': 'about {distance} from here',
'roadtrip.stop.fillNoRange': 'Set a range to see what that buys.',
'roadtrip.stop.fillDefault': 'Use my default',
'roadtrip.stop.fillSet': 'Set how full this stop fills',
'roadtrip.leg.pending': 'No route',
'roadtrip.stop.addTitle': 'Add as a stop',
'roadtrip.stop.kind': 'Kind of stop',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} en {time}',
'roadtrip.day.stopCount': '{count} paradas',
'roadtrip.stop.stayShort': 'Parada',
'roadtrip.stop.fillTitle': 'Reposta al',
'roadtrip.stop.fillGives': 'unos {distance} desde aquí',
'roadtrip.stop.fillNoRange': 'Indica una autonomía para ver lo que da.',
'roadtrip.stop.fillDefault': 'Usar mi valor por defecto',
'roadtrip.stop.fillSet': 'Definir cuánto se reposta en esta parada',
'roadtrip.leg.pending': 'Sin ruta',
'roadtrip.stop.addTitle': 'Añadir como parada',
'roadtrip.stop.kind': 'Tipo de parada',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} en {time}',
'roadtrip.day.stopCount': '{count} arrêts',
'roadtrip.stop.stayShort': 'Durée',
'roadtrip.stop.fillTitle': 'Remplit à',
'roadtrip.stop.fillGives': 'environ {distance} à partir d’ici',
'roadtrip.stop.fillNoRange': 'Indiquez une autonomie pour voir ce que cela donne.',
'roadtrip.stop.fillDefault': 'Utiliser ma valeur par défaut',
'roadtrip.stop.fillSet': 'Définir le niveau de remplissage de cet arrêt',
'roadtrip.leg.pending': 'Pas d’itinéraire',
'roadtrip.stop.addTitle': 'Ajouter comme arrêt',
'roadtrip.stop.kind': 'Type d’arrêt',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} σε {time}',
'roadtrip.day.stopCount': '{count} στάσεις',
'roadtrip.stop.stayShort': 'Στάση',
'roadtrip.stop.fillTitle': 'Γεμίζει στο',
'roadtrip.stop.fillGives': 'περίπου {distance} από εδώ',
'roadtrip.stop.fillNoRange': 'Δώσε μια αυτονομία για να φανεί τι αποδίδει.',
'roadtrip.stop.fillDefault': 'Χρήση της προεπιλογής μου',
'roadtrip.stop.fillSet': 'Όρισε πόσο γεμίζει αυτή η στάση',
'roadtrip.leg.pending': 'Χωρίς διαδρομή',
'roadtrip.stop.addTitle': 'Προσθήκη ως στάση',
'roadtrip.stop.kind': 'Είδος στάσης',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} {time} alatt',
'roadtrip.day.stopCount': '{count} megálló',
'roadtrip.stop.stayShort': 'Idő',
'roadtrip.stop.fillTitle': 'Feltölt eddig',
'roadtrip.stop.fillGives': 'innen körülbelül {distance}',
'roadtrip.stop.fillNoRange': 'Add meg a hatótávot, hogy látszódjon, mennyit ér.',
'roadtrip.stop.fillDefault': 'Az alapértelmezettet használom',
'roadtrip.stop.fillSet': 'Beállítás: mennyire tölt fel ez a megálló',
'roadtrip.leg.pending': 'Nincs útvonal',
'roadtrip.stop.addTitle': 'Hozzáadás megállóként',
'roadtrip.stop.kind': 'Megálló típusa',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} dalam {time}',
'roadtrip.day.stopCount': '{count} perhentian',
'roadtrip.stop.stayShort': 'Singgah',
'roadtrip.stop.fillTitle': 'Isi sampai',
'roadtrip.stop.fillGives': 'sekitar {distance} dari sini',
'roadtrip.stop.fillNoRange': 'Isi jarak jangkau untuk melihat hasilnya.',
'roadtrip.stop.fillDefault': 'Pakai bawaan saya',
'roadtrip.stop.fillSet': 'Atur seberapa penuh perhentian ini mengisi',
'roadtrip.leg.pending': 'Tidak ada rute',
'roadtrip.stop.addTitle': 'Tambahkan sebagai perhentian',
'roadtrip.stop.kind': 'Jenis perhentian',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} in {time}',
'roadtrip.day.stopCount': '{count} soste',
'roadtrip.stop.stayShort': 'Sosta',
'roadtrip.stop.fillTitle': 'Riempie al',
'roadtrip.stop.fillGives': 'circa {distance} da qui',
'roadtrip.stop.fillNoRange': 'Inserisci un’autonomia per vedere quanto rende.',
'roadtrip.stop.fillDefault': 'Usa il mio valore predefinito',
'roadtrip.stop.fillSet': 'Imposta quanto si riempie in questa sosta',
'roadtrip.leg.pending': 'Nessun percorso',
'roadtrip.stop.addTitle': 'Aggiungi come sosta',
'roadtrip.stop.kind': 'Tipo di sosta',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance}/{time}',
'roadtrip.day.stopCount': '{count} 箇所',
'roadtrip.stop.stayShort': '滞在',
'roadtrip.stop.fillTitle': '補給する量',
'roadtrip.stop.fillGives': 'ここから約 {distance}',
'roadtrip.stop.fillNoRange': '航続距離を入れると、これで何 km 走れるか出ます。',
'roadtrip.stop.fillDefault': '自分の既定値を使う',
'roadtrip.stop.fillSet': 'この停車地でどこまで補給するか決める',
'roadtrip.leg.pending': 'ルートなし',
'roadtrip.stop.addTitle': '立ち寄り先として追加',
'roadtrip.stop.kind': '立ち寄りの種類',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance}, {time}',
'roadtrip.day.stopCount': '{count}곳',
'roadtrip.stop.stayShort': '체류',
'roadtrip.stop.fillTitle': '충전 목표',
'roadtrip.stop.fillGives': '여기서 약 {distance}',
'roadtrip.stop.fillNoRange': '주행거리를 입력하면 얼마나 가는지 표시됩니다.',
'roadtrip.stop.fillDefault': '내 기본값 사용',
'roadtrip.stop.fillSet': '이 정차지에서 얼마나 충전할지 설정',
'roadtrip.leg.pending': '경로 없음',
'roadtrip.stop.addTitle': '경유지로 추가',
'roadtrip.stop.kind': '경유지 종류',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} in {time}',
'roadtrip.day.stopCount': '{count} stops',
'roadtrip.stop.stayShort': 'Duur',
'roadtrip.stop.fillTitle': 'Vult tot',
'roadtrip.stop.fillGives': 'ongeveer {distance} vanaf hier',
'roadtrip.stop.fillNoRange': 'Vul een actieradius in om te zien wat dat oplevert.',
'roadtrip.stop.fillDefault': 'Mijn standaard gebruiken',
'roadtrip.stop.fillSet': 'Instellen hoe vol er hier wordt getankt',
'roadtrip.leg.pending': 'Geen route',
'roadtrip.stop.addTitle': 'Als stop toevoegen',
'roadtrip.stop.kind': 'Soort stop',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} w {time}',
'roadtrip.day.stopCount': '{count} przystanków',
'roadtrip.stop.stayShort': 'Postój',
'roadtrip.stop.fillTitle': 'Tankuje do',
'roadtrip.stop.fillGives': 'około {distance} stąd',
'roadtrip.stop.fillNoRange': 'Podaj zasięg, żeby zobaczyć, ile to daje.',
'roadtrip.stop.fillDefault': 'Użyj mojej wartości domyślnej',
'roadtrip.stop.fillSet': 'Ustaw, do ile tankować na tym postoju',
'roadtrip.leg.pending': 'Brak trasy',
'roadtrip.stop.addTitle': 'Dodaj jako przystanek',
'roadtrip.stop.kind': 'Rodzaj przystanku',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} за {time}',
'roadtrip.day.stopCount': 'остановок: {count}',
'roadtrip.stop.stayShort': 'Стоянка',
'roadtrip.stop.fillTitle': 'Заправка до',
'roadtrip.stop.fillGives': 'примерно {distance} отсюда',
'roadtrip.stop.fillNoRange': 'Укажите запас хода, чтобы увидеть, сколько это даёт.',
'roadtrip.stop.fillDefault': 'Взять моё значение по умолчанию',
'roadtrip.stop.fillSet': 'Задать, насколько заправляться на этой остановке',
'roadtrip.leg.pending': 'Нет маршрута',
'roadtrip.stop.addTitle': 'Добавить как остановку',
'roadtrip.stop.kind': 'Тип остановки',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} på {time}',
'roadtrip.day.stopCount': '{count} stopp',
'roadtrip.stop.stayShort': 'Stopp',
'roadtrip.stop.fillTitle': 'Fyller till',
'roadtrip.stop.fillGives': 'cirka {distance} härifrån',
'roadtrip.stop.fillNoRange': 'Ange en räckvidd för att se vad det ger.',
'roadtrip.stop.fillDefault': 'Använd mitt standardvärde',
'roadtrip.stop.fillSet': 'Ange hur mycket det här stoppet fyller',
'roadtrip.leg.pending': 'Ingen rutt',
'roadtrip.stop.addTitle': 'Lägg till som stopp',
'roadtrip.stop.kind': 'Typ av stopp',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{time} içinde {distance}',
'roadtrip.day.stopCount': '{count} mola',
'roadtrip.stop.stayShort': 'Süre',
'roadtrip.stop.fillTitle': 'Şu kadar dolar',
'roadtrip.stop.fillGives': 'buradan yaklaşık {distance}',
'roadtrip.stop.fillNoRange': 'Ne kazandırdığını görmek için bir menzil gir.',
'roadtrip.stop.fillDefault': 'Kendi varsayılanımı kullan',
'roadtrip.stop.fillSet': 'Bu molada ne kadar doldurulacağını ayarla',
'roadtrip.leg.pending': 'Rota yok',
'roadtrip.stop.addTitle': 'Mola olarak ekle',
'roadtrip.stop.kind': 'Mola türü',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} за {time}',
'roadtrip.day.stopCount': 'зупинок: {count}',
'roadtrip.stop.stayShort': 'Стоянка',
'roadtrip.stop.fillTitle': 'Заправка до',
'roadtrip.stop.fillGives': 'приблизно {distance} звідси',
'roadtrip.stop.fillNoRange': 'Вкажіть запас ходу, щоб побачити, скільки це дає.',
'roadtrip.stop.fillDefault': 'Узяти моє значення за замовчуванням',
'roadtrip.stop.fillSet': 'Задати, наскільки заправлятися на цій зупинці',
'roadtrip.leg.pending': 'Немає маршруту',
'roadtrip.stop.addTitle': 'Додати як зупинку',
'roadtrip.stop.kind': 'Тип зупинки',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance} trong {time}',
'roadtrip.day.stopCount': '{count} điểm dừng',
'roadtrip.stop.stayShort': 'Dừng',
'roadtrip.stop.fillTitle': 'Đổ đến',
'roadtrip.stop.fillGives': 'khoảng {distance} từ đây',
'roadtrip.stop.fillNoRange': 'Nhập quãng đường để thấy được bao nhiêu.',
'roadtrip.stop.fillDefault': 'Dùng mặc định của tôi',
'roadtrip.stop.fillSet': 'Đặt mức đổ tại điểm dừng này',
'roadtrip.leg.pending': 'Không có lộ trình',
'roadtrip.stop.addTitle': 'Thêm làm điểm dừng',
'roadtrip.stop.kind': 'Loại điểm dừng',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance},{time}',
'roadtrip.day.stopCount': '{count} 個停靠點',
'roadtrip.stop.stayShort': '停留',
'roadtrip.stop.fillTitle': '加到',
'roadtrip.stop.fillGives': '從這裡約 {distance}',
'roadtrip.stop.fillNoRange': '填寫續航後,這裡會顯示能跑多遠。',
'roadtrip.stop.fillDefault': '使用我的預設值',
'roadtrip.stop.fillSet': '設定這一站加到多少',
'roadtrip.leg.pending': '無路線',
'roadtrip.stop.addTitle': '新增為停靠點',
'roadtrip.stop.kind': '停靠類型',
+5
View File
@@ -143,6 +143,11 @@ const roadtrip: TranslationStrings = {
'roadtrip.leg.driveText': '{distance},{time}',
'roadtrip.day.stopCount': '{count} 个停靠点',
'roadtrip.stop.stayShort': '停留',
'roadtrip.stop.fillTitle': '加到',
'roadtrip.stop.fillGives': '从这里约 {distance}',
'roadtrip.stop.fillNoRange': '填写续航后,这里会显示能跑多远。',
'roadtrip.stop.fillDefault': '使用我的默认值',
'roadtrip.stop.fillSet': '设置这一站加到多少',
'roadtrip.leg.pending': '无路线',
'roadtrip.stop.addTitle': '添加为停靠点',
'roadtrip.stop.kind': '停靠类型',
+28 -1
View File
@@ -94,6 +94,14 @@ export type PlaceRatingVote = z.infer<typeof placeRatingVoteSchema>;
export const roadtripStopTypeSchema = z.enum(['fuel', 'charging', 'rest_area', 'campsite', 'restaurant', 'sights']);
export type RoadtripStopType = z.infer<typeof roadtripStopTypeSchema>;
/**
* A percentage of a tank, 1 to 100, or null for "no opinion, use the setting".
*
* Integer because a tenth of a percent of a tank is not a thing anybody knows about
* their own car, and bounded away from zero because a fill of nothing is not a fill.
*/
const fillPercentSchema = z.number().int().min(1).max(100).nullable().optional();
export const placeSchema = z.object({
id: z.number(),
trip_id: z.number(),
@@ -128,6 +136,16 @@ export const placeSchema = z.object({
* already knows and that owns its own icon and colour.
*/
stop_type: roadtripStopTypeSchema.nullable().optional(),
/**
* How full THIS stop fills the tank, 1-100 (#1797). null follows the traveller's own
* setting, which is every place that predates the field.
*
* A property of the stop rather than of the person: a motorway rapid charger is worth
* 80 % because the last fifth costs as long again, while the one at the hotel is worth
* 100 % because the car stands there all night. One figure for the whole trip cannot
* say both, and the difference between them is a leg.
*/
fill_percent: fillPercentSchema,
website: z.string().nullable().optional(),
phone: z.string().nullable().optional(),
transport_mode: z.string().nullable().optional(),
@@ -175,6 +193,9 @@ export const assignmentPlaceSchema = z.object({
// Carried through so the road-trip rail can mark a fuel stop as one without a
// second request per stop.
stop_type: roadtripStopTypeSchema.nullable().optional(),
// Carried for the same reason as stop_type: the rail resets a range budget at this
// stop and needs to know how far it fills without a request per stop.
fill_percent: fillPercentSchema,
category: placeCategorySchema.optional(),
tags: z.array(tagSchema.partial()).optional(),
});
@@ -191,7 +212,13 @@ export type AssignmentPlace = z.infer<typeof assignmentPlaceSchema>;
* Nullable: an explicit null is how a fuel stop becomes an ordinary place again, and the
* service already reads it that way rather than as "leave alone".
*/
const stopTypeField = z.object({ stop_type: roadtripStopTypeSchema.nullable().optional() });
const stopTypeField = z.object({
stop_type: roadtripStopTypeSchema.nullable().optional(),
// Named for the same reason: a bounded vocabulary on an otherwise open body. Zero is
// outside it on purpose — a stop that fills nothing is not a stop, and letting one
// through would leave a range budget that never resets.
fill_percent: fillPercentSchema,
});
export const placeCreateRequestSchema = open.and(z.object({ name: z.string().min(1) })).and(stopTypeField);
export type PlaceCreateRequest = z.infer<typeof placeCreateRequestSchema>;