From a06f9b581fe0677f74768c892b6a353f0384f7b5 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Fri, 19 Jul 2024 13:11:58 +0200 Subject: [PATCH] adds selectProfilRequest to the new ProfilUpdate FhcAPIController --- .../api/frontend/v1/ProfilUpdate.php | 19 +++++++++++++++++++ public/js/api/profilUpdate.js | 13 +++++-------- .../Cis/Profil/MitarbeiterProfil.js | 14 ++++++-------- .../js/components/Cis/Profil/StudentProfil.js | 12 ++++++------ 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/application/controllers/api/frontend/v1/ProfilUpdate.php b/application/controllers/api/frontend/v1/ProfilUpdate.php index 706f2bf29..75e3bf9f0 100644 --- a/application/controllers/api/frontend/v1/ProfilUpdate.php +++ b/application/controllers/api/frontend/v1/ProfilUpdate.php @@ -43,6 +43,7 @@ class ProfilUpdate extends FHCAPI_Controller 'getProfilRequestFiles' => self::PERM_LOGGED, 'denyProfilRequest' => ['student/stammdaten:rw', 'mitarbeiter/stammdaten:rw'], 'acceptProfilRequest' => ['student/stammdaten:rw', 'mitarbeiter/stammdaten:rw'], + 'selectProfilRequest' => self::PERM_LOGGED, ]); @@ -115,6 +116,24 @@ class ProfilUpdate extends FHCAPI_Controller $this->terminateWithSuccess(self::$TOPICS); } + public function selectProfilRequest() + { + + $uid = $this->input->get('uid',true); + $id = $this->input->get('id',true); + $whereClause = ['uid' => $this->uid]; + + if (isset($uid)) + $whereClause['uid'] = $uid; + if (isset($id)) + $whereClause['id'] = $id; + + $res = $this->ProfilUpdateModel->getProfilUpdatesWhere($whereClause); + $res = $this->getDataOrTerminateWithError($res); + $this->terminateWithSuccess($res); + + } + public function getProfilRequestFiles($id) { if(!$id){ diff --git a/public/js/api/profilUpdate.js b/public/js/api/profilUpdate.js index 8d121fa65..ccef2f0b2 100644 --- a/public/js/api/profilUpdate.js +++ b/public/js/api/profilUpdate.js @@ -43,7 +43,7 @@ export default { }, //TODO post request - //? new reuquests + //? new requests insertFile: function (dms, replace = null) { const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + @@ -61,19 +61,16 @@ export default { FHC_JS_DATA_STORAGE_OBJECT.ci_router + `/api/frontend/v1/ProfilUpdate/getProfilRequestFiles/${requestID}`,{}); }, - - search(searchsettings) { - const url = '/api/frontend/v1/searchbar/search'; - return this.$fhcApi.post(url, searchsettings); - }, - selectProfilRequest: function (uid = null, id = null) { return this.$fhcApi.get( FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + - `/Cis/ProfilUpdate/selectProfilRequest`,{ uid: uid, id: id }); + `/api/frontend/v1/ProfilUpdate/selectProfilRequest`, + {...(uid?{uid}:{}), + ...(id?{id}:{}) + }); }, //TODO post request diff --git a/public/js/components/Cis/Profil/MitarbeiterProfil.js b/public/js/components/Cis/Profil/MitarbeiterProfil.js index 6653c8253..94ae0078f 100755 --- a/public/js/components/Cis/Profil/MitarbeiterProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterProfil.js @@ -151,17 +151,17 @@ export default { hideEditProfilModal: function () { //? checks the editModal component property result, if the user made a successful request or not if (this.$refs.editModal.result) { - Vue.$fhcapi.ProfilUpdate.selectProfilRequest() + this.$fhcApi.factory.profilUpdate.selectProfilRequest() .then((request) => { - if (!request.error) { + if (!request.error && request) { this.data.profilUpdates = request.data; this.data.profilUpdates.sort(this.sortProfilUpdates); } else { - console.log("Error when fetching profile updates: " + res.data); + console.error("Error when fetching profile updates: " + res.data); } }) .catch((err) => { - console.log(err); + console.error(err); }); } else { // when modal was closed without submitting request @@ -184,8 +184,8 @@ export default { }, fetchProfilUpdates: function () { - Vue.$fhcapi.ProfilUpdate.selectProfilRequest().then((res) => { - if (!res.error) { + this.$fhcApi.factory.profilUpdate.selectProfilRequest().then((res) => { + if (!res.error && res) { this.data.profilUpdates = res.data?.length ? res.data.sort(this.sortProfilUpdates) : null; @@ -451,8 +451,6 @@ export default {
- - diff --git a/public/js/components/Cis/Profil/StudentProfil.js b/public/js/components/Cis/Profil/StudentProfil.js index ffb0d0fd3..5cf92fd9f 100755 --- a/public/js/components/Cis/Profil/StudentProfil.js +++ b/public/js/components/Cis/Profil/StudentProfil.js @@ -95,8 +95,8 @@ export default { ); }, fetchProfilUpdates: function () { - Vue.$fhcapi.ProfilUpdate.selectProfilRequest().then((res) => { - if (!res.error) { + this.$fhcApi.factory.profilUpdate.selectProfilRequest().then((res) => { + if (!res.error && res) { this.data.profilUpdates = res.data?.length ? res.data.sort(this.sortProfilUpdates) : null; @@ -107,17 +107,17 @@ export default { hideEditProfilModal: function () { //? checks the editModal component property result, if the user made a successful request or not if (this.$refs.editModal.result) { - Vue.$fhcapi.ProfilUpdate.selectProfilRequest() + this.$fhcApi.factory.profilUpdate.selectProfilRequest() .then((request) => { - if (!request.error) { + if (!request.error && res) { this.data.profilUpdates = request.data; this.data.profilUpdates.sort(this.sortProfilUpdates); } else { - console.log("Error when fetching profile updates: " + res.data); + console.error("Error when fetching profile updates: " + res.data); } }) .catch((err) => { - console.log(err); + console.error(err); }); } else { // when modal was closed without submitting request