feat: custom types can bind a field layout (profile) - layout select in type editor, respected in record form
This commit is contained in:
+6
-5
@@ -125,6 +125,7 @@ function preMigrateColumns(d) {
|
||||
}
|
||||
};
|
||||
for (const t of SYNC_TABLES) addCols(t, SYNC_COLS);
|
||||
addCols('footprint_type', [['profile', 'TEXT']]);
|
||||
addCols('attachment', [['sha256', 'TEXT'], ['thumb_rel_path', 'TEXT'], ['remote_url', 'TEXT'], ['remote_thumb', 'TEXT'], ['remote_key', 'TEXT'], ['remote_thumb_key', 'TEXT']]);
|
||||
}
|
||||
|
||||
@@ -564,7 +565,7 @@ function listFootprints(d, query) {
|
||||
const items = d.prepare(`
|
||||
SELECT t.*, (SELECT COUNT(*) FROM footprint f WHERE f.type_id = t.id AND f.deleted_at IS NULL) AS usage_count
|
||||
FROM footprint_type t WHERE t.deleted_at IS NULL ORDER BY t.sort, t.id`).all()
|
||||
.map(t => ({ ...t, form_template: JSON.parse(t.form_template || '[]'), is_builtin: !!t.is_builtin, closed: !!t.closed }));
|
||||
.map(t => ({ ...t, form_template: JSON.parse(t.form_template || '[]'), profile: t.profile ?? null, is_builtin: !!t.is_builtin, closed: !!t.closed }));
|
||||
return { items };
|
||||
}
|
||||
|
||||
@@ -575,8 +576,8 @@ function listFootprints(d, query) {
|
||||
if (id) {
|
||||
withTx(d, () => {
|
||||
const h = hlcNext(d);
|
||||
d.prepare('UPDATE footprint_type SET name=?, icon=?, color=?, sort=?, form_template=?, closed=?, hlc=? WHERE id=?')
|
||||
.run(p.name, p.icon, p.color, p.sort, tpl, p.closed ? 1 : 0, h, id);
|
||||
d.prepare('UPDATE footprint_type SET name=?, icon=?, color=?, sort=?, form_template=?, profile=?, closed=?, hlc=? WHERE id=?')
|
||||
.run(p.name, p.icon, p.color, p.sort, tpl, p.profile ?? null, p.closed ? 1 : 0, h, id);
|
||||
touchOplog(d, 'footprint_type', getUuid(d, 'footprint_type', id), 'upsert', h);
|
||||
});
|
||||
} else {
|
||||
@@ -584,8 +585,8 @@ function listFootprints(d, query) {
|
||||
const h = hlcNext(d);
|
||||
const uuid = uuidv7();
|
||||
id = Number(d.prepare(
|
||||
'INSERT INTO footprint_type (name, icon, color, sort, form_template, closed, uuid, hlc, origin) VALUES (?,?,?,?,?,?,?,?,?)')
|
||||
.run(p.name, p.icon, p.color, p.sort, tpl, p.closed ? 1 : 0, uuid, h, getDeviceId(d)).lastInsertRowid);
|
||||
'INSERT INTO footprint_type (name, icon, color, sort, form_template, profile, closed, uuid, hlc, origin) VALUES (?,?,?,?,?,?,?,?,?,?,?)')
|
||||
.run(p.name, p.icon, p.color, p.sort, tpl, p.profile ?? null, p.closed ? 1 : 0, uuid, h, getDeviceId(d)).lastInsertRowid);
|
||||
touchOplog(d, 'footprint_type', uuid, 'upsert', h);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user