From 81b080ec4119d8c1f2451c1218fa3f458f992334 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Thu, 2 Nov 2023 16:41:28 +0100 Subject: [PATCH] Modal Adressen --- .../controllers/components/stv/Student.php | 22 ++++- .../Details/Kontakt/Address.js | 98 ++++++++++++------- 2 files changed, 80 insertions(+), 40 deletions(-) diff --git a/application/controllers/components/stv/Student.php b/application/controllers/components/stv/Student.php index 480e07a2c..33e0bf5bf 100644 --- a/application/controllers/components/stv/Student.php +++ b/application/controllers/components/stv/Student.php @@ -310,19 +310,35 @@ class Student extends FHC_Controller 'zustelladresse' => $_POST['zustelladresse'], 'co_name' => $_POST['co_name'], 'typ' => $_POST['typ'] - ] ); - if (isError($result)) { + if (isError($result)) + { $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); return $this->outputJson($result); } - return $this->outputJsonSuccess(true); + } + public function getAdressentypen() + { + $this->load->model('person/Adressentyp_model', 'AdressentypModel'); + $result = $this->AdressentypModel->load(); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } + public function getGmeinden($plz) + { + //TODO(manu) finish + $result = ""; + return $result; } public function getKontakte($person_id) diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js index 477b3baa2..3222326af 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js @@ -65,7 +65,12 @@ export default{ lastSelected: null, modalRefVis: false, addressData: [], - formData: {} + formData: { + zustelladresse: false, + heimatadresse: false + }, + nations: [], + adressentypen: [] } }, methods:{ @@ -75,10 +80,10 @@ export default{ bootstrap.Modal.getOrCreateInstance(this.$refs.newAdressModal).show(); }, deleteAdressData(){ - formData: {} + return this.formData = null; }, hideModal(){ - this.modalRefVis = false; + bootstrap.Modal.getOrCreateInstance(this.$refs.newAdressModal).hide(); }, addNewAddress(formData) { CoreRESTClient.post('components/stv/Student/addNewAddress/' + this.uid, @@ -86,25 +91,26 @@ export default{ ).then(response => { console.log(response); if (!response.data.error) { - this.statusCode = response.data.retval[0]; - this.statusMsg = response.data.retval[0].typ; + this.statusCode = 0; + this.statusMsg = 'success'; console.log('Speichern erfolgreich: ' + this.statusMsg); this.$fhcAlert.alertSuccess('Speichern erfolgreich'); } else { this.statusCode = 0; this.statusMsg = 'Error'; console.log('Speichern nicht erfolgreich: ' + this.statusMsg); -/* this.$fhcAlert.alertDanger('Speichern nicht erfolgreich');*/ + this.$fhcAlert.alertError('Speichern nicht erfolgreich'); } }).catch(error => { console.log(error); this.statusCode = 0; - this.statusMsg = 'Error2'; + this.statusMsg = 'Error in Catch'; console.log('Speichern nicht erfolgreich ' + this.statusMsg); + this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten'); }).finally(() => { window.scrollTo(0, 0); + hideModal(); }); - this.deleteAdressData(); }, @@ -124,17 +130,31 @@ export default{ this.$refs.table.tabulator.setData(url); }*/ }, + created(){ + CoreRESTClient + .get('components/stv/Student/getNations') + .then(result => { + this.nations = result.data; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); + CoreRESTClient + .get('components/stv/Student/getAdressentypen') + .then(result => { + this.adressentypen = result.data; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); + }, template: `
- -
- - - -
- - + +