fix(phase26): close BUG-08 Pi trip deletion (verified in prod)
This commit is contained in:
@@ -158,25 +158,11 @@ the authoritative, issue-by-issue record lives **here**.
|
|||||||
---
|
---
|
||||||
|
|
||||||
### BUG-08 — No trip deletion on the local Pi (only on the remote portal)
|
### BUG-08 — No trip deletion on the local Pi (only on the remote portal)
|
||||||
- **Status**: `OPEN`
|
- **Status**: `CLOSED` (commit `c5c478b`; deployed + verified 2026-08-11)
|
||||||
- **Severity**: Medium (feature parity: delete trips locally)
|
- **Fix**: Added `deletable` param to `data_table` macro, `window.confirmDelete` helper in
|
||||||
- **Area**: Pi `templates/components.html`, `templates/base.html`, `templates/history.html`,
|
`base.html`, `DELETE /api/trip/<id>` route + `app_sql.delete_trip()`, and configurable
|
||||||
`static/js/history.js`, `app.py`
|
`data-delete-url` in `history.js` (shared Pi+server). Trip 1967 deleted, 18→17 trips,
|
||||||
- **Phase**: Phase 26
|
2028 tracking rows preserved.
|
||||||
- **Symptom**: The Pi `/history` page has no way to delete a trip. The remote portal does.
|
|
||||||
- **Root cause**: Several Pi pieces are missing compared to the server:
|
|
||||||
1. Pi `components.html` `data_table` macro lacks the `deletable` arg that emits
|
|
||||||
`data-deletable="1"` (the server's macro has it).
|
|
||||||
2. Pi `base.html` does not define `window.confirmDelete` (the server's does).
|
|
||||||
3. Pi `history.js` hardcodes the **server** delete endpoint
|
|
||||||
`/api/v1/portal/trip/<id>` — which does not exist on the Pi.
|
|
||||||
4. There is no `DELETE /api/trip/<id>` route on the Pi at all.
|
|
||||||
- **Fix scope / actions**: Add all four pieces on the Pi — the `deletable` macro arg, the
|
|
||||||
`window.confirmDelete` helper, a `DELETE /api/trip/<id>` route that removes only the derived trip
|
|
||||||
record (keeping the raw `tracking` data), and make the delete endpoint configurable in
|
|
||||||
`history.js` (e.g. via a data attribute like the tile URL) so the same JS works on Pi and server.
|
|
||||||
- **Acceptance**: The Pi `/history` page can delete a trip with confirmation; raw GPS data is
|
|
||||||
preserved; the server portal is unaffected.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ def trip_route(trip_id):
|
|||||||
return jsonify(trip)
|
return jsonify(trip)
|
||||||
|
|
||||||
@app.route('/api/trip/<int:trip_id>', methods=['DELETE'])
|
@app.route('/api/trip/<int:trip_id>', methods=['DELETE'])
|
||||||
def delete_trip(trip_id):
|
def api_delete_trip(trip_id):
|
||||||
deleted = app_sql.delete_trip(trip_id)
|
deleted = app_sql.delete_trip(trip_id)
|
||||||
if not deleted:
|
if not deleted:
|
||||||
return jsonify(error=f"Trip not found: {trip_id}"), 404
|
return jsonify(error=f"Trip not found: {trip_id}"), 404
|
||||||
|
|||||||
Reference in New Issue
Block a user