|
|
@@ -1,6 +1,7 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
|
|
|
|
type State = 'VIEW INITIAL DETAILS'|'ENTER MORE DETAILS'|'ASSIGN COMMITTEE'; |
|
|
|
type Role = 'Investigator'|'Hod'|'Panel'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-investigate-business-entities-and-individuals', |
|
|
@@ -10,10 +11,43 @@ type State = 'VIEW INITIAL DETAILS'|'ENTER MORE DETAILS'|'ASSIGN COMMITTEE'; |
|
|
|
export class InvestigateBusinessEntitiesAndIndividualsComponent implements OnInit { |
|
|
|
hasEnoughData = false; |
|
|
|
|
|
|
|
state: State = 'VIEW INITIAL DETAILS'; |
|
|
|
state: State; |
|
|
|
stateHistory: Array<State> = []; |
|
|
|
|
|
|
|
constructor() { } |
|
|
|
loginRole: Role; |
|
|
|
|
|
|
|
canExecute: boolean; |
|
|
|
executingRole: Role; |
|
|
|
|
|
|
|
constructor() { |
|
|
|
const loginEmail = localStorage.getItem('loginEmail'); |
|
|
|
|
|
|
|
if (loginEmail && loginEmail.toLocaleLowerCase().startsWith('hod')) { |
|
|
|
this.loginRole = 'Hod'; |
|
|
|
} else if (loginEmail && loginEmail.toLocaleLowerCase().startsWith('panel')) { |
|
|
|
this.loginRole = 'Panel'; |
|
|
|
} else { |
|
|
|
this.loginRole = 'Investigator'; |
|
|
|
} |
|
|
|
|
|
|
|
const savedState = localStorage.getItem('state'); |
|
|
|
|
|
|
|
switch (savedState) { |
|
|
|
case 'ENTER MORE DETAILS': |
|
|
|
this.state = 'ENTER MORE DETAILS'; |
|
|
|
this.executingRole = 'Investigator'; |
|
|
|
break; |
|
|
|
case 'ASSIGN COMMITTEE': |
|
|
|
this.state = 'ASSIGN COMMITTEE'; |
|
|
|
this.executingRole = 'Hod'; |
|
|
|
break; |
|
|
|
default: |
|
|
|
this.state = 'VIEW INITIAL DETAILS'; |
|
|
|
this.executingRole = 'Investigator'; |
|
|
|
} |
|
|
|
|
|
|
|
this.canExecute = this.loginRole === this.executingRole; |
|
|
|
} |
|
|
|
|
|
|
|
proceed() { |
|
|
|
this.stateHistory.push(this.state); |
|
|
@@ -22,14 +56,21 @@ export class InvestigateBusinessEntitiesAndIndividualsComponent implements OnIni |
|
|
|
case 'VIEW INITIAL DETAILS': |
|
|
|
if (this.hasEnoughData) { |
|
|
|
this.state = 'ASSIGN COMMITTEE'; |
|
|
|
this.executingRole = 'Hod'; |
|
|
|
} else { |
|
|
|
this.state = 'ENTER MORE DETAILS'; |
|
|
|
this.executingRole = 'Investigator'; |
|
|
|
} |
|
|
|
break; |
|
|
|
case 'ENTER MORE DETAILS': |
|
|
|
this.state = 'ASSIGN COMMITTEE'; |
|
|
|
this.executingRole = 'Hod'; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
localStorage.setItem('state', this.state); |
|
|
|
|
|
|
|
this.canExecute = this.loginRole === this.executingRole; |
|
|
|
} |
|
|
|
|
|
|
|
goBack() { |
|
|
|