new widget types 3

This commit is contained in:
davmar
2026-09-10 17:37:10 +02:00
parent 68a2a484c6
commit ecc5185d3b
2 changed files with 43 additions and 42 deletions
@@ -6,7 +6,9 @@ migrate((app) => {
const col = app.findCollectionByNameOrId("home_filter_widgets"); const col = app.findCollectionByNameOrId("home_filter_widgets");
if (col.fields.getByName("half_width")) return; if (col.fields.getByName("half_width")) return;
col.fields.add(new BoolField({ // Automigrate-style constructor (plain objects are rejected by fields.add).
col.fields.add(new Field({
type: "bool",
name: "half_width", name: "half_width",
required: false, required: false,
})); }));
@@ -2,47 +2,46 @@
migrate((app) => { migrate((app) => {
const col = app.findCollectionByNameOrId("home_filter_widgets"); const col = app.findCollectionByNameOrId("home_filter_widgets");
if (!col.fields.getByName("widget_type")) { const addIfMissing = (config) => {
col.fields.add(new TextField({ if (col.fields.getByName(config.name)) return;
name: "widget_type", col.fields.add(new Field(config));
required: false, };
max: 40,
})); addIfMissing({
} type: "text",
if (!col.fields.getByName("icon_id")) { name: "widget_type",
col.fields.add(new TextField({ required: false,
name: "icon_id", max: 40,
required: false, });
max: 40, addIfMissing({
})); type: "text",
} name: "icon_id",
if (!col.fields.getByName("chart_style")) { required: false,
col.fields.add(new TextField({ max: 40,
name: "chart_style", });
required: false, addIfMissing({
max: 40, type: "text",
})); name: "chart_style",
} required: false,
if (!col.fields.getByName("budget_cap_mode")) { max: 40,
col.fields.add(new TextField({ });
name: "budget_cap_mode", addIfMissing({
required: false, type: "text",
max: 40, name: "budget_cap_mode",
})); required: false,
} max: 40,
if (!col.fields.getByName("budget_fixed_amount")) { });
col.fields.add(new NumberField({ addIfMissing({
name: "budget_fixed_amount", type: "number",
required: false, name: "budget_fixed_amount",
})); required: false,
} });
if (!col.fields.getByName("budget_average_months")) { addIfMissing({
col.fields.add(new NumberField({ type: "number",
name: "budget_average_months", name: "budget_average_months",
required: false, required: false,
onlyInt: true, onlyInt: true,
})); });
}
app.save(col); app.save(col);
}, (app) => { }, (app) => {