Skip to content

Commit 1da3bad

Browse files
authored
Merge pull request #2633 from bcgov/2475-add-chronology-entry-qa-1
2475: Add chronology entry QA 1
2 parents 1c1ddd6 + 28f9dd1 commit 1da3bad

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

alcs-frontend/src/app/features/compliance-and-enforcement/details/chronology/chronology.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
border: 1px solid colors.$grey;
1212
border-radius: 8px;
1313
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
14+
overflow: hidden;
1415
}
1516

1617
.no-entries {

alcs-frontend/src/app/features/compliance-and-enforcement/details/chronology/chronology.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export class ComplianceAndEnforcementChronologyComponent implements OnInit, Afte
4141
allowsFileEdit: true,
4242
allowedDocumentSources: Object.values(DOCUMENT_SOURCE),
4343
allowedDocumentTypes: Object.values(DOCUMENT_TYPE),
44-
defaultDocumentSource: DOCUMENT_SOURCE.PUBLIC,
4544
defaultDocumentType: DOCUMENT_TYPE.CORRESPONDENCE_FROM_PUBLIC,
4645
};
4746

alcs-frontend/src/app/features/compliance-and-enforcement/details/chronology/entry/entry.component.html

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<mat-datepicker #datePicker type="date"></mat-datepicker>
1616
</mat-form-field>
1717

18-
<div *ngIf="date.errors">
18+
<div *ngIf="showErrors && date.errors">
1919
<app-error-message *ngIf="date.errors['required']" message="This field is required"></app-error-message>
2020
<app-error-message *ngIf="date.errors['dateInUse']" message="Date is already in use"></app-error-message>
2121
</div>
@@ -44,7 +44,7 @@
4444
<textarea matInput formControlName="description" rows="3"></textarea>
4545
</mat-form-field>
4646

47-
<div *ngIf="description.touched && description.errors">
47+
<div *ngIf="showErrors && description.errors">
4848
<app-error-message
4949
*ngIf="description.errors['required']"
5050
message="This field is required"
@@ -54,7 +54,7 @@
5454
</ng-container>
5555

5656
<ng-template #descriptionViewTemplate>
57-
<div>{{ entry?.description }}</div>
57+
<div class="description-view">{{ entry?.description }}</div>
5858
</ng-template>
5959

6060
<div *ngIf="entry?.isDraft" class="c-and-e-action-list">
@@ -96,13 +96,8 @@
9696
mat-flat-button
9797
color="primary"
9898
type="button"
99-
[disabled]="!entry?.uuid || !form.valid"
100-
(click)="
101-
complete.emit({
102-
uuid: entry?.uuid!,
103-
updateDto: dtoFromForm(),
104-
})
105-
"
99+
[disabled]="!entry?.uuid"
100+
(click)="onCompleteButtonClick()"
106101
>
107102
Complete
108103
</button>

alcs-frontend/src/app/features/compliance-and-enforcement/details/chronology/entry/entry.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ form {
6464
flex-direction: column;
6565
}
6666

67+
.description-view {
68+
white-space: pre-line;
69+
}
70+
6771
.c-and-e-action-list {
6872
.no-data {
6973
color: colors.$grey;

alcs-frontend/src/app/features/compliance-and-enforcement/details/chronology/entry/entry.component.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export class ComplianceAndEnforcementChronologyEntryComponent implements OnInit,
4949
isPatching = false;
5050
isSubscribed = false;
5151

52+
showErrors = false;
53+
5254
date: FormControl<moment.Moment | null> = new FormControl<moment.Moment | null>(null, [
5355
Validators.required,
5456
this.dateInUseValidator.bind(this),
@@ -119,6 +121,21 @@ export class ComplianceAndEnforcementChronologyEntryComponent implements OnInit,
119121
return !control.value || !this.datesInUse?.includes(control.value.toDate().getTime()) ? null : { dateInUse: true };
120122
}
121123

124+
onCompleteButtonClick(): void {
125+
if (this.form.invalid) {
126+
this.date.markAsTouched();
127+
this.description.markAsTouched();
128+
this.showErrors = true;
129+
return;
130+
}
131+
this.showErrors = false;
132+
133+
this.complete.emit({
134+
uuid: this.entry?.uuid!,
135+
updateDto: this.dtoFromForm(),
136+
});
137+
}
138+
122139
ngOnDestroy(): void {
123140
this.$destroy.next();
124141
this.$destroy.complete();

0 commit comments

Comments
 (0)