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: `
- +