瀏覽代碼

Conserve state and show screens based on logged in user

master
Adwaith Rao 3 年之前
父節點
當前提交
09ab184a0f
共有 12 個檔案被更改,包括 115 行新增56 行删除
  1. +1
    -0
      src/app/layout/notifications/notifications.component.ts
  2. +5
    -3
      src/app/layout/tabs/tabs.component.html
  3. +28
    -21
      src/app/pages/investigate-business-entities-and-individuals/investigate-business-entities-and-individuals.component.html
  4. +43
    -2
      src/app/pages/investigate-business-entities-and-individuals/investigate-business-entities-and-individuals.component.ts
  5. +3
    -1
      src/app/pages/login/login.component.html
  6. +7
    -0
      src/app/pages/login/login.component.ts
  7. +1
    -1
      src/app/pages/register-business/register-business.component.html
  8. +5
    -11
      src/app/widgets/check-status/check-status.component.html
  9. +6
    -1
      src/app/widgets/check-status/check-status.component.scss
  10. +4
    -12
      src/app/widgets/check-status/check-status.component.ts
  11. +1
    -1
      src/app/widgets/form/generic-input/generic-input.component.html
  12. +11
    -3
      src/app/widgets/form/generic-input/generic-input.component.ts

+ 1
- 0
src/app/layout/notifications/notifications.component.ts 查看文件

@@ -22,6 +22,7 @@ export class NotificationsComponent implements OnInit {
}, { }, {
text: 'Request to create a new Committee', text: 'Request to create a new Committee',
timeStamp: '2 hours ago', timeStamp: '2 hours ago',
redirectionUrl: '/tabs/investigate-business-entities-and-individuals',
}, { }, {
text: 'New name application has been submitted', text: 'New name application has been submitted',
description: 'A new Applicant in the company name Kimao has applied for an appeal', description: 'A new Applicant in the company name Kimao has applied for an appeal',


+ 5
- 3
src/app/layout/tabs/tabs.component.html 查看文件

@@ -27,9 +27,11 @@
<img src="assets/icons/chevron-down.svg" alt="chevron down image"> <img src="assets/icons/chevron-down.svg" alt="chevron down image">
</ng-container> </ng-container>
<ng-container *ngIf="showLogout"> <ng-container *ngIf="showLogout">
<img src="assets/icons/logout.svg" class="logout-icon" alt="logout icon">
<span> Log me out </span>
<img src="assets/icons/chevron-down.svg" alt="chevron down image">
<a [routerLink]="['/login']">
<img src="assets/icons/logout.svg" class="logout-icon" alt="logout icon">
<span> Log me out </span>
<img src="assets/icons/chevron-down.svg" alt="chevron down image">
</a>
</ng-container> </ng-container>
</section> </section>




+ 28
- 21
src/app/pages/investigate-business-entities-and-individuals/investigate-business-entities-and-individuals.component.html 查看文件

@@ -9,26 +9,33 @@
<span class="current-page"> Investigating Business Entities and Individuals </span> <span class="current-page"> Investigating Business Entities and Individuals </span>
</section> </section>


<app-check-status
*ngIf="!canExecute"
[status]="state"
[assignedTo]="executingRole"
></app-check-status>


<app-view-case-details
*ngIf="state === 'VIEW INITIAL DETAILS'"
[hasEnoughData]="hasEnoughData"
(updateHasEnoughData)="hasEnoughData = $event"
></app-view-case-details>

<app-modify-case-details
*ngIf="state === 'ENTER MORE DETAILS'"
></app-modify-case-details>

<app-assign-panel
*ngIf="state === 'ASSIGN COMMITTEE'"
></app-assign-panel>
<ng-container *ngIf="canExecute">
<app-view-case-details
*ngIf="state === 'VIEW INITIAL DETAILS'"
[hasEnoughData]="hasEnoughData"
(updateHasEnoughData)="hasEnoughData = $event"
></app-view-case-details>
<app-modify-case-details
*ngIf="state === 'ENTER MORE DETAILS'"
></app-modify-case-details>
<div class="form-action-buttons">
<button class="common-button neutral" *ngIf="stateHistory.length > 0" (click)="goBack()">
Back
</button>
<button class="common-button" (click)="proceed()">
Proceed
</button>
</div>
<app-assign-panel
*ngIf="state === 'ASSIGN COMMITTEE'"
></app-assign-panel>
<div class="form-action-buttons">
<button class="common-button neutral" *ngIf="stateHistory.length > 0" (click)="goBack()">
Back
</button>
<button class="common-button" (click)="proceed()">
Proceed
</button>
</div>
</ng-container>

+ 43
- 2
src/app/pages/investigate-business-entities-and-individuals/investigate-business-entities-and-individuals.component.ts 查看文件

@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';


type State = 'VIEW INITIAL DETAILS'|'ENTER MORE DETAILS'|'ASSIGN COMMITTEE'; type State = 'VIEW INITIAL DETAILS'|'ENTER MORE DETAILS'|'ASSIGN COMMITTEE';
type Role = 'Investigator'|'Hod'|'Panel';


@Component({ @Component({
selector: 'app-investigate-business-entities-and-individuals', 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 { export class InvestigateBusinessEntitiesAndIndividualsComponent implements OnInit {
hasEnoughData = false; hasEnoughData = false;


state: State = 'VIEW INITIAL DETAILS';
state: State;
stateHistory: Array<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() { proceed() {
this.stateHistory.push(this.state); this.stateHistory.push(this.state);
@@ -22,14 +56,21 @@ export class InvestigateBusinessEntitiesAndIndividualsComponent implements OnIni
case 'VIEW INITIAL DETAILS': case 'VIEW INITIAL DETAILS':
if (this.hasEnoughData) { if (this.hasEnoughData) {
this.state = 'ASSIGN COMMITTEE'; this.state = 'ASSIGN COMMITTEE';
this.executingRole = 'Hod';
} else { } else {
this.state = 'ENTER MORE DETAILS'; this.state = 'ENTER MORE DETAILS';
this.executingRole = 'Investigator';
} }
break; break;
case 'ENTER MORE DETAILS': case 'ENTER MORE DETAILS':
this.state = 'ASSIGN COMMITTEE'; this.state = 'ASSIGN COMMITTEE';
this.executingRole = 'Hod';
break; break;
} }

localStorage.setItem('state', this.state);

this.canExecute = this.loginRole === this.executingRole;
} }


goBack() { goBack() {


+ 3
- 1
src/app/pages/login/login.component.html 查看文件

@@ -8,8 +8,10 @@


<app-generic-input <app-generic-input
type="email" type="email"
placeholder="johndoe@mail.com"
placeholder="e.g. johndoe@mail.com"
label="Email ID" label="Email ID"
[value]="email"
(onChange)="updateEmail($event)"
></app-generic-input> ></app-generic-input>


<app-generic-input <app-generic-input


+ 7
- 0
src/app/pages/login/login.component.ts 查看文件

@@ -6,10 +6,17 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./login.component.scss'] styleUrls: ['./login.component.scss']
}) })
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
email = '';
constructor() { } constructor() { }


ngOnInit(): void { ngOnInit(): void {
} }


updateEmail(email: string) {
this.email = email;

localStorage.setItem('loginEmail', email);
}

} }

+ 1
- 1
src/app/pages/register-business/register-business.component.html 查看文件

@@ -53,7 +53,7 @@
></app-select-input> ></app-select-input>
</ng-container> </ng-container>
<ng-container *ngIf="registerInput.type === 'text' || registerInput.type === 'email' || registerInput.type === 'number'">
<ng-container *ngIf="registerInput.type === 'text' || registerInput.type === 'email'">
<app-generic-input <app-generic-input
[label]="registerInput.name" [label]="registerInput.name"
[type]="registerInput.type" [type]="registerInput.type"


+ 5
- 11
src/app/widgets/check-status/check-status.component.html 查看文件

@@ -1,13 +1,7 @@
<header class="tab-header">
<h2>
Application Status
</h2>
</header>


<div class="search-input-container">
<section class="form-message" [ngClass]="{'error' : error.type === 'DANGER', 'warning' : error.type === 'WARNING' }" *ngIf="error">
<p> <strong> Assigned To: </strong> {{ error.assignedTo }} </p>
<h5> {{ error.status }} </h5>
<div class="message-container">
<section class="form-message" [ngClass]="{'error' : type === 'DANGER', 'warning' : type === 'WARNING' }" >
<p> <strong> Assigned To: </strong> {{ assignedTo }} </p>
<h5> {{ status }} </h5>
</section> </section>
<p class="note">Please wait for the assigned user to continue this process.</p>
</div> </div>

+ 6
- 1
src/app/widgets/check-status/check-status.component.scss 查看文件

@@ -1,4 +1,4 @@
.search-input-container {
.message-container {
width: 60%; width: 60%;
margin: 0 auto; margin: 0 auto;
text-align: center; text-align: center;
@@ -33,4 +33,9 @@
color: var(--dark-grey); color: var(--dark-grey);
} }
} }
}

.note {
font-size: 1.4rem;
font-style: italic;
} }

+ 4
- 12
src/app/widgets/check-status/check-status.component.ts 查看文件

@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';


@Component({ @Component({
selector: 'app-check-status', selector: 'app-check-status',
@@ -6,20 +6,12 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./check-status.component.scss'] styleUrls: ['./check-status.component.scss']
}) })
export class CheckStatusComponent implements OnInit { export class CheckStatusComponent implements OnInit {
error?: {
status: string,
assignedTo: string,
type: 'SUCCESS' | 'WARNING' | 'DANGER',
};
@Input() status = 'PENDING';
@Input() assignedTo = 'Another User';
@Input() type: 'SUCCESS' | 'WARNING' | 'DANGER' = 'WARNING';


constructor() { } constructor() { }


ngOnInit(): void { ngOnInit(): void {
this.error = {
status: 'In Progress',
assignedTo: 'Mr Miyagi',
type: 'WARNING'
};
} }
} }

+ 1
- 1
src/app/widgets/form/generic-input/generic-input.component.html 查看文件

@@ -1,5 +1,5 @@
<div class="input-holder"> <div class="input-holder">
<input [type]="type" [placeholder]="placeholder ? placeholder : ''">
<input [type]="type" [placeholder]="placeholder ? placeholder : ''" [ngModel]="value" (ngModelChange)="updateValue($event)">


<label> {{ label }}: </label> <label> {{ label }}: </label>
</div> </div>

+ 11
- 3
src/app/widgets/form/generic-input/generic-input.component.ts 查看文件

@@ -1,8 +1,8 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core';


export interface GenericInputProperties { export interface GenericInputProperties {
name: string, name: string,
type: 'text' | 'email' | 'number' | 'password',
type: 'text' | 'email' | 'password',
placeholder?: string, placeholder?: string,
} }


@@ -14,11 +14,19 @@ export interface GenericInputProperties {
export class GenericInputComponent implements OnInit { export class GenericInputComponent implements OnInit {
@Input() label = ''; @Input() label = '';
@Input() placeholder: string|undefined; @Input() placeholder: string|undefined;
@Input() type: 'text'|'email'|'number'|'password' = 'text';
@Input() type: 'text'|'email'|'password' = 'text';
@Input() value = '';

@Output() onChange = new EventEmitter<string>();



constructor() { } constructor() { }


ngOnInit(): void { ngOnInit(): void {
} }


updateValue(value: string) {
this.onChange.emit(value);
}

} }

Loading…
取消
儲存