Skip to content

Commit

Permalink
Add Mobile Inbox List
Browse files Browse the repository at this point in the history
* Add new mobile layout for inbox
* Clean up CSS
  • Loading branch information
Daniel Haselhan committed Oct 4, 2023
1 parent 6a1d96d commit 60402c0
Show file tree
Hide file tree
Showing 24 changed files with 261 additions and 128 deletions.
2 changes: 2 additions & 0 deletions portal-frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { AuthorizationComponent } from './features/authorization/authorization.c
import { CreateSubmissionDialogComponent } from './features/create-submission-dialog/create-submission-dialog.component';
import { ApplicationListComponent } from './features/home/application-list/application-list.component';
import { HomeComponent } from './features/home/home.component';
import { InboxListComponent } from './features/home/inbox-list/inbox-list.component';
import { NoiListComponent } from './features/home/noi-list/noi-list.component';
import { NotificationListComponent } from './features/home/notification-list/notification-list.component';
import { LandingPageComponent } from './features/landing-page/landing-page.component';
Expand All @@ -38,6 +39,7 @@ import { SharedModule } from './shared/shared.module';
CreateSubmissionDialogComponent,
LandingPageComponent,
ConfirmationDialogComponent,
InboxListComponent,
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="table-wrapper">
<div *ngIf="!isMobile" class="table-wrapper">
<div class="table-container">
<table mat-table [dataSource]="dataSource">
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
Expand Down Expand Up @@ -59,3 +59,4 @@
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" aria-label="Select page of applications"></mat-paginator>
</div>
</div>
<app-inbox-list *ngIf="isMobile" [items]="listItems"></app-inbox-list>
Original file line number Diff line number Diff line change
@@ -1,31 +0,0 @@
@use '../../../../styles/functions' as *;
@use '../../../../styles/colors';

.label {
display: inline-block;
padding: rem(4) rem(16);
border-radius: rem(16);
font-weight: bold;
}

.table-wrapper {
overflow-x: auto;

.table-container {
display: table;
width: 100%;

table {
width: 100%;
}

::ng-deep .mat-table {
::ng-deep .mat-cell,
::ng-deep .mat-header-cell,
::ng-deep .mat-row,
::ng-deep .mat-header-row {
min-width: rem(150);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatTableDataSource } from '@angular/material/table';
import { ApplicationSubmissionDto } from '../../../services/application-submission/application-submission.dto';
import {
ApplicationSubmissionDto,
SUBMISSION_STATUS,
} from '../../../services/application-submission/application-submission.dto';
import { ApplicationSubmissionService } from '../../../services/application-submission/application-submission.service';
import { InboxListItem } from '../inbox-list/inbox-list.component';

@Component({
selector: 'app-application-list',
Expand All @@ -21,7 +25,10 @@ export class ApplicationListComponent implements OnInit {
'actions',
];

listItems: InboxListItem[] = [];

@ViewChild(MatPaginator) paginator!: MatPaginator;
@Input() isMobile = false;

constructor(private applicationService: ApplicationSubmissionService) {}

Expand All @@ -33,5 +40,10 @@ export class ApplicationListComponent implements OnInit {
const applications = await this.applicationService.getApplications();
this.dataSource = new MatTableDataSource(applications);
this.dataSource.paginator = this.paginator;

this.listItems = applications.map((app) => ({
...app,
routerLink: app.status.code !== SUBMISSION_STATUS.CANCELLED ? `/application/${app.fileNumber}` : undefined,
}));
}
}
6 changes: 3 additions & 3 deletions portal-frontend/src/app/features/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ <h3>Portal Inbox</h3>
fee of $1,500 fee, except for inclusion of land (no fee). Application fees are split equally between the local
government and the ALC.
</app-warning-banner>
<app-application-list></app-application-list>
<app-application-list [isMobile]="isMobile"></app-application-list>
</mat-tab>
<mat-tab label="Notice of Intent">
<app-warning-banner>
Create a Notice of Intent if you are proposing to remove soil and/or place fill that does not qualify for
exemption under Section 35 of the Agricultural Land Reserve Use Regulation. All notices are subject to a $150
fee.
</app-warning-banner>
<app-noi-list></app-noi-list>
<app-noi-list [isMobile]="isMobile"></app-noi-list>
</mat-tab>
<mat-tab label="Notification of SRW">
<app-warning-banner>
Expand All @@ -50,7 +50,7 @@ <h3>Portal Inbox</h3>
>
in the ALR.
</app-warning-banner>
<app-notification-list></app-notification-list>
<app-notification-list [isMobile]="isMobile"></app-notification-list>
</mat-tab>
</mat-tab-group>
</div>
Expand Down
29 changes: 29 additions & 0 deletions portal-frontend/src/app/features/home/home.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,35 @@
text-align: center;
padding: rem(8);
}

.label {
display: inline-block;
padding: rem(4) rem(16);
border-radius: rem(16);
font-weight: bold;
}

.table-wrapper {
overflow-x: auto;

.table-container {
display: table;
width: 100%;

table {
width: 100%;
}

::ng-deep .mat-table {
::ng-deep .mat-cell,
::ng-deep .mat-header-cell,
::ng-deep .mat-row,
::ng-deep .mat-header-row {
min-width: rem(150);
}
}
}
}
}

.header-row {
Expand Down
4 changes: 0 additions & 4 deletions portal-frontend/src/app/features/home/home.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ describe('HomeComponent', () => {
provide: AuthenticationService,
useValue: mockAuthService,
},
{
provide: ApplicationSubmissionService,
useValue: {},
},
],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();
Expand Down
12 changes: 10 additions & 2 deletions portal-frontend/src/app/features/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, HostListener, OnDestroy, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Subject, takeUntil } from 'rxjs';
import { UserDto } from '../../services/authentication/authentication.dto';
import { AuthenticationService } from '../../services/authentication/authentication.service';
import { MOBILE_BREAKPOINT } from '../../shared/utils/breakpoints';
import { CreateSubmissionDialogComponent } from '../create-submission-dialog/create-submission-dialog.component';

@Component({
Expand All @@ -11,8 +12,14 @@ import { CreateSubmissionDialogComponent } from '../create-submission-dialog/cre
styleUrls: ['./home.component.scss'],
})
export class HomeComponent implements OnInit, OnDestroy {
@HostListener('window:resize', ['$event'])
onWindowResize() {
this.isMobile = window.innerWidth <= MOBILE_BREAKPOINT;
}

$destroy = new Subject<void>();
public isLearnMoreOpen = false;
isLearnMoreOpen = false;
isMobile = false;
profile: UserDto | undefined;

constructor(private authenticationService: AuthenticationService, private dialog: MatDialog) {}
Expand All @@ -21,6 +28,7 @@ export class HomeComponent implements OnInit, OnDestroy {
this.authenticationService.$currentProfile.pipe(takeUntil(this.$destroy)).subscribe((profile) => {
this.profile = profile;
});
this.isMobile = window.innerWidth <= MOBILE_BREAKPOINT;
}

ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="result-list" *ngIf="totalCount > 0">
<div
*ngFor="let result of _items"
[routerLink]="result.routerLink"
class="result"
[ngClass]="{
hoverable: result.routerLink
}"
>
<div class="subheading2">{{ result.fileNumber }} - {{ result.applicant ?? '(Unknown)' }}</div>
<div>Created: {{ result.createdAt | momentFormat }}</div>
<div [title]="result.type">{{ result.type }}</div>
<div
*ngIf="result.status"
class="label"
[style]="{ 'background-color': result.status.portalBackgroundColor, color: result.status.portalColor }"
>
{{ result.status.label }}
</div>
<div>Last Updated: {{ result.lastStatusUpdate | momentFormat }}</div>
</div>
</div>
<div *ngIf="totalCount !== 0">
<div class="center">Showing results 1-{{ visibleCount }} of {{ totalCount }}</div>
<div class="center">
<a *ngIf="visibleCount < totalCount" (click)="onLoadMore()"> View more results </a>
</div>
</div>

<div class="no-data" *ngIf="totalCount === 0">
<div><b>No applications found.</b></div>
<div>Please adjust search criteria and try again.</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@use '../../../../styles/functions' as *;
@use '../../../../styles/colors';

.result-list {
margin-top: rem(16);
}

.result {
border-radius: rem(4);
border: 2px solid var(--portal-grey-light, #efefef);
margin: rem(4) rem(4) rem(20); //BOX SHADOWS
padding: rem(12) rem(8);
font-size: rem(14) !important;

div {
margin: rem(4);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.subheading2 {
margin-bottom: rem(8) !important;
}

&.hoverable {
border-color: transparent;
box-shadow: 0 rem(2) rem(6) 0 rgba(0, 0, 0, 0.2);
}

&.hoverable:hover {
cursor: pointer;
background-color: colors.$grey-light;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { createMock, DeepMocked } from '@golevelup/ts-jest';

import { InboxListComponent } from './inbox-list.component';

describe('InboxListComponent', () => {
let component: InboxListComponent;
let fixture: ComponentFixture<InboxListComponent>;
let mockRouter: DeepMocked<Router>;

beforeEach(async () => {
mockRouter = createMock();

await TestBed.configureTestingModule({
declarations: [InboxListComponent],
providers: [
{
provide: Router,
useValue: mockRouter,
},
],
}).compileComponents();

fixture = TestBed.createComponent(InboxListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Component, EventEmitter, Input, OnDestroy, Output } from '@angular/core';
import { Router } from '@angular/router';
import { Subject } from 'rxjs';
import { BaseCodeDto } from '../../../shared/dto/base.dto';

export interface InboxListItem {
applicant?: string;
fileNumber: string;
lastStatusUpdate: number;
createdAt: number;
status?: BaseCodeDto & {
portalBackgroundColor: string;
portalColor: string;
};
type: string;
routerLink?: string;
}

@Component({
selector: 'app-inbox-list',
templateUrl: './inbox-list.component.html',
styleUrls: ['./inbox-list.component.scss'],
})
export class InboxListComponent implements OnDestroy {
$destroy = new Subject<void>();

@Input() totalCount = 0;

_items: InboxListItem[] = [];
@Input() set items(items: InboxListItem[]) {
this._items = items;
this.visibleCount = items.length;
this.totalCount = items.length;
}

@Output() loadMore = new EventEmitter<void>();
@Output() selectRecord = new EventEmitter<string>();
visibleCount = 0;

constructor(private router: Router) {}

ngOnDestroy(): void {
this.$destroy.next();
this.$destroy.complete();
}

async onSelectRecord(record: InboxListItem) {
this.selectRecord.emit(record.fileNumber);
}

onLoadMore() {
this.loadMore.emit();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="table-wrapper">
<div *ngIf="!isMobile" class="table-wrapper">
<div class="table-container">
<table mat-table [dataSource]="dataSource">
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
Expand Down Expand Up @@ -64,3 +64,5 @@
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" aria-label="Select page of notice of intents"></mat-paginator>
</div>
</div>

<app-inbox-list *ngIf="isMobile" [items]="listItems"></app-inbox-list>
Loading

0 comments on commit 60402c0

Please sign in to comment.