diff --git a/public/js/apps/vbform/presets.js b/public/js/apps/vbform/presets.js index 70f23809f..3971a4bf9 100644 --- a/public/js/apps/vbform/presets.js +++ b/public/js/apps/vbform/presets.js @@ -59,9 +59,7 @@ export default [ data: { dienstverhaeltnisid: null }, - vbs: { - - } + vbs: {} }, { type: 'preset', diff --git a/public/js/apps/vbform/vbform.js b/public/js/apps/vbform/vbform.js index 2431e10b9..c70e4d06f 100644 --- a/public/js/apps/vbform/vbform.js +++ b/public/js/apps/vbform/vbform.js @@ -62,15 +62,19 @@ Vue.createApp({ 'vbformhelper': vbformhelper }, created: function() { - var vbs = JSON.parse(JSON.stringify(this.preset.vbs)); - for( var key in vbs ) { - this.store.addVB(key, vbs[key]); - } - this.store.setDV(JSON.parse(JSON.stringify(this.preset.data))); + this.presettostore(); }, methods: { presetselected: function(preset) { this.preset = preset; + this.presettostore(); + }, + presettostore: function() { + var vbs = JSON.parse(JSON.stringify(this.preset.vbs)); + for( var key in vbs ) { + this.store.addVB(key, vbs[key]); + } + this.store.setDV(JSON.parse(JSON.stringify(this.preset.data))); }, processJSON: function(payload) { this.vbhjson = payload; diff --git a/public/js/components/vbform/gehaltsbestandteil.js b/public/js/components/vbform/gehaltsbestandteil.js index 6c53501b1..f6833b0ce 100644 --- a/public/js/components/vbform/gehaltsbestandteil.js +++ b/public/js/components/vbform/gehaltsbestandteil.js @@ -62,17 +62,13 @@ export default { }, methods: { setDataFromConfig: function() { - if( typeof this.config.data === 'undefined' ) { - return; - } - - if( typeof this.config.data.gehaltstyp !== 'undefined' ) { + if( typeof this.config?.data?.gehaltstyp !== 'undefined' ) { this.gehaltstyp = this.config.data.gehaltstyp; } - if( typeof this.config.data.betrag !== 'undefined' ) { + if( typeof this.config?.data?.betrag !== 'undefined' ) { this.betrag = this.config.data.betrag; } - if( typeof this.config.data.valorisierung !== 'undefined' ) { + if( typeof this.config?.data?.valorisierung !== 'undefined' ) { this.valorisierung = this.config.data.valorisierung; } }, @@ -82,7 +78,7 @@ export default { getPayload: function() { return { type: this.config.type, - guioptions: this.config.guioptions, + guioptions: JSON.parse(JSON.stringify(this.config.guioptions)), data: { gehaltstyp: this.gehaltstyp, betrag: this.betrag, diff --git a/public/js/components/vbform/presets_chooser.js b/public/js/components/vbform/presets_chooser.js index a77a4b7ac..1d80d7651 100644 --- a/public/js/components/vbform/presets_chooser.js +++ b/public/js/components/vbform/presets_chooser.js @@ -1,3 +1,5 @@ +import store from './vbsharedstate.js'; + export default { template: `
@@ -20,6 +22,7 @@ export default { ], data: function() { return { + store: store, selectedpresetidx: 1 } }, @@ -29,6 +32,7 @@ export default { methods: { selectpreset: function() { var preset = this.presets[this.selectedpresetidx]; + this.store.reset(); this.$emit("presetselected", preset); } } diff --git a/public/js/components/vbform/vbsharedstate.js b/public/js/components/vbform/vbsharedstate.js index d9912dfef..6ca21be26 100644 --- a/public/js/components/vbform/vbsharedstate.js +++ b/public/js/components/vbform/vbsharedstate.js @@ -29,5 +29,13 @@ export default Vue.reactive({ }, getVBsPayload: function() { return JSON.parse(JSON.stringify(this.vbs)); + }, + reset: function() { + this.gueltigkeit = { + gueltig_ab: '', + gueltig_bis: '' + }; + this.dv = {}; + this.vbs = {}; } }); diff --git a/public/js/components/vbform/vertragsbestandteil_freitext.js b/public/js/components/vbform/vertragsbestandteil_freitext.js index f4742a4ab..f13b11337 100644 --- a/public/js/components/vbform/vertragsbestandteil_freitext.js +++ b/public/js/components/vbform/vertragsbestandteil_freitext.js @@ -77,7 +77,7 @@ export default { this.$emit('removeVB', {id: this.config.guioptions.id}); }, getGehaltsbestandteilePayload: function() { - return (!this.$refs?.gbh === undefined) ? this.$refs.gbh.getPayload() : []; + return (this.$refs?.gbh !== undefined) ? this.$refs.gbh.getPayload() : []; }, getPayload: function() { return { diff --git a/public/js/components/vbform/vertragsbestandteil_funktion.js b/public/js/components/vbform/vertragsbestandteil_funktion.js index 3b0020907..75555d42c 100644 --- a/public/js/components/vbform/vertragsbestandteil_funktion.js +++ b/public/js/components/vbform/vertragsbestandteil_funktion.js @@ -53,7 +53,7 @@ export default { this.$emit('removeVB', {id: this.config.guioptions.id}); }, getGehaltsbestandteilePayload: function() { - return (!this.$refs?.gbh === undefined) ? this.$refs.gbh.getPayload() : []; + return (this.$refs?.gbh !== undefined) ? this.$refs.gbh.getPayload() : []; }, getPayload: function() { return {