diff --git a/application/controllers/api/frontend/v1/stv/Address.php b/application/controllers/api/frontend/v1/stv/Address.php new file mode 100644 index 000000000..7685fcd04 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Address.php @@ -0,0 +1,66 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about addresses + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Address extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'getNations' => self::PERM_LOGGED, + 'getPlaces' => self::PERM_LOGGED + ]); + } + + public function getNations() + { + $this->load->model('codex/Nation_model', 'NationModel'); + + $this->NationModel->addOrder('kurztext'); + + $result = $this->NationModel->load(); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function getPlaces($plz) + { + $this->load->model('codex/Gemeinde_model', 'GemeindeModel'); + + $this->load->library('form_validation'); + + $this->form_validation->set_data(['address.plz' => $plz]); + + $this->form_validation->set_rules('address.plz', 'PLZ', 'numeric|less_than[10000]'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $result = $this->GemeindeModel->getGemeindeByPlz($plz); + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/components/stv/Address.php b/application/controllers/components/stv/Address.php deleted file mode 100644 index c0e34c0c3..000000000 --- a/application/controllers/components/stv/Address.php +++ /dev/null @@ -1,47 +0,0 @@ -load->model('codex/Nation_model', 'NationModel'); - - $this->NationModel->addOrder('kurztext'); - - $result = $this->NationModel->load(); - if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - } - $this->outputJson($result); - } - - public function getPlaces($plz) - { - $this->load->model('codex/Gemeinde_model', 'GemeindeModel'); - - $this->load->library('form_validation'); - - $this->form_validation->set_data(['address.plz' => $plz]); - - $this->form_validation->set_rules('address.plz', 'PLZ', 'numeric|less_than[10000]'); - - if ($this->form_validation->run() == false) { - $this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST); - return $this->outputJsonError($this->form_validation->error_array()); - } - - $result = $this->GemeindeModel->getGemeindeByPlz($plz); - if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - } - $this->outputJson($result); - } -} diff --git a/public/js/components/Stv/Studentenverwaltung.js b/public/js/components/Stv/Studentenverwaltung.js index 05a84499d..2fe6c9713 100644 --- a/public/js/components/Stv/Studentenverwaltung.js +++ b/public/js/components/Stv/Studentenverwaltung.js @@ -21,7 +21,6 @@ import StvVerband from "./Studentenverwaltung/Verband.js"; import StvList from "./Studentenverwaltung/List.js"; import StvDetails from "./Studentenverwaltung/Details.js"; import StvStudiensemester from "./Studentenverwaltung/Studiensemester.js"; -import {CoreRESTClient} from '../../RESTClient.js'; export default { @@ -107,25 +106,20 @@ export default { this.studiengangKz = studiengang_kz; this.$refs.stvList.updateUrl(link); }, - searchfunction(searchsettings) { - return Vue.$fhcapi.Search.search(searchsettings); - }, studiensemesterChanged(v) { this.studiensemesterKurzbz = v; this.$refs.stvList.updateUrl(); this.$refs.details.reload(); }, reloadList() { - console.log('reloadList2'); this.$refs.stvList.reload(); } }, created() { - CoreRESTClient - .get('components/stv/Address/getNations') - .then(result => CoreRESTClient.getData(result.data) || []) + this.$fhcApi + .get('api/frontend/v1/stv/address/getNations') .then(result => { - this.lists.nations = result; + this.lists.nations = result.data; }) .catch(this.$fhcAlert.handleSystemError); this.$fhcApi @@ -187,7 +181,7 @@ export default {
diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js index 017f3a056..e2301f7a3 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js @@ -1,5 +1,4 @@ import {CoreFilterCmpt} from "../../../../filter/Filter.js"; -import {CoreRESTClient} from "../../../../../RESTClient"; import PvAutoComplete from "../../../../../../../index.ci.php/public/js/components/primevue/autocomplete/autocomplete.esm.min.js"; import FhcFormValidation from '../../../../Form/Validation.js'; import BsModal from "../../../../Bootstrap/Modal.js"; @@ -17,7 +16,7 @@ export default{ data() { return{ tabulatorOptions: { - ajaxURL: 'api/frontend/v1/stv/Kontakt/getAdressen/' + this.uid, + ajaxURL: 'api/frontend/v1/stv/kontakt/getAdressen/' + this.uid, ajaxRequestFunc: this.$fhcApi.get, ajaxResponse: (url, params, response) => response.data, //autoColumns: true, @@ -169,21 +168,21 @@ export default{ } }, watch: { - uid(){ + uid() { this.$refs.table.tabulator.setData('api/frontend/v1/stv/Kontakt/getAdressen/' + this.uid); } }, methods:{ - actionNewAdress(){ + actionNewAdress() { this.$refs.newAdressModal.show(); }, - actionEditAdress(adress_id){ + actionEditAdress(adress_id) { this.loadAdress(adress_id).then(() => { if(this.addressData.adresse_id) this.$refs.editAdressModal.show(); }); }, - actionDeleteAdress(adress_id){ + actionDeleteAdress(adress_id) { this.loadAdress(adress_id).then(() => { if(this.addressData.adresse_id) if(this.addressData.heimatadresse) @@ -205,10 +204,10 @@ export default{ this.reload(); }); }, - reload(){ + reload() { this.$refs.table.reloadTable(); }, - loadAdress(adress_id){ + loadAdress(adress_id) { return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadAddress/' + adress_id) .then(result => { this.addressData = result.data; @@ -216,7 +215,7 @@ export default{ }) .catch(this.$fhcAlert.handleSystemError); }, - updateAddress(adress_id){ + updateAddress(adress_id) { this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateAddress/' + adress_id, this.addressData ).then(response => { @@ -229,7 +228,7 @@ export default{ this.reload(); }); }, - deleteAddress(adress_id){ + deleteAddress(adress_id) { this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteAddress/' + adress_id) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); @@ -247,13 +246,12 @@ export default{ return; this.abortController.places = new AbortController(); - CoreRESTClient - .get('components/stv/address/getPlaces/' + this.addressData.plz, undefined, { + this.$fhcApi + .get('api/frontend/v1/stv/address/getPlaces/' + this.addressData.plz, undefined, { signal: this.abortController.places.signal }) - .then(result => CoreRESTClient.getData(result.data) || []) .then(result => { - this.places = result; + this.places = result.data; }); /* .catch(error => { if (error.code == 'ERR_BAD_REQUEST') { @@ -271,20 +269,19 @@ export default{ this.filteredFirmen = result.data.retval; }); }, - hideModal(modalRef){ + hideModal(modalRef) { this.$refs[modalRef].hide(); }, - resetModal(){ + resetModal() { this.addressData = {}; this.addressData = this.initData; }, }, - created(){ - CoreRESTClient - .get('components/stv/Address/getNations') - .then(result => CoreRESTClient.getData(result.data) || []) + created() { + this.$fhcApi + .get('api/frontend/v1/stv/address/getNations') .then(result => { - this.nations = result; + this.nations = result.data; }) .catch(this.$fhcAlert.handleSystemError); this.$fhcApi