diff --git a/data/furniture.json b/data/furniture.json new file mode 100644 index 0000000..19c2710 --- /dev/null +++ b/data/furniture.json @@ -0,0 +1,121 @@ +{ + "units": [ + { + "name": "Library Kallax", + "openings": [ + { + "id": "library-kallax-a1", + "label": "A1", + "zone": "oversize", + "width_in": 26.5, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-a2", + "label": "A2", + "zone": "oversize", + "width_in": 26.5, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-b1", + "label": "B1", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-b2", + "label": "B2", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-b3", + "label": "B3", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-b4", + "label": "B4", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-c1", + "label": "C1", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-c2", + "label": "C2", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-c3", + "label": "C3", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-c4", + "label": "C4", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-d1", + "label": "D1", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-d2", + "label": "D2", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-d3", + "label": "D3", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + }, + { + "id": "library-kallax-d4", + "label": "D4", + "zone": "cubes", + "width_in": 13.25, + "height_in": 13.25, + "depth_in": 15.4 + } + ] + } + ] +} diff --git a/src/bggpipe/templates/pages/shelves.html b/src/bggpipe/templates/pages/shelves.html index 4243eda..11c8324 100644 --- a/src/bggpipe/templates/pages/shelves.html +++ b/src/bggpipe/templates/pages/shelves.html @@ -110,13 +110,17 @@ function unitBlock(u) {
${u.openings.map(openingCell).join("")}
`; @@ -259,12 +263,27 @@ function wire() { alert("Give all three interior dimensions, or none for a no-limit spot."); return; } - await post("/api/furniture/add-openings", { - unit: form.dataset.unit, label: f.label.value, zone: f.zone.value, - width_in: parseFloat(f.width_in.value) || null, - height_in: parseFloat(f.height_in.value) || null, - depth_in: parseFloat(f.depth_in.value) || null, - }); + const rows = parseInt(f.rows.value) || 1; + const cols = parseInt(f.cols.value) || 1; + const grid = rows * cols > 1; + if (!grid && !f.label.value.trim()) { + alert("A single opening needs a label (or set rows × columns for a grid)."); + return; + } + const btn = form.querySelector('button[type="submit"]'); + if (btn.disabled) return; + btn.disabled = true; + try { + await post("/api/furniture/add-openings", { + unit: form.dataset.unit, zone: f.zone.value, + ...(grid ? {rows, cols} : {label: f.label.value}), + width_in: parseFloat(f.width_in.value) || null, + height_in: parseFloat(f.height_in.value) || null, + depth_in: parseFloat(f.depth_in.value) || null, + }); + } finally { + btn.disabled = false; + } }); }