diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index d308c5700..6789de7b8 100644 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -446,6 +446,8 @@ class Profil extends Auth_Controller // handle error } else { $kontakte_res = hasData($kontakte_res) ? getData($kontakte_res) : null; + + } } @@ -659,6 +661,7 @@ class Profil extends Auth_Controller // handle error } else { $kontakte_res = hasData($kontakte_res) ? getData($kontakte_res) : null; + } } diff --git a/public/js/components/Cis/Profil/EditProfilSelect.js b/public/js/components/Cis/Profil/EditProfilSelect.js index cef314eb6..f067d1778 100644 --- a/public/js/components/Cis/Profil/EditProfilSelect.js +++ b/public/js/components/Cis/Profil/EditProfilSelect.js @@ -62,17 +62,19 @@ export default { this.data= this.view=="EditAdresse"? { - adresse_id: "", - strasse: "", - adr_typ: "", - plz: "", - ort: "" + added:true, + adresse_id: null, + strasse: null, + adr_typ: null, + plz: null, + ort: null }: { - kontakt_id: "", - kontakttyp: "", - kontakt: "", - anmerkung: "", + added:true, + kontakt_id: null, + kontakttyp: null, + kontakt: null, + anmerkung: null, zustellung: false } diff --git a/public/js/components/Cis/Profil/ProfilComponents.js b/public/js/components/Cis/Profil/ProfilComponents.js index 361890251..3b666002c 100644 --- a/public/js/components/Cis/Profil/ProfilComponents.js +++ b/public/js/components/Cis/Profil/ProfilComponents.js @@ -60,15 +60,24 @@ const Adresse = { const EditAdresse = { props:{data:Object}, data(){ - return{} + return{ + originalValue:null, + } }, methods:{ updateValue: function(event,bind){ - this.data[bind] = event.target.value; - this.$emit('profilUpdate',this.data); + //? sets the value of a property to null when an empty string is entered to keep the isChanged function valid + this.data[bind] = event.target.value === "" ? null : event.target.value; + this.$emit('profilUpdate',this.isChanged?this.data:null); + }, + }, + computed:{ + isChanged: function(){ + return this.originalValue !== JSON.stringify(this.data); }, }, created(){ + this.originalValue = JSON.stringify(this.data); }, template:` @@ -183,7 +192,7 @@ const EditKontakt = { }, data(){ return{ - + originalValue:null, } }, methods:{ @@ -191,18 +200,31 @@ const EditKontakt = { if(bind === 'zustellung'){ this.data[bind] = event.target.checked; }else{ - this.data[bind] = event.target.value; + //? sets the value of a property to null when an empty string is entered to keep the isChanged function valid + this.data[bind] = event.target.value === "" ? null: event.target.value; } - this.$emit('profilUpdate',this.data); + + this.$emit('profilUpdate',this.isChanged?this.data:null); + }, }, + computed:{ + isChanged: function(){ + //? returns true if the original passed data object was changed + return JSON.stringify(this.data) !== this.originalValue; + } + }, created(){ + + this.originalValue = JSON.stringify(this.data); + }, template: ` - +
{{JSON.stringify(data)}}
+ {{originalValue}}