From b681ca29c17929bd7bfd85dbde11444d99234261 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Tue, 7 Oct 2025 15:13:07 +0200 Subject: [PATCH] add info alert for heimatadresse, tune duplicate zustellkontakt handling --- .../api/frontend/v1/ProfilUpdate.php | 12 +++-- .../models/person/Profil_update_model.php | 1 + public/js/components/Cis/Profil/Profil.js | 20 +++++--- .../Cis/Profil/ProfilComponents/Adresse.js | 2 +- .../EditProfilComponents/EditAdresse.js | 6 +-- .../EditProfilComponents/EditKontakt.js | 29 +++++------ .../Profil/ProfilModal/EditProfilSelect.js | 22 +++++++-- system/phrasesupdate.php | 48 +++++++++++++++++-- 8 files changed, 103 insertions(+), 37 deletions(-) diff --git a/application/controllers/api/frontend/v1/ProfilUpdate.php b/application/controllers/api/frontend/v1/ProfilUpdate.php index d0eb26858..e5129b678 100644 --- a/application/controllers/api/frontend/v1/ProfilUpdate.php +++ b/application/controllers/api/frontend/v1/ProfilUpdate.php @@ -873,7 +873,7 @@ class ProfilUpdate extends FHCAPI_Controller $insert_kontakt_id = $insertID; $insert_kontakt_id = $this->getDataOrTerminateWithError($insert_kontakt_id, $this->p->t('profilUpdate', 'profilUpdate_insertKontakt_error')); if ($insert_kontakt_id) { - $this->handleDupplicateZustellKontakte($requested_change['zustellung'], $insert_kontakt_id, $personID); + $this->handleDupplicateZustellKontakte($requested_change['zustellung'], $insert_kontakt_id, $requested_change['kontakttyp'], $personID); } } //! DELETE @@ -890,7 +890,7 @@ class ProfilUpdate extends FHCAPI_Controller $update_kontakt_id = $this->KontaktModel->update($kontakt_id, $requested_change); $update_kontakt_id = $this->getDataOrTerminateWithError($update_kontakt_id, $this->p->t('profilUpdate', 'profilUpdate_updateKontakt_error')); if ($update_kontakt_id) { - $this->handleDupplicateZustellKontakte($requested_change['zustellung'], $update_kontakt_id, $personID); + $this->handleDupplicateZustellKontakte($requested_change['zustellung'], $update_kontakt_id, $requested_change['kontakttyp'], $personID); } } return isset($insertID) ? $insertID : null; @@ -925,12 +925,16 @@ class ProfilUpdate extends FHCAPI_Controller } } - private function handleDupplicateZustellKontakte($zustellung, $kontakt_id, $person_id) + private function handleDupplicateZustellKontakte($zustellung, $kontakt_id, $kontakttyp, $person_id) { if ($zustellung) { $this->PersonModel->addSelect("public.tbl_kontakt.kontakt_id"); $this->PersonModel->addJoin("public.tbl_kontakt", "public.tbl_kontakt.person_id = public.tbl_person.person_id"); - $zustellKontakteArray = $this->PersonModel->loadWhere(["public.tbl_person.person_id" => $person_id, "zustellung" => TRUE]); + $zustellKontakteArray = $this->PersonModel->loadWhere([ + "public.tbl_person.person_id" => $person_id, + "zustellung" => TRUE, + "kontakttyp" => $kontakttyp + ]); if (!isSuccess($zustellKontakteArray)) { return error($this->p->t('profilUpdate', 'profilUpdate_loadingZustellkontakte_error')); } diff --git a/application/models/person/Profil_update_model.php b/application/models/person/Profil_update_model.php index 141044a2c..36f53ff75 100644 --- a/application/models/person/Profil_update_model.php +++ b/application/models/person/Profil_update_model.php @@ -63,6 +63,7 @@ class Profil_update_model extends DB_Model $this->addSelect(["public.tbl_profil_update.*", "public.tbl_person.vorname"]); $this->addJoin("public.tbl_benutzer", "public.tbl_benutzer.uid = public.tbl_profil_update.uid"); $this->addJoin("public.tbl_person", "public.tbl_person.person_id = public.tbl_benutzer.person_id"); + $this->db->order_by('COALESCE(public.tbl_profil_update.updateamum, public.tbl_profil_update.insertamum)', 'DESC', false); $res = $this->loadWhere($whereClause); if (isError($res)) { return $res; diff --git a/public/js/components/Cis/Profil/Profil.js b/public/js/components/Cis/Profil/Profil.js index 8ca2cfe8e..da205816d 100644 --- a/public/js/components/Cis/Profil/Profil.js +++ b/public/js/components/Cis/Profil/Profil.js @@ -120,10 +120,10 @@ export const Profil = { }, sortProfilUpdates: (ele1, ele2) => { let result = 0; - if (ele1.status === "pending") { + if (ele1.status.toLowerCase() === "pending") { result = -1; - } else if (ele1.status === "accepted") { - result = ele2.status === "rejected" ? -1 : 1; + } else if (ele1.status.toLowerCase() === "accepted") { + result = ele2.status.toLowerCase() === "rejected" ? -1 : 1; } else { result = 1; } @@ -226,10 +226,13 @@ export const Profil = { kontakteArray = kontakteArray.concat( this.data.profilUpdates .filter((update) => { - return update.requested_change.zustellung; + return update.status === 'Pending' && update.requested_change.zustellung; }) .map((kontant) => { - return kontant.requested_change.kontakt_id; + return { + kontakt_id: kontant.requested_change.kontakt_id, + kontakttyp: kontant.requested_change.kontakttyp + }; }) ); } @@ -241,7 +244,7 @@ export const Profil = { .every((kontakt) => this.data.profilUpdates.some( (update) => - update.requested_change.kontakt_id == kontakt.kontakt_id + update.status === 'Pending' && update.requested_change.kontakt_id == kontakt.kontakt_id ) ) ) { @@ -251,7 +254,10 @@ export const Profil = { return kontakt.zustellung; }) .map((kon) => { - return kon.kontakt_id; + return { + kontakt_id: kon.kontakt_id, + kontakttyp: kon.kontakttyp + }; }) ); } diff --git a/public/js/components/Cis/Profil/ProfilComponents/Adresse.js b/public/js/components/Cis/Profil/ProfilComponents/Adresse.js index 5ba2f1fe7..7ec1213e2 100644 --- a/public/js/components/Cis/Profil/ProfilComponents/Adresse.js +++ b/public/js/components/Cis/Profil/ProfilComponents/Adresse.js @@ -4,7 +4,7 @@ export default { view:String, withZustelladresse:{ type:Boolean, - default:false, + default:true, }, }, data(){ diff --git a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js index 76e08b974..8f0724f9c 100644 --- a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js +++ b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js @@ -160,10 +160,8 @@ export default {
-
-
+
{{$p.t('profilUpdate','zustell_adressen_warning')}} -
@@ -173,7 +171,7 @@ export default {
diff --git a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js index 4f978f636..b484c9dd5 100644 --- a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js +++ b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js @@ -30,12 +30,15 @@ export default { // if the kontakt is already a zustellungskontakt when the user is editing the kontakt, then no warning is shown and the zustellung will be overwritten if (JSON.parse(this.originalValue).zustellung) { return false; - } + } + const kontakteOfSelectedType = this.zustellKontakteCount.filter((element) => { + return element.kontakttyp === this.data?.kontakttyp + }); // 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.zustellKontakteCount.some((element) => element.kontakt_id === this.data.kontakt_id)) { + return this.data.zustellung && kontakteOfSelectedType.length; } - return this.zustellKontakteCount.length >= 2 && this.data.zustellung; + return this.kontakteOfSelectedType.length >= 2 && this.data.zustellung; }, isChanged: function () { //? returns true if the original passed data object was changed @@ -57,16 +60,6 @@ export default {
- -
-
-
- {{$p.t('profilUpdate','zustell_kontakte_warning')}} -
-
-
- -
@@ -108,6 +101,14 @@ export default {
+ +
+
+ {{$p.t('profilUpdate','zustell_kontakte_warning')}} +
+
+ +
{{$p.t('profilUpdate','zustellungsKontakt')}} diff --git a/public/js/components/Cis/Profil/ProfilModal/EditProfilSelect.js b/public/js/components/Cis/Profil/ProfilModal/EditProfilSelect.js index 60dd759b3..921758ae0 100644 --- a/public/js/components/Cis/Profil/ProfilModal/EditProfilSelect.js +++ b/public/js/components/Cis/Profil/ProfilModal/EditProfilSelect.js @@ -148,16 +148,32 @@ export default {