update functions changeStatus, part 1, fix tags

This commit is contained in:
ma0068
2024-07-25 10:46:45 +02:00
parent 7f0373e0e9
commit a3377a77fa
@@ -152,12 +152,13 @@ export default{
status_kurzbz: status, status_kurzbz: status,
statusgrund_id: null, statusgrund_id: null,
link: `changeStatusTo${status}`, link: `changeStatusTo${status}`,
dropEntry: null, // dropEntry: null,
children: [] children: []
}; };
if (status === "Student") { if (status === "Student") {
defaultObject.link = 'changeInteressentToStudent'; defaultObject.link = 'changeInteressentToStudent';
} }
result.push(defaultObject); result.push(defaultObject);
if(this.sortedGruende[status]) { if(this.sortedGruende[status]) {
@@ -167,15 +168,25 @@ export default{
statusgrund_id: item.statusgrund_id, statusgrund_id: item.statusgrund_id,
beschreibung: item.beschreibung, beschreibung: item.beschreibung,
link: `changeStatusTo${item.status_kurzbz}(${item.statusgrund_id})`, link: `changeStatusTo${item.status_kurzbz}(${item.statusgrund_id})`,
dropEntry: `[${item.beschreibung}]` //dropEntry: `[${item.beschreibung}]`
}; };
if (item.status_kurzbz === "Student") { if (item.status_kurzbz === "Student") {
itemObject.link = `changeInteressentTo${item.status_kurzbz}(${item.statusgrund_id})`; itemObject.link = `changeInteressentTo${item.status_kurzbz}(${item.statusgrund_id})`;
} }
defaultObject.children.push(itemObject); defaultObject.children.push(itemObject);
}); });
//push one item object if student is in the array
const hasStudentChild = defaultObject.children.some(child => child.status_kurzbz === "Student");
if (hasStudentChild) {
defaultObject.children.push({
status_kurzbz: 'Student',
statusgrund_id: null,
beschreibung: 'Student',
link: 'changeInteressentToStudent'
});
}
} }
}); });
return result; return result;
@@ -183,24 +194,37 @@ export default{
resultStudentArray() { resultStudentArray() {
const result = []; const result = [];
this.statiStudent.forEach(status => { this.statiStudent.forEach(status => {
result.push({ const defaultObject = {
status_kurzbz: status, status_kurzbz: status,
statusgrund_id: null, statusgrund_id: null,
link: `changeStatusTo${status}`, link: `changeStatusTo${status}`,
dropEntry: null dropEntry: null,
}); children: []
};
result.push(defaultObject);
if(this.sortedGruende[status]) {
this.sortedGruende[status].forEach(item => {
const itemObject = {
status_kurzbz: item.status_kurzbz,
statusgrund_id: item.statusgrund_id,
beschreibung: item.beschreibung,
link: `changeStatusTo${item.status_kurzbz}(${item.statusgrund_id})`,
dropEntry: `[${item.beschreibung}]`,
};
defaultObject.children.push(itemObject);
});
}
//push one item object if student is in the array
const hasStudentChild = defaultObject.children.some(child => child.status_kurzbz === "Student");
this.toolbarStudent.forEach(item => { if (hasStudentChild) {
if (item.status_kurzbz === status) { defaultObject.children.push({
result.push({ status_kurzbz: 'Student',
status_kurzbz: item.status_kurzbz, statusgrund_id: null,
statusgrund_id: item.statusgrund_id, beschreibung: 'Student',
beschreibung: item.beschreibung, link: 'changeStatusToStudent'
link: `changeStatusTo${item.status_kurzbz}(${item.statusgrund_id})`, });
dropEntry: `[${item.beschreibung}]`, }
});
}
});
}); });
return result; return result;
} }
@@ -493,36 +517,26 @@ export default{
this.$refs.askForAusbildungssemester.show(); this.$refs.askForAusbildungssemester.show();
} }
}, },
changeStatusToAbbrecherStgl(prestudentIds){ changeStatusToAbbrecher(statusgrund_id){
this.hideModal('confirmStatusAction'); this.hideModal('confirmStatusAction');
this.hideModal('askForAusbildungssemester');
console.log("in function changeStatusToAbbrecher: ", statusgrund_id);
let def_date = this.getDefaultDate(); let def_date = this.getDefaultDate();
let abbruchData = let abbruchData =
{ {
status_kurzbz: 'Abbrecher', status_kurzbz: 'Abbrecher',
datum: def_date, datum: def_date,
bestaetigtam: def_date, bestaetigtam: def_date,
statusgrund_id: 17 statusgrund_id: statusgrund_id
}; };
console.log(this.updateData);
this.newArray = this.updateData.map(objekt => ({ ...objekt, ...abbruchData })); this.newArray = this.updateData.map(objekt => ({ ...objekt, ...abbruchData }));
this.changeStatus(prestudentIds);
},
changeStatusToAbbrecherStud(prestudentIds){
this.hideModal('confirmStatusAction');
let def_date = this.getDefaultDate();
let deltaData =
{
status_kurzbz: 'Abbrecher',
datum: def_date,
bestaetigtam: def_date,
statusgrund_id: 18
};
this.newArray = this.updateData.map(objekt => ({ ...objekt, ...deltaData })); this.actionConfirmDialogue(this.updateData, 'studenten','Abbrecher');
this.changeStatus(prestudentIds); //this.changeStatus(prestudentIds);
}, },
changeStatusToUnterbrecher(prestudentIds){ changeStatusToUnterbrecher(){
this.hideModal('confirmStatusAction'); this.hideModal('confirmStatusAction');
this.hideModal('askForAusbildungssemester');
let def_date = this.getDefaultDate(); let def_date = this.getDefaultDate();
let deltaData = let deltaData =
{ {
@@ -532,14 +546,32 @@ export default{
}; };
this.newArray = this.updateData.map(objekt => ({ ...objekt, ...deltaData })); this.newArray = this.updateData.map(objekt => ({ ...objekt, ...deltaData }));
this.changeStatus(prestudentIds); this.actionConfirmDialogue(this.updateData, 'studenten','Unterbrecher');
}, },
changeStatusToStudent(statusgrund_id){ changeStatusToStudent(statusgrund_id){
this.hideModal('confirmStatusAction');
this.hideModal('askForAusbildungssemester');
console.log("in function changeStatusToStudent: ", statusgrund_id); console.log("in function changeStatusToStudent: ", statusgrund_id);
let def_date = this.getDefaultDate(); let def_date = this.getDefaultDate();
//TODO Manu validation if Bewerber already before asking for ausbildungssemester //TODO Manu validation if Bewerber already before asking for ausbildungssemester
//this.checkIfBewerber(); //this.checkIfBewerber();
this.hideModal('askForAusbildungssemester');
this.actionButton = 'student';
if(statusgrund_id == 19){
this.actionStatusText = 'Pre-Abbrecher';
}
if(statusgrund_id == 11){
this.actionStatusText = 'Pre-Wiederholer';
}
if(statusgrund_id == 16){
this.actionStatusText = 'Wiederholer';
}
if(!statusgrund_id){
this.actionStatusText = 'Student';
}
let deltaData = let deltaData =
{ {
status_kurzbz: 'Student', status_kurzbz: 'Student',
@@ -548,24 +580,12 @@ export default{
statusgrund_id: statusgrund_id statusgrund_id: statusgrund_id
}; };
this.newArray = this.updateData.map(objekt => ({ ...objekt, ...deltaData, ausbildungssemester: this.actionSem})); // this.newArray = this.updateData.map(objekt => ({ ...objekt, ...deltaData, ausbildungssemester: this.actionSem}));
//TODO(Manu) get bezeichnung von statusgrund_kurzbz //now actionSem is asked later
this.actionConfirmDialogue(this.updateData, 'student','Studenten'); this.newArray = this.updateData.map(objekt => ({ ...objekt, ...deltaData}));
},
changeStatusToWiederholer(prestudentIds){
this.hideModal('askForAusbildungssemester');
let def_date = this.getDefaultDate();
let deltaData =
{
status_kurzbz: 'Student',
datum: def_date,
bestaetigtam: def_date,
statusgrund_id: 16
};
this.newArray = this.updateData.map(objekt => ({ ...objekt, ...deltaData, ausbildungssemester: this.actionSem})); this.actionConfirmDialogue(this.updateData, this.actionButton, this.actionStatusText);
this.changeStatus(prestudentIds);
}, },
changeStatusToDiplomand(prestudentIds){ changeStatusToDiplomand(prestudentIds){
let def_date = this.getDefaultDate(); let def_date = this.getDefaultDate();
@@ -592,6 +612,8 @@ export default{
this.changeStatus(prestudentIds); this.changeStatus(prestudentIds);
}, },
changeStatusToBewerber(){ changeStatusToBewerber(){
this.hideModal('confirmStatusAction');
this.hideModal('askForAusbildungssemester');
let def_date = this.getDefaultDate(); let def_date = this.getDefaultDate();
let deltaData = let deltaData =
{ {
@@ -607,6 +629,8 @@ export default{
this.changeStatus(this.prestudentIds); this.changeStatus(this.prestudentIds);
}, },
changeStatusToAufgenommener(){ changeStatusToAufgenommener(){
this.hideModal('confirmStatusAction');
this.hideModal('askForAusbildungssemester');
let def_date = this.getDefaultDate(); let def_date = this.getDefaultDate();
let deltaData = let deltaData =
{ {
@@ -624,6 +648,8 @@ export default{
}, },
changeInteressentToStudent(statusgrund_id){ changeInteressentToStudent(statusgrund_id){
this.hideModal('confirmStatusAction');
this.hideModal('askForAusbildungssemester');
//TODO(Manu) test statusgrund_id //TODO(Manu) test statusgrund_id
console.log("in function changeInteressentToStudent mit statusgrund_id", statusgrund_id); console.log("in function changeInteressentToStudent mit statusgrund_id", statusgrund_id);
let def_date = this.getDefaultDate(); let def_date = this.getDefaultDate();
@@ -644,6 +670,8 @@ export default{
}, },
changeStatusToAbgewiesener(statusgrund_id){ changeStatusToAbgewiesener(statusgrund_id){
this.hideModal('confirmStatusAction');
this.hideModal('askForAusbildungssemester');
let def_date = this.getDefaultDate(); let def_date = this.getDefaultDate();
let deltaData = let deltaData =
{ {
@@ -661,6 +689,8 @@ export default{
this.actionConfirmDialogue(this.updateData, 'abgewiesener','Abgewiesenen'); this.actionConfirmDialogue(this.updateData, 'abgewiesener','Abgewiesenen');
}, },
changeStatusToWartender(){ changeStatusToWartender(){
this.hideModal('confirmStatusAction');
this.hideModal('askForAusbildungssemester');
let def_date = this.getDefaultDate(); let def_date = this.getDefaultDate();
let deltaData = let deltaData =
{ {
@@ -745,6 +775,7 @@ export default{
}, },
changeStatus(prestudentIds){ changeStatus(prestudentIds){
this.hideModal('confirmStatusAction'); this.hideModal('confirmStatusAction');
this.hideModal('askForAusbildungssemester');
//Array.isArray(prestudentIds) ? this.modelValue.prestudent_id : [prestudentIds]; //Array.isArray(prestudentIds) ? this.modelValue.prestudent_id : [prestudentIds];
let changeData = {}; let changeData = {};
@@ -755,6 +786,18 @@ export default{
if(!prestudentIds) if(!prestudentIds)
prestudentIds = [this.modelValue.prestudent_id]; prestudentIds = [this.modelValue.prestudent_id];
// Check if ausbildungssemester is already in this.newArray
const existingEntry = this.newArray.find(
(entry) => entry.ausbildungssemester === this.actionSem
);
// If the entry doesn't exist, add a new object with ausbildungssemester
if (!existingEntry) {
this.newArray.push({ ausbildungssemester: this.actionSem });
}
console.log(this.actionSem + ' ' + this.newArray['ausbildungssemester']);
const promises = prestudentIds.map(prestudentId => { const promises = prestudentIds.map(prestudentId => {
//TODO(manu) besserer check //TODO(manu) besserer check
changeData = this.statusData.status_kurzbz ? this.statusData : this.newArray.find(item => item.prestudent_id === prestudentId); changeData = this.statusData.status_kurzbz ? this.statusData : this.newArray.find(item => item.prestudent_id === prestudentId);
@@ -776,16 +819,16 @@ export default{
Promise Promise
.allSettled(promises) .allSettled(promises)
.then(values => { .then(values => {
if (this.abbruchData.length < 1) { /* if (this.abbruchData.length < 1) {
} }
else{ else{*/
if(this.newArray.length > 0) { if(this.newArray.length > 0) {
this.newStatus = this.newArray[0].status_kurzbz; this.newStatus = this.newArray[0].status_kurzbz;
}
else {
this.newStatus = this.statusData.status_kurzbz;
}
} }
else {
this.newStatus = this.statusData.status_kurzbz;
}
// }
//Feedback Success als infoalert //Feedback Success als infoalert
if (countSuccess > 0) { if (countSuccess > 0) {
@@ -1025,6 +1068,70 @@ export default{
<div class="stv-list h-100 pt-3"> <div class="stv-list h-100 pt-3">
<table class="table">
<thead>
<tr>
<th>Status Kurzbez</th>
<th>Bezeichnung</th>
<th>Status Grund ID</th>
<th>Link</th>
<th>Link statusgrund_id</th>
</tr>
</thead>
<tbody>
<tr v-for="item in resultStudentArray" :key="item.status_kurzbz + (item.statusgrund_id !== null ? '-' + item.statusgrund_id : '')">
<td>{{item.status_kurzbz}}</td>
<td v-if="item.children[0]">
<div v-for="child in item.children">
{{child.beschreibung}}
</div>
</td>
<td v-else>{{ item.beschreibung }}</td>
<td>{{ item.children[0] }}</td>
<td><a :href="item.link">{{ item.link }}</a></td>
<td v-if="item.children[0]">
<div v-for="child in item.children">
{{child.link}}
</div>
</td>
</tr>
</tbody>
</table>
<!-- <table class="table">
<thead>
<tr>
<th>Status Kurzbez</th>
<th>Bezeichnung</th>
<th>Status Grund ID</th>
<th>Link</th>
<th>Link statusgrund_id</th>
</tr>
</thead>
<tbody>
<tr v-for="item in resultInteressentArray" :key="item.status_kurzbz + (item.statusgrund_id !== null ? '-' + item.statusgrund_id : '')">
<td>{{item.status_kurzbz}}</td>
<td v-if="item.children[0]">
<div v-for="child in item.children">
{{child.beschreibung}}
</div>
</td>
<td v-else>{{ item.beschreibung }}</td>
<td>{{ item.children[0] }}</td>
<td><a :href="item.link">{{ item.link }}</a></td>
<td v-if="item.children[0]">
<div v-for="child in item.children">
{{child.link}}
</div>
</td>
</tr>
</tbody>
</table>-->
<!--Modal: statusModal--> <!--Modal: statusModal-->
<bs-modal ref="statusModal"> <bs-modal ref="statusModal">
<template #title> <template #title>
@@ -1188,19 +1295,20 @@ export default{
</template> </template>
<template #footer> <template #footer>
<div v-if="actionButton=='abbrecherStgl'"> <!-- <div v-if="actionButton=='abbrecherStgl'">
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToAbbrecherStgl(prestudentIds)">OK</button> <button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToAbbrecher(17)">OK</button>
</div> </div>
<div v-if="actionButton=='abbrecherStud'"> <div v-if="actionButton=='abbrecherStud'">
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToAbbrecherStud(prestudentIds)">OK</button> <button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToAbbrecher(18)">OK</button>
</div> </div>
<div v-if="actionButton=='unterbrecher'"> <div v-if="actionButton=='unterbrecher'">
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToUnterbrecher(prestudentIds)">OK</button> <button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToUnterbrecher()">OK</button>
</div> </div>
<div v-if="actionButton=='aufgenommener'"> <div v-if="actionButton=='aufgenommener'">
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatus(prestudentIds)">OK</button> <button ref="Close" type="button" class="btn btn-primary" @click="changeStatus(prestudentIds)">OK</button>
</div> </div>-->
<div v-if="actionButton=='student'">
<!-- <div v-if="actionButton=='student'">
<button ref="Close" type="button" class="btn btn-primary" @click="changeInteressentToStudent(prestudentIds)">OK</button> <button ref="Close" type="button" class="btn btn-primary" @click="changeInteressentToStudent(prestudentIds)">OK</button>
</div> </div>
<div v-if="actionButton=='wartender'"> <div v-if="actionButton=='wartender'">
@@ -1208,7 +1316,12 @@ export default{
</div> </div>
<div v-if="actionButton=='abgewiesener'"> <div v-if="actionButton=='abgewiesener'">
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatus(prestudentIds)">OK</button> <button ref="Close" type="button" class="btn btn-primary" @click="changeStatus(prestudentIds)">OK</button>
</div> </div>-->
<!--Action changeStatus-->
<div>
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatus(prestudentIds)">OK</button>
</div>
</template> </template>
</BsModal> </BsModal>
@@ -1242,11 +1355,15 @@ export default{
</template> </template>
<template #footer> <template #footer>
<div v-if="actionStatusText=='Student'"> <!-- <div v-if="actionStatusText=='Student'">
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToStudent(prestudentIds)">OK</button> <button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToStudent(prestudentIds)">OK</button>
</div> </div>
<div v-if="actionStatusText=='Wiederholer'"> <div v-if="actionStatusText=='Wiederholer'">
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatusToWiederholer(prestudentIds)">OK</button> <button ref="Close" type="button" class="btn btn-primary" @click="changeStatusTo(prestudentIds)">OK</button>
</div>-->
<div>
<button ref="Close" type="button" class="btn btn-primary" @click="changeStatus(prestudentIds)">OK</button>
</div> </div>
</template> </template>
@@ -1306,25 +1423,31 @@ export default{
<!--toolbar Student--> <!--toolbar Student-->
<ul v-if="showToolbarStudent" class="dropdown-menu"> <ul v-if="showToolbarStudent" class="dropdown-menu">
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'abbrecherStgl', 'Abbrecher')">Abbrecher durch Stgl</a> <a class="dropdown-item" @click="changeStatusToAbbrecher(17)">Abbrecher durch Stgl</a>
</li> </li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'abbrecherStud','Abbrecher')">Abbrecher durch Student</a> <a class="dropdown-item" @click="changeStatusToAbbrecher(18)">Abbrecher durch Student</a>
</li> </li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'unterbrecher','Unterbrecher')">Unterbrecher</a> <a class="dropdown-item" @click="changeStatusToUnterbrecher()">Unterbrecher</a>
</li> </li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'student','Student')">Student</a> <a class="dropdown-item" @click="changeStatusToStudent()">Student</a>
</li> </li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a class="dropdown-item" @click="actionConfirmDialogue(updateData, 'student','Wiederholer')">Wiederholer</a> <a class="dropdown-item" @click="changeStatusToStudent(16)">Wiederholer</a>
</li> </li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a class="dropdown-item" @click="changeStatusToDiplomand(prestudentIds)">Diplomand</a> <a class="dropdown-item" @click="changeStatusToStudent(15)">Pre-Wiederholer</a>
</li> </li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a class="dropdown-item" @click="changeStatusToAbsolvent(prestudentIds)">Absolvent</a> <a class="dropdown-item" @click="changeStatusToStudent(19)">Pre-Abbrecher</a>
</li>
<li class="dropdown-submenu">
<a class="dropdown-item" @click="changeStatusToDiplomand()">Diplomand</a>
</li>
<li class="dropdown-submenu">
<a class="dropdown-item" @click="changeStatusToAbsolvent()">Absolvent</a>
</li> </li>
</ul> </ul>
</div> </div>
@@ -1343,7 +1466,6 @@ export default{
</select> </select>
</div> </div>
</template> </template>
</template>
</core-filter-cmpt> </core-filter-cmpt>
@@ -1426,7 +1548,6 @@ export default{
</option> </option>
</select> </select>
</div> </div>
</div>
</div>` </div>`
}; };