Skip to content

Commit

Permalink
Merge commit 'ada884f887c2292d75f09dd88deb093d50bb75b8' into EXUI-131…
Browse files Browse the repository at this point in the history
…4-special-tribunals-incorrect-font-size-class-for-fields
  • Loading branch information
MunishSharmaHMCTS committed Dec 18, 2024
2 parents a446bdb + ada884f commit 2aca4f1
Show file tree
Hide file tree
Showing 35 changed files with 631 additions and 369 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
name: code-coverage-report
path: coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@v3.0.0
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
18 changes: 17 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
## RELEASE NOTES
## RELEASE NOTES

### Version 7.0.75-exui-2575
**EXUI-2536** issue with DynamicMultiSelectList
**EXUI-2431** Special characters stopping events
**EXUI-2537** upgrade pdf-dist in media viewer
**EXUI-2389** PED and Media Viewer

### Version 7.0.75-exui-2315
**EXUI-2315** etrieve current user language selection


### Version 7.0.75-exui-2515
**EXUI-2515** case-link-issue

### Version 7.0.75-exui-2462-rc1
**EXUI-2462** DynamicRadioList incorrectly selects the wrong radio button

### Version 7.0.75
**EXUI-2415** Redirect to an new event by a hyperlink
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.1.20-incorrect-font-size-fix-v2",
"version": "7.1.20-incorrect-font-size-fix-v3",
"engines": {
"node": ">=18.19.0"
},
Expand Down Expand Up @@ -64,7 +64,7 @@
"@edium/fsm": "^2.1.2",
"@hmcts/ccpay-web-component": "6.2.1",
"@hmcts/frontend": "0.0.50-alpha",
"@hmcts/media-viewer": "4.0.8",
"@hmcts/media-viewer": "4.0.9",
"@ngrx/effects": "17.2.0",
"@ngrx/store": "^17.2.0",
"@nicky-lenaers/ngx-scroll-to": "^14.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { CaseEditUtils, convertNonASCIICharacter } from "./case-edit.utils";

describe('CaseEditUtils', () => {
const caseUtils: CaseEditUtils = new CaseEditUtils();
const LONG_ASCII_STRING = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@£$%^&*()-=[];\,./`<>?:"|{}_+';
const LONG_PRE_STRING: string = 'Examples of non-ASCII characters: éこ¥🌍';
const LONG_POST_STRING: string = 'Examples of non-ASCII characters: &#233;&#12371;&#165;&#55356;&#57101;';

describe('editNonASCIICharacters', () => {

it('should not edit undefined', () => {
// Note: Should never happen
const response = caseUtils.convertNonASCIICharacters(undefined);
expect(response).toEqual('');
});

it('should not edit an empty string', () => {
const mockString = '';
const response = caseUtils.convertNonASCIICharacters(mockString);
expect(response).toEqual(mockString);
});

it('should note edit ASCII characters', () => {
// note: string includes £ (non-ASCII) which should not be edited
const response = caseUtils.convertNonASCIICharacters(LONG_ASCII_STRING);
expect(response).toEqual(LONG_ASCII_STRING);
});

it('should not edit £ (non ASCII)', () => {
const mockString = 'Cost: £2.50';
const response = caseUtils.convertNonASCIICharacters(mockString);
expect(response).toEqual(mockString);
});

it('should edit ASCII characters', () => {
// Summarises with copied mock string
const response = caseUtils.convertNonASCIICharacters(LONG_PRE_STRING);
expect(response).toEqual(LONG_POST_STRING);

// Goes deeper into what should be happening just in case
const chineseCharacter = '漢';
const secondMockString = 'Examples of non-ASCII characters: ' + chineseCharacter;
const editedSecondMockString =
`Examples of non-ASCII characters: ${CaseEditUtils.PREFIX + chineseCharacter.charCodeAt(0) + CaseEditUtils.SUFFIX}`;
const secondResponse = caseUtils.convertNonASCIICharacters(secondMockString);
expect(secondResponse).toEqual(editedSecondMockString);
});
});

describe('revertEditNonASCIICharacters', () => {

it('should not revert strings without the prefix and/or suffix', () => {
const mockString = 'Hello World!';
const response = caseUtils.convertHTMLEntities(mockString);
expect(response).toEqual(mockString);
});

it('should revert relevant strings', () => {
const response = caseUtils.convertHTMLEntities(LONG_POST_STRING);
expect(response).toEqual(LONG_PRE_STRING);
});
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

export function convertNonASCIICharacter(character: string): string {
if (character === '£') {
// pound sign will be frequently used and works for btoa despite being non-ASCII
// note: this could be done for other characters provided they work for btoa()
return character;
}
// Note: Will convert to HTML entity
return CaseEditUtils.PREFIX + character.charCodeAt(0) + CaseEditUtils.SUFFIX;
}

export class CaseEditUtils {

public static readonly PREFIX = '&#';
public static readonly SUFFIX = ';';

public convertNonASCIICharacters(rawString: string): string {
return rawString ? rawString.replace(/[^\x20-\x7E]/g, function (c) {
return convertNonASCIICharacter(c);
}) : '';
}

public convertHTMLEntities(editedString: string): string {
const revertedCharacterList = editedString.split(CaseEditUtils.PREFIX);
let rawString = revertedCharacterList[0];
for (let index = 1; index < revertedCharacterList.length; index++) {
const currentSection = revertedCharacterList[index];
if (!currentSection.includes(CaseEditUtils.SUFFIX)) {
return rawString.concat(currentSection);
} else {
const suffixSplitList = currentSection.split(CaseEditUtils.SUFFIX);
const characterCode = Number(suffixSplitList[0]);
rawString = rawString.concat(String.fromCharCode(characterCode), suffixSplitList[1]);
}
}
return rawString;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { LinkedCasesResponse } from '../../palette/linked-cases/domain/linked-ca
import { CaseAccessUtils } from '../case-access-utils';
import { WizardPage } from '../domain';
import { WizardPageFieldToCaseFieldMapper } from './wizard-page-field-to-case-field.mapper';
import { CaseEditUtils } from '../case-edit-utils/case-edit.utils';

@Injectable()
export class CasesService {
Expand Down Expand Up @@ -396,8 +397,10 @@ export class CasesService {
private addClientContextHeader(headers: HttpHeaders): HttpHeaders {
const clientContextDetails = this.sessionStorageService.getItem('clientContext');
if (clientContextDetails) {
// may require URI encoding in certain circumstances
const clientContext = window.btoa(clientContextDetails);
const caseEditUtils = new CaseEditUtils();
// below changes non-ASCII characters
const editedClientContext = caseEditUtils.convertNonASCIICharacters(clientContextDetails);
const clientContext = window.btoa(editedClientContext);
if (clientContext) {
headers = headers.set('Client-Context', clientContext);
}
Expand All @@ -406,59 +409,13 @@ export class CasesService {
}

private updateClientContextStorage(headers: HttpHeaders): void {
// for mocking - TODO: Kasi Remove/Uncomment for testing
// headers = this.setMockClientContextHeader(headers);
if (headers && headers.get('Client-Context')) {
const caseEditUtils = new CaseEditUtils();
const clientContextString = window.atob(headers.get('Client-Context'));
this.sessionStorageService.setItem('clientContext', clientContextString);
// below reverts non-ASCII characters
const editedClientContextString = caseEditUtils.convertHTMLEntities(clientContextString);
this.sessionStorageService.setItem('clientContext', editedClientContextString);
}
}

// for mocking - TODO: Kasi Remove/Uncomment for testing
/* private setMockClientContextHeader(headers: HttpHeaders): HttpHeaders {
const mockClientContext = { client_context: {
user_task: {
task_data: {
// Replace with relevant task id to complete other/current task
id: "2c7e03cc-18e8-11ef-bfd0-763319b21cea",
// Can edit other details to check they update
name: "Review the appeal - Test mocked",
assignee: "dfd4c2d1-67b1-40f9-8680-c9551632f5d9",
type: "reviewTheAppeal",
task_state: "assigned",
task_system: "SELF",
security_classification: "PUBLIC",
task_title: "Review the appeal",
created_date: "2024-05-23T09:38:12+0000",
due_date: "2024-05-28T09:39:00+0000",
location_name: "Taylor House",
location: "765324",
execution_type: "Case Management Task",
jurisdiction: "IA",
region: "1",
case_type_id: "Asylum",
case_id: "1716456926502698",
case_category: "Protection",
case_name: "Aipp Check",
auto_assigned: false,
warnings: false,
warning_list: { values: [] },
case_management_category: "Protection",
work_type_id: "decision_making_work",
work_type_label: "Decision-making work",
permissions: { values : ["Read","Own","Manage","Execute","Cancel","Complete","Claim","Assign","Unassign"] },
description: "[Request respondent evidence](/case/IA/Asylum/${[CASE_REFERENCE]}/trigger/requestRespondentEvidence)",
role_category: "LEGAL_OPERATIONS",
minor_priority: 500,
major_priority: 5000,
priority_date: "2024-05-28T09:39:00+0000"
},
// determines whether task will be completed - sets default to true via EXUI
complete_task: true
}
}};
const encodedMockedClientContext = window.btoa(JSON.stringify(mockClientContext));
headers = headers.set('Client-Context', encodedMockedClientContext);
return headers;
} */
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export class PageValidationService {
public getInvalidFields(page: WizardPage, editForm: FormGroup): CaseField[] {
const failingCaseFields = [];
page.case_fields
.filter(caseField => !this.caseFieldService.isReadOnly(caseField))
.filter(caseField => !this.isHidden(caseField, editForm))
.map(caseField => {
.filter((caseField) => !this.caseFieldService.isReadOnly(caseField))
.filter((caseField) => !this.isHidden(caseField, editForm))
.forEach((caseField) => {
const theControl = FieldsUtils.isCaseFieldOfType(caseField, ['JudicialUser'])
? editForm.controls['data'].get(`${caseField.id}_judicialUserControl`)
: editForm.controls['data'].get(caseField.id);
? editForm.controls.data.get(`${caseField.id}_judicialUserControl`)
: editForm.controls.data.get(caseField.id);
if (!(this.checkDocumentField(caseField, theControl) && this.checkOptionalField(caseField, theControl))) {
failingCaseFields.push(caseField);
};
}
});
return failingCaseFields;
}
Expand All @@ -46,9 +46,8 @@ export class PageValidationService {
private checkOptionalField(caseField: CaseField, theControl: AbstractControl): boolean {
if (!theControl) {
return this.caseFieldService.isOptional(caseField);
} else {
return theControl.valid || theControl.disabled;
}
return theControl.valid || theControl.disabled;
}

private checkMandatoryField(caseField: CaseField, theControl: AbstractControl): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ import { Draft } from '../../domain/draft.model';
})

export class CaseHeaderComponent implements OnInit {
@Input() public caseDetails: CaseView;

@Input()
public caseDetails: CaseView;
public caseTitle: CaseField;
public caseFields: CaseField[];

public ngOnInit(): void {
this.caseTitle = new CaseField();
this.caseTitle.label = this.caseDetails.state.title_display;
this.caseFields = this.getCaseFieldsInfo();
if (!this.isDraft() && this.caseDetails.state.title_display) {
this.caseTitle.label = this.caseDetails.state.title_display;
this.caseFields = this.getCaseFields();
}
}

public isDraft(): boolean {
return Draft.isDraft(this.caseDetails.case_id);
}

private getCaseFieldsInfo(): CaseField[] {
private getCaseFields(): CaseField[] {
const caseDataFields = this.caseDetails.tabs.reduce((acc, tab) => {
return acc.concat(tab.fields);
}, []);
Expand Down
Loading

0 comments on commit 2aca4f1

Please sign in to comment.