Skip to content

Commit b6f023b

Browse files
authored
Feature/query management (#1818)
* Copy update (#1817) * update response status (#1816) * Update yarn-audit-known-issues * Update case-header.component.ts (#1814) * Update query-case-details-header.component.ts * Update yarn-audit-known-issues * update toolkit version * code tidy and fix sonar cloud issue * code tidy * version update * Remove copy and link (#1820) * version update * version update * version toolkit * Update qualifying-question-options.component.spec.ts * Code tidy * release version
1 parent 1383e18 commit b6f023b

File tree

13 files changed

+79
-62
lines changed

13 files changed

+79
-62
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hmcts/ccd-case-ui-toolkit",
3-
"version": "7.1.15-fix-event-hiding",
3+
"version": "7.1.22",
44
"engines": {
55
"node": ">=18.19.0"
66
},

projects/ccd-case-ui-toolkit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hmcts/ccd-case-ui-toolkit",
3-
"version": "7.1.15-fix-event-hiding",
3+
"version": "7.1.22",
44
"engines": {
55
"node": ">=18.19.0"
66
},

projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/page-validation.service.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ export class PageValidationService {
1414
public getInvalidFields(page: WizardPage, editForm: FormGroup): CaseField[] {
1515
const failingCaseFields = [];
1616
page.case_fields
17-
.filter(caseField => !this.caseFieldService.isReadOnly(caseField))
18-
.filter(caseField => !this.isHidden(caseField, editForm))
19-
.forEach(caseField => {
17+
.filter((caseField) => !this.caseFieldService.isReadOnly(caseField))
18+
.filter((caseField) => !this.isHidden(caseField, editForm))
19+
.forEach((caseField) => {
2020
const theControl = FieldsUtils.isCaseFieldOfType(caseField, ['JudicialUser'])
21-
? editForm.controls['data'].get(`${caseField.id}_judicialUserControl`)
22-
: editForm.controls['data'].get(caseField.id);
21+
? editForm.controls.data.get(`${caseField.id}_judicialUserControl`)
22+
: editForm.controls.data.get(caseField.id);
2323
if (!(this.checkDocumentField(caseField, theControl) && this.checkOptionalField(caseField, theControl))) {
2424
failingCaseFields.push(caseField);
25-
};
25+
}
2626
});
2727
return failingCaseFields;
2828
}
@@ -46,9 +46,8 @@ export class PageValidationService {
4646
private checkOptionalField(caseField: CaseField, theControl: AbstractControl): boolean {
4747
if (!theControl) {
4848
return this.caseFieldService.isOptional(caseField);
49-
} else {
50-
return theControl.valid || theControl.disabled;
5149
}
50+
return theControl.valid || theControl.disabled;
5251
}
5352

5453
private checkMandatoryField(caseField: CaseField, theControl: AbstractControl): boolean {

projects/ccd-case-ui-toolkit/src/lib/shared/components/case-header/case-header.component.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ import { Draft } from '../../domain/draft.model';
1010
})
1111

1212
export class CaseHeaderComponent implements OnInit {
13-
@Input() public caseDetails: CaseView;
13+
14+
@Input()
15+
public caseDetails: CaseView;
1416
public caseTitle: CaseField;
1517
public caseFields: CaseField[];
1618

1719
public ngOnInit(): void {
1820
this.caseTitle = new CaseField();
19-
this.caseTitle.label = this.caseDetails.state.title_display;
20-
this.caseFields = this.getCaseFieldsInfo();
21+
if (!this.isDraft() && this.caseDetails.state.title_display) {
22+
this.caseTitle.label = this.caseDetails.state.title_display;
23+
this.caseFields = this.getCaseFields();
24+
}
25+
}
26+
27+
public isDraft(): boolean {
28+
return Draft.isDraft(this.caseDetails.case_id);
2129
}
2230

23-
private getCaseFieldsInfo(): CaseField[] {
31+
private getCaseFields(): CaseField[] {
2432
const caseDataFields = this.caseDetails.tabs.reduce((acc, tab) => {
2533
return acc.concat(tab.fields);
2634
}, []);

projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-flag/components/select-flag-type/select-flag-type.component.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,6 @@ export class SelectFlagTypeComponent implements OnInit, OnDestroy {
9898
}
9999
);
100100

101-
this.formGroup.addControl(CaseFlagFormFields.FLAG_TYPE, new FormControl(''));
102-
this.formGroup.addControl(CaseFlagFormFields.OTHER_FLAG_DESCRIPTION, new FormControl(''));
103-
this.formGroup.addControl(CaseFlagFormFields.IS_VISIBLE_INTERNALLY_ONLY, new FormControl(''));
104-
105-
// Should clear descriptionControlName if flagTypeControlName is changed
106-
this.flagTypeControlChangesSubscription = this.formGroup.get(CaseFlagFormFields.FLAG_TYPE).valueChanges
107-
.subscribe(_ => {
108-
this.formGroup.get(CaseFlagFormFields.OTHER_FLAG_DESCRIPTION).setValue('');
109-
this.cachedPath = [];
110-
111-
// required to clear language interpreter
112-
this.formGroup.patchValue({
113-
[SearchLanguageInterpreterControlNames.LANGUAGE_SEARCH_TERM]: '',
114-
[SearchLanguageInterpreterControlNames.MANUAL_LANGUAGE_ENTRY]: ''
115-
});
116-
}
117-
);
118-
119101
// If hmctsServiceId is present, use this to retrieve the relevant list of flag types
120102
if (this.hmctsServiceId) {
121103
this.flagRefdata$ = this.caseFlagRefdataService

projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ <h2 class="govuk-heading-m govuk-!-margin-top-10">
2727
type="radio" [formControl]="qualifyingQuestionsControl" [value]="qualifyingQuestion">
2828
<label class="govuk-label govuk-radios__label" [for]="qualifyingQuestion.name">{{ qualifyingQuestion.name |
2929
rpxTranslate }}</label>
30-
<div *ngIf="isLast" class="govuk-hint govuk-radios__hint">
31-
{{ '(To follow-up on an existing query' | rpxTranslate }}
32-
<a class="govuk-link" href="javascript:void(0)" (click)="click()">{{ 'click here' | rpxTranslate }}</a>.)
33-
</div>
3430
</div>
3531
</ng-container>
3632
</div>

projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('QualifyingQuestionOptionsComponent', () => {
6666

6767
it('should have the link to case details queries tab', () => {
6868
component.click();
69-
expect(router.navigate).toHaveBeenCalledWith(['cases', 'case-details', '12345'], { fragment: 'Query Management' });
69+
expect(router.navigate).toHaveBeenCalledWith(['cases', 'case-details', '12345'], { fragment: 'Queries' });
7070
});
7171

7272
describe('displayError', () => {
@@ -109,5 +109,15 @@ describe('QualifyingQuestionOptionsComponent', () => {
109109
expect(errorMessageEl).toBeTruthy();
110110
expect(errorMessageEl.nativeElement.textContent.trim()).toBe(`Error: ${QualifyingQuestionsErrorMessage.SELECT_AN_OPTION}`);
111111
});
112+
113+
it('should initialize qualifyingQuestionsControl with saved selection if available', () => {
114+
const savedSelection = 'saved-option';
115+
qualifyingQuestionService.getQualifyingQuestionSelection.and.returnValue(savedSelection);
116+
117+
component.ngOnInit();
118+
119+
expect(qualifyingQuestionService.getQualifyingQuestionSelection).toHaveBeenCalled();
120+
expect(component.qualifyingQuestionsControl.value).toBe(savedSelection);
121+
});
112122
});
113123
});

projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/qualifying-questions/qualifying-question-options/qualifying-question-options.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class QualifyingQuestionOptionsComponent implements OnInit {
3333
}
3434

3535
public click(): void {
36-
this.router.navigate(['cases', 'case-details', this.caseId], { fragment: 'Query Management' });
36+
this.router.navigate(['cases', 'case-details', this.caseId], { fragment: 'Queries' });
3737
}
3838

3939
public get displayError(): boolean {

projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/components/query-case-details-header/query-case-details-header.component.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,24 @@
11
import { Component, Input, OnInit } from '@angular/core';
22
import { CaseView } from '../../../../../domain/case-view/case-view.model';
33
import { CaseField } from '../../../../../domain/definition/case-field.model';
4-
import { Draft } from '../../../../../domain/draft.model';
5-
import { ActivatedRoute } from '@angular/router';
64

75
@Component({
86
selector: 'ccd-query-case-details-header',
97
templateUrl: './query-case-details-header.component.html'
108
})
9+
1110
export class QueryCaseDetailsHeaderComponent implements OnInit {
12-
@Input()
13-
public caseDetails: CaseView;
11+
@Input() public caseDetails: CaseView;
1412
public caseTitle: CaseField;
1513
public caseFields: CaseField[];
16-
public caseView: CaseView;
17-
18-
constructor(activatedRoute: ActivatedRoute) {
19-
this.caseView = activatedRoute.snapshot.data.case;
20-
}
2114

2215
public ngOnInit(): void {
2316
this.caseTitle = new CaseField();
24-
if (!this.isDraft() && this.caseDetails.state.title_display) {
25-
this.caseTitle.label = this.caseDetails.state.title_display;
26-
this.caseFields = this.getCaseFields();
27-
}
28-
}
29-
30-
public isDraft(): boolean {
31-
return Draft.isDraft(this.caseDetails.case_id);
17+
this.caseTitle.label = this.caseDetails.state.title_display;
18+
this.caseFields = this.getCaseFieldsInfo();
3219
}
3320

34-
private getCaseFields(): CaseField[] {
21+
private getCaseFieldsInfo(): CaseField[] {
3522
const caseDataFields = this.caseDetails.tabs.reduce((acc, tab) => {
3623
return acc.concat(tab.fields);
3724
}, []);
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export enum QueryItemResponseStatus {
22
NEW = 'New',
3-
RESPONDED = 'Responded'
3+
RESPONDED = 'Responded',
4+
AWAITING = 'Awaiting Response'
45
}

projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/models/query-list/query-list-item/query-list-item.model.spec.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ describe('QueryListItem', () => {
5656
hearingDate: '',
5757
createdOn: new Date('2023-06-01'),
5858
createdBy: 'Person D',
59-
parentId: '444-444',
59+
parentId: '444-444'
6060
}
6161
];
6262

63-
const childrenItems = items.map(item => {
63+
const childrenItems = items.map((item) => {
6464
const listItem = new QueryListItem();
6565
Object.assign(listItem, item);
6666
return listItem;
@@ -163,7 +163,37 @@ describe('QueryListItem', () => {
163163
it('should return "No response required" when it has no children', () => {
164164
queryListItem.children = [];
165165
expect(queryListItem.children).toEqual([]);
166-
expect(queryListItem.responseStatus).toEqual(QueryItemResponseStatus.NEW);
166+
expect(queryListItem.responseStatus).toEqual(QueryItemResponseStatus.AWAITING);
167+
});
168+
169+
it('should return "Awaiting Response" when it has children and is for Follow up question', () => {
170+
// Create additional child items
171+
const additionalChildren = [
172+
new QueryListItem(),
173+
new QueryListItem(),
174+
new QueryListItem(),
175+
new QueryListItem()
176+
].map((child, index) => {
177+
Object.assign(child, {
178+
id: `child-${index + 1}`,
179+
subject: `Subject ${index + 2}`,
180+
name: `Name ${index + 2}`,
181+
body: `Body ${index + 2}`,
182+
attachments: [],
183+
isHearingRelated: false,
184+
hearingDate: '',
185+
createdOn: new Date(`2021-0${index + 2}-01`),
186+
createdBy: `Person ${String.fromCharCode(65 + index + 1)}`,
187+
parentId: queryListItem.id,
188+
children: []
189+
});
190+
return child;
191+
});
192+
193+
// Assign these new children to queryListItem
194+
queryListItem.children = additionalChildren;
195+
expect(queryListItem.children.length).toEqual(4);
196+
expect(queryListItem.responseStatus).toEqual(QueryItemResponseStatus.AWAITING);
167197
});
168198
});
169199
});

projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/query-management/models/query-list/query-list-item/query-list-item.model.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ export class QueryListItem implements CaseMessage {
5050
}
5151

5252
public get responseStatus(): QueryItemResponseStatus {
53-
return this.children?.length > 0 ? QueryItemResponseStatus.RESPONDED : QueryItemResponseStatus.NEW;
53+
if (this.children?.length > 0) {
54+
return this.children.length % 2 === 1
55+
? QueryItemResponseStatus.RESPONDED
56+
: QueryItemResponseStatus.AWAITING;
57+
}
58+
return QueryItemResponseStatus.AWAITING;
5459
}
5560
}

projects/ccd-case-ui-toolkit/src/lib/shared/services/jurisdiction/jurisdiction.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export class JurisdictionService {
2020
}
2121

2222
public announceSelectedJurisdiction(jurisdiction: Jurisdiction): void {
23-
console.info ('Announcing selected jurisdiction = ' + jurisdiction?.id);
2423
this.selectedJurisdictionSource.next(jurisdiction);
2524
this.selectedJurisdictionBS.next(jurisdiction);
2625
}

0 commit comments

Comments
 (0)