From c0e6552c085786fbf72720f14efb0ab38dc10601 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Wed, 13 Mar 2024 13:44:08 +0100 Subject: [PATCH] fixes zustellKontakteCount in EditKontakt --- public/js/apps/Cis/Profil.js | 25 ++++++++++--------- .../EditProfilComponents/EditKontakt.js | 20 ++++----------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/public/js/apps/Cis/Profil.js b/public/js/apps/Cis/Profil.js index d0ffacbb8..6f0eec2c8 100755 --- a/public/js/apps/Cis/Profil.js +++ b/public/js/apps/Cis/Profil.js @@ -148,17 +148,10 @@ const profilApp = Vue.createApp({ return null; } - - return this.data.kontakte.filter(kontakt => { - return kontakt.zustellung; - }).map(kon =>{ - return kon.kontakt_id; - }); - - //TODO counting the zustellKontakte/Adresse does not work correctly - /* let kontakteArray = []; + //TODO: not sure if how it is implemented is the best way + let kontakteArray = []; - if(this.data.profilUpdates.length){ + if(this.data.profilUpdates?.length){ kontakteArray = kontakteArray.concat(this.data.profilUpdates.filter((update)=> { @@ -169,7 +162,7 @@ const profilApp = Vue.createApp({ } - if(!this.data.profilUpdates.length || !this.data.kontakte.every(kontakt=> this.data.profilUpdates.some(update=>update.requested_change.kontakt_id == kontakt.kontakt_id))){ + if(!this.data.profilUpdates?.length || !this.data.kontakte.filter(kontakt => kontakt.zustellung).every(kontakt=> this.data.profilUpdates.some(update=>update.requested_change.kontakt_id == kontakt.kontakt_id))){ kontakteArray = kontakteArray.concat(this.data.kontakte.filter(kontakt => { return kontakt.zustellung; }).map(kon =>{ @@ -177,7 +170,15 @@ const profilApp = Vue.createApp({ })); } - return [...(new Set(kontakteArray))]; */ + return [...(new Set(kontakteArray))]; + + // OLD version + // return this.data.kontakte.filter(kontakt => { + // return kontakt.zustellung; + // }).map(kon =>{ + // return kon.kontakt_id; + // }); + }, }, computed:{ diff --git a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js index 4823c88c1..1a0bc94b9 100755 --- a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js +++ b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js @@ -15,9 +15,7 @@ export default { inject:["getZustellkontakteCount"], methods:{ - getNewKontanteCount:function(){ - console.log(this.getZustellkontakteCount()); - }, + updateValue: function(event,bind){ if(bind === 'zustellung'){ @@ -35,19 +33,11 @@ export default { }, computed:{ showZustellKontakteWarning: function(){ - - if(this.zustellKontakteCount){ - - if(this.zustellKontakteCount.includes(this.data.kontakt_id)){ - //? if the adresse was already saved - return false; - } - return this.zustellKontakteCount.length && this.data.zustellung; + // if zustellKontakteCount is not 0 and the own kontakt has the flag zustellung set to true + if(!this.zustellKontakteCount.includes(this.data.kontakt_id)){ + return this.data.zustellung && this.zustellKontakteCount.length } - //? if this.zustellAdressenCount is still not set by the api call and is still null - return false; - - + return this.zustellKontakteCount.length >=2 && this.data.zustellung; }, isChanged: function(){ //? returns true if the original passed data object was changed