From 7abe04a69f6acb5b07c8431e7c49f123747df961 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Mon, 22 Jan 2024 16:02:52 +0100 Subject: [PATCH] fixes little bug for View Profil and changes layout of the profil update fetch component --- application/controllers/Cis/Profil.php | 11 ++-- public/js/components/Cis/Profil/EditProfil.js | 1 + .../components/Cis/Profil/EditProfilSelect.js | 4 +- .../ProfilComponents/FetchProfilUpdates.js | 51 +++++++++++-------- .../Cis/Profil/ProfilComponents/Status.js | 35 +++++++++++++ 5 files changed, 78 insertions(+), 24 deletions(-) create mode 100644 public/js/components/Cis/Profil/ProfilComponents/Status.js diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index c9801bbb5..797db3ed9 100644 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -19,6 +19,7 @@ class Profil extends Auth_Controller 'index' => ['student/anrechnung_beantragen:r', 'user:r'], // TODO(chris): permissions? 'foto_sperre_function' => ['student/anrechnung_beantragen:r', 'user:r'], 'getView' => ['student/anrechnung_beantragen:r', 'user:r'], + 'View' => ['student/anrechnung_beantragen:r', 'user:r'], 'insertProfilRequest' => ['student/anrechnung_beantragen:r', 'user:r'], 'updateProfilRequest' => ['student/anrechnung_beantragen:r', 'user:r'], 'deleteProfilRequest' => ['student/anrechnung_beantragen:r', 'user:r'], @@ -99,11 +100,14 @@ class Profil extends Auth_Controller //? loops over all updateRequests from a user to validate if the new request is valid $res = $this->ProfilChangeModel->loadWhere(["uid"=>$this->uid]); $res = hasData($res) ? getData($res) : null; + if($res){ foreach($res as $update_request){ $existing_change = json_decode($update_request->requested_change); - - if(isset($existing_change->$type) && $existing_change->$type == $payload->$type){ + echo json_encode($existing_change); + echo property_exists($existing_change,$type); + + if(property_exists($existing_change,$type) && $existing_change->$type == $payload->$type){ //? the kontakt_id / adresse_id of a change has to be unique echo json_encode(error("cannot change the same resource twice")); @@ -267,6 +271,7 @@ class Profil extends Auth_Controller } + print_r($telefon_res); $res = new stdClass(); $res->username = $uid; @@ -303,7 +308,7 @@ class Profil extends Auth_Controller //? Mailverteiler Info $res->mailverteiler = $mailverteiler_res; - $res->standort_telefon = $telefon_res->kontakt; + $res->standort_telefon = isset($telefon_res)? $telefon_res->kontakt : null; return $res; diff --git a/public/js/components/Cis/Profil/EditProfil.js b/public/js/components/Cis/Profil/EditProfil.js index 10bcea898..316d6966f 100644 --- a/public/js/components/Cis/Profil/EditProfil.js +++ b/public/js/components/Cis/Profil/EditProfil.js @@ -68,6 +68,7 @@ export default { //? if the topic was passed through the prop add it to the component this.topic = this.editData.topic; } + console.log("here",this.editData); }, diff --git a/public/js/components/Cis/Profil/EditProfilSelect.js b/public/js/components/Cis/Profil/EditProfilSelect.js index e721b6f11..a5869eb75 100644 --- a/public/js/components/Cis/Profil/EditProfilSelect.js +++ b/public/js/components/Cis/Profil/EditProfilSelect.js @@ -2,6 +2,7 @@ import Kontakt from "./ProfilComponents/Kontakt.js"; import EditKontakt from "./ProfilComponents/EditKontakt.js"; import Adresse from "./ProfilComponents/Adresse.js"; import EditAdresse from "./ProfilComponents/EditAdresse.js"; +import Status from "./ProfilComponents/Status.js"; export default { components: { @@ -9,6 +10,7 @@ export default { EditKontakt, Adresse, EditAdresse, + Status, }, props: { @@ -173,7 +175,7 @@ export default { `, }; diff --git a/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js b/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js index 5af4a89ae..50dcc1440 100644 --- a/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js +++ b/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js @@ -16,6 +16,7 @@ export default { } }, methods:{ + deleteRequest: function(item){ Vue.$fhcapi.UserData.deleteProfilRequest(item.profil_update_id).then((res)=>{ @@ -27,42 +28,46 @@ export default { } }); }, - getView: function(topic){ + getView: function(topic,status){ switch(topic){ case "Private Kontakte" : return "EditKontakt"; break; case "Private Adressen" : return "EditAdresse"; break; case "Add Adressen" : return "EditAdresse"; break; case "Add Kontakte" : return "EditKontakt"; break; - case "Delete Adressen" : return "Adresse"; break; - case "Delete Kontakte" : return "Kontakt"; break; + case "Delete Adressen" : return status ==='pending'? "Adresse": "Status" ; break; + case "Delete Kontakte" : return status ==='pending'? "Kontakt": "Status"; break; default: return "text_input"; break; } }, openModal(updateRequest) { console.log(JSON.stringify(updateRequest)); - let view = this.getView(updateRequest.topic); + let view = this.getView(updateRequest.topic,updateRequest.status); + let data = null; let content =null; if(view === 'text_input'){ - content={ - view:view, - data:{ + //TODO: change data handling for text_input component to accept the data in the same way as the other components + data = { titel:updateRequest.topic, value:updateRequest.requested_change, - }, - update:true, - topic:updateRequest.topic, - - } + }; }else{ - content = { - view: view, - data: updateRequest.requested_change, - update:true, - topic:updateRequest.topic, - - - } + data = updateRequest.requested_change; + } + + content={ + view:view, + data:data, + update:true, + topic:updateRequest.topic, + + } + + //? 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; } @@ -136,6 +141,12 @@ export default { + + diff --git a/public/js/components/Cis/Profil/ProfilComponents/Status.js b/public/js/components/Cis/Profil/ProfilComponents/Status.js new file mode 100644 index 000000000..bc69497bd --- /dev/null +++ b/public/js/components/Cis/Profil/ProfilComponents/Status.js @@ -0,0 +1,35 @@ +export default { + + data(){ + return { + + } + }, + props:{ + data:{type:Object}, + view:{type:String}, + status:{type:String}, + status_message:{type:String}, + status_timestamp:{type:String}, + update:{type:Boolean}, + }, + created(){ + + + },template:` +
+
Status
+ {{status}} +
+ +
+
Status message
+ {{status_message}} +
+ +
+
Date
+ {{status_timestamp}} +
`, + +} \ No newline at end of file