Skip to content
Snippets Groups Projects
Commit bdb53432 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch 'make-objectform-implicitly-handle-undefined-iscreate' into 'master'

Make objectForm implicitly handle undefined isCreate

See merge request !1798
parents 5d2ca707 7364fc80
Branches master
No related tags found
1 merge request!1798Make objectForm implicitly handle undefined isCreate
Pipeline #197958 canceled
...@@ -14,6 +14,7 @@ Changed ...@@ -14,6 +14,7 @@ Changed
* Announcements are shown in calendar. * Announcements are shown in calendar.
* DialogObjectForm is now slightly wider. * DialogObjectForm is now slightly wider.
* [Dev] DialogObjectForm now implicitly handles a missing ``isCreate`` prop depending on the presence of ``editItem``.
Fixed Fixed
~~~~~ ~~~~~
......
...@@ -15,7 +15,7 @@ export default { ...@@ -15,7 +15,7 @@ export default {
isCreate: { isCreate: {
type: Boolean, type: Boolean,
required: false, required: false,
default: true, default: undefined,
}, },
/** /**
* The graphQL create mutation * The graphQL create mutation
......
...@@ -55,6 +55,13 @@ export default { ...@@ -55,6 +55,13 @@ export default {
this.resetModel(); this.resetModel();
}, },
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( this.itemModel = JSON.parse(
JSON.stringify(this.isCreate ? this.defaultItem : this.editItem), JSON.stringify(this.isCreate ? this.defaultItem : this.editItem),
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment