place-contrib: community hours in the details' own shape, and no origin rows for collection copies

Community opening hours laid over OSM details now go through the same parser
as OSM's own, so they arrive as one line per day with open-now and the periods,
and a community description lands in the details' summary. A place copied from
a collection no longer records its values as an import: without an origin row a
value is never sent anyway, and a later edit marks only the fields it changes.
This commit is contained in:
Maurice
2026-10-30 21:04:15 +01:00
parent f01ffc2c67
commit 04458bee12
8 changed files with 19 additions and 23 deletions
+11 -2
View File
@@ -1,3 +1,4 @@
import { buildOsmDetails } from './maps.helpers';
import { trekCommunityByKeys, type TrekCommunityValues } from './trek-places.client';
import { normalizePlaceWebsite } from '@trek/shared';
@@ -26,8 +27,16 @@ export function withCommunityValues(
if (website) out.website = website;
if (values.contact?.phone) out.phone = values.contact.phone;
if (values.contact?.email) out.email = values.contact.email;
if (values.hours?.osm) out.opening_hours = values.hours.osm;
if (values.description?.text) out.description = values.description.text;
if (values.hours?.osm) {
// The same shape OSM's own hours take in the details: one line per day, open now, the periods.
const hours = buildOsmDetails({ opening_hours: values.hours.osm }, '', '');
if (hours.opening_hours) {
out.opening_hours = hours.opening_hours;
out.open_now = hours.open_now;
out.opening_periods = hours.opening_periods;
}
}
if (values.description?.text) out.summary = values.description.text;
if (typeof values.community.version === 'number') out.community_version = values.community.version;
return out;
}