mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
revert(collections): a saved place carries no price, website or phone again
Takes back the editable price, currency, website and phone on collection places from0df82185band its review follow-up ina910c2a83. Costs are kept inside a trip only; a collection does not carry them, and #2471 is a feature request rather than a bug. The collection files are back to how they were before, including the dimmed save button fromf16698bdb, which only mattered for the price field.
This commit is contained in:
@@ -229,7 +229,7 @@ export class CollectionsMcp {
|
||||
|
||||
@Tool({
|
||||
name: 'update_collection_place',
|
||||
description: 'Update a saved place\'s name, address, coordinates (lat/lng), description, notes, price with currency (a rough cost such as an entry fee; always send the three-letter currency with a price, since a collection has no base currency, and it travels into a trip when the place is copied there), website, phone, status, category, links, tags, labels, image, or move it to another collection (set collection_id).',
|
||||
description: 'Update a saved place\'s name, address, coordinates (lat/lng), description, notes, status, category, links, tags, labels, image, or move it to another collection (set collection_id).',
|
||||
inputSchema: { placeId: z.number().int().positive(), ...collectionPlaceUpdateRequestSchema.shape, links: linksInput },
|
||||
annotations: TOOL_ANNOTATIONS_WRITE,
|
||||
when: collectionsAddonOn,
|
||||
|
||||
@@ -995,7 +995,6 @@ export class CollectionsService {
|
||||
async updatePlace(userId: number, placeId: number, body: CollectionPlaceUpdateRequest, socketId?: string): Promise<CollectionPlace> {
|
||||
const currentCollection = this.collectionIdOfPlace(placeId);
|
||||
this.assertCanEdit(userId, currentCollection);
|
||||
if (body.price !== undefined || body.currency !== undefined) this.assertPriceHasCurrency(placeId, body);
|
||||
|
||||
// Capture the previous thumbnail so a replaced/cleared custom upload (#1136)
|
||||
// can be reclaimed once nothing references it any more.
|
||||
@@ -1011,10 +1010,6 @@ export class CollectionsService {
|
||||
if (body.lat !== undefined) { updates.push('lat = ?'); params.push(body.lat ?? null); }
|
||||
if (body.lng !== undefined) { updates.push('lng = ?'); params.push(body.lng ?? null); }
|
||||
if (body.address !== undefined) { updates.push('address = ?'); params.push(body.address ?? null); }
|
||||
if (body.price !== undefined) { updates.push('price = ?'); params.push(body.price ?? null); }
|
||||
if (body.currency !== undefined) { updates.push('currency = ?'); params.push(body.currency ?? null); }
|
||||
if (body.website !== undefined) { updates.push('website = ?'); params.push(body.website ?? null); }
|
||||
if (body.phone !== undefined) { updates.push('phone = ?'); params.push(body.phone ?? null); }
|
||||
if (body.status !== undefined) { updates.push('status = ?'); params.push(body.status); }
|
||||
if (body.category_id !== undefined) { updates.push('category_id = ?'); params.push(body.category_id ?? null); }
|
||||
if (body.image_url !== undefined) { updates.push('image_url = ?'); params.push(body.image_url ?? null); }
|
||||
@@ -1057,23 +1052,6 @@ export class CollectionsService {
|
||||
return this.getPlaceById(placeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* A list has no base currency, so a price that names none would be read in
|
||||
* each viewer's own default currency and carried into a trip as the trip's
|
||||
* (#2471). Checked here rather than in the contract so REST and the MCP tool,
|
||||
* which spreads the contract's shape, refuse it alike. Only the row as it
|
||||
* would look after this update counts, so a zero price or clearing both
|
||||
* fields still goes through.
|
||||
*/
|
||||
private assertPriceHasCurrency(placeId: number, body: Pick<CollectionPlaceUpdateRequest, 'price' | 'currency'>): void {
|
||||
const stored = this.db.get<{ price: number | null; currency: string | null }>(
|
||||
'SELECT price, currency FROM collection_places WHERE id = ?', placeId,
|
||||
);
|
||||
const price = body.price === undefined ? stored?.price ?? null : body.price;
|
||||
const currency = body.currency === undefined ? stored?.currency ?? null : body.currency;
|
||||
if (price != null && price > 0 && !currency) httpError(400, 'A price needs a currency: send its three-letter code along');
|
||||
}
|
||||
|
||||
setStatus(userId: number, placeId: number, status: CollectionStatus, socketId?: string): CollectionPlace {
|
||||
const collectionId = this.collectionIdOfPlace(placeId);
|
||||
this.assertCanEdit(userId, collectionId);
|
||||
|
||||
Reference in New Issue
Block a user