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;
col.fields.add(new Field(config));
};
addIfMissing({
type: "text",
name: "widget_type", name: "widget_type",
required: false, required: false,
max: 40, max: 40,
})); });
} addIfMissing({
if (!col.fields.getByName("icon_id")) { type: "text",
col.fields.add(new TextField({
name: "icon_id", name: "icon_id",
required: false, required: false,
max: 40, max: 40,
})); });
} addIfMissing({
if (!col.fields.getByName("chart_style")) { type: "text",
col.fields.add(new TextField({
name: "chart_style", name: "chart_style",
required: false, required: false,
max: 40, max: 40,
})); });
} addIfMissing({
if (!col.fields.getByName("budget_cap_mode")) { type: "text",
col.fields.add(new TextField({
name: "budget_cap_mode", name: "budget_cap_mode",
required: false, required: false,
max: 40, max: 40,
})); });
} addIfMissing({
if (!col.fields.getByName("budget_fixed_amount")) { type: "number",
col.fields.add(new NumberField({
name: "budget_fixed_amount", name: "budget_fixed_amount",
required: false, required: false,
})); });
} addIfMissing({
if (!col.fields.getByName("budget_average_months")) { type: "number",
col.fields.add(new NumberField({
name: "budget_average_months", name: "budget_average_months",
required: false, required: false,
onlyInt: true, onlyInt: true,
})); });
}
app.save(col); app.save(col);
}, (app) => { }, (app) => {