Angular Web App
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

investigate-business-entities-and-individuals.component.ts 4.3 KiB

преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import { Component, OnInit } from '@angular/core';
  2. type State = 'VIEW INITIAL DETAILS'|'ENTER MORE DETAILS'|'ASSIGN COMMITTEE'|'REVIEW NON COMPLIANCE'|'CONCUR COMPLIANCE REVIEW';
  3. type Role = 'Investigator'|'Hod'|'Panel';
  4. @Component({
  5. selector: 'app-investigate-business-entities-and-individuals',
  6. templateUrl: './investigate-business-entities-and-individuals.component.html',
  7. styleUrls: ['./investigate-business-entities-and-individuals.component.scss']
  8. })
  9. export class InvestigateBusinessEntitiesAndIndividualsComponent implements OnInit {
  10. hasEnoughData = false;
  11. isNonCompliant = false;
  12. isPanelConcurring = true;
  13. panelRemarks = '';
  14. state: State;
  15. stateHistory: Array<State> = [];
  16. loginRole: Role;
  17. canExecute: boolean;
  18. executingRole: Role;
  19. constructor() {
  20. const panelRemarks = localStorage.getItem('panelRemarks');
  21. if (panelRemarks) {
  22. this.panelRemarks = panelRemarks;
  23. }
  24. const loginEmail = localStorage.getItem('loginEmail');
  25. if (loginEmail && loginEmail.toLocaleLowerCase().startsWith('hod')) {
  26. this.loginRole = 'Hod';
  27. } else if (loginEmail && loginEmail.toLocaleLowerCase().startsWith('panel')) {
  28. this.loginRole = 'Panel';
  29. } else {
  30. this.loginRole = 'Investigator';
  31. }
  32. const savedState = localStorage.getItem('state');
  33. switch (savedState) {
  34. case 'ENTER MORE DETAILS':
  35. this.state = 'ENTER MORE DETAILS';
  36. this.executingRole = 'Investigator';
  37. break;
  38. case 'ASSIGN COMMITTEE':
  39. this.state = 'ASSIGN COMMITTEE';
  40. this.executingRole = 'Hod';
  41. break;
  42. case 'REVIEW NON COMPLIANCE':
  43. this.state = 'REVIEW NON COMPLIANCE';
  44. this.executingRole = 'Investigator';
  45. break;
  46. case 'CONCUR COMPLIANCE REVIEW':
  47. this.state = 'CONCUR COMPLIANCE REVIEW';
  48. this.executingRole = 'Panel';
  49. break;
  50. default:
  51. this.state = 'VIEW INITIAL DETAILS';
  52. this.executingRole = 'Investigator';
  53. }
  54. this.canExecute = this.loginRole === this.executingRole;
  55. }
  56. updatePanelRemarks(remarks: string) {
  57. this.panelRemarks = remarks;
  58. localStorage.setItem('panelRemarks', remarks);
  59. }
  60. proceed() {
  61. this.stateHistory.push(this.state);
  62. switch (this.state) {
  63. case 'VIEW INITIAL DETAILS':
  64. if (this.hasEnoughData) {
  65. this.state = 'ASSIGN COMMITTEE';
  66. this.executingRole = 'Hod';
  67. } else {
  68. this.state = 'ENTER MORE DETAILS';
  69. this.executingRole = 'Investigator';
  70. }
  71. break;
  72. case 'ENTER MORE DETAILS':
  73. this.state = 'ASSIGN COMMITTEE';
  74. this.executingRole = 'Hod';
  75. break;
  76. case 'ASSIGN COMMITTEE':
  77. this.state = 'REVIEW NON COMPLIANCE';
  78. this.executingRole = 'Investigator';
  79. break;
  80. case 'REVIEW NON COMPLIANCE':
  81. this.state = 'CONCUR COMPLIANCE REVIEW';
  82. this.executingRole = 'Panel';
  83. break;
  84. case 'CONCUR COMPLIANCE REVIEW':
  85. if (!this.isPanelConcurring) {
  86. this.state = 'REVIEW NON COMPLIANCE';
  87. this.executingRole = 'Investigator';
  88. }
  89. break;
  90. }
  91. localStorage.setItem('state', this.state);
  92. this.canExecute = this.loginRole === this.executingRole;
  93. }
  94. goBack() {
  95. const state = this.stateHistory.pop();
  96. if (state) {
  97. this.state = state;
  98. }
  99. switch (this.state) {
  100. case 'ASSIGN COMMITTEE':
  101. this.executingRole = 'Hod';
  102. break;
  103. case 'CONCUR COMPLIANCE REVIEW':
  104. this.executingRole = 'Panel';
  105. break;
  106. default:
  107. this.executingRole = 'Investigator';
  108. }
  109. localStorage.setItem('state', this.state);
  110. this.canExecute = this.loginRole === this.executingRole;
  111. }
  112. ngOnInit(): void {
  113. }
  114. }