Refactoring FhcApi_Factory

This commit is contained in:
ma0068
2025-04-22 14:29:45 +02:00
parent 2b9805aeb3
commit 08b27edd64
2 changed files with 40 additions and 7 deletions
+33
View File
@@ -0,0 +1,33 @@
/**
* 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 {
getGruppen(id) {
return {
method: 'get',
url: 'api/frontend/v1/stv/Gruppen/getGruppen/' + id
};
},
deleteGroup(params) {
return {
method: 'post',
url: 'api/frontend/v1/stv/Gruppen/deleteGruppe/',
params
};
}
}
@@ -1,5 +1,7 @@
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
import ApiStvGroups from '../../../../../api/factory/stv/group.js';
export default {
name: 'TblGroups',
components: {
@@ -17,12 +19,9 @@ export default {
return {
tabulatorOptions: {
ajaxURL: 'dummy',
ajaxRequestFunc: this.$fhcApi.factory.stv.group.getGruppen,
ajaxParams: () => {
return {
id: this.student.uid
};
},
ajaxRequestFunc: () => this.$api.call(
ApiStvGroups.getGruppen(this.student.uid)
),
ajaxResponse: (url, params, response) => response.data,
initialFilter: [
{field: "uid", type: "=", value: this.student.uid},
@@ -130,7 +129,8 @@ export default {
gruppe_kurzbz: gruppe_kurzbz
};
return this.$fhcApi.factory.stv.group.deleteGroup(group_id)
return this.$api
.call(ApiStvGroups.deleteGroup(group_id))
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
}).catch(this.$fhcAlert.handleSystemError)