From 51c9c6482fa1734c134d54cdb393c38762b3647d Mon Sep 17 00:00:00 2001 From: manueltauber Date: Mon, 5 Jun 2023 12:21:25 +0200 Subject: [PATCH] validateButtons/Done --- frontend/src/app/data.service.ts | 47 ++++++++++++++----- frontend/src/ntt-gantt/ntt-gantt.component.ts | 23 +++++++-- 2 files changed, 54 insertions(+), 16 deletions(-) diff --git a/frontend/src/app/data.service.ts b/frontend/src/app/data.service.ts index 4a3d960..2802fd2 100644 --- a/frontend/src/app/data.service.ts +++ b/frontend/src/app/data.service.ts @@ -295,7 +295,7 @@ export class DataService { } ); } - + let approval = this.validateApproval(resp.approvalStatus); res.push({ resourceId: resp.resourceId, approvalStatus: this.validateApproval(resp.approvalStatus), @@ -311,15 +311,14 @@ export class DataService { supportGroup: resp.supportGroup, tasks: tasks, supportGroupId: resp.supportGroupId, - implementerEdit: resp.implementerEdit, - flagApprove: resp.flagApprove, - flagCancel: resp.flagChancel, - flagPermit: resp.flagPermit, - flagReject: resp.flagReject, + implementerEdit: this.validateImplementerEdit(resp.state), + flagApproval: approval, + flagReject: approval, + flagCancel: this.validateCancel(resp.state), + flagPermit: this.validatePermit(resp.state), changeImplementerLogin: resp.changeImplementerLogin, packageName: resp.packageName, coordinatorSg: resp.coordinatorSg - }); @@ -331,16 +330,38 @@ export class DataService { return promise; } - validateApproval(approval):number{ - if(approval!=""){ - return 1; + validateImplementerEdit(state):boolean{ + if(state == 1){ + return true }else{ - return 0; + return false } - - } + validateCancel(state):boolean{ + if(state == 1){ + return true + }else{ + return false + } + } + validatePermit(state): boolean{ + if(state == 0){ + return true + }else{ + return false + } + } + + validateApproval(approval):boolean{ + if(approval!==""){ + return true; + }else{ + return false; + } + } + + getStateNameById(stateNr): String { if(this.selectedLanguage == 'EN'){ for (let state of this.states) { diff --git a/frontend/src/ntt-gantt/ntt-gantt.component.ts b/frontend/src/ntt-gantt/ntt-gantt.component.ts index 4a9d51e..603e819 100644 --- a/frontend/src/ntt-gantt/ntt-gantt.component.ts +++ b/frontend/src/ntt-gantt/ntt-gantt.component.ts @@ -621,6 +621,7 @@ public logg(args){ let allReject: boolean = true; let allCancel: boolean = true; let allImplementer: boolean = true; + let allTransition: boolean = true; this.selectedRescourceIds = []; for (const change of this.selRecs) { if(change.taskData.approvalStatus == 1){ @@ -645,7 +646,7 @@ public logg(args){ }else{ allApprove = false; } - if(change.taskData.flagReject == true && allCancel == true){ + if(change.taskData.flagReject == true && allReject == true){ allReject = true; }else{ allReject = false; @@ -660,10 +661,18 @@ public logg(args){ }else{ allImplementer = false; } + if(change.taskData.state > 0 && allTransition == true){ + allTransition = true; + }else{ + allTransition = false; + } } + if(allStates){ this.toolbar = []; - this.toolbar.push({text:this.lMap.get("stateChange"), id: "6"}); + if(allTransition){ + this.toolbar.push({text:this.lMap.get("stateChange"), id: "6"}); + } if(allPermit){ this.toolbar.push({text: this.lMap.get("permit"), id: "5"}); } @@ -720,6 +729,7 @@ public logg(args){ let allReject: boolean = true; let allCancel: boolean = true; let allImplementer: boolean = true; + let allTransition: boolean = true; this.selectedRescourceIds = []; for (const change of this.selRecs) { if(change.taskData.state == this.selRecs[0].taskData.state){ @@ -760,11 +770,18 @@ public logg(args){ }else{ allImplementer = false; } + if(change.taskData.state > 0 && allTransition == true){ + allTransition = true; + }else{ + allTransition = false; + } } if(allStates){ this.toolbar = []; - this.toolbar.push({text:this.lMap.get("stateChange"), id: "6"}); + if(allTransition){ + this.toolbar.push({text:this.lMap.get("stateChange"), id: "6"}); + } if(allPermit){ this.toolbar.push({text: this.lMap.get("permit"), id: "5"}); }