Refactoring FhcApi_Factory

This commit is contained in:
ma0068
2025-04-23 11:06:08 +02:00
parent 874c91e21c
commit 3200a94d17
2 changed files with 107 additions and 16 deletions
+81
View File
@@ -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 <https://www.gnu.org/licenses/>.
*/
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
};
},
}
@@ -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;
})