From 7c7291c2817bd71704f85c97cfe0e65f63c11c3f Mon Sep 17 00:00:00 2001 From: Michael Bauer <michael-bauer@posteo.de> Date: Thu, 17 Apr 2025 20:32:05 +0200 Subject: [PATCH] Make objectForm implicitly handle undefined isCreate depending on the presence of editItem. For the rationale see comment in change. --- CHANGELOG.rst | 1 + aleksis/core/frontend/mixins/createOrPatchPropsMixin.js | 2 +- aleksis/core/frontend/mixins/objectFormMixin.js | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e84fcd3a8..e40fc5f9f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,7 @@ Changed * Announcements are shown in calendar. * DialogObjectForm is now slightly wider. +* [Dev] DialogObjectForm now implicitly handles a missing isCreate-prop depending on the presence of editItem. Fixed ~~~~~ diff --git a/aleksis/core/frontend/mixins/createOrPatchPropsMixin.js b/aleksis/core/frontend/mixins/createOrPatchPropsMixin.js index c91221369..5b0cf78d2 100644 --- a/aleksis/core/frontend/mixins/createOrPatchPropsMixin.js +++ b/aleksis/core/frontend/mixins/createOrPatchPropsMixin.js @@ -15,7 +15,7 @@ export default { isCreate: { type: Boolean, required: false, - default: true, + default: undefined, }, /** * The graphQL create mutation diff --git a/aleksis/core/frontend/mixins/objectFormMixin.js b/aleksis/core/frontend/mixins/objectFormMixin.js index 6797590d2..08bd7ff78 100644 --- a/aleksis/core/frontend/mixins/objectFormMixin.js +++ b/aleksis/core/frontend/mixins/objectFormMixin.js @@ -55,6 +55,13 @@ export default { this.resetModel(); }, resetModel() { + // Handle isCreate undefined, by deciding on the presence of editItem + // This implicit behaviour often makes more sense + // and doing it higher up (in parent) makes parent less flexible. + // Specifically not working anymore with CRUD. + if (!this.isCreate) { + this.isCreate = !this.editItem; + } this.itemModel = JSON.parse( JSON.stringify(this.isCreate ? this.defaultItem : this.editItem), ); -- GitLab