Add bin types: reusable named dimension presets for bins
Bin types store a name, physical W×H in mm, and optional description. When editing a bin, a type can be selected from a dropdown; this pre-fills and locks the dimension inputs. Custom dimensions remain available when no type is selected. - lib/storage.mjs: bin type CRUD with bt: prefix - server.mjs: /api/bin-types CRUD routes; type_id accepted on bin create/update routes; DELETE protected if any bin references the type; type dims copied onto bin when type_id is set - public/lib/api.mjs: bin type wrappers; rename_bin → update_bin (accepts any fields) - public/templates.html: Types tab in bins section; t-bin-type-row; t-dialog-bin-type; type selector in bin editor dialog - public/app.mjs: all_bin_types state loaded at startup; render_bin_types_list(); open_bin_type_dialog(); type selector in open_bin_editor(); /bins/types routing - public/style.css: bin types list styles Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -174,6 +174,28 @@ export function find_pdf_references(pdf_id) {
|
||||
return list_components().filter(c => c.file_ids?.includes(pdf_id));
|
||||
}
|
||||
|
||||
// --- Bin types ---
|
||||
|
||||
export function list_bin_types() {
|
||||
const result = [];
|
||||
for (const [key] of store.data.entries()) {
|
||||
if (key.startsWith('bt:')) result.push(store.get(key));
|
||||
}
|
||||
return result.sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
|
||||
export function get_bin_type(id) {
|
||||
return store.get(`bt:${id}`) ?? null;
|
||||
}
|
||||
|
||||
export function set_bin_type(bt) {
|
||||
store.set(`bt:${bt.id}`, bt);
|
||||
}
|
||||
|
||||
export function delete_bin_type(id) {
|
||||
return store.delete(`bt:${id}`);
|
||||
}
|
||||
|
||||
// --- Bins ---
|
||||
|
||||
export function list_bins() {
|
||||
|
||||
Reference in New Issue
Block a user