From 9d5a0585b037b0540c99772df0ee1398362cb058 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Thu, 26 Sep 2024 07:56:15 +0200 Subject: [PATCH 01/15] Phrases alerts, templates, tabulator --- .../api/frontend/v1/stv/Kontakt.php | 10 -- .../Betriebsmittel/Betriebsmittel.js | 17 +- .../Details/Kontakt/Address.js | 8 +- .../Details/Kontakt/Bankaccount.js | 18 +- .../Details/Kontakt/Contact.js | 4 +- .../Details/Prestudent/MultiStatus.js | 12 +- .../Details/Status/Dropdown.js | 1 - system/phrasesupdate.php | 161 ++++++++++++++++++ 8 files changed, 199 insertions(+), 32 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Kontakt.php b/application/controllers/api/frontend/v1/stv/Kontakt.php index 379184ee0..35c6f3e96 100644 --- a/application/controllers/api/frontend/v1/stv/Kontakt.php +++ b/application/controllers/api/frontend/v1/stv/Kontakt.php @@ -439,7 +439,6 @@ class Kontakt extends FHCAPI_Controller { return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL); } - // $this->outputJsonSuccess(current(getData($result))); $this->terminateWithSuccess(current(getData($result))); } @@ -523,13 +522,6 @@ class Kontakt extends FHCAPI_Controller $this->terminateWithValidationErrors($this->form_validation->error_array()); } -/* if(isset($_POST['standort'])) - { - $standort_id = $_POST['standort']['standort_id']; - } - else - $standort_id = null;*/ - $uid = getAuthUID(); $kontakttyp = $this->input->post('kontakttyp'); $anmerkung = $this->input->post('anmerkung'); @@ -538,8 +530,6 @@ class Kontakt extends FHCAPI_Controller $person_id = $this->input->post('person_id'); $standort_id = $this->input->post('standort_id'); - //return $this->terminateWithError("in update " . $standort_id, self::ERROR_TYPE_GENERAL); - $result = $this->KontaktModel->update( [ 'kontakt_id' => $kontakt_id diff --git a/public/js/components/Betriebsmittel/Betriebsmittel.js b/public/js/components/Betriebsmittel/Betriebsmittel.js index a3acb6673..3849578ea 100644 --- a/public/js/components/Betriebsmittel/Betriebsmittel.js +++ b/public/js/components/Betriebsmittel/Betriebsmittel.js @@ -66,7 +66,7 @@ export default { let button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; - button.title = 'Übernahmebestätigung drucken'; + button.title = this.$p.t('betriebsmittel', 'btn_printUebernahmebestaetigung'); let cellData = cell.getData(); button.addEventListener( 'click', @@ -82,7 +82,7 @@ export default { button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; - button.title = 'Betriebsmittel bearbeiten'; + button.title = this.$p.t('betriebsmittel', 'btn_editBetriebsmittel'); button.addEventListener( 'click', (event) => @@ -93,7 +93,7 @@ export default { button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; - button.title = 'Betriebsmittel löschen'; + button.title = this.$p.t('betriebsmittel', 'btn_deleteBetriebsmittel'); button.addEventListener( 'click', () => @@ -117,26 +117,31 @@ export default { event: 'tableBuilt', handler: async() => { - await this.$p.loadCategory(['wawi', 'global', 'infocenter']); + await this.$p.loadCategory(['wawi', 'global', 'infocenter', 'betriebsmittel']); let cm = this.$refs.table.tabulator.columnManager; cm.getColumnByField('nummer').component.updateDefinition({ title: this.$p.t('wawi', 'nummer') }); + cm.getColumnByField('betriebsmitteltyp').component.updateDefinition({ + title: this.$p.t('global', 'typ') + }); cm.getColumnByField('anmerkung').component.updateDefinition({ title: this.$p.t('global', 'anmerkung') }); cm.getColumnByField('format_retour').component.updateDefinition({ title: this.$p.t('wawi', 'retourdatum') }); + cm.getColumnByField('beschreibung').component.updateDefinition({ + title: this.$p.t('global', 'beschreibung') + }); cm.getColumnByField('kaution').component.updateDefinition({ title: this.$p.t('infocenter', 'kaution') }); cm.getColumnByField('format_ausgabe').component.updateDefinition({ title: this.$p.t('wawi', 'ausgabedatum') }); - } } ], @@ -261,7 +266,7 @@ export default { :side-menu="false" reload new-btn-show - new-btn-label="Betriebsmittel" + :new-btn-label="this.$p.t('ui', 'betriebsmittel')" @click:new="actionNewBetriebsmittel" > diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js index c6bd07be4..872f16122 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js @@ -60,7 +60,7 @@ export default{ {title:"letzte Änderung", field:"updateamum", visible:false}, {title:"Rechnungsadresse", field:"rechnungsadresse", visible:false, formatter: (cell, formatterParams, onRendered) => { - let output = cell.getValue() ? "ja" : "nein"; + let output = cell.getValue() ? this.$p.t('ui','ja') : this.$p.t('ui','nein'); return output; } }, @@ -74,6 +74,7 @@ export default{ let button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; + button.title = this.$p.t('person', 'adresse_edit'); button.addEventListener('click', (event) => this.actionEditAdress(cell.getData().adresse_id) ); @@ -82,6 +83,7 @@ export default{ button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; + button.title = this.$p.t('person', 'adresse_delete'); button.addEventListener('click', () => this.actionDeleteAdress(cell.getData().adresse_id) ); @@ -103,7 +105,7 @@ export default{ { event: 'tableBuilt', handler: async () => { - await this.$p.loadCategory(['notiz','global','person', 'ui']); + await this.$p.loadCategory(['notiz', 'global', 'person', 'ui']); let cm = this.$refs.table.tabulator.columnManager; cm.getColumnByField('bezeichnung').component.updateDefinition({ @@ -574,7 +576,7 @@ export default{ :side-menu="false" reload new-btn-show - new-btn-label="Adresse" + :new-btn-label="this.$p.t('person', 'adresse')" @click:new="actionNewAdress" > diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js index 7eb1229f7..41ca5e550 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js @@ -63,6 +63,7 @@ export default{ let button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; + button.title = this.$p.t('person', 'bankvb_edit'); button.addEventListener('click', (event) => this.actionEditBankverbindung(cell.getData().bankverbindung_id) ); @@ -71,6 +72,7 @@ export default{ button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; + button.title = this.$p.t('person', 'bankvb_delete'); button.addEventListener('click', () => this.actionDeleteBankverbindung(cell.getData().bankverbindung_id) ); @@ -96,6 +98,14 @@ export default{ let cm = this.$refs.table.tabulator.columnManager; + cm.getColumnByField('name').component.updateDefinition({ + title: this.$p.t('global', 'name') + }); + + cm.getColumnByField('typ').component.updateDefinition({ + title: this.$p.t('global', 'typ') + }); + cm.getColumnByField('anschrift').component.updateDefinition({ title: this.$p.t('person', 'anschrift') }); @@ -105,9 +115,7 @@ export default{ cm.getColumnByField('blz').component.updateDefinition({ title: this.$p.t('person', 'blz') }); - cm.getColumnByField('typ').component.updateDefinition({ - title: this.$p.t('global', 'typ') - }); + cm.getColumnByField('verrechnung').component.updateDefinition({ title: this.$p.t('person', 'verrechnung') }); @@ -234,7 +242,7 @@ export default{ @@ -328,7 +336,7 @@ export default{ :side-menu="false" reload new-btn-show - new-btn-label="Bankverbindung" + :new-btn-label="this.$p.t('person', 'bankverbindung')" @click:new="actionNewBankverbindung" > diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js index 3acb6353d..9d6eb06d7 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js @@ -51,6 +51,7 @@ export default{ let button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; + button.title = this.$p.t('person', 'kontakt_edit'); button.addEventListener('click', (event) => this.actionEditContact(cell.getData().kontakt_id) ); @@ -59,6 +60,7 @@ export default{ button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; + button.title = this.$p.t('person', 'kontakt_delete'); button.addEventListener('click', () => this.actionDeleteContact(cell.getData().kontakt_id) ); @@ -393,7 +395,7 @@ export default{ :side-menu="false" reload new-btn-show - new-btn-label="Kontakt" + :new-btn-label="this.$p.t('global', 'kontakt')" @click:new="actionNewContact" > diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js index ac4a2dd9e..0552f1a37 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js @@ -92,7 +92,7 @@ export default{ let button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; - button.title = 'Status vorrücken'; + button.title = this.$p.t('ui', 'btn_statusVorruecken'); button.addEventListener('click', () => this.actionAdvanceStatus(data.status_kurzbz, data.studiensemester_kurzbz, data.ausbildungssemester) ); @@ -103,7 +103,7 @@ export default{ button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; - button.title = 'Status bestätigen'; + button.title = this.$p.t('ui', 'btn_confirmStatus'); button.addEventListener('click', () => this.actionConfirmStatus(data.status_kurzbz, data.studiensemester_kurzbz, data.ausbildungssemester) ); @@ -114,7 +114,7 @@ export default{ button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; - button.title = 'Status bearbeiten'; + button.title = this.$p.t('ui', 'btn_editStatus'); button.addEventListener('click', () => this.actionEditStatus(data.status_kurzbz, data.studiensemester_kurzbz, data.ausbildungssemester) ); @@ -125,7 +125,7 @@ export default{ button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; - button.title = 'Status löschen'; + button.title = this.$p.t('ui', 'btn_deleteStatus'); button.addEventListener('click', () => this.actionDeleteStatus(data.status_kurzbz, data.studiensemester_kurzbz, data.ausbildungssemester) ); @@ -154,7 +154,7 @@ export default{ { event: 'tableBuilt', handler: async () => { - await this.$p.loadCategory(['lehre','global','person']); + await this.$p.loadCategory(['lehre','global','person','ui']); let cm = this.$refs.table.tabulator.columnManager; @@ -328,7 +328,7 @@ export default{ :side-menu="false" reload new-btn-show - new-btn-label="Status" + :new-btn-label="this.$p.t('global', 'status')" @click:new="actionNewStatus" > diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Status/Dropdown.js b/public/js/components/Stv/Studentenverwaltung/Details/Status/Dropdown.js index 77e1db67b..203442975 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Status/Dropdown.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Status/Dropdown.js @@ -35,7 +35,6 @@ export default { data() { return { listDataToolbar: [], - //TODO(Manu) get from config statiInteressent: ["Bewerber", "Aufgenommener", "Student" , "Wartender", "Abgewiesener"], statiStudent: ["Abbrecher", "Unterbrecher", "Student" , "Diplomand", "Absolvent"] }; diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 7019892e0..5577f4079 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -27295,6 +27295,26 @@ array( ) ) ), + array( + 'app' => 'core', + 'category' => 'person', + 'phrase' => 'bankverbindung', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Bankverbindung', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'bank details', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), //Status array( 'app' => 'core', @@ -28416,6 +28436,87 @@ array( ) ) ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'btn_statusVorruecken', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Status vorrücken', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'advance status', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'btn_confirmStatus', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Status bestätigen', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'confirm status', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'btn_editStatus', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Status bearbeiten', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'edit status', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'btn_deleteStatus', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Status löschen', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'delete status', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + // Betriebsmittel begin array( 'app' => 'core', @@ -30165,6 +30266,66 @@ array( ) ) ), + array( + 'app' => 'core', + 'category' => 'betriebsmittel', + 'phrase' => 'btn_printUebernahmebestaetigung', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Übernahmebestätigung drucken', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Print acceptance confirmation', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'betriebsmittel', + 'phrase' => 'btn_editBetriebsmittel', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Betriebsmittel bearbeiten', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Edit Resource', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'betriebsmittel', + 'phrase' => 'btn_deleteBetriebsmittel', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Betriebsmittel löschen', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Delete Resource', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), // Betriebsmittel end array( 'app' => 'core', From 0127982f50567ee80e874257676e84d49c1fb6af Mon Sep 17 00:00:00 2001 From: ma0068 Date: Fri, 27 Sep 2024 10:54:54 +0200 Subject: [PATCH 02/15] use factories in Address.js, Bankaccount.js, Contact.js --- .../api/frontend/v1/stv/Address.php | 6 +- .../api/frontend/v1/stv/Kontakt.php | 49 +++++++++--- public/js/api/stv.js | 2 + public/js/api/stv/kontakt.js | 78 +++++++++++++++++++ .../Details/Kontakt/Address.js | 46 +++++------ .../Details/Kontakt/Bankaccount.js | 20 +++-- .../Details/Kontakt/Contact.js | 30 +++---- 7 files changed, 176 insertions(+), 55 deletions(-) create mode 100644 public/js/api/stv/kontakt.js diff --git a/application/controllers/api/frontend/v1/stv/Address.php b/application/controllers/api/frontend/v1/stv/Address.php index 7685fcd04..48a3a3aa0 100644 --- a/application/controllers/api/frontend/v1/stv/Address.php +++ b/application/controllers/api/frontend/v1/stv/Address.php @@ -45,8 +45,12 @@ class Address extends FHCAPI_Controller $this->terminateWithSuccess($data); } - public function getPlaces($plz) + public function getPlaces($plz = null) { + //TODO(Manu) check with Chris + if (!$plz){ + $plz = $this->input->post('plz'); + } $this->load->model('codex/Gemeinde_model', 'GemeindeModel'); $this->load->library('form_validation'); diff --git a/application/controllers/api/frontend/v1/stv/Kontakt.php b/application/controllers/api/frontend/v1/stv/Kontakt.php index 35c6f3e96..1bc751a27 100644 --- a/application/controllers/api/frontend/v1/stv/Kontakt.php +++ b/application/controllers/api/frontend/v1/stv/Kontakt.php @@ -97,7 +97,22 @@ class Kontakt extends FHCAPI_Controller || $this->router->method == 'deleteContact' || $this->router->method == 'deleteBankverbindung' ) { - $id = current(array_slice($this->uri->rsegments, 2)); + + //TODO(manu) build all new with postparamater + + if($this->input->post('address_id')) + $id = $this->input->post('address_id'); + if($this->input->post('adresse_id')) + $id = $this->input->post('adresse_id'); + if($this->input->post('bankverbindung_id')) + $id = $this->input->post('bankverbindung_id'); + if($this->input->post('kontakt_id')) + $id = $this->input->post('kontakt_id'); + + //$id = current(array_slice($this->uri->rsegments, 2)); + // $id = $this->input->post('address_id') || $this->input->post('adresse_id'); + //$id: no more uri parameter + // $this->terminateWithError($this->router->method, self::ERROR_TYPE_GENERAL); $model = 'person/Adresse_model'; if ($this->router->method == 'loadContact' @@ -203,8 +218,11 @@ class Kontakt extends FHCAPI_Controller return $this->outputJsonSuccess(true); } - public function updateAddress($address_id) + public function updateAddress() { + //TODO(Manu) rename all to same + $address_id = $this->input->post('adresse_id'); + $uid = getAuthUID(); $this->form_validation->set_rules('plz', 'PLZ', 'required|numeric', [ 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'PLZ']), @@ -279,8 +297,10 @@ class Kontakt extends FHCAPI_Controller return $this->outputJsonSuccess(true); } - public function loadAddress($adresse_id) + public function loadAddress() { + $adresse_id = $this->input->post('address_id'); + $this->load->model('person/Adresse_model', 'AdresseModel'); $this->AdresseModel->addSelect('public.tbl_adresse.*'); @@ -306,8 +326,12 @@ class Kontakt extends FHCAPI_Controller $this->terminateWithSuccess(current(getData($result)) ? : null); } - public function deleteAddress($adresse_id) + public function deleteAddress() { + //TODO(Manu) rename all to same + $adresse_id = $this->input->post('address_id'); + // return $this->terminateWithError($adresse_id, self::ERROR_TYPE_GENERAL); + $this->load->model('person/Adresse_model', 'AdresseModel'); $result = $this->AdresseModel->load([ 'adresse_id'=> $adresse_id, @@ -418,8 +442,9 @@ class Kontakt extends FHCAPI_Controller } } - public function loadContact($kontakt_id) + public function loadContact() { + $kontakt_id = $this->input->post('kontakt_id'); $this->load->model('person/Kontakt_model', 'KontaktModel'); $this->KontaktModel->addSelect('*, public.tbl_kontakt.*'); @@ -494,8 +519,9 @@ class Kontakt extends FHCAPI_Controller return $this->outputJsonSuccess(true); } - public function updateContact($kontakt_id) + public function updateContact() { + $kontakt_id = $this->input->post('kontakt_id'); $this->load->model('person/Kontakt_model', 'KontaktModel'); if(!$kontakt_id) @@ -554,8 +580,9 @@ class Kontakt extends FHCAPI_Controller return $this->outputJsonSuccess(true); } - public function deleteContact($kontakt_id) + public function deleteContact() { + $kontakt_id = $this->input->post('kontakt_id'); $this->load->model('person/Kontakt_model', 'KontaktModel'); $result = $this->KontaktModel->delete( @@ -640,8 +667,10 @@ class Kontakt extends FHCAPI_Controller return $this->outputJsonSuccess(true); } - public function loadBankverbindung($bankverbindung_id) + public function loadBankverbindung() { + $bankverbindung_id = $this->input->post('bankverbindung_id'); + $this->load->model('person/Bankverbindung_model', 'BankverbindungModel'); $this->BankverbindungModel->addSelect('*'); @@ -716,8 +745,10 @@ class Kontakt extends FHCAPI_Controller return $this->outputJsonSuccess(true); } - public function deleteBankverbindung($bankverbindung_id) + public function deleteBankverbindung() { + $bankverbindung_id = $this->input->post('bankverbindung_id'); + $this->load->model('person/Bankverbindung_model', 'BankverbindungModel'); $result = $this->BankverbindungModel->delete( diff --git a/public/js/api/stv.js b/public/js/api/stv.js index 14fcc6661..aabbc813a 100644 --- a/public/js/api/stv.js +++ b/public/js/api/stv.js @@ -2,12 +2,14 @@ import verband from './stv/verband.js'; import students from './stv/students.js'; import filter from './stv/filter.js'; import konto from './stv/konto.js'; +import kontakt from './stv/kontakt.js'; export default { verband, students, filter, konto, + kontakt, configStudent() { return this.$fhcApi.get('api/frontend/v1/stv/config/student'); }, diff --git a/public/js/api/stv/kontakt.js b/public/js/api/stv/kontakt.js new file mode 100644 index 000000000..718db5b63 --- /dev/null +++ b/public/js/api/stv/kontakt.js @@ -0,0 +1,78 @@ +export default { + //TODO(Manu) check if tabulatorConfig use here like in konto.js + getAdressen (url, config, params){ + return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getAdressen/' + params.id); + }, + addNewAddress(id, data) { + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewAddress/' + id, + data + ); + }, + loadAddress(address_id){ + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/loadAddress/', {address_id}); + }, + updateAddress(address_id, data) { + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateAddress/' + address_id, + data + ); + }, + deleteAddress(address_id) { + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteAddress/', {address_id}); + }, + getPlaces(plz) { + return this.$fhcApi.get('api/frontend/v1/stv/address/getPlaces/' + plz); + }, + getFirmen(searchString) { + return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getFirmen/' + searchString); + }, + getNations() { + return this.$fhcApi.get('api/frontend/v1/stv/address/getNations/'); + }, + getAdressentypen() { + return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getAdressentypen/'); + }, + getBankverbindung (url, config, params){ + return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getBankverbindung/' + params.id); + }, + addNewBankverbindung(id, data) { + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewBankverbindung/' + id, + data + ); + }, + loadBankverbindung(bankverbindung_id){ + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/loadBankverbindung/', {bankverbindung_id}); + }, + updateBankverbindung(bankverbindung_id, data) { + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateBankverbindung/' + bankverbindung_id, + data + ); + }, + deleteBankverbindung(bankverbindung_id) { + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteBankverbindung/', {bankverbindung_id}); + }, + getKontakte (url, config, params){ + return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getKontakte/' + params.id); + }, + addNewContact(id, data) { + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewContact/' + id, + data + ); + }, + loadContact(kontakt_id){ + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/loadContact/', {kontakt_id}); + }, + updateContact(kontakt_id, data) { + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateContact/' + kontakt_id, + data + ); + }, + deleteContact(kontakt_id) { + return this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteContact/', {kontakt_id}); + }, + getStandorteByFirma(searchString){ + return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getStandorteByFirma/' + searchString); + }, + getKontakttypen(){ + return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getKontakttypen/'); + } +}; \ No newline at end of file diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js index 872f16122..7c3933f01 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js @@ -18,10 +18,15 @@ export default{ uid: Number }, data() { - return{ + return { tabulatorOptions: { - ajaxURL: 'api/frontend/v1/stv/kontakt/getAdressen/' + this.uid, - ajaxRequestFunc: this.$fhcApi.get, + ajaxURL: 'dummy', + ajaxRequestFunc: this.$fhcApi.factory.stv.kontakt.getAdressen, + ajaxParams: () => { + return { + id: this.uid + }; + }, ajaxResponse: (url, params, response) => response.data, //autoColumns: true, columns:[ @@ -219,9 +224,8 @@ export default{ }); }, addNewAddress(addressData) { - this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewAddress/' + this.uid, - this.addressData - ).then(response => { + return this.$fhcApi.factory.stv.kontakt.addNewAddress(this.uid, this.addressData) + .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); this.hideModal('adressModal'); this.resetModal(); @@ -236,7 +240,7 @@ export default{ }, loadAdress(adress_id) { this.statusNew = false; - return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadAddress/' + adress_id) + return this.$fhcApi.factory.stv.kontakt.loadAddress(adress_id) .then(result => { this.addressData = result.data; return result; @@ -244,7 +248,7 @@ export default{ .catch(this.$fhcAlert.handleSystemError); }, updateAddress(adress_id) { - this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateAddress/' + adress_id, + return this.$fhcApi.factory.stv.kontakt.updateAddress(adress_id, this.addressData ).then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); @@ -257,7 +261,7 @@ export default{ }); }, deleteAddress(adress_id) { - this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteAddress/' + adress_id) + return this.$fhcApi.factory.stv.kontakt.deleteAddress(adress_id) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); }).catch(this.$fhcAlert.handleSystemError) @@ -267,16 +271,14 @@ export default{ }); }, loadPlaces() { - if (this.abortController.places) - this.abortController.places.abort(); + //TODO(Manu) check with chris if its okay without abortion controller +/* if (this.abortController.places) + this.abortController.places.abort();*/ if (this.addressData.nation != 'A' || !this.addressData.plz) return; - this.abortController.places = new AbortController(); - this.$fhcApi - .get('api/frontend/v1/stv/address/getPlaces/' + this.addressData.plz, undefined, { - signal: this.abortController.places.signal - }) + //this.abortController.places = new AbortController(); + return this.$fhcApi.factory.stv.kontakt.getPlaces(this.addressData.plz) .then(result => { this.places = result.data; }); @@ -288,8 +290,7 @@ export default{ });*/ }, search(event) { - return this.$fhcApi - .get('api/frontend/v1/stv/kontakt/getFirmen/' + event.query) + return this.$fhcApi.factory.stv.kontakt.getFirmen(event.query) .then(result => { this.filteredFirmen = result.data.retval; }); @@ -316,18 +317,17 @@ export default{ }, }, created() { - this.$fhcApi - .get('api/frontend/v1/stv/address/getNations') + this.$fhcApi.factory.stv.kontakt.getNations() .then(result => { this.nations = result.data; }) .catch(this.$fhcAlert.handleSystemError); - this.$fhcApi - .get('api/frontend/v1/stv/kontakt/getAdressentypen') + + this.$fhcApi.factory.stv.kontakt.getAdressentypen() .then(result => { this.adressentypen = result.data; }) - .catch(this.$fhcAlert.handleSystemError) + .catch(this.$fhcAlert.handleSystemError); }, template: `
diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js index 41ca5e550..fbb9b4a8b 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js @@ -16,8 +16,13 @@ export default{ data() { return{ tabulatorOptions: { - ajaxURL: 'api/frontend/v1/stv/Kontakt/getBankverbindung/' + this.uid, - ajaxRequestFunc: this.$fhcApi.get, + ajaxURL: 'dummy', + ajaxRequestFunc: this.$fhcApi.factory.stv.kontakt.getBankverbindung, + ajaxParams: () => { + return { + id: this.uid + }; + }, ajaxResponse: (url, params, response) => response.data, columns:[ {title:"Name", field:"name"}, @@ -159,9 +164,8 @@ export default{ }); }, addNewBankverbindung(bankverbindungData) { - this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewBankverbindung/' + this.uid, - this.bankverbindungData - ).then(response => { + return this.$fhcApi.factory.stv.kontakt.addNewBankverbindung(this.uid, this.bankverbindungData) + .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); this.hideModal('bankverbindungModal'); this.resetModal(); @@ -173,7 +177,7 @@ export default{ }, loadBankverbindung(bankverbindung_id){ this.statusNew = false; - return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadBankverbindung/' + bankverbindung_id) + return this.$fhcApi.factory.stv.kontakt.loadBankverbindung(bankverbindung_id) .then( result => { this.bankverbindungData = result.data; @@ -182,7 +186,7 @@ export default{ .catch(this.$fhcAlert.handleSystemError); }, updateBankverbindung(bankverbindung_id){ - this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateBankverbindung/' + bankverbindung_id, + return this.$fhcApi.factory.stv.kontakt.updateBankverbindung(bankverbindung_id, this.bankverbindungData) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); @@ -195,7 +199,7 @@ export default{ }); }, deleteBankverbindung(bankverbindung_id){ - this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteBankverbindung/' + bankverbindung_id) + return this.$fhcApi.factory.stv.kontakt.deleteBankverbindung(bankverbindung_id) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); }).catch(this.$fhcAlert.handleSystemError) diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js index 9d6eb06d7..cfa4e3fc6 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js @@ -18,8 +18,13 @@ export default{ data() { return{ tabulatorOptions: { - ajaxURL: 'api/frontend/v1/stv/Kontakt/getKontakte/' + this.uid, - ajaxRequestFunc: this.$fhcApi.get, + ajaxURL: 'dummy', + ajaxRequestFunc: this.$fhcApi.factory.stv.kontakt.getKontakte, + ajaxParams: () => { + return { + id: this.uid + }; + }, ajaxResponse: (url, params, response) => response.data, columns:[ {title:"Typ", field:"kontakttyp"}, @@ -158,8 +163,7 @@ export default{ .catch(this.$fhcAlert.handleSystemError); }, addNewContact(formData) { - this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewContact/' + this.uid, - this.contactData) + return this.$fhcApi.factory.stv.kontakt.addNewContact(this.uid, this.contactData) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); this.hideModal("contactModal"); @@ -170,11 +174,11 @@ export default{ this.reload(); }); }, - loadContact(contact_id){ + loadContact(kontakt_id){ this.statusNew = false; if(this.contactData.firma_id) this.loadStandorte(this.contactData.firma_id); - return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadContact/' + contact_id) + return this.$fhcApi.factory.stv.kontakt.loadContact(kontakt_id) .then( result => { this.contactData = result.data; @@ -183,7 +187,7 @@ export default{ .catch(this.$fhcAlert.handleSystemError); }, deleteContact(kontakt_id){ - this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteContact/' + kontakt_id) + return this.$fhcApi.factory.stv.kontakt.deleteContact(kontakt_id) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); }) @@ -195,9 +199,9 @@ export default{ }); }, updateContact(kontakt_id){ - this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateContact/' + kontakt_id, - this.contactData). - then(response => { + return this.$fhcApi.factory.stv.kontakt.updateContact(kontakt_id, + this.contactData) + .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); this.hideModal('contactModal'); this.resetModal(); @@ -223,8 +227,7 @@ export default{ }); }, loadStandorte(firmen_id) { - return this.$fhcApi - .get('api/frontend/v1/stv/kontakt/getStandorteByFirma/' + firmen_id) + return this.$fhcApi.factory.stv.kontakt.getStandorteByFirma(firmen_id) .then(result => { this.filteredOrte = result.data; }); @@ -244,8 +247,7 @@ export default{ }, }, created(){ - this.$fhcApi - .get('api/frontend/v1/stv/kontakt/getKontakttypen') + this.$fhcApi.factory.stv.kontakt.getKontakttypen() .then(result => { this.kontakttypen = result.data; }) From 00cf7b8112054bbd1e283ad133a9a1ddbe504192 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Tue, 1 Oct 2024 15:27:36 +0200 Subject: [PATCH 03/15] tabs Status and Gesamthistorie: use factories --- .../api/frontend/v1/stv/Status.php | 9 +-- public/js/api/stv.js | 4 + public/js/api/stv/kontakt.js | 5 ++ public/js/api/stv/prestudent.js | 32 ++++++++ public/js/api/stv/status.js | 46 +++++++++++ .../Details/Prestudent/History.js | 17 +++- .../Details/Prestudent/MultiStatus.js | 81 ++++++++++--------- .../Details/Status/Dropdown.js | 19 +---- .../Details/Status/Modal.js | 41 ++++------ 9 files changed, 166 insertions(+), 88 deletions(-) create mode 100644 public/js/api/stv/prestudent.js create mode 100644 public/js/api/stv/status.js diff --git a/application/controllers/api/frontend/v1/stv/Status.php b/application/controllers/api/frontend/v1/stv/Status.php index 074f4029e..4e7189d1d 100644 --- a/application/controllers/api/frontend/v1/stv/Status.php +++ b/application/controllers/api/frontend/v1/stv/Status.php @@ -647,15 +647,8 @@ class Status extends FHCAPI_Controller return $this->outputJsonSuccess(true); } - public function loadStatus() + public function loadStatus($prestudent_id, $status_kurzbz, $studiensemester_kurzbz, $ausbildungssemester) { - $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); - - $prestudent_id = $this->input->post('prestudent_id'); - $status_kurzbz = $this->input->post('status_kurzbz'); - $ausbildungssemester = $this->input->post('ausbildungssemester'); - $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); - $result = $this->PrestudentstatusModel->loadWhere( array( 'prestudent_id' => $prestudent_id, diff --git a/public/js/api/stv.js b/public/js/api/stv.js index aabbc813a..5a8316916 100644 --- a/public/js/api/stv.js +++ b/public/js/api/stv.js @@ -3,6 +3,8 @@ import students from './stv/students.js'; import filter from './stv/filter.js'; import konto from './stv/konto.js'; import kontakt from './stv/kontakt.js'; +import prestudent from './stv/prestudent.js'; +import status from './stv/status.js'; export default { verband, @@ -10,6 +12,8 @@ export default { filter, konto, kontakt, + prestudent, + status, configStudent() { return this.$fhcApi.get('api/frontend/v1/stv/config/student'); }, diff --git a/public/js/api/stv/kontakt.js b/public/js/api/stv/kontakt.js index 718db5b63..8a309564c 100644 --- a/public/js/api/stv/kontakt.js +++ b/public/js/api/stv/kontakt.js @@ -1,5 +1,6 @@ export default { //TODO(Manu) check if tabulatorConfig use here like in konto.js + //------------- address.js----------- getAdressen (url, config, params){ return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getAdressen/' + params.id); }, @@ -31,6 +32,8 @@ export default { getAdressentypen() { return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getAdressentypen/'); }, + + //------------- bankverbindung.js----------- getBankverbindung (url, config, params){ return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getBankverbindung/' + params.id); }, @@ -50,6 +53,8 @@ export default { deleteBankverbindung(bankverbindung_id) { return this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteBankverbindung/', {bankverbindung_id}); }, + + //------------- contact.js----------- getKontakte (url, config, params){ return this.$fhcApi.get('api/frontend/v1/stv/kontakt/getKontakte/' + params.id); }, diff --git a/public/js/api/stv/prestudent.js b/public/js/api/stv/prestudent.js new file mode 100644 index 000000000..4e97759f4 --- /dev/null +++ b/public/js/api/stv/prestudent.js @@ -0,0 +1,32 @@ +export default { + +//------------- MultiStatus.js------------------------------------------------------ + + getHistoryPrestudent (url, config, params){ + return this.$fhcApi.get('api/frontend/v1/stv/status/getHistoryPrestudent/' + params.id); + }, + getMaxSem(studiengang_kzs) { + return this.$fhcApi.post('api/frontend/v1/stv/status/getMaxSemester/', {studiengang_kzs}); + }, + advanceStatus(status_id) { + return this.$fhcApi.post('api/frontend/v1/stv/status/advanceStatus/' + Object.values(status_id).join('/')); + }, + confirmStatus(status_id) { + return this.$fhcApi.post('api/frontend/v1/stv/status/confirmStatus/' + Object.values(status_id).join('/')); + }, + isLastStatus(id) { + return this.$fhcApi.get('api/frontend/v1/stv/status/isLastStatus/' + id); + }, + deleteStatus(status_id) { + return this.$fhcApi.post('api/frontend/v1/stv/status/deleteStatus/' + Object.values(status_id).join('/')); + }, + getLastBismeldestichtag() { + return this.$fhcApi.get('api/frontend/v1/stv/status/getLastBismeldestichtag/'); + }, + +//------------- History.js------------------------------------------------------ + getHistoryPrestudents (url, config, params){ + return this.$fhcApi.get('api/frontend/v1/stv/prestudent/getHistoryPrestudents/' + params.id); + }, + +} \ No newline at end of file diff --git a/public/js/api/stv/status.js b/public/js/api/stv/status.js new file mode 100644 index 000000000..20b59c8de --- /dev/null +++ b/public/js/api/stv/status.js @@ -0,0 +1,46 @@ +export default { + +//------------- Modal.js------------------------------------------------------ + + insertStatus(id, data) { + return this.$fhcApi.post('api/frontend/v1/stv/status/insertStatus/' + id, + data + ); + }, + loadStatus(status_id) { + return this.$fhcApi.post('api/frontend/v1/stv/status/loadStatus/' + Object.values(status_id).join('/')); + }, + updateStatus(status_id, data) { + return this.$fhcApi.post('api/frontend/v1/stv/status/updateStatus/' + Object.values(status_id).join('/'), data); + }, + getStudienplaene(prestudent_id) { + return this.$fhcApi.get('api/frontend/v1/stv/prestudent/getStudienplaene/' + prestudent_id); + }, + getStudiengang(prestudent_id) { + return this.$fhcApi.get('api/frontend/v1/stv/prestudent/getStudiengang/' + prestudent_id); + }, + getStatusgruende() { + return this.$fhcApi.get('api/frontend/v1/stv/status/getStatusgruende/'); + }, + getStati() { + return this.$fhcApi.get('api/frontend/v1/stv/lists/getStati/'); + }, + +//------------- Dropdown.js------------------------------------------------------ + + addStudent(id, data) { + return this.$fhcApi.post('api/frontend/v1/stv/status/addStudent/' + id, + data, + {errorHeader: id} + ); + }, + changeStatus(id, data) { + return this.$fhcApi.post('api/frontend/v1/stv/status/changeStatus/' + id, + data, + {errorHeader: id} + ); + }, + getStatusarray() { + return this.$fhcApi.get('api/frontend/v1/stv/status/getStatusarray/'); + } +} \ No newline at end of file diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/History.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/History.js index ac071d306..f573e6d85 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/History.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/History.js @@ -11,8 +11,13 @@ export default{ data() { return { tabulatorOptions: { - ajaxURL: 'api/frontend/v1/stv/Prestudent/getHistoryPrestudents/' + this.personId, - ajaxRequestFunc: this.$fhcApi.get, + ajaxURL: 'dummy', + ajaxRequestFunc: this.$fhcApi.factory.stv.prestudent.getHistoryPrestudents, + ajaxParams: () => { + return { + id: this.personId + }; + }, ajaxResponse: (url, params, response) => response.data, //autoColumns: true, columns:[ @@ -63,8 +68,12 @@ export default{ }, watch: { personId() { - this.$refs.table.tabulator.setData('api/frontend/v1/stv/Prestudent/getHistoryPrestudents/' + this.personId); - } + this.$fhcApi.factory.stv.prestudent.getHistoryPrestudents(this.personId) + .then(result => { + this.$refs.table.tabulator.setData(result.data); + }) + .catch(this.$fhcAlert.handleSystemError); // Handle any errors + }, }, template: `
diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js index 0552f1a37..6935810b1 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js @@ -57,8 +57,13 @@ export default{ data() { return { tabulatorOptions: { - ajaxURL: 'api/frontend/v1/stv/Status/getHistoryPrestudent/' + this.modelValue.prestudent_id, - ajaxRequestFunc: this.$fhcApi.get, + ajaxURL: 'dummy', + ajaxRequestFunc: this.$fhcApi.factory.stv.prestudent.getHistoryPrestudent, + ajaxParams: () => { + return { + id: this.modelValue.prestudent_id + }; + }, ajaxResponse: (url, params, response) => response.data, columns: [ {title: "Kurzbz", field: "status_kurzbz", tooltip: true}, @@ -208,6 +213,7 @@ export default{ }; }, watch: { + //TODO(Manu) Watcher to factory modelValue() { if (this.$refs.table) { if (this.$refs.table.tableBuilt) @@ -224,8 +230,7 @@ export default{ ? [this.modelValue.studiengang_kz] : this.modelValue.map(prestudent => prestudent.studiengang_kz); this.maxSem = 0; - this.$fhcApi - .post('api/frontend/v1/stv/status/getMaxSemester/', {studiengang_kzs}) + this.$fhcApi.factory.stv.prestudent.getMaxSem(studiengang_kzs) .then(result => this.maxSem = result.data) .catch(this.$fhcAlert.handleSystemError); }, @@ -245,24 +250,32 @@ export default{ this.$fhcAlert .confirmDelete() - .then(result => result - ? 'api/frontend/v1/stv/status/isLastStatus/' + statusId.prestudent_id - : Promise.reject({handled: true}) - ) - .then(this.$fhcApi.get) - .then(result => result.data - ? new Promise((resolve, reject) => { BsConfirm.popup(this.$p.t('lehre', 'last_status_confirm_delete')).then(resolve).catch(() => reject({handled:true})) }) - : true - ) - .then(result => result - ? 'api/frontend/v1/stv/status/deleteStatus/' + Object.values(statusId).join('/') - : Promise.reject({handled: true}) - ) - .then(this.$fhcApi.post) - .then(() => this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'))) - .then(this.reload) - .then(this.$reloadList) - .catch(this.$fhcAlert.handleSystemError); + .then(result => { + // If confirmed, check if this is the last status + return result + ? this.$fhcApi.factory.stv.prestudent.isLastStatus(statusId.prestudent_id) + : Promise.reject({handled: true}); + }) + .then(result => { + return result.data + ? new Promise((resolve, reject) => { + BsConfirm.popup(this.$p.t('lehre', 'last_status_confirm_delete')) + .then(resolve) + .catch(() => reject({handled: true})); + }) + : true; + }) + .then(result => { + return result + ? this.$fhcApi.factory.stv.prestudent.deleteStatus(statusId) + : Promise.reject({handled: true}); + }) + .then(() => { + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); + this.reload(); + this.$reloadList(); + }) + .catch(this.$fhcAlert.handleSystemError); // Handle any errors }, actionAdvanceStatus(status, stdsem, ausbildungssemester) { const statusId = { @@ -271,22 +284,21 @@ export default{ studiensemester_kurzbz: stdsem, ausbildungssemester: ausbildungssemester }; - this.$fhcApi - .post('api/frontend/v1/stv/status/advanceStatus/' + Object.values(statusId).join('/')) + return this.$fhcApi.factory.stv.prestudent.advanceStatus(statusId) .then(() => this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successAdvance'))) .then(this.reload) .catch(this.$fhcAlert.handleSystemError); }, actionConfirmStatus(status, stdsem, ausbildungssemester) { + const statusId = { + prestudent_id: this.modelValue.prestudent_id, + status_kurzbz: status, + studiensemester_kurzbz: stdsem, + ausbildungssemester: ausbildungssemester + }; BsConfirm .popup(this.$p.t('stv', 'status_confirm_popup')) - .then(() => this.$fhcApi.post( - 'api/frontend/v1/stv/status/confirmStatus/' + - this.modelValue.prestudent_id + '/' + - status + '/' + - stdsem + '/' + - ausbildungssemester - )) + .then(() => this.$fhcApi.factory.stv.prestudent.confirmStatus(statusId)) .then(() => this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successConfirm'))) .then(this.reload) .catch(this.$fhcAlert.handleSystemError); @@ -298,9 +310,7 @@ export default{ }, created() { this.getMaxSem(); - - this.$fhcApi - .get('api/frontend/v1/stv/status/getLastBismeldestichtag/') + this.$fhcApi.factory.stv.prestudent.getLastBismeldestichtag() .then(result => { this.dataMeldestichtag = result.data[0].meldestichtag; if (this.$refs.table && this.$refs.table.tableBuilt) @@ -309,8 +319,7 @@ export default{ .catch(this.$fhcAlert.handleSystemError); }, template: ` -
- +
this.$fhcApi.post( - 'api/frontend/v1/stv/status/addStudent/' + prestudent_id, - data, - { errorHeader: prestudent_id } - )) - ) + this.prestudentIds.map(prestudent_id => this.$fhcApi.factory.stv.status.addStudent(prestudent_id, data))) .then(res => this.showFeedback(res, data.status_kurzbz)); }, changeStatusToAbbrecher(statusgrund_id) { @@ -221,12 +216,7 @@ export default { changeStatus(data) { Promise .allSettled( - this.prestudentIds.map(prestudent_id => this.$fhcApi.post( - 'api/frontend/v1/stv/status/changeStatus/' + prestudent_id, - data, - { errorHeader: prestudent_id } - )) - ) + this.prestudentIds.map(prestudent_id => this.$fhcApi.factory.stv.status.changeStatus(prestudent_id, data))) .then(res => this.showFeedback(res, data.status_kurzbz)); }, showFeedback(results, status_kurzbz) { @@ -247,8 +237,7 @@ export default { } }, created() { - this.$fhcApi - .get('api/frontend/v1/stv/status/getStatusarray/') + this.$fhcApi.factory.stv.status.getStatusarray() .then(result => result.data) .then(result => { this.listDataToolbar = result; @@ -257,7 +246,7 @@ export default { }, template: `
- +