diff --git a/application/controllers/api/frontend/v1/stv/Kontakt.php b/application/controllers/api/frontend/v1/stv/Kontakt.php index 517388b39..48a8d7c15 100644 --- a/application/controllers/api/frontend/v1/stv/Kontakt.php +++ b/application/controllers/api/frontend/v1/stv/Kontakt.php @@ -37,7 +37,8 @@ class Kontakt extends FHCAPI_Controller // Load language phrases $this->loadPhrases([ - 'ui' + 'ui', + 'person' ]); } @@ -221,6 +222,18 @@ class Kontakt extends FHCAPI_Controller public function deleteAddress($adresse_id) { $this->load->model('person/Adresse_model', 'AdresseModel'); + $result = $this->AdresseModel->load([ + 'adresse_id'=> $adresse_id, + ]); + if(isError($result)) + { + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $result = current(getData($result)); + + if($result->heimatadresse) + + $this->terminateWithError($this->p->t('person', 'error_deleteHomeAdress'), self::ERROR_TYPE_GENERAL); $result = $this->AdresseModel->delete( array('adresse_id' => $adresse_id) @@ -234,7 +247,7 @@ class Kontakt extends FHCAPI_Controller { return $this->terminateWithError($this->p->t('ui','error_missingId',['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL); } - //return $this->outputJsonSuccess(current(getData($result))); + return $this->terminateWithSuccess(current(getData($result)) ? : null); } diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js index 8f6cd9888..1f727f474 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js @@ -27,10 +27,24 @@ export default{ {title:"Ort", field:"ort"}, {title:"Gemeinde", field:"gemeinde"}, {title:"Nation", field:"nation"}, - {title:"Heimatadresse", field:"heimatadresse", - formatter: (cell, formatterParams, onRendered) => { - let output = cell.getValue() ? "ja" : "nein"; - return output; + { + title:"Heimatadresse", + field:"heimatadresse", + formatter:"tickCross", + hozAlign:"center", + formatterParams: { + tickElement: '', + crossElement: '' + } + }, + { + title:"Zustelladresse", + field:"zustelladresse", + formatter:"tickCross", + hozAlign:"center", + formatterParams: { + tickElement: '', + crossElement: '' } }, {title:"Abweich.Empf", field:"co_name"}, @@ -125,7 +139,7 @@ export default{ title: this.$p.t('person', 'rechnungsadresse') }); cm.getColumnByField('anmerkung').component.updateDefinition({ - title: this.$p.t('notiz', 'document') + title: this.$p.t('global', 'anmerkung') }); } } @@ -239,7 +253,7 @@ export default{ this.reload(); }); }, - loadPlaces() { //TODO(manu) Refactor API-controller + loadPlaces() { if (this.abortController.places) this.abortController.places.abort(); if (this.addressData.nation != 'A' || !this.addressData.plz) @@ -254,13 +268,11 @@ export default{ this.places = result.data; }); /* .catch(error => { - if (error.code == 'ERR_BAD_REQUEST') { - return this.$fhcAlert.handleFormValidation(error, this.$refs.form); - } - // NOTE(chris): repeat request - if (error.code != "ERR_CANCELED") - window.setTimeout(this.loadPlaces, 100); - });*/ + if (error.code != "ERR_CANCELED") + window.setTimeout(this.loadPlaces, 100); + else + this.$fhcAlert.handleSystemError(error); + });*/ }, search(event) { return this.$fhcApi @@ -324,7 +336,7 @@ export default{