Skip to content

Commit

Permalink
Merge branch 'bug/EXUI-2431-special-characters-crashing' of https://g…
Browse files Browse the repository at this point in the history
…ithub.com/hmcts/ccd-case-ui-toolkit into bug/EXUI-2431-special-characters-crashing
  • Loading branch information
connorpgpmcelroy committed Oct 24, 2024
2 parents 428255b + a2e8998 commit c4a9d7e
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 7 deletions.
5 changes: 5 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## RELEASE NOTES

### Version 7.0.70
**EXUI-2193** Get rid of mc-menu-items LD flag
**EXUI-2346** Not able to see unavailable dates on check your answers page
**EXUI-2460** Describe your evidence' free text boxes not being

### Version 7.0.69
**EXUI-2354** Flakyness/slow login/Search issue

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.0.69-special-characters",
"version": "7.0.70-special-characters",
"engines": {
"node": ">=18.19.0"
},
Expand Down
2 changes: 1 addition & 1 deletion projects/ccd-case-ui-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.0.69-special-characters",
"version": "7.0.70-special-characters",
"engines": {
"node": ">=18.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,126 @@ describe('ReadComplexFieldTableComponent', () => {

expect(compoundRowsValues[0].componentInstance.context).toEqual(PaletteContext.CHECK_YOUR_ANSWER);
});

it('should set the dummy path for child fields correctly', () => {
component.idPrefix = 'testString';
component.ngOnInit();
expect(component.path).toBe(ReadComplexFieldTableComponent.DUMMY_STRING_PRE + component.idPrefix + ReadComplexFieldTableComponent.DUMMY_STRING_POST);
});

it('should show child fields based on show conditions', () => {
component.caseField = (({
field_type: {
collection_field_type: null,
complex_fields: [
{
id: 'unavailableDateType',
display_context: 'MANDATORY',
field_type: {
type: 'FixedRadioList'
}
},
{
id: 'date',
display_context: 'MANDATORY',
show_condition: 'parent.unavailableDatesForMediation.unavailableDateType=\"SINGLE_DATE\"',
field_type: {
type: 'Date'
}
},
{
id: 'fromDate',
display_context: 'MANDATORY',
show_condition: 'parent.unavailableDatesForMediation.unavailableDateType=\"DATE_RANGE\"',
field_type: {
type: 'Date'
}
},
{
id: 'toDate',
display_context: 'MANDATORY',
show_condition: 'parent.unavailableDatesForMediation.unavailableDateType=\"DATE_RANGE\"',
field_type: {
type: 'Date'
}
}
],
id: 'MediationUnavailableDate',
type: 'Complex',
},
hidden: false,
id: 0,
label: 'Unavailable dates 1',
value: {
unavailableDateType: 'DATE_RANGE',
date: null,
fromDate: '2025-01-01',
toDate: '2025-01-03'
}
}) as unknown as CaseField);
fixture.detectChanges();

const rangeValues = de.queryAll($COMPLEX_PANEL_ALL_VALUES);

// values will be date type, fromDate and toDate (date hidden)
expect(rangeValues.length).toEqual(3);

component.caseField = (({
field_type: {
collection_field_type: null,
complex_fields: [
{
id: 'unavailableDateType',
display_context: 'MANDATORY',
field_type: {
type: 'FixedRadioList'
}
},
{
id: 'date',
display_context: 'MANDATORY',
show_condition: 'parent.unavailableDatesForMediation.unavailableDateType=\"SINGLE_DATE\"',
field_type: {
type: 'Date'
}
},
{
id: 'fromDate',
display_context: 'MANDATORY',
show_condition: 'parent.unavailableDatesForMediation.unavailableDateType=\"DATE_RANGE\"',
field_type: {
type: 'Date'
}
},
{
id: 'toDate',
display_context: 'MANDATORY',
show_condition: 'parent.unavailableDatesForMediation.unavailableDateType=\"DATE_RANGE\"',
field_type: {
type: 'Date'
}
}
],
id: 'MediationUnavailableDate',
type: 'Complex',
},
hidden: false,
id: 0,
label: 'Unavailable dates 1',
value: {
unavailableDateType: 'SINGLE_DATE',
date: '2025-01-01',
fromDate: null,
toDate: null
}
}) as unknown as CaseField);
fixture.detectChanges();

const singleValues = de.queryAll($COMPLEX_PANEL_ALL_VALUES);

// values will be date type and date (fromDate and toDate hidden)
expect(singleValues.length).toEqual(2);
})
});

describe('when values as object in root field', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { CaseField } from '../../../domain/definition';
import { AbstractFieldReadComponent } from '../base-field/abstract-field-read.component';

Expand All @@ -7,7 +7,27 @@ import { AbstractFieldReadComponent } from '../base-field/abstract-field-read.co
templateUrl: './read-complex-field-table.html',
styleUrls: ['./read-complex-field-table.scss']
})
export class ReadComplexFieldTableComponent extends AbstractFieldReadComponent {
export class ReadComplexFieldTableComponent extends AbstractFieldReadComponent implements OnInit {
// parent_ can be replaced with any ***_ - underscore is only important character
// value can also be replaced with anything
public static readonly DUMMY_STRING_PRE = 'parent_';
public static readonly DUMMY_STRING_POST = 'value';

@Input()
public caseFields: CaseField[] = [];

public path: string;

public ngOnInit(): void {
this.setDummyPathForChildArrays();
}

/* In order to get child arrays (within casefield) to display their logic
we need to add a path. This path needs to include the idPrefix as that
is the part of the path that is used to display the elements.
The joining strings will allow us to use the existing show condition to
match against this path. */
private setDummyPathForChildArrays(): void {
this.path = ReadComplexFieldTableComponent.DUMMY_STRING_PRE + this.idPrefix + ReadComplexFieldTableComponent.DUMMY_STRING_POST;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<dl class="complex-panel-title"><dt><span class="text-16">{{caseField.label | rpxTranslate}}</span></dt><dd></dd></dl>
<table class="complex-panel-table" aria-describedby="complex field table">
<tbody>
<ng-container *ngFor="let field of caseField | ccdReadFieldsFilter:false :undefined :true :topLevelFormGroup: undefined :idPrefix">
<ng-container *ngFor="let field of caseField | ccdReadFieldsFilter:false :undefined :true :topLevelFormGroup :path :idPrefix">
<ng-container *ngIf="(field | ccdIsCompound); else SimpleRow">
<tr class="complex-panel-compound-field" [hidden]="field.hidden">
<td colspan="2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ export class ConditionParser {
}
}
} else {
console.error('Path in formArray should start with ', head, ', full path: ', path);
// EXUI-2460 - if path present then show error, otherwise log message to stop unnecessary console errors
path ? console.error('Path in formArray should start with ', head, ', full path: ', path) :
console.log('Path not present in formArray');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ export class ReadFieldsFilterPipe implements PipeTransform {
} else {
cond = ShowCondition.getInstance(field.show_condition);
}
field.hidden = !cond.match(formValue, path);
if (path) {
// EXUI-2460 - evaluate with and without path to ensure validity
field.hidden = !cond.match(formValue, path) ? !cond.match(formValue) : false;
} else {
// if no path there is no need to evaluate twice
field.hidden = !cond.match(formValue);
}
} else {
field.hidden = false;
}
Expand Down

0 comments on commit c4a9d7e

Please sign in to comment.