From 3200a94d17bfc4c87c3d98e845e8449b9aafd4f9 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Wed, 23 Apr 2025 11:06:08 +0200 Subject: [PATCH] Refactoring FhcApi_Factory --- public/js/api/factory/stv/jointstudies.js | 81 +++++++++++++++++++ .../Details/JointStudies/JointStudies.js | 42 ++++++---- 2 files changed, 107 insertions(+), 16 deletions(-) create mode 100644 public/js/api/factory/stv/jointstudies.js diff --git a/public/js/api/factory/stv/jointstudies.js b/public/js/api/factory/stv/jointstudies.js new file mode 100644 index 000000000..18f398bb4 --- /dev/null +++ b/public/js/api/factory/stv/jointstudies.js @@ -0,0 +1,81 @@ +/** + * 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 { + getStudies(uid) { + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getStudien/' + uid + }; + }, + getTypenMobility(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getTypenMobility/' + }; + }, + getStudiensemester(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getStudiensemester/' + }; + }, + getStudyprograms(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getStudienprogramme/' + }; + }, + getListPartner(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getPartnerfirmen/' + }; + }, + getStatiPrestudent(){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/getStatiPrestudent/' + }; + }, + loadStudy(id){ + return { + method: 'get', + url: 'api/frontend/v1/stv/GemeinsameStudien/loadStudie/' + id + }; + }, + insertStudy(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/GemeinsameStudien/insertStudie/', + params + }; + }, + updateStudy(params){ + return { + method: 'post', + url: 'api/frontend/v1/stv/GemeinsameStudien/updateStudie/', + params + }; + }, + deleteStudy(id){ + return { + method: 'post', + url: 'api/frontend/v1/stv/GemeinsameStudien/deleteStudie/' + id + }; + }, +} diff --git a/public/js/components/Stv/Studentenverwaltung/Details/JointStudies/JointStudies.js b/public/js/components/Stv/Studentenverwaltung/Details/JointStudies/JointStudies.js index 1c75486de..16d1593d3 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/JointStudies/JointStudies.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/JointStudies/JointStudies.js @@ -3,6 +3,9 @@ import BsModal from "../../../../Bootstrap/Modal.js"; import FormForm from "../../../../Form/Form.js"; import FormInput from "../../../../Form/Input.js"; +import ApiStvJointstudies from '../../../../../api/factory/stv/jointstudies.js'; +import ApiStvMobility from "../../../../../api/factory/stv/mobility"; + export default { name: 'Tbl_JointStudies', components: { @@ -23,12 +26,9 @@ export default { return { tabulatorOptions: { ajaxURL: 'dummy', - ajaxRequestFunc: this.$fhcApi.factory.stv.jointstudies.getStudies, - ajaxParams: () => { - return { - id: this.student.prestudent_id - }; - }, + ajaxRequestFunc: () => this.$api.call( + ApiStvJointstudies.getStudies(this.student.prestudent_id) + ), ajaxResponse: (url, params, response) => response.data, columns: [ {title: "mobilitaet_id", field: "mobilitaet_id", visible: false}, @@ -217,7 +217,8 @@ export default { prestudent_id: this.student.prestudent_id, formData: this.formData }; - return this.$fhcApi.factory.stv.jointstudies.insertStudy(this.$refs.formJointStudies, data) + return this.$refs.formJointStudies + .call(ApiStvJointstudies.insertStudy(data)) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); this.hideModal("jointstudyModal"); @@ -233,7 +234,8 @@ export default { prestudent_id: this.student.prestudent_id, formData: this.formData }; - return this.$fhcApi.factory.stv.jointstudies.updateStudy(this.$refs.formJointStudies, data) + return this.$refs.formJointStudies + .call(ApiStvJointstudies.updateStudy(data)) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); this.hideModal("jointstudyModal"); @@ -245,14 +247,16 @@ export default { }); }, loadJointStudy(mobilitaet_id) { - return this.$fhcApi.factory.stv.jointstudies.loadStudy(mobilitaet_id) + return this.$api + .call(ApiStvJointstudies.loadStudy(mobilitaet_id)) .then(result => { this.formData = result.data; }) .catch(this.$fhcAlert.handleSystemError); }, deleteJointStudy(mobilitaet_id) { - return this.$fhcApi.factory.stv.jointstudies.deleteStudy(mobilitaet_id) + return this.$api + .call(ApiStvJointstudies.deleteStudy(mobilitaet_id)) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); }) @@ -276,32 +280,38 @@ export default { } }, created(){ - this.$fhcApi.factory.stv.jointstudies.getTypenMobility() + this.$api + .call(ApiStvJointstudies.getTypenMobility()) .then(result => { this.listTypenMobility = result.data; }) .catch(this.$fhcAlert.handleSystemError); - this.$fhcApi.factory.stv.jointstudies.getStudiensemester() + this.$api + .call(ApiStvJointstudies.getStudiensemester()) .then(result => { this.listStudiensemester = result.data; }) .catch(this.$fhcAlert.handleSystemError); - this.$fhcApi.factory.stv.mobility.getProgramsMobility() + this.$api + .call(ApiStvMobility.getProgramsMobility()) .then(result => { this.programsMobility = result.data; }) .catch(this.$fhcAlert.handleSystemError); - this.$fhcApi.factory.stv.jointstudies.getStudyprograms() + this.$api + .call(ApiStvJointstudies.getStudyprograms()) .then(result => { this.listStudienprogramme = result.data; }) .catch(this.$fhcAlert.handleSystemError); - this.$fhcApi.factory.stv.jointstudies.getListPartner() + this.$api + .call(ApiStvJointstudies.getListPartner()) .then(result => { this.listPartner = result.data; }) .catch(this.$fhcAlert.handleSystemError); - this.$fhcApi.factory.stv.jointstudies.getStatiPrestudent() + this.$api + .call(ApiStvJointstudies.getStatiPrestudent()) .then(result => { this.statiPrestudent = result.data; })