diff --git a/public/js/api/factory/stv/exemptions.js b/public/js/api/factory/stv/exemptions.js new file mode 100644 index 000000000..2bf8ee610 --- /dev/null +++ b/public/js/api/factory/stv/exemptions.js @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + getAnrechnungen(id) { + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/getAnrechnungen/' + id + }; + }, + getLehrveranstaltungen(prestudent_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/getLehrveranstaltungen/' + prestudent_id + }; + }, + getBegruendungen(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/getBegruendungen/' + }; + }, + getLvsKompatibel(lv_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/getLvsKompatibel/' + lv_id + }; + }, + getLektoren(studiengang_kz){ + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/getLektoren/' + studiengang_kz + }; + }, + addNewAnrechnung(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/anrechnungen/insertAnrechnung/', + params + }; + }, + loadAnrechnung(anrechnung_id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/anrechnungen/loadAnrechnung/' + anrechnung_id + }; + }, + editAnrechnung(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/anrechnungen/updateAnrechnung/', + params + }; + }, + deleteAnrechnung(anrechnung_id){ + return { + method: 'post', + url: 'api/frontend/v1/stv/anrechnungen/deleteAnrechnung/' + anrechnung_id + }; + }, +} diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Anrechnungen/Anrechnungen.js b/public/js/components/Stv/Studentenverwaltung/Details/Anrechnungen/Anrechnungen.js index 9515f2be6..1d6bd20df 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Anrechnungen/Anrechnungen.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Anrechnungen/Anrechnungen.js @@ -4,6 +4,9 @@ import CoreForm from "../../../../Form/Form.js"; import FormInput from "../../../../Form/Input.js"; import CoreNotiz from "../../../../Notiz/Notiz.js"; +import ApiStvExemptions from "../../../../../api/factory/stv/exemptions.js"; +import ApiNotizPerson from '../../../../../api/factory/notiz/person.js'; + export default { name: "ExemptionComponent", components: { @@ -30,12 +33,9 @@ export default { return { tabulatorOptions: { ajaxURL: 'dummy', - ajaxRequestFunc: this.$fhcApi.factory.stv.exemptions.getAnrechnungen, - ajaxParams: () => { - return { - id: this.student.prestudent_id - }; - }, + ajaxRequestFunc: () => this.$api.call( + ApiStvExemptions.getAnrechnungen(this.student.prestudent_id) + ), ajaxResponse: (url, params, response) => response.data, columns: [ {title: "anrechnung_id", field: "anrechnung_id", visible: false}, @@ -83,7 +83,7 @@ export default { button.innerHTML = ''; button.title = this.$p.t('ui', 'loeschen'); button.addEventListener('click', () => - this.deleteAnrechnung(cell.getData().anrechnung_id) + this.actionDeleteAnrechnung(cell.getData().anrechnung_id) ); container.append(button); @@ -158,7 +158,8 @@ export default { listKompatibleLehrveranstaltungen: [], statusNew: true, showNotizen: false, - currentAnrechnung_id: null + currentAnrechnung_id: null, + endpoint: ApiNotizPerson } }, watch: { @@ -188,7 +189,9 @@ export default { prestudent_id: this.student.prestudent_id, formData: this.formData }; - return this.$fhcApi.factory.stv.exemptions.addNewAnrechnung(this.$refs.formExemptions, dataToSend) + + return this.$refs.formExemptions + .call(ApiStvExemptions.addNewAnrechnung(dataToSend)) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); this.$refs.anrechnungsModal.hide(); @@ -204,7 +207,8 @@ export default { anrechnung_id: anrechnung_id, formData: this.formData }; - return this.$fhcApi.factory.stv.exemptions.editAnrechnung(this.$refs.formExemptions, dataToSend) + return this.$refs.formExemptions + .call(ApiStvExemptions.editAnrechnung(dataToSend)) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); this.$refs.anrechnungsModal.hide(); @@ -215,22 +219,30 @@ export default { this.reload(); }); }, - deleteAnrechnung(anrechnung_id){ + actionDeleteAnrechnung(anrechnung_id) { this.$fhcAlert .confirmDelete() .then(result => result ? anrechnung_id : Promise.reject({handled: true})) - .then(this.$fhcApi.factory.stv.exemptions.deleteAnrechnung) - .then(result => { - this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); - this.reload(); - }) + .then(this.deleteAnrechnung) .catch(this.$fhcAlert.handleSystemError); }, + deleteAnrechnung(anrechnung_id){ + return this.$api + .call(ApiStvExemptions.deleteAnrechnung(anrechnung_id)) + .then(response => { + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { + this.reload(); + }); + }, getLvsKompatibel(){ if(this.formData.lehrveranstaltung_id) { - this.$fhcApi.factory.stv.exemptions.getLvsKompatibel(this.formData.lehrveranstaltung_id) + this.$api + .call(ApiStvExemptions.getLvsKompatibel(this.formData.lehrveranstaltung_id)) .then(result => { this.listKompatibleLehrveranstaltungen = result.data; }) @@ -243,7 +255,8 @@ export default { } }, loadAnrechnung(anrechnung_id){ - return this.$fhcApi.factory.stv.exemptions.loadAnrechnung(anrechnung_id) + return this.$api + .call(ApiStvExemptions.loadAnrechnung(anrechnung_id)) .then(result => { this.formData = result.data; this.getLvsKompatibel(); @@ -263,19 +276,22 @@ export default { } }, created() { - this.$fhcApi.factory.stv.exemptions.getLehrveranstaltungen(this.student.prestudent_id) + this.$api + .call(ApiStvExemptions.getLehrveranstaltungen(this.student.prestudent_id)) .then(result => { this.listNewLehrveranstaltungen = result.data; }) .catch(this.$fhcAlert.handleSystemError); - this.$fhcApi.factory.stv.exemptions.getBegruendungen() + this.$api + .call(ApiStvExemptions.getBegruendungen()) .then(result => { this.listBegruendungen = result.data; }) .catch(this.$fhcAlert.handleSystemError); - this.$fhcApi.factory.stv.exemptions.getLektoren(this.student.studiengang_kz) + this.$api + .call(ApiStvExemptions.getLektoren(this.student.studiengang_kz)) .then(result => { this.listLektoren = result.data; }) @@ -298,7 +314,7 @@ export default {