tabs Status and Gesamthistorie: use factories

This commit is contained in:
ma0068
2024-10-01 15:27:36 +02:00
parent 0127982f50
commit 00cf7b8112
9 changed files with 166 additions and 88 deletions
@@ -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,
+4
View File
@@ -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');
},
+5
View File
@@ -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);
},
+32
View File
@@ -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);
},
}
+46
View File
@@ -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/');
}
}
@@ -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: `
<div class="stv-details-prestudent-history h-100 pt-3">
@@ -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: `
<div class="stv-multistatus h-100 pt-3">
<div class="stv-multistatus h-100 pt-3">
<status-modal
ref="test"
:meldestichtag="new Date(dataMeldestichtag)"
@@ -138,12 +138,7 @@ export default {
addStudent(data) {
Promise
.allSettled(
this.prestudentIds.map(prestudent_id => 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: `
<div class="stv-status-dropdown">
<div v-if="showToolbar" class="btn-group">
<button ref="toolbarButton" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
{{$p.t('lehre', 'btn_statusAendern')}}
@@ -127,9 +127,8 @@ export default{
studiensemester_kurzbz,
ausbildungssemester
};
this.$fhcApi
.post('api/frontend/v1/stv/status/loadStatus/', this.statusId)
this.$fhcApi.factory.stv.status.loadStatus(this.statusId)
.then(result => {
this.statusNew = false;
this.formData = result.data;
@@ -143,12 +142,9 @@ export default{
}
},
insertStatus() {
this.$refs.form
.post(
'api/frontend/v1/stv/status/insertStatus/' + this.statusId,
this.formData
)
this.$fhcApi.factory.stv.status.insertStatus(this.statusId, this.formData)
.then(result => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.$reloadList();
this.$emit('saved');
this.$refs.modal.hide();
@@ -156,11 +152,7 @@ export default{
.catch(this.$fhcAlert.handleSystemError);
},
editStatus() {
this.$refs.form
.post(
'api/frontend/v1/stv/status/updateStatus/' + Object.values(this.statusId).join('/'),
this.formData
)
this.$fhcApi.factory.stv.status.updateStatus(this.statusId, this.formData)
.then(result => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.$reloadList();
@@ -174,24 +166,23 @@ export default{
this.prestudent = prestudent;
if (old_id == prestudent.prestudent_id)
return Promise.resolve();
return this.$fhcApi
.get('api/frontend/v1/stv/prestudent/getStudienplaene/' + prestudent.prestudent_id)
return this.$fhcApi.factory.stv.status.getStudienplaene(prestudent.prestudent_id)
.then(result => this.studienplaene = result.data)
.then(() => this.$fhcApi.get('api/frontend/v1/stv/prestudent/getStudiengang/' + prestudent.prestudent_id))
.then(() => this.$fhcApi.factory.stv.status.getStudiengang(prestudent.prestudent_id))
.then(result => this.mischform = result.data.mischform);
}
},
created() {
this.$fhcApi
.get('api/frontend/v1/stv/status/getStatusgruende')
this.$fhcApi.factory.stv.status.getStatusgruende()
.then(result => this.statusgruende = result.data)
.catch(this.$fhcAlert.handleSystemError);
/*this.$fhcApi
.get('api/frontend/v1/stv/lists/getStati')
//TODO(Manu) check why it is/was hard coded
this.$fhcApi.factory.stv.status.getStati()
.then(result => this.stati = result.data)
.catch(this.$fhcAlert.handleSystemError);*/
this.stati = [
.catch(this.$fhcAlert.handleSystemError);
/* this.stati = [
{ status_kurzbz: 'Interessent', bezeichnung: 'Interessent'},
{ status_kurzbz: 'Bewerber', bezeichnung: 'Bewerber'},
{ status_kurzbz: 'Aufgenommener', bezeichnung: 'Aufgenommener'},
@@ -203,7 +194,7 @@ export default{
{ status_kurzbz: 'Abbrecher', bezeichnung: 'Abbrecher'},
{ status_kurzbz: 'Abgewiesener', bezeichnung: 'Abgewiesener'},
{ status_kurzbz: 'Wartender', bezeichnung: 'Wartender'}
];
];*/
},
template: `
<bs-modal class="stv-status-modal" ref="modal">
@@ -212,7 +203,7 @@ export default{
</template>
<core-form ref="form">
<form-validation></form-validation>
<p v-if="bisLocked && !isStatusBeforeStudent">