From 5b597dbc3112624ecc69cf16db28c70ccf2083af Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Mon, 8 Jan 2024 15:19:18 +0100 Subject: [PATCH] changing the editProfil Modal from an Accordion to a select --- application/controllers/Cis/Profil.php | 39 +++-- .../models/person/Profil_change_model.php | 4 +- public/js/components/Cis/Profil/EditProfil.js | 159 ++++++++---------- .../Cis/Profil/MitarbeiterProfil.js | 13 +- .../Cis/Profil/MitarbeiterViewProfil.js | 4 +- .../js/components/Cis/Profil/StudentProfil.js | 4 +- .../Cis/Profil/StudentViewProfil.js | 4 +- .../js/components/Cis/Profil/oldAccordion.txt | 72 ++++++++ system/dbupdate_3.4.php | 4 +- system/dbupdate_3.4/25999_C4_ma0594.php | 48 +++++- 10 files changed, 227 insertions(+), 124 deletions(-) create mode 100644 public/js/components/Cis/Profil/oldAccordion.txt diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index 272474d22..da601b890 100644 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -71,35 +71,38 @@ class Profil extends Auth_Controller { $json = $this->input->raw_input_stream; + - $data = ["uid" => $this->uid, "profil_changes" => $json, "change_timestamp" => "NOW()"]; + $data = ["uid" => $this->uid, "requested_change" => $json, "change_timestamp" => "NOW()"]; - $res = $this->ProfilChangeModel->load([$this->uid]); + //? gets all the requested changes from a user + $res = $this->ProfilChangeModel->loadWhere(["uid"=>$this->uid]); $res = hasData($res) ? getData($res) : null; - if (empty($res)) { + $insert_res = $this->ProfilChangeModel->insert($data); + if(isError($insert_res)){ //catch error }else{ - $editTimestamp = $this->ProfilChangeModel->getTimestamp($this->uid); - //? status code 201 CREATED - $insert_res->code = 201; - $insert_res->retval = date_create($editTimestamp)->format('d/m/Y'); + $editTimestamp = $this->ProfilChangeModel->getTimestamp($insert_res->retval); + + $insert_res->retval = date_create($editTimestamp)->format('d.m.Y'); echo json_encode($insert_res); } - + /* if (empty($res)) { } else { $update_res = $this->ProfilChangeModel->update([$this->uid], $data); + if(isError($update_res)){ //catch error } $editTimestamp = $this->ProfilChangeModel->getTimestamp($this->uid); //? status code 200 OK $update_res->code = 200; - $update_res->retval = date_create($editTimestamp)->format('d/m/Y');; + $update_res->retval = date_create($editTimestamp)->format('d.m.Y');; echo json_encode($update_res); - } + } */ @@ -502,12 +505,12 @@ class Profil extends Auth_Controller //? querying if the user already has a pending profil information update request - $editData_res = $this->ProfilChangeModel->load([$this->uid]); + /* $editData_res = $this->ProfilChangeModel->load([$this->uid]); if(isError($editData_res)){ //error handling }else{ $editData_res = hasData($editData_res) ? getData($editData_res)[0] : null; - } + } */ $res = new stdClass(); $res->foto = $person_res->foto; @@ -548,9 +551,9 @@ class Profil extends Auth_Controller //telefon nummer von dem Standort $res->standort_telefon = $telefon_res; - $res->editData = $editData_res? json_decode($editData_res->profil_changes): null; + /* $res->editData = $editData_res? json_decode($editData_res->profil_data): null; $res->editDataTimestamp = $editData_res? date_create($editData_res->change_timestamp)->format('d/m/Y') : null; - + */ return $res; } @@ -705,12 +708,12 @@ class Profil extends Auth_Controller } //? querying if the user already has a pending profil information update request - $editData_res = $this->ProfilChangeModel->load([$this->uid]); + /* $editData_res = $this->ProfilChangeModel->load([$this->uid]); if(isError($editData_res)){ //error handling }else{ $editData_res = hasData($editData_res) ? getData($editData_res)[0] : null; - } + } */ $res = new stdClass(); @@ -749,9 +752,9 @@ class Profil extends Auth_Controller $res->mailverteiler = $mailverteiler_res; - $res->editData = $editData_res? json_decode($editData_res->profil_changes): null; + /* $res->editData = $editData_res? json_decode($editData_res->profil_data): null; $res->editDataTimestamp = $editData_res? date_create($editData_res->change_timestamp)->format('d/m/Y'): null; - + */ return $res; diff --git a/application/models/person/Profil_change_model.php b/application/models/person/Profil_change_model.php index f7e514847..54b8adf4f 100644 --- a/application/models/person/Profil_change_model.php +++ b/application/models/person/Profil_change_model.php @@ -9,8 +9,8 @@ class Profil_change_model extends DB_Model { parent::__construct(); $this->dbTable = 'public.tbl_cis_profil_update'; - $this->pk = ['uid']; - $this->hasSequence = false; + $this->pk = ['profil_update_id']; + $this->hasSequence = true; } diff --git a/public/js/components/Cis/Profil/EditProfil.js b/public/js/components/Cis/Profil/EditProfil.js index c61a9faf5..b6363077b 100644 --- a/public/js/components/Cis/Profil/EditProfil.js +++ b/public/js/components/Cis/Profil/EditProfil.js @@ -27,10 +27,17 @@ export default { }, data() { return { + selection: null, + propertySelection:true, + selectedProperty:null, + inputField:null, + detailSelection:false, editData: this.value, //? tracks what specific profil data was changed changesData: {}, editTimestamp: this.timestamp, + selectionOrder: {firstSelect: true, secondSelect:false}, + result: true, info: null, } @@ -38,6 +45,20 @@ export default { }, methods: { + + formSelection: function(selection){ + + if(Array.isArray(selection)){ + return ['a','b']; + }else if(typeof(selection) === 'object'){ + console.log(selection); + return Object.keys(selection); + + }else{ + // it is not an array or and object + return null; + } + }, updateData: function(event,key,ArrayKey,ObjectKey=null){ @@ -88,18 +109,18 @@ export default { }, submitProfilChange(){ - if(this.isEditDataChanged){ + //? inserts new row in public.tbl_cis_profil_update - Vue.$fhcapi.UserData.editProfil(this.editData).then((res)=>{ + Vue.$fhcapi.UserData.editProfil(this.inputField).then((res)=>{ this.result = { editData: this.editData, timestamp: res.data.retval, }; this.hide(); - if(res.data.error == 0){ + if(res.data.error == 0){ Alert.popup("Ihre Anfrage wurde erfolgreich gesendet. Bitte warten Sie, während sich das Team um Ihre Anfrage kümmert."); }else{ @@ -108,24 +129,34 @@ export default { // }); - } + }, }, computed: { + + firstSelection(){ + return Object.keys(this.value); + }, + + secondSelection(){ + switch(this.selectedProperty){ + case "Personen_Informationen": return Object.keys(this.editData[this.selectedProperty]); + case "Private_Kontakte": return this.editData[this.selectedProperty]; + case "Private_Adressen": return this.editData[this.selectedProperty]; + default: return []; + } + }, + + + + - getFormatedDate: function(){ - return [ - this.editTimestamp.getDate().toString().padStart(2,'0'), - (this.editTimestamp.getMonth()+1).toString().padStart(2,'0'), - this.editTimestamp.getFullYear(), - ].join('/'); - }, + isEditDataChanged(){ return this.originalEditData != JSON.stringify(this.editData) }, }, created() { - this.originalEditData = JSON.stringify(this.editData); /* @@ -161,86 +192,42 @@ export default { -