Add grid cell inventory linking and component quick-create

- New 'grid' location type on inventory entries (grid_id, grid_row, grid_col)
- Clicking a grid cell shows a popup with what's stored there
- Popup has '+ Add entry' pre-filled with the cell coordinates
- Inventory dialog: 'New...' button next to component selector opens
  component creation dialog on top, returns with new component selected
- Grid entries display as e.g. 'Black Component Box R3C5' in lists
- Store original filename on source image upload

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-20 23:53:06 +00:00
parent cf37759893
commit 6c37912ec5
4 changed files with 267 additions and 13 deletions

View File

@@ -156,7 +156,8 @@ app.get('/api/inventory', (req, res) => {
});
app.post('/api/inventory', (req, res) => {
const { component_id, location_type, location_ref = '', quantity = '', notes = '' } = req.body;
const { component_id, location_type, location_ref = '', quantity = '', notes = '',
grid_id = null, grid_row = null, grid_col = null } = req.body;
if (!component_id) return fail(res, 'component_id is required');
if (!location_type) return fail(res, 'location_type is required');
if (!get_component(component_id)) return fail(res, 'component not found', 404);
@@ -168,6 +169,9 @@ app.post('/api/inventory', (req, res) => {
location_ref: String(location_ref).trim(),
quantity: String(quantity).trim(),
notes: String(notes).trim(),
grid_id: grid_id ?? null,
grid_row: grid_row != null ? parseInt(grid_row) : null,
grid_col: grid_col != null ? parseInt(grid_col) : null,
images: [],
created_at: now,
updated_at: now,
@@ -185,6 +189,9 @@ app.put('/api/inventory/:id', (req, res) => {
if (location_ref !== undefined) updated.location_ref = String(location_ref).trim();
if (quantity !== undefined) updated.quantity = String(quantity).trim();
if (notes !== undefined) updated.notes = String(notes).trim();
if (req.body.grid_id !== undefined) updated.grid_id = req.body.grid_id ?? null;
if (req.body.grid_row !== undefined) updated.grid_row = req.body.grid_row != null ? parseInt(req.body.grid_row) : null;
if (req.body.grid_col !== undefined) updated.grid_col = req.body.grid_col != null ? parseInt(req.body.grid_col) : null;
set_inventory_entry(updated);
ok(res, { entry: updated });
});