From 27fa61cb9cb239bc353d10e8b4e06eaa006f5083 Mon Sep 17 00:00:00 2001 From: manueltauber Date: Tue, 16 May 2023 16:13:47 +0200 Subject: [PATCH] approve/reject/cancel Done --- frontend/src/app/data.service.ts | 41 ++----------------- frontend/src/ntt-gantt/ntt-gantt.component.ts | 39 +++++++++++++----- 2 files changed, 32 insertions(+), 48 deletions(-) diff --git a/frontend/src/app/data.service.ts b/frontend/src/app/data.service.ts index 088cf50..e557ecc 100644 --- a/frontend/src/app/data.service.ts +++ b/frontend/src/app/data.service.ts @@ -199,13 +199,13 @@ export class DataService { return promise; } - public async approve(change: any){ + public async updateApproval(change: any, approvalAction){ 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 dataJson = JSON.parse(stringyfiedData) as typeof stringyfiedData; 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); },(error:any)=>{ console.log(error); @@ -216,41 +216,6 @@ export class DataService { 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 diff --git a/frontend/src/ntt-gantt/ntt-gantt.component.ts b/frontend/src/ntt-gantt/ntt-gantt.component.ts index 04a7a6a..7c1f408 100644 --- a/frontend/src/ntt-gantt/ntt-gantt.component.ts +++ b/frontend/src/ntt-gantt/ntt-gantt.component.ts @@ -497,12 +497,16 @@ export class NttGanttComponent implements OnInit { this.toolbar = ['Cancel',{text: "Statusübergang", id: "6"} ,{text: "Implementer eintragen", id: "10"}]; }else{ 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{ this.toolbar = ['Cancel']; } + this.approvalPending = false; this.selRecs = []; this.selectedrecords = []; @@ -556,6 +560,9 @@ export class NttGanttComponent implements OnInit { this.toolbar = ['Cancel',{text: "Statusübergang", id: "6"} ,{text: "Implementer eintragen", id: "10"}]; }else{ 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{ @@ -615,7 +622,7 @@ export class NttGanttComponent implements OnInit { for (const selectedRescourceId of this.selectedRescourceIds) { for (const change of this.resources) { if(change.resourceId == selectedRescourceId){ - this.dataService.approve(change); + this.dataService.updateApproval(change, 1); } } } @@ -623,22 +630,34 @@ export class NttGanttComponent implements OnInit { } + if(args.item.text === "ablehnen"){ for (const selectedRescourceId of this.selectedRescourceIds) { - for (const iterator of this.resources) { - if(iterator.resourceId == selectedRescourceId){ - for (const i of iterator.tasks) { - i.isFixed = true; - } - iterator.state = iterator.state - 1; - this.dataService.updateDatePerChange(iterator); - } + for (const change of this.resources) { + if(change.resourceId == selectedRescourceId){ + this.dataService.updateApproval(change, 2); } } - 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(){ this.renderGantt = false; let newData = [];