Skip to content

Commit

Permalink
Merge pull request #1923 from bcgov/feature/ALCS-2229-validation
Browse files Browse the repository at this point in the history
ALCS-2229 Added validation
  • Loading branch information
fbarreta authored Oct 21, 2024
2 parents 2c0df0a + 23cd6bd commit 74548eb
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h2 *ngIf="data.isEdit">
</div>
<mat-dialog-actions align="end">
<div class="button-container">
<button *ngIf="this.data.structureData" mat-flat-button color="primary" (click)="onSubmit()" [disabled]="isLoading || !form.valid">
<button *ngIf="this.data.structureData" mat-flat-button color="primary" (click)="onSubmit()" [disabled]="isLoading">
{{ !data.isEdit ? "ADD" : "SAVE" }}
</button>
<button mat-stroked-button color="primary" [mat-dialog-close]="false" (click)="onCancel()">CANCEL</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mat-dialog-title {

h2 {
font-size: rem(19.5);
margin-left: rem(10) !important;
}

.actions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export class AddStructureDialogComponent {
}

async onSubmit() {
if (!this.form.valid) {
this.dialogRef.close(null);
return;
}
this.isLoading = true;
const dto: ProposedStructure = {
area: Number(this.area.value!),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
<mat-card [ngClass]="{ 'last-card': isLast, 'review-step': isReviewStep }">
<mat-card [ngClass]="{ 'last-card': isLast, 'review-step': isReviewStep, 'error-card': isError && !isReviewStep }">
<mat-card-header>
<mat-card-title>
<div class="line-info-floor">
<span class="strong">#{{ index+1 }} Total Floor Area: </span><span [class.strong]="isReviewStep">{{ structure.area }} <span matTextSuffix>(m<sup>2</sup>)</span></span> <br />
</div>
<span class="strong">#{{ index+1 }} Total Floor Area: </span>
<ng-container *ngIf="structure.area === 0 || !structure.area; else validFloorArea">
<div class="text-error">No Data</div>
</ng-container>
<ng-template #validFloorArea>
<span [class.strong]="isReviewStep">{{ structure.area }} <span matTextSuffix>(m<sup>2</sup>)</span></span>
</ng-template>
<div class="line-info-type">
<span class="strong">Type: </span>{{ mapStructureTypeValueToLabel(structure.type) }}
</div>
<div class="field-error" *ngIf="(!structure.area || structure.area === 0 || !structure.type) && !isReviewStep">
<mat-icon>warning</mat-icon>
<div>This field is required</div>
</div>
<app-no-data [showRequired]="showErrors" *ngIf="(!structure.area || structure.area === 0 || !structure.type) && isReviewStep"></app-no-data>
</div>
</mat-card-title>
<ng-container *ngIf="!isReviewStep">
<button mat-icon-button [mat-menu-trigger-for]="menu">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use '../../../styles/colors';
@use '../../../styles/functions' as *;
@use '../../../../styles/colors.scss';
@use '../../../../styles/functions' as *;

mat-card {
width: 100%;
Expand All @@ -9,6 +9,7 @@ mat-card {
border-radius: 0;
word-wrap: break-word;
white-space: normal;
padding-left: rem(10);
}

mat-card-header {
Expand Down Expand Up @@ -60,3 +61,34 @@ a {
.line-info-type {
padding-bottom: rem(10);
}

.text-error {
color: colors.$grey-dark;
font-weight: 400;
display: inline;
padding-bottom: 0 !important;
}

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

.mat-icon {
min-width: rem(24);
}
}

.error-card {
border-radius: rem(4) !important;
border: rem(2) solid colors.$error-color !important;
padding: 0 0 rem(5) rem(10);
margin-top: rem(5);
}

.no-data {
margin-bottom: rem(-5) !important;
margin-top: rem(-10) !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
FormProposedStructure,
NOI_STRUCTURE_TYPE_LABEL_MAP,
STRUCTURE_TYPES,
} from '../../features/notice-of-intents/edit-submission/additional-information/additional-information.component';
import { ProposedStructure } from '../../services/notice-of-intent-submission/notice-of-intent-submission.dto';
} from '../../../features/notice-of-intents/edit-submission/additional-information/additional-information.component';
import { ProposedStructure } from '../../../services/notice-of-intent-submission/notice-of-intent-submission.dto';

@Component({
selector: 'app-structure-mobile-card',
Expand All @@ -16,9 +16,19 @@ export class StructureMobileCardComponent {
@Input() isLast: boolean = false;
@Input() index: number = 0;
@Input() isReviewStep: boolean = false;
@Input() showErrors: boolean = false;
@Output() editClicked = new EventEmitter<FormProposedStructure | ProposedStructure>();
@Output() removeClicked = new EventEmitter<FormProposedStructure | ProposedStructure>();

isError: boolean = false;

ngOnInit(): void {
if (this.structure.area === null || this.structure.area === 0 || this.structure.type === null) {
this.isError = true;
this.showErrors = true;
}
}

onEdit() {
this.editClicked.emit(this.structure);
}
Expand Down
2 changes: 1 addition & 1 deletion portal-frontend/src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { OtherAttachmentMobileCardComponent } from './other-attachment-mobile-ca
import { ParcelOwnerMobileCardComponent } from './mobile/parcel-owner-mobile-card/parcel-owner-mobile-card.component';
import { TransfereeMobileCardComponent } from './mobile/transferee-mobile-card/transferee-mobile-card.component';
import { NaruResidenceMobileCardComponent } from './mobile/naru-residence-mobile-card/naru-residence-mobile-card.component';
import { StructureMobileCardComponent } from './structure-mobile-card/structure-mobile-card.component';
import { StructureMobileCardComponent } from './mobile/structure-mobile-card/structure-mobile-card.component';

@NgModule({
providers: [
Expand Down

0 comments on commit 74548eb

Please sign in to comment.