From 0cc62221757639ad30f4afe7d1777fa246a65fa8 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Fri, 19 Jul 2024 14:57:42 +0200 Subject: [PATCH] adds deleteProfilRequest to the new ProfilUpdate FhcAPIController --- .../controllers/api/frontend/v1/ProfilUpdate.php | 15 +++++++++++++-- public/js/api/profilUpdate.js | 11 ++++++----- .../Profil/ProfilComponents/FetchProfilUpdates.js | 5 +++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/application/controllers/api/frontend/v1/ProfilUpdate.php b/application/controllers/api/frontend/v1/ProfilUpdate.php index c9b453c78..44d70afb4 100644 --- a/application/controllers/api/frontend/v1/ProfilUpdate.php +++ b/application/controllers/api/frontend/v1/ProfilUpdate.php @@ -46,8 +46,8 @@ class ProfilUpdate extends FHCAPI_Controller 'selectProfilRequest' => self::PERM_LOGGED, 'insertProfilRequest' => self::PERM_LOGGED, 'updateProfilRequest' => self::PERM_LOGGED, - - ]); + 'deleteProfilRequest' => self::PERM_LOGGED, + ]); // Load language phrases $this->loadPhrases( @@ -238,6 +238,17 @@ class ProfilUpdate extends FHCAPI_Controller $this->terminateWithSuccess(success($updateID)); } + public function deleteProfilRequest() + { + + $requestID = $this->input->post('requestID', true); + $result = $this->ProfilUpdateModel->delete([$requestID]); + if (isError($result)) { + $this->terminateWithError(getError($result)); + } + $this->terminateWithSuccess($result); + } + public function getProfilRequestFiles($id) { if(!$id){ diff --git a/public/js/api/profilUpdate.js b/public/js/api/profilUpdate.js index 50ced7cdd..742e4a1b1 100644 --- a/public/js/api/profilUpdate.js +++ b/public/js/api/profilUpdate.js @@ -100,14 +100,15 @@ export default { }); }, - //TODO post request deleteProfilRequest: function (requestID) { - const url = + + return this.$fhcApi.post( FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + - `/Cis/ProfilUpdate/deleteProfilRequest`; - - return axios.post(url, requestID); + `/api/frontend/v1/ProfilUpdate/deleteProfilRequest`, + { + requestID, + }); }, }; \ No newline at end of file diff --git a/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js b/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js index 368b5e111..9caee9468 100755 --- a/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js +++ b/public/js/components/Cis/Profil/ProfilComponents/FetchProfilUpdates.js @@ -107,17 +107,18 @@ export default { }, deleteRequest: function (item) { - Vue.$fhcapi.ProfilUpdate.deleteProfilRequest(item.profil_update_id).then( + this.$fhcApi.factory.profilUpdate.deleteProfilRequest(item.profil_update_id).then( (res) => { if (res.data.error) { //? open alert - console.log(res.data); + console.error("error happened",res.data); } else { this.$emit("fetchUpdates"); } } ); }, + getView: function (topic, status) { if (!(status === this.profilUpdateStates["Pending"])) { return "Status";