mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 07:07:31 +00:00
feat(tours): places along the tour picked on the map, stops that keep their kind, and calmer station rows
Along the tour (PLN-02, PLN-03): the list shows one line per place (its icon, name and distance from the route) and scrolls past ten. A place picked in the list or on the map opens its card over the map, where the other cards of the planner sit, with what the source says and the way to take it in as a stop. What taking it in did is one line in the list. The intro, the theme line and the out-of-date note are gone: the themes say what they look for on hover, and the search button says when to search again. A stop taken in from there keeps the kind of place it was found as (migration 045400, poi_category, read back only where the contract knows the kind) and its number carries that kind's icon at the corner, as a via ferrata's end does. City walks (CW-02, CW-03, CW-10): a stay nobody entered says nothing. While no stay is entered at all the walk is planned as its walking time, with no "unknown" and no "at least". A must-see rings its number, an optional stop has a dashed ring, a protected one a shield at the corner; only the stay stays under the name, below the coordinates.
This commit is contained in:
@@ -23,6 +23,7 @@ export class TourWaypoints {
|
||||
importance?: TTourWaypointsImportance | null;
|
||||
protected: number & Opt = 0;
|
||||
opening_hours?: string | null;
|
||||
poi_category?: string | null;
|
||||
}
|
||||
|
||||
export const TourWaypointsImportance = {
|
||||
@@ -70,5 +71,6 @@ export const TourWaypointsSchema = defineEntity({
|
||||
importance: p.enum(() => TourWaypointsImportance).nullable(),
|
||||
protected: p.integer().default(0),
|
||||
opening_hours: p.text().nullable(),
|
||||
poi_category: p.text().nullable(),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -19,4 +19,5 @@ export interface TourWaypointsTable {
|
||||
importance: InsertOptional<string | null>;
|
||||
protected: InsertOptional<number>;
|
||||
opening_hours: InsertOptional<string | null>;
|
||||
poi_category: InsertOptional<string | null>;
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { Migration } from '@mikro-orm/migrations';
|
||||
|
||||
/**
|
||||
* PLN-03: a point taken in from the places found along a tour keeps the kind
|
||||
* of place it was found as (a restaurant, a museum), so the planner can mark
|
||||
* its row with that kind's icon as the map drew the place. Plain text, read
|
||||
* back only where the contract knows the kind, so a kind added later needs no
|
||||
* migration. NULL on every point saved before and on a point set by hand.
|
||||
*/
|
||||
export class Migration20200101045400_a_tour_waypoint_remembers_the_kind_of_place_it_was_found_as extends Migration {
|
||||
override name = 'Migration20200101045400_a_tour_waypoint_remembers_the_kind_of_place_it_was_found_as';
|
||||
|
||||
override up(): void {
|
||||
this.addSql('ALTER TABLE tour_waypoints ADD COLUMN poi_category TEXT');
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import type { TourWaypoints, TTourWaypointsImportance } from '../entities/TourWa
|
||||
import { TOUR_WAYPOINT_FIXED_LEG, TOUR_WAYPOINT_LOCK } from '../json-columns';
|
||||
import type { DB } from '../kysely/db';
|
||||
import { TrekRepository } from './_shared/trek-repository';
|
||||
import type { PaddleLock, TourFixedLeg } from '@trek/shared';
|
||||
import { TOUR_POI_CATEGORIES, type PaddleLock, type TourFixedLeg, type TourPoiCategory } from '@trek/shared';
|
||||
|
||||
/** One saved routing control point of a tour, in route order. */
|
||||
export interface TourWaypointRow {
|
||||
@@ -31,6 +31,8 @@ export interface TourWaypointRow {
|
||||
protected?: boolean;
|
||||
/** CW-04: the station's opening hours as OpenStreetMap writes them; absent where there are none. */
|
||||
opening_hours?: string | null;
|
||||
/** PLN-03: the kind of place the point was taken in from along the tour; absent on a point set by hand. */
|
||||
poi_category?: TourPoiCategory | null;
|
||||
}
|
||||
|
||||
/** The row as stored, the fixed leg still JSON text. */
|
||||
@@ -49,6 +51,7 @@ interface StoredWaypoint {
|
||||
importance: TTourWaypointsImportance | null;
|
||||
protected: number;
|
||||
opening_hours: string | null;
|
||||
poi_category: string | null;
|
||||
}
|
||||
|
||||
/** The columns a waypoint is read with, as the stored row names them. */
|
||||
@@ -67,13 +70,20 @@ const WAYPOINT_COLUMNS = [
|
||||
'importance',
|
||||
'protected',
|
||||
'opening_hours',
|
||||
'poi_category',
|
||||
] as const;
|
||||
|
||||
/** A stored kind the contract knows; one it does not (dropped since) reads as none. */
|
||||
function poiCategoryOf(stored: string | null): TourPoiCategory | null {
|
||||
return TOUR_POI_CATEGORIES.find((category) => category === stored) ?? null;
|
||||
}
|
||||
|
||||
/** A stored row as callers read it: every optional part left out entirely where there is none. */
|
||||
function readWaypoint(row: StoredWaypoint): TourWaypointRow {
|
||||
const { fixed_leg, lock, shaping, linked_place_id, station_key, name, stay_minutes, importance, opening_hours } = row;
|
||||
const leg = decodeJson(TOUR_WAYPOINT_FIXED_LEG, fixed_leg, 'tour waypoint');
|
||||
const stop = decodeJson(TOUR_WAYPOINT_LOCK, lock, 'tour waypoint');
|
||||
const poi_category = poiCategoryOf(row.poi_category);
|
||||
return {
|
||||
lat: row.lat,
|
||||
lng: row.lng,
|
||||
@@ -89,6 +99,7 @@ function readWaypoint(row: StoredWaypoint): TourWaypointRow {
|
||||
...(importance ? { importance } : {}),
|
||||
...(row.protected ? { protected: true } : {}),
|
||||
...(opening_hours ? { opening_hours } : {}),
|
||||
...(poi_category ? { poi_category } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -184,6 +195,7 @@ export class TourWaypointsRepository extends TrekRepository<TourWaypoints> {
|
||||
importance: w.importance ?? null,
|
||||
protected: w.protected ? 1 : 0,
|
||||
opening_hours: w.opening_hours ?? null,
|
||||
poi_category: w.poi_category ?? null,
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user