feat(template): per-experiment daily record template — rename/add/hide fields, custom_fields JSONB
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* The default daily-record template applied to every new experiment
|
||||
* (and returned as a fallback when an experiment's template is empty).
|
||||
*
|
||||
* `builtin: true` — value lives in the named column of daily_statuses
|
||||
* `builtin: false` — value lives in daily_statuses.custom_fields JSON
|
||||
* `active: false` — field is hidden (not deleted; data preserved)
|
||||
*/
|
||||
const DEFAULT_TEMPLATE = [
|
||||
{ key: 'experiment_description', label: 'Experiment Description', type: 'textarea', builtin: true, active: true },
|
||||
{ key: 'vitals', label: 'Vitals', type: 'text', builtin: true, active: true },
|
||||
{ key: 'treatment', label: 'Treatment', type: 'text', builtin: true, active: true },
|
||||
{ key: 'notes', label: 'Notes', type: 'textarea', builtin: true, active: true },
|
||||
];
|
||||
|
||||
/**
|
||||
* Resolve the effective template for an experiment.
|
||||
* If the stored template is empty (new experiment), return the default.
|
||||
*/
|
||||
function resolveTemplate(stored) {
|
||||
if (!Array.isArray(stored) || stored.length === 0) return DEFAULT_TEMPLATE;
|
||||
return stored;
|
||||
}
|
||||
|
||||
module.exports = { DEFAULT_TEMPLATE, resolveTemplate };
|
||||
Reference in New Issue
Block a user