Skip to content

Commit

Permalink
Merge pull request #1791 from bcgov/feature/ALCS-2004
Browse files Browse the repository at this point in the history
Add Upload Modal for Optional Attachments and Card Views for Mobile
  • Loading branch information
Abradat authored Jul 17, 2024
2 parents 4f583cc + 582f59f commit 1dc95b9
Show file tree
Hide file tree
Showing 43 changed files with 1,694 additions and 349 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ <h3>6. Proposal</h3>
<section>
<h3>7. Optional Documents</h3>
<div *ngIf="applicationSubmission" class="review-table">
<div class="other-attachments full-width">
<div *ngIf="!isMobile" class="other-attachments full-width">
<div class="grid-1 subheading2">File Name</div>
<div class="grid-2 subheading2">Type</div>
<div class="grid-3 subheading2">Description</div>
Expand All @@ -335,6 +335,14 @@ <h3>7. Optional Documents</h3>
<app-no-data *ngIf="otherFiles.length === 0" [showRequired]="false"></app-no-data>
</div>
</div>
<div *ngIf="isMobile">
<app-optional-attachments-mobile-card
*ngFor="let file of otherFiles"
[file]="file"
(fileClicked)="openFile(file)">
</app-optional-attachments-mobile-card>
<app-no-data *ngIf="otherFiles.length === 0" [showRequired]="showErrors"></app-no-data>
</div>
<div *ngIf="showEdit" class="edit-button">
<button (click)="onNavigateToStep(6)" color="accent" mat-flat-button>Edit Section</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Component, HostListener, Input, OnDestroy, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { BehaviorSubject, Subject, takeUntil } from 'rxjs';
import { ApplicationDocumentDto } from '../../../services/application-document/application-document.dto';
Expand All @@ -14,6 +14,7 @@ import { CodeService } from '../../../services/code/code.service';
import { DOCUMENT_SOURCE, DOCUMENT_TYPE } from '../../../shared/dto/document.dto';
import { OWNER_TYPE } from '../../../shared/dto/owner.dto';
import { openFileInline } from '../../../shared/utils/file';
import { MOBILE_BREAKPOINT } from '../../../shared/utils/breakpoints';

@Component({
selector: 'app-application-details',
Expand All @@ -22,6 +23,7 @@ import { openFileInline } from '../../../shared/utils/file';
})
export class ApplicationDetailsComponent implements OnInit, OnDestroy {
$destroy = new Subject<void>();
isMobile = window.innerWidth <= MOBILE_BREAKPOINT;

@Input() $application!: BehaviorSubject<ApplicationSubmissionDetailedDto | undefined>;
@Input() $applicationDocuments!: BehaviorSubject<ApplicationDocumentDto[]>;
Expand Down Expand Up @@ -131,4 +133,9 @@ export class ApplicationDetailsComponent implements OnInit, OnDestroy {
this.needsAuthorizationLetter = isGovernmentContact || !isSelfApplicant;
}
}

@HostListener('window:resize', ['$event'])
onWindowResize() {
this.isMobile = window.innerWidth <= MOBILE_BREAKPOINT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import { SubmitConfirmationDialogComponent } from './review-and-submit/submit-co
import { SelectGovernmentComponent } from './select-government/select-government.component';
import { SuccessComponent } from './success/success.component';
import { PrimaryContactConfirmationDialogComponent } from './primary-contact/primary-contact-confirmation-dialog/primary-contact-confirmation-dialog.component';
import { OtherAttachmentsUploadDialogComponent } from './other-attachments/other-attachments-upload-dialog/other-attachments-upload-dialog.component';
import { OtherAttachmentsCardComponent } from './other-attachments/other-attachments-card/other-attachments-card.component';
import { MatCard, MatCardHeader, MatCardModule } from '@angular/material/card';

@NgModule({
declarations: [
Expand All @@ -50,6 +53,8 @@ import { PrimaryContactConfirmationDialogComponent } from './primary-contact/pri
LandUseComponent,
OtherParcelsComponent,
OtherAttachmentsComponent,
OtherAttachmentsUploadDialogComponent,
OtherAttachmentsCardComponent,
PrimaryContactComponent,
PrimaryContactConfirmationDialogComponent,
ReviewAndSubmitComponent,
Expand Down Expand Up @@ -80,6 +85,7 @@ import { PrimaryContactConfirmationDialogComponent } from './primary-contact/pri
MatOptionModule,
MatSelectModule,
MatTableModule,
MatCardModule,
RouterLink,
],
exports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,11 @@ export abstract class FilesStepComponent extends StepComponent {
openFileInline(res.url, file.fileName);
}
}

async refreshFiles() {
const documents = await this.applicationDocumentService.getByFileId(this.fileId);
if (documents) {
this.$applicationDocuments.next(documents);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<mat-card>
<mat-card-header>
<mat-card-title>{{file.type?.label}}</mat-card-title>
<button mat-icon-button [mat-menu-trigger-for]="menu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="onEdit()">
<span>Edit</span>
</button>
<button mat-menu-item (click)="onRemove()">
<span>Remove</span>
</button>
</mat-menu>
</mat-card-header>
<mat-card-content>
<a (click)="onClick()">{{file.fileName}}</a>
<p>{{file.description}}</p>
</mat-card-content>
</mat-card>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
mat-card {
width: 100%;
border-bottom: 1px solid #EFEFEF;
}

mat-card-header {
display: flex;
justify-content: space-between;
align-items: center;
font-weight: bold;
}

mat-card-content {
display: flex;
flex-direction: column;
gap: 10px;
}

span {
font-weight: normal;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import {MatCardModule} from '@angular/material/card'
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, type OnInit } from '@angular/core';
import { ApplicationDocumentDto } from "src/app/services/application-document/application-document.dto";

@Component({
selector: 'app-other-attachments-card',
templateUrl: './other-attachments-card.component.html',
styleUrl: './other-attachments-card.component.scss',
})
export class OtherAttachmentsCardComponent implements OnInit {
@Input() file!: ApplicationDocumentDto;
@Output() editClicked = new EventEmitter<ApplicationDocumentDto>();
@Output() removeClicked = new EventEmitter<ApplicationDocumentDto>();
@Output() fileClicked = new EventEmitter<ApplicationDocumentDto>();

ngOnInit(): void { }

onEdit() {
this.editClicked.emit(this.file);
}

onRemove() {
this.removeClicked.emit(this.file);
}

onClick() {
this.fileClicked.emit(this.file);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<div mat-dialog-title>
<h4>{{title}} optional attachment</h4>
</div>
<div mat-dialog-content>
<div class="uploader">
<app-file-drag-drop
(uploadFiles)="attachDocument($event)"
[uploadedFiles]="attachment"
(openFile)="openFile()"
(deleteFile)="deleteFile()">
</app-file-drag-drop>
</div>
<mat-error *ngIf="showVirusError" class="left" style="display: flex">
<mat-icon>warning</mat-icon>&nbsp;A virus was detected in the file. Choose another file and try again.
</mat-error>
<form [formGroup]="form">
<div class="form-container">
<div class="form-field">
<mat-form-field appearance="outline" >
<mat-select
placeholder="Select a Type"
id="fileType"
formControlName="fileType"
(valueChange)="onChangeType($event)">
<mat-option *ngFor="let type of selectableTypes"
[value]="type.code">
{{ type.label }}
</mat-option>
</mat-select>
</mat-form-field>
<div
*ngIf="
form.controls['fileType']!.invalid &&
(form.controls['fileType']!.dirty ||
form.controls['fileType']!.touched)"
class="field-error"
>
<mat-icon>warning</mat-icon>
<div *ngIf="form.controls['fileType']!.errors?.['required']">
This field is required
</div>
</div>
</div>
<div class="form-field">
<mat-form-field appearance="outline">
<input matInput
type="text"
placeholder="Type Description"
id="fileDescription"
formControlName="fileDescription"
(input)="onChangeDescription()">
</mat-form-field>
<div
*ngIf="
form.controls['fileDescription']!.invalid &&
(form.controls['fileDescription']!.dirty ||
form.controls['fileDescription']!.touched)"
class="field-error"
>
<mat-icon>warning</mat-icon>
<div *ngIf="form.controls['fileDescription']!.errors?.['required']">
This field is required
</div>
</div>
</div>
</div>
</form>
</div>
<mat-dialog-actions align="end">
<div class="button-container">
<button *ngIf="!this.data.existingDocument" mat-flat-button color="primary" (click)="onAdd()"
[disabled]="form.invalid || pendingFile === undefined || !isDirty || !isFileDirty || isSaving">
ADD
</button>
<button *ngIf="this.data.existingDocument" mat-flat-button color="primary" (click)="onEdit()"
[disabled]="form.invalid || (!isFileDirty && !isDirty) || isSaving">
SAVE
</button>
<button mat-stroked-button color="primary" [mat-dialog-close]="false">CANCEL</button>
</div>
</mat-dialog-actions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@use '../../../../../../styles/functions.scss' as *;
@use '../../../../../../styles/colors';

.uploader {
margin: 10px 0 10px 0;
}

.field-error {
color: colors.$error-color;
font-size: rem(15);
font-weight: 700;
display: flex;
align-items: center;
margin-top: rem(4);
}

.form-container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin: 10px 0 0 0;
gap: 20px;

.form-field {
flex: 1 1 48%;
box-sizing: border-box;
display: grid;
flex-direction: column;
align-items: flex-start;
}

@media screen and (max-width: $tabletBreakpoint) {
.form-field {
flex: 1 1 100%;
margin: 0 5px;
}
}
}

.button-container {
display: flex;
flex-direction: row-reverse;
gap: 15px;
margin: 0 15px 10px 0;
button {
flex: 0 0 100px;
padding: 10px 10px;
}

@media screen and (max-width: $tabletBreakpoint) {
button {
flex: 1 1 48%;
}
}
}
Loading

0 comments on commit 1dc95b9

Please sign in to comment.