diff --git a/lib/model/frames/form.js b/lib/model/frames/form.js index 7627fbbc5..7a3b79bf1 100644 --- a/lib/model/frames/form.js +++ b/lib/model/frames/form.js @@ -76,8 +76,8 @@ class Form extends Frame.define( .then((partial) => partial.with({ key: Option.of(key) })); } - async withUpgradeEntityVersion() { - const xml = await updateEntityForm(this.xml, '2023.1.0', '2024.1.0', '_upgrade'); + async withUpgradeEntityVersion(oldVersion, newVersion, suffix) { + const xml = await updateEntityForm(this.xml, oldVersion, newVersion, suffix); // If the XML doesnt change (not the version in question, or a parsing error), don't return the new partial Form if (xml === this.xml) return null; diff --git a/lib/worker/form.js b/lib/worker/form.js index 47a3c8a8b..bc9e2cb94 100644 --- a/lib/worker/form.js +++ b/lib/worker/form.js @@ -46,14 +46,14 @@ const updateEntitiesVersion = async ({ Forms }, event) => { const { projectId, xmlFormId } = await Forms.getByActeeIdForUpdate(event.acteeId).then(o => o.get()); const publishedVersion = await Forms.getByProjectAndXmlFormId(projectId, xmlFormId, true, Form.PublishedVersion).then(o => o.orNull()); if (publishedVersion && publishedVersion.currentDefId != null) { - const partial = await publishedVersion.withUpgradeEntityVersion(); + const partial = await publishedVersion.withUpgradeEntityVersion('2023.1.0', '2024.1.0', '_upgrade'); if (partial != null) await Forms.createVersion(partial, publishedVersion, true, true); } const draftVersion = await Forms.getByProjectAndXmlFormId(projectId, xmlFormId, true, Form.DraftVersion).then(o => o.orNull()); if (draftVersion && draftVersion.draftDefId != null) { - const partial = await draftVersion.withUpgradeEntityVersion(); + const partial = await draftVersion.withUpgradeEntityVersion('2023.1.0', '2024.1.0', '_upgrade'); // update xml and version in place if (partial != null) await Forms._updateDef(draftVersion.def, { xml: partial.xml, version: partial.def.version });