diff --git a/package.json b/package.json index 2a3aabeef2..d880e11874 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.1.15-fix-event-hiding", + "version": "7.1.16-response-status", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index 5afc666adf..9b6c7220c8 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.1.15-fix-event-hiding", + "version": "7.1.16-response-status", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.spec.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.spec.ts index 50d3f0acd5..463a3b7d99 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.spec.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.spec.ts @@ -66,7 +66,7 @@ describe('QualifyingQuestionOptionsComponent', () => { it('should have the link to case details queries tab', () => { component.click(); - expect(router.navigate).toHaveBeenCalledWith(['cases', 'case-details', '12345'], { fragment: 'Query Management' }); + expect(router.navigate).toHaveBeenCalledWith(['cases', 'case-details', '12345'], { fragment: 'Queries' }); }); describe('displayError', () => { diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.ts index f809a37a50..765a6115be 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.ts @@ -33,7 +33,7 @@ export class QualifyingQuestionOptionsComponent implements OnInit { } public click(): void { - this.router.navigate(['cases', 'case-details', this.caseId], { fragment: 'Query Management' }); + this.router.navigate(['cases', 'case-details', this.caseId], { fragment: 'Queries' }); } public get displayError(): boolean { diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/enums/query-item-response-status.enum.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/enums/query-item-response-status.enum.ts index 7cf440f594..d4138e919d 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/enums/query-item-response-status.enum.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/enums/query-item-response-status.enum.ts @@ -1,4 +1,5 @@ export enum QueryItemResponseStatus { NEW = 'New', - RESPONDED = 'Responded' + RESPONDED = 'Responded', + Awaiting = 'Awaiting Response' } diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/models/query-list/query-list-item/query-list-item.model.spec.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/models/query-list/query-list-item/query-list-item.model.spec.ts index e52e9b2a04..6fc5f4b121 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/models/query-list/query-list-item/query-list-item.model.spec.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/models/query-list/query-list-item/query-list-item.model.spec.ts @@ -56,11 +56,11 @@ describe('QueryListItem', () => { hearingDate: '', createdOn: new Date('2023-06-01'), createdBy: 'Person D', - parentId: '444-444', + parentId: '444-444' } ]; - const childrenItems = items.map(item => { + const childrenItems = items.map((item) => { const listItem = new QueryListItem(); Object.assign(listItem, item); return listItem; @@ -163,7 +163,37 @@ describe('QueryListItem', () => { it('should return "No response required" when it has no children', () => { queryListItem.children = []; expect(queryListItem.children).toEqual([]); - expect(queryListItem.responseStatus).toEqual(QueryItemResponseStatus.NEW); + expect(queryListItem.responseStatus).toEqual(QueryItemResponseStatus.Awaiting); + }); + + it('should return "Awaiting Response" when it has children and is for Follow up question', () => { + // Create additional child items + const additionalChildren = [ + new QueryListItem(), + new QueryListItem(), + new QueryListItem(), + new QueryListItem() + ].map((child, index) => { + Object.assign(child, { + id: `child-${index + 1}`, + subject: `Subject ${index + 2}`, + name: `Name ${index + 2}`, + body: `Body ${index + 2}`, + attachments: [], + isHearingRelated: false, + hearingDate: '', + createdOn: new Date(`2021-0${index + 2}-01`), + createdBy: `Person ${String.fromCharCode(65 + index + 1)}`, + parentId: queryListItem.id, + children: [] + }); + return child; + }); + + // Assign these new children to queryListItem + queryListItem.children = additionalChildren; + expect(queryListItem.children.length).toEqual(4); + expect(queryListItem.responseStatus).toEqual(QueryItemResponseStatus.Awaiting); }); }); }); diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/models/query-list/query-list-item/query-list-item.model.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/models/query-list/query-list-item/query-list-item.model.ts index 57c54dd275..69248557d9 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/models/query-list/query-list-item/query-list-item.model.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/models/query-list/query-list-item/query-list-item.model.ts @@ -50,6 +50,11 @@ export class QueryListItem implements CaseMessage { } public get responseStatus(): QueryItemResponseStatus { - return this.children?.length > 0 ? QueryItemResponseStatus.RESPONDED : QueryItemResponseStatus.NEW; + if (this.children?.length > 0) { + return this.children.length % 2 === 1 + ? QueryItemResponseStatus.RESPONDED + : QueryItemResponseStatus.Awaiting; + } + return QueryItemResponseStatus.Awaiting; } }