diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index b8b6fa685..7ed1454ed 100755 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -246,7 +246,7 @@ class Profil extends Auth_Controller if ($nation == "A") { if (isset($zip) && $zip > 999 && $zip < 32000) { - $gemeinde_res = $this->GemeindeModel->loadWhere(['ortschaftskennziffer' => $zip]); + $gemeinde_res = $this->GemeindeModel->loadWhere(['plz' => $zip]); if (isError($gemeinde_res)) { show_error("error while trying to query bis.tbl_gemeinde"); } diff --git a/public/js/apps/Cis/Profil.js b/public/js/apps/Cis/Profil.js index c8219eb94..d0ffacbb8 100755 --- a/public/js/apps/Cis/Profil.js +++ b/public/js/apps/Cis/Profil.js @@ -148,11 +148,36 @@ 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 = []; + + if(this.data.profilUpdates.length){ + kontakteArray = kontakteArray.concat(this.data.profilUpdates.filter((update)=> + { + + return update.requested_change.zustellung; + }).map((kontant)=>{ + return kontant.requested_change.kontakt_id + })) + + } + + if(!this.data.profilUpdates.length || !this.data.kontakte.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 =>{ + return kon.kontakt_id; + })); + } + + return [...(new Set(kontakteArray))]; */ }, }, computed:{ @@ -234,13 +259,13 @@ const profilApp = Vue.createApp({ data:kontakt }}) }, - Password_Change : { - title:"Passwort Ändern", - view:"ChangePassword", - data:{ - test:"testvalue", - } - }, + // Password_Change : { + // title:"Passwort Ändern", + // view:"ChangePassword", + // data:{ + // test:"testvalue", + // } + // }, }, }; diff --git a/public/js/components/Cis/Profil/MitarbeiterProfil.js b/public/js/components/Cis/Profil/MitarbeiterProfil.js index aa4467ce8..5b851b654 100755 --- a/public/js/components/Cis/Profil/MitarbeiterProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterProfil.js @@ -174,7 +174,6 @@ export default { fetchProfilUpdates: function(){ Vue.$fhcapi.ProfilUpdate.selectProfilRequest().then((res)=>{ - if(!res.error){ this.data.profilUpdates = res.data?.length ? res.data.sort(this.sortProfilUpdates) : null ; } @@ -240,6 +239,7 @@ export default { template: /*html*/`
+
diff --git a/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js b/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js index 373b3f22c..16225f896 100755 --- a/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js +++ b/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js @@ -1,6 +1,7 @@ import EditProfil from "../ProfilModal/EditProfil.js"; //? EditProfil is the modal used to edit the profil updates export default { + components:{EditProfil}, props: { data: { type: Object, @@ -10,9 +11,93 @@ export default { emits: ["fetchUpdates"], data() { - return {}; + return { + showUpdateModal:false, + content:null, + editProfilTitle:"Profil bearbeiten", + }; }, methods: { + + hideEditProfilModal: function(){ + + //? checks the editModal component property result, if the user made a successful request or not + if(this.$refs.updateEditModal.result){ + this.$emit("fetchUpdates"); + }else{ + // when modal was closed without submitting request + } + this.showUpdateModal=false; + + }, + + async showEditProfilModal(updateRequest) { + let view = this.getView(updateRequest.topic, updateRequest.status); + + let data = null; + let content = null; + let files = null; + let withFiles = false; + + if (view === "TextInputDokument") { + data = { + titel: updateRequest.topic, + value: updateRequest.requested_change.value, + }; + + const filesFromDatabase = await Vue.$fhcapi.ProfilUpdate.getProfilRequestFiles(updateRequest.profil_update_id).then(res=>{ + return res.data; + }); + + files= filesFromDatabase; + if(files){ + withFiles = true; + } + } else { + data = updateRequest.requested_change; + } + + content = { + updateID: updateRequest.profil_update_id, + view: view, + data: data, + withFiles: withFiles, + topic: updateRequest.topic, + files: files, + + }; + + //?TODO: check if updateRequest.uid is a mitarbeiter, if so add the flag isMitarbeiter:true + if(view === "EditAdresse"){ + const isMitarbeiter = await Vue.$fhcapi.UserData.isMitarbeiter(updateRequest.uid).then(res => res.data); + + if(isMitarbeiter){ + content['isMitarbeiter']=isMitarbeiter; + } + } + + //? adds the status information if the profil update request was rejected or accepted + if (updateRequest.status !== "pending") { + content["status"] = updateRequest.status; + content["status_message"] = updateRequest.status_message; + content["status_timestamp"] = updateRequest.status_timestamp; + } + + //? update data of the reactive content + this.content = content; + this.editProfilTitle = updateRequest.topic; + + //? only show the popup if also the right content is available + if (content) { + this.showUpdateModal = true; + // after a state change, wait for the DOM updates to complete + Vue.nextTick(()=>{ + this.$refs.updateEditModal.show(); + }); + } + + }, + deleteRequest: function (item) { Vue.$fhcapi.ProfilUpdate.deleteProfilRequest(item.profil_update_id).then( (res) => { @@ -55,6 +140,9 @@ export default { break; } }, + + + // OLD way to open the editProfil modal, which was dynamically added to the html and then removed async openModal(updateRequest) { let view = this.getView(updateRequest.topic, updateRequest.status); @@ -126,15 +214,20 @@ export default { } }, }, - created() {}, + created() { + + + }, computed: {}, template: ` -
+
+ +
Profil Updates
-
+
@@ -155,11 +248,11 @@ export default {
@@ -172,7 +265,7 @@ export default {
diff --git a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js index 8ddc12fe2..840f23c4b 100755 --- a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js +++ b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js @@ -54,6 +54,8 @@ export default { } this.$emit('profilUpdate',this.isChanged?this.data:null); + // update the zustellAdressen count + this.zustellAdressenCount = this.getZustelladressenCount(); }, }, @@ -95,7 +97,6 @@ export default { template:/*html*/`
-
diff --git a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js index 06368c097..4823c88c1 100755 --- a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js +++ b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditKontakt.js @@ -14,6 +14,10 @@ export default { }, inject:["getZustellkontakteCount"], methods:{ + + getNewKontanteCount:function(){ + console.log(this.getZustellkontakteCount()); + }, updateValue: function(event,bind){ if(bind === 'zustellung'){ @@ -25,12 +29,13 @@ export default { this.$emit('profilUpdate',this.isChanged?this.data:null); - + this.zustellKontakteCount = this.getZustellkontakteCount(); }, }, computed:{ showZustellKontakteWarning: function(){ + if(this.zustellKontakteCount){ if(this.zustellKontakteCount.includes(this.data.kontakt_id)){ @@ -61,8 +66,7 @@ export default { `
- - +
- +