fixes zustellKontakteCount in EditKontakt

This commit is contained in:
SimonGschnell
2024-03-13 13:44:08 +01:00
parent e7480eb9ff
commit c0e6552c08
2 changed files with 18 additions and 27 deletions
+13 -12
View File
@@ -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:{
@@ -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