approve/reject/cancel Done

main
manueltauber 2023-05-16 16:13:47 +02:00
parent 4db28dd98e
commit 27fa61cb9c
2 changed files with 32 additions and 48 deletions

View File

@ -199,13 +199,13 @@ export class DataService {
return promise; return promise;
} }
public async approve(change: any){ public async updateApproval(change: any, approvalAction){
const promise = new Promise(resolve=>{ const promise = new Promise(resolve=>{
let obj = {changeNr : change.changeNr, resourceId : change.resourceId, state: 1}; let obj = {changeNr : change.changeNr, approvalAction: approvalAction};
let stringyfiedData = JSON.stringify(obj); let stringyfiedData = JSON.stringify(obj);
let dataJson = JSON.parse(stringyfiedData) as typeof stringyfiedData; let dataJson = JSON.parse(stringyfiedData) as typeof stringyfiedData;
console.log(dataJson); console.log(dataJson);
this.http.post('http://localhost:8080/api/approve', dataJson).subscribe((response:any)=>{ this.http.post('http://localhost:8080/api/updateApproval', dataJson).subscribe((response:any)=>{
resolve(response); resolve(response);
},(error:any)=>{ },(error:any)=>{
console.log(error); console.log(error);
@ -216,41 +216,6 @@ export class DataService {
return promise; return promise;
} }
public async reject(change: any){
const promise = new Promise(resolve=>{
// console.log(change);
let obj = {pkgId : change.resourceId, loginId : change.loginId};
let stringyfiedData = JSON.stringify(obj);
let dataJson = JSON.parse(stringyfiedData) as typeof stringyfiedData;
// console.log(dataJson);
this.http.post('http://localhost:8080/api/updateImplementer', dataJson).subscribe((response:any)=>{
resolve(response);
},(error:any)=>{
console.log(error);
resolve(error);
});
})
return promise;
}
public async cancel(change: any){
const promise = new Promise(resolve=>{
// console.log(change);
let obj = {pkgId : change.resourceId, loginId : change.loginId};
let stringyfiedData = JSON.stringify(obj);
let dataJson = JSON.parse(stringyfiedData) as typeof stringyfiedData;
// console.log(dataJson);
this.http.post('http://localhost:8080/api/updateImplementer', dataJson).subscribe((response:any)=>{
resolve(response);
},(error:any)=>{
console.log(error);
resolve(error);
});
})
return promise;
}
/** /**
* The function fetchChanges fetches the changes from backend and maps them to a structure that the Gannt component can interpret * The function fetchChanges fetches the changes from backend and maps them to a structure that the Gannt component can interpret

View File

@ -497,12 +497,16 @@ export class NttGanttComponent implements OnInit {
this.toolbar = ['Cancel',{text: "Statusübergang", id: "6"} ,{text: "Implementer eintragen", id: "10"}]; this.toolbar = ['Cancel',{text: "Statusübergang", id: "6"} ,{text: "Implementer eintragen", id: "10"}];
}else{ }else{
this.toolbar = ['Cancel',{text: "Statusübergang", id: "6"}]; this.toolbar = ['Cancel',{text: "Statusübergang", id: "6"}];
if(this.selRecs[0].taskData.state == 0){
this.toolbar = [{text: "stornieren", id: "11"},{text: "Statusübergang", id: "6"} ,{text: "Implementer eintragen", id: "10"}];
}
} }
} }
}else{ }else{
this.toolbar = ['Cancel']; this.toolbar = ['Cancel'];
} }
this.approvalPending = false; this.approvalPending = false;
this.selRecs = []; this.selRecs = [];
this.selectedrecords = []; this.selectedrecords = [];
@ -556,6 +560,9 @@ export class NttGanttComponent implements OnInit {
this.toolbar = ['Cancel',{text: "Statusübergang", id: "6"} ,{text: "Implementer eintragen", id: "10"}]; this.toolbar = ['Cancel',{text: "Statusübergang", id: "6"} ,{text: "Implementer eintragen", id: "10"}];
}else{ }else{
this.toolbar = ['Cancel',{text: "Statusübergang", id: "6"}]; this.toolbar = ['Cancel',{text: "Statusübergang", id: "6"}];
if(this.selRecs[0].taskData.state == 0){
this.toolbar = [{text: "stornieren", id: "11"},{text: "Statusübergang", id: "6"} ,{text: "Implementer eintragen", id: "10"}];
}
} }
} }
}else{ }else{
@ -615,7 +622,7 @@ export class NttGanttComponent implements OnInit {
for (const selectedRescourceId of this.selectedRescourceIds) { for (const selectedRescourceId of this.selectedRescourceIds) {
for (const change of this.resources) { for (const change of this.resources) {
if(change.resourceId == selectedRescourceId){ if(change.resourceId == selectedRescourceId){
this.dataService.approve(change); this.dataService.updateApproval(change, 1);
} }
} }
} }
@ -623,21 +630,33 @@ export class NttGanttComponent implements OnInit {
} }
if(args.item.text === "ablehnen"){ if(args.item.text === "ablehnen"){
for (const selectedRescourceId of this.selectedRescourceIds) { for (const selectedRescourceId of this.selectedRescourceIds) {
for (const iterator of this.resources) { for (const change of this.resources) {
if(iterator.resourceId == selectedRescourceId){ if(change.resourceId == selectedRescourceId){
for (const i of iterator.tasks) { this.dataService.updateApproval(change, 2);
i.isFixed = true;
}
iterator.state = iterator.state - 1;
this.dataService.updateDatePerChange(iterator);
} }
} }
} }
this.ganttDefault.refresh(); //this.ganttDefault.refresh();
}
if(args.item.text === "stornieren"){
for (const selectedRescourceId of this.selectedRescourceIds) {
for (const change of this.resources) {
if(change.resourceId == selectedRescourceId){
this.dataService.updateApproval(change, 3);
} }
} }
}
//this.ganttDefault.refresh();
}
}
quickRefresh(){ quickRefresh(){
this.renderGantt = false; this.renderGantt = false;