From 84029fc72963b29f31af68524251c2864c6ca147 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Mon, 8 Jul 2024 15:15:08 +0200 Subject: [PATCH] updates editAdressen in the Profil --- application/controllers/Cis/Profil.php | 28 +-- .../controllers/api/frontend/v1/Profil.php | 27 +++ application/models/codex/Gemeinde_model.php | 24 ++ public/js/api/profil.js | 7 +- public/js/apps/Cis/Profil.js | 6 +- .../Cis/Profil/MitarbeiterProfil.js | 1 + .../ProfilComponents/ProfilInformation.js | 8 +- .../EditProfilComponents/EditAdresse.js | 221 +++++++++--------- .../js/components/Cis/Profil/StudentProfil.js | 3 + 9 files changed, 194 insertions(+), 131 deletions(-) diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index dd2c1a311..1141808fe 100755 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -244,23 +244,23 @@ class Profil extends Auth_Controller $this->GemeindeModel->addDistinct(); $this->GemeindeModel->addSelect(["name"]); if ($nation == "A") { - if (isset($zip) && $zip > 999 && $zip < 32000) { + if (isset($zip) && $zip > 999 && $zip < 32000) { - $gemeinde_res = $this->GemeindeModel->loadWhere(['plz' => $zip]); - if (isError($gemeinde_res)) { - show_error("error while trying to query bis.tbl_gemeinde"); + $gemeinde_res = $this->GemeindeModel->loadWhere(['plz' => $zip]); + if (isError($gemeinde_res)) { + show_error("error while trying to query bis.tbl_gemeinde"); + } + $gemeinde_res = hasData($gemeinde_res) ? getData($gemeinde_res) : null; + $gemeinde_res = array_map(function ($obj) { + return $obj->name; + }, $gemeinde_res); + echo json_encode($gemeinde_res); + + } else { + echo json_encode(error("ortschaftskennziffer code was not valid")); } - $gemeinde_res = hasData($gemeinde_res) ? getData($gemeinde_res) : null; - $gemeinde_res = array_map(function ($obj) { - return $obj->name; - }, $gemeinde_res); - echo json_encode($gemeinde_res); - - } else { - echo json_encode(error("ortschaftskennziffer code was not valid")); - } } else { - echo json_encode(error("Nation was not 'A' (Austria)")); + echo json_encode(error("Nation was not 'A' (Austria)")); } } diff --git a/application/controllers/api/frontend/v1/Profil.php b/application/controllers/api/frontend/v1/Profil.php index 88679c636..401c0b791 100644 --- a/application/controllers/api/frontend/v1/Profil.php +++ b/application/controllers/api/frontend/v1/Profil.php @@ -34,6 +34,8 @@ class Profil extends FHCAPI_Controller parent::__construct([ 'getView' => self::PERM_LOGGED, 'fotoSperre' => self::PERM_LOGGED, + 'getGemeinden' => self::PERM_LOGGED, + ]); @@ -143,6 +145,31 @@ class Profil extends FHCAPI_Controller $this->terminateWithSuccess(current($res)); } + public function getGemeinden($nation, $zip) + { + if(!isset($nation) || !isset($zip)){ + echo json_encode(error("Missing parameters")); + return; + } + + $this->load->model('codex/Gemeinde_model', "GemeindeModel"); + + + $gemeinde_res = $this->GemeindeModel->getGemeindeByPlz($zip); + + if (isError($gemeinde_res)) { + $this->terminateWithError(getError($gemeinde_res),self::ERROR_TYPE_GENERAL); + } + $gemeinde_res = $this->getDataOrTerminateWithError($gemeinde_res); + + /* $gemeinde_res = array_map(function ($obj) { + return $obj->ortschaftsname; + }, $gemeinde_res); */ + + $this->terminateWithSuccess($gemeinde_res); + + } + // ----------------------------------------------------------------------------------------------------------------- // Private methods diff --git a/application/models/codex/Gemeinde_model.php b/application/models/codex/Gemeinde_model.php index c782346a0..92f0e0ca4 100755 --- a/application/models/codex/Gemeinde_model.php +++ b/application/models/codex/Gemeinde_model.php @@ -19,4 +19,28 @@ class Gemeinde_model extends DB_Model return $this->loadWhere(array("plz" => $plz)); } + + public function getGemeindeByNation($nation, $zip){ + + + $this->addSelect(["name"]); + + if ($nation == "A") { + if (isset($zip) && $zip > 999 && $zip < 32000) { + + $gemeinde_res = $this->GemeindeModel->loadWhere(['plz' => $zip]); + if (isError($gemeinde_res)) { + show_error("error while trying to query bis.tbl_gemeinde"); + } + $gemeinde_res = hasData($gemeinde_res) ? getData($gemeinde_res) : null; + $gemeinde_res = array_map(function ($obj) { + return $obj->name; + }, $gemeinde_res); + echo json_encode($gemeinde_res); + + } else { + echo json_encode(error("ortschaftskennziffer code was not valid")); + } + } else {} + } } \ No newline at end of file diff --git a/public/js/api/profil.js b/public/js/api/profil.js index e2fba5f83..eefe7d880 100755 --- a/public/js/api/profil.js +++ b/public/js/api/profil.js @@ -56,13 +56,12 @@ export default { ); }, - getGemeinden: function(nation,zip=null){ + getGemeinden: function(nation,zip){ return this.$fhcApi.get( FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + - "/api/frontend/v1/Profil/getGemeinden", - { nation: nation, - ...(zip? {zip:zip}:{}) } + `/api/frontend/v1/Profil/getGemeinden/${nation}/${zip}`, + {} ); }, diff --git a/public/js/apps/Cis/Profil.js b/public/js/apps/Cis/Profil.js index 3c3855147..f2726a3db 100755 --- a/public/js/apps/Cis/Profil.js +++ b/public/js/apps/Cis/Profil.js @@ -318,16 +318,16 @@ const profilApp = Vue.createApp({ ?.filter((item) => { return !this.data.profilUpdates?.some((update) => { return ( - update.status === "pending" && + update.status === this.profilUpdateStates["Pending"] && update.requested_change?.adresse_id == item.adresse_id ); }); }) - .map((kontakt) => { + .map((adresse) => { return { listview: "Adresse", view: "EditAdresse", - data: kontakt, + data: adresse, }; }), }, diff --git a/public/js/components/Cis/Profil/MitarbeiterProfil.js b/public/js/components/Cis/Profil/MitarbeiterProfil.js index a899b0050..6653c8253 100755 --- a/public/js/components/Cis/Profil/MitarbeiterProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterProfil.js @@ -238,6 +238,7 @@ export default { created() { //? sorts the profil Updates: pending -> accepted -> rejected this.data.profilUpdates?.sort(this.sortProfilUpdates); + }, template: /*html*/ ` diff --git a/public/js/components/Cis/Profil/ProfilComponents/ProfilInformation.js b/public/js/components/Cis/Profil/ProfilComponents/ProfilInformation.js index a82f7bf3e..78e198170 100755 --- a/public/js/components/Cis/Profil/ProfilComponents/ProfilInformation.js +++ b/public/js/components/Cis/Profil/ProfilComponents/ProfilInformation.js @@ -20,11 +20,9 @@ export default { if (!this.data) { return; } - Vue.$fhcapi.UserData.sperre_foto_function(!this.FotoSperre).then( - (res) => { - this.FotoSperre = res.data.foto_sperre; - } - ); + this.$fhcApi.factory.profil.fotoSperre(!this.FotoSperre).then(res =>{ + this.FotoSperre = res.data.foto_sperre; + }) }, }, computed: { diff --git a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js index d1199686c..e51bef24c 100755 --- a/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js +++ b/public/js/components/Cis/Profil/ProfilModal/EditProfilComponents/EditAdresse.js @@ -16,6 +16,7 @@ export default { data() { return { gemeinden: [], + ortschaftnamen: [], selectedNation: null, nationenList: [], originalValue: null, @@ -27,13 +28,25 @@ export default { "data.gemeinde": function (newValue, oldValue) { this.$emit("profilUpdate", this.isChanged ? this.data : null); }, + "data.ort": function (newValue, oldValue) { + this.$emit("profilUpdate", this.isChanged ? this.data : null); + }, }, methods: { - autocompleteSearch: function (event) { + test: function () { + console.log(this.gemeinden, "this are the gemeinden"); + console.log(this.ortschaftnamen, "this are the ortschaftsnamen"); + }, + + autocompleteSearchGemeinden: function (event) { this.gemeinden = this.gemeinden.map((gemeinde) => gemeinde); }, + autocompleteSearchOrtschaftsnamen: function (event) { + this.ortschaftnamen = this.ortschaftnamen.map((ortschaft) => ortschaft); + }, + getGemeinde: function () { //? only query the gemeinde is the nation is Austria and the PLZ is greater than 999 and less than 32000 if ( @@ -43,14 +56,27 @@ export default { this.data.plz > 999 && this.data.plz < 32000 ) { - - Vue.$fhcapi.UserData.getGemeinden(this.data.nation, this.data.plz).then( - (res) => { + this.$fhcApi.factory.profil + .getGemeinden(this.data.nation, this.data.plz) + .then((res) => { if (res.data.length) { - this.gemeinden = res.data; + console.log(res.data, "this is the data from the gemeinden"); + this.gemeinden = [ + ...new Set( + res.data.map((element) => { + return element.name; + }) + ), + ]; + this.ortschaftnamen = [ + ...new Set( + res.data.map((element) => { + return element.ortschaftsname; + }) + ), + ]; } - } - ); + }); } else { this.gemeinden = []; } @@ -87,13 +113,12 @@ export default { ) { return false; } + return this.originalValue !== JSON.stringify(this.data); }, }, created() { - - Vue.$fhcapi.UserData.getAllNationen().then((res) => { this.nationenList = res.data; this.getGemeinde(); @@ -104,103 +129,89 @@ export default { }, template: /*html*/ ` -
- - -
-
-
- {{$p.t('profilUpdate','zustelladresseWarning')}} -
-
-
- +
- -
- - -
- - -
- - - - - -
- - -
- -
-
{{$p.t('person','strasse')}}*
- - -
- - -
- -
- -
-
{{$p.t('profilUpdate','kontaktTyp')}}*
- - -
- - - - - -
- -
- -
-
{{$p.t('person','ort')}}*
- - -
-
-
-
-
{{$p.t('person','plz')}}*
- - - -
-
-
- -
-
{{$p.t('person','gemeinde')}}*
- -
-
-
-
-
{{$p.t('person','nation')}}*
- - -
-
- + +
+
+
+ {{$p.t('profilUpdate','zustelladresseWarning')}} +
+
+ + + +
+
+ + +
+
+ + +
+
+
{{$p.t('person','nation')}}*
+ +
+
+ + +
+
+
{{$p.t('person','plz')}}*
+ +
+
+ + +
+
+
{{$p.t('person','gemeinde')}}*
+ +
+
+ + +
+
+
{{$p.t('person','ort')}}*
+ +
+
+ + +
+
+
{{$p.t('person','strasse')}}*
+ +
+
+ + +
+
+
{{$p.t('profilUpdate','kontaktTyp')}}*
+ +
+
+ + + + + +
`, }; diff --git a/public/js/components/Cis/Profil/StudentProfil.js b/public/js/components/Cis/Profil/StudentProfil.js index 059742c69..ffb0d0fd3 100755 --- a/public/js/components/Cis/Profil/StudentProfil.js +++ b/public/js/components/Cis/Profil/StudentProfil.js @@ -85,6 +85,7 @@ export default { editData: Object, }, methods: { + betriebsmittelTableBuilt: function () { this.$refs.betriebsmittelTable.tabulator.setData(this.data.mittel); }, @@ -181,6 +182,7 @@ export default { created() { //? sorts the profil Updates: pending -> accepted -> rejected this.data.profilUpdates?.sort(this.sortProfilUpdates); + }, @@ -205,6 +207,7 @@ export default {
+