From e48ea12c3ef04f3b8f668f0489dfed81e82ed5fd Mon Sep 17 00:00:00 2001 From: OgunyemiO Date: Wed, 3 Apr 2024 18:52:58 +0100 Subject: [PATCH 1/7] service error message added --- .../generic-filter.component.html | 1 + .../generic-filter.component.ts | 42 ++++++++++++------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.html b/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.html index 9ae56521..bcc78f1f 100644 --- a/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.html +++ b/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.html @@ -162,6 +162,7 @@

+ {{serviceErrorMsg | rpxTranslate}} (); + public isServiceSelected: boolean = false; + public serviceErrorMsg = 'Please select a service'; + private selectedServices: string[] = []; - constructor(private readonly filterService: FilterService, private readonly fb: FormBuilder) {} + constructor(private readonly filterService: FilterService, private readonly fb: FormBuilder) { } // tslint:disable-next-line:variable-name private _config: FilterConfig; @@ -90,7 +93,7 @@ export class GenericFilterComponent implements OnInit, OnDestroy { const services = this.config.fields.find(field => field.name === 'user-services'); if (services) { this.startFilterSkillsByServices(this.form, services); - if(!this._config.copyFields) { + if (!this._config.copyFields) { this.initValuesFromCacheForSkillsByServices(); } } @@ -179,7 +182,7 @@ export class GenericFilterComponent implements OnInit, OnDestroy { fields: this.getSelectedValues(form.value, this.config) }; this.filterService.givenErrors.next(null); - const settings = {...this.settings, reset: false}; + const settings = { ...this.settings, reset: false }; this.filterService.persist(settings, this.config.persistence); } else { this.emitFormErrors(form); @@ -202,6 +205,13 @@ export class GenericFilterComponent implements OnInit, OnDestroy { // when user enters input change radio button public inputChanged(field: FilterFieldConfig): void { + if (field.name === 'user-location') { + if (!this.selectedServices.length) { + this.isServiceSelected = true; + } else { + this.isServiceSelected = false; + } + } if (field.radioSelectionChange && typeof field.radioSelectionChange === 'string') { const [name, value] = field.enableCondition.split('='); this.form.get(name).patchValue(value); @@ -210,8 +220,8 @@ export class GenericFilterComponent implements OnInit, OnDestroy { public inputServiceChanged(field: FilterFieldConfig): void { if (field.name === 'user-services') { - const selectedServices = this.getSelectedValuesForFields(this.form.controls, field); - this.filterSkillsByServices(selectedServices, this.config); + this.selectedServices = this.getSelectedValuesForFields(this.form.controls, field); + this.filterSkillsByServices(this.selectedServices, this.config); } } @@ -220,7 +230,7 @@ export class GenericFilterComponent implements OnInit, OnDestroy { if (this.config && this.config.cancelSetting) { this._settings.fields = JSON.parse(JSON.stringify(this.config.cancelSetting.fields)); } - const settings = {...this.settings, reset: true}; + const settings = { ...this.settings, reset: true }; this.filterService.persist(settings, this.config.persistence); this.filterService.givenErrors.next(null); this.submitted = false; @@ -477,12 +487,12 @@ export class GenericFilterComponent implements OnInit, OnDestroy { if (Array.isArray(values)) { const field = config.fields.find(f => f.name === name); if (field.type === 'find-location' || field.type === 'find-service') { - return {value: values, name}; + return { value: values, name }; } else { - return {value: getValues(field.options, values), name}; + return { value: getValues(field.options, values), name }; } } else { - return {value: [values], name}; + return { value: [values], name }; } }); } @@ -493,15 +503,15 @@ export class GenericFilterComponent implements OnInit, OnDestroy { const fieldName = field.name; const formGroup = form.get(fieldName); if (formGroup && formGroup.errors && (formGroup.errors.minlength || formGroup.errors.required)) { - errors.push({name: fieldName, error: field.minSelectedError}); + errors.push({ name: fieldName, error: field.minSelectedError }); } if (formGroup && formGroup.errors && formGroup.errors.maxlength) { - errors.push({name: fieldName, error: field.maxSelectedError}); + errors.push({ name: fieldName, error: field.maxSelectedError }); } } // remove duplicates - errors = errors.filter( (filterError, i, arr) => { + errors = errors.filter((filterError, i, arr) => { return errors.indexOf(arr.find(item => item.name === filterError.name)) === i; }); @@ -602,10 +612,10 @@ export class GenericFilterComponent implements OnInit, OnDestroy { const preSelectedSkills: boolean[] = []; this.filteredSkillsByServicesCheckbox.map((skillsByServices, index) => { - for(let i = 0; i 0) { + if (preSelectedSkills.length > 0) { preSelectedSkills.forEach((h) => { (this.form.get('user-skills') as FormArray).push(new FormControl(h)); }); @@ -655,7 +665,7 @@ export class GenericFilterComponent implements OnInit, OnDestroy { return a.label.toLowerCase() > b.label.toLowerCase() ? 1 : (b.label.toLowerCase() > a.label.toLowerCase() ? -1 : 0); }); const result = { - group : g, + group: g, options: sortedOptions }; sortedResults.push(result); From b16bc81554ae1f67a711ceabb68694099a54253c Mon Sep 17 00:00:00 2001 From: OgunyemiO Date: Wed, 3 Apr 2024 20:37:05 +0100 Subject: [PATCH 2/7] version changed --- package.json | 2 +- projects/exui-common-lib/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6a1d6442..19086818 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/rpx-xui-common-lib", - "version": "2.0.17", + "version": "2.0.18-location-search-fix", "engines": { "node": ">=18.17.0" }, diff --git a/projects/exui-common-lib/package.json b/projects/exui-common-lib/package.json index 296a73a4..7e6dae3c 100644 --- a/projects/exui-common-lib/package.json +++ b/projects/exui-common-lib/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/rpx-xui-common-lib", - "version": "2.0.17", + "version": "2.0.18-location-search-fix", "peerDependencies": { "launchdarkly-js-client-sdk": "^2.15.2", "ngx-pagination": "^3.2.1", From 8023f2b9181a43de6ee9c118a07cd3afdf3855e9 Mon Sep 17 00:00:00 2001 From: OgunyemiO Date: Thu, 4 Apr 2024 11:55:36 +0100 Subject: [PATCH 3/7] unit test --- .../generic-filter.component.spec.ts | 108 ++++++++++-------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.spec.ts b/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.spec.ts index 81ba9653..abfbafe3 100644 --- a/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.spec.ts +++ b/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.spec.ts @@ -59,8 +59,8 @@ describe('GenericFilterComponent', () => { RpxTranslateMockPipe ], providers: [ - {provide: FilterService, useValue: mockFilterService}, - {provide: LocationService, useValue: searchFilterServiceMock} + { provide: FilterService, useValue: mockFilterService }, + { provide: LocationService, useValue: searchFilterServiceMock } ] }) .compileComponents(); @@ -76,17 +76,17 @@ describe('GenericFilterComponent', () => { cancelButtonText: 'cancel', cancelSetting: { id: 'examples', - fields: [{name: 'example1', value: ['Fernando Alonso']}] + fields: [{ name: 'example1', value: ['Fernando Alonso'] }] }, fields: [ { name: 'example1', options: [ - {key: 'Fernando Alonso', label: 'Fernando Alonso'}, - {key: 'Sebastian Vettel', label: 'Sebastian Vettel'}, - {key: 'Lewis Hamilton', label: 'Lewis Hamilton'}, - {key: 'Mick Schumacher', label: 'Mick Schumacher'}, - {key: 'Lando Norris', label: 'Lando Norris'}, + { key: 'Fernando Alonso', label: 'Fernando Alonso' }, + { key: 'Sebastian Vettel', label: 'Sebastian Vettel' }, + { key: 'Lewis Hamilton', label: 'Lewis Hamilton' }, + { key: 'Mick Schumacher', label: 'Mick Schumacher' }, + { key: 'Lando Norris', label: 'Lando Norris' }, ], title: 'Sample title', subTitle: 'Sample subtitle', @@ -97,11 +97,11 @@ describe('GenericFilterComponent', () => { { name: 'example2', options: [ - {key: 'Tinky Winky', label: 'Tinky Winky'}, - {key: 'Dipsy', label: 'Dipsy'}, - {key: 'Laa-Laa', label: 'Laa-Laa'}, - {key: 'Po', label: 'Po'}, - {key: 'Noo-noo', label: 'Noo-noo'}, + { key: 'Tinky Winky', label: 'Tinky Winky' }, + { key: 'Dipsy', label: 'Dipsy' }, + { key: 'Laa-Laa', label: 'Laa-Laa' }, + { key: 'Po', label: 'Po' }, + { key: 'Noo-noo', label: 'Noo-noo' }, ], title: 'Sample2 title', subTitle: 'Sample2 subtitle', @@ -112,11 +112,11 @@ describe('GenericFilterComponent', () => { { name: 'example3', options: [ - {key: 'yellow', label: 'Yellow'}, - {key: 'green', label: 'Green'}, - {key: 'red', label: 'Red'}, - {key: 'blue', label: 'Blue'}, - {key: 'orange', label: 'Orange'}, + { key: 'yellow', label: 'Yellow' }, + { key: 'green', label: 'Green' }, + { key: 'red', label: 'Red' }, + { key: 'blue', label: 'Blue' }, + { key: 'orange', label: 'Orange' }, ], title: 'Sample3 title', subTitle: 'Sample3 subtitle', @@ -443,12 +443,12 @@ describe('Select all checkboxes', () => { { name: 'example1', options: [ - {key: 'All', label: 'Select All', selectAll: true}, - {key: 'Fernando Alonso', label: 'Fernando Alonso'}, - {key: 'Sebastian Vettel', label: 'Sebastian Vettel'}, - {key: 'Lewis Hamilton', label: 'Lewis Hamilton'}, - {key: 'Mick Schumacher', label: 'Mick Schumacher'}, - {key: 'Lando Norris', label: 'Lando Norris'}, + { key: 'All', label: 'Select All', selectAll: true }, + { key: 'Fernando Alonso', label: 'Fernando Alonso' }, + { key: 'Sebastian Vettel', label: 'Sebastian Vettel' }, + { key: 'Lewis Hamilton', label: 'Lewis Hamilton' }, + { key: 'Mick Schumacher', label: 'Mick Schumacher' }, + { key: 'Lando Norris', label: 'Lando Norris' }, ], title: 'Sample title', subTitle: 'Sample subtitle', @@ -521,7 +521,7 @@ describe('Find location filter config', () => { ], providers: [ FilterService, - {provide: LocationService, useValue: searchFilterServiceMock} + { provide: LocationService, useValue: searchFilterServiceMock } ] }) .compileComponents(); @@ -557,58 +557,76 @@ describe('Find location filter config', () => { expect(findLocationFormGroup).toBeTruthy(); }); + it('should call the inputchanged function and set isSelectedService', () => { + const field: FilterFieldConfig = { + name: 'user-location', + title: 'Skills', + options: [], + minSelected: 0, + maxSelected: 0, + type: 'find-location', + lineBreakBefore: true, + disabledText: 'All' + }; + component['selectedServices'] = []; + component.isServiceSelected = false; + fixture.detectChanges(); + component.inputChanged(field); + expect(component.isServiceSelected).toBeTruthy(); + }); + describe('group-select dropdown', () => { - const groupOptions: GroupOptions[] = [ + const groupOptions: GroupOptions[] = [ { group: 'servieA', options: [ - {key: 'serviceA-key1', label: 'Key1'}, - {key: 'serviceA-key3', label: 'Key3'}, - {key: 'serviceA-key2', label: 'Key2'} + { key: 'serviceA-key1', label: 'Key1' }, + { key: 'serviceA-key3', label: 'Key3' }, + { key: 'serviceA-key2', label: 'Key2' } ] }, { group: 'servieC', options: [ - {key: 'serviceC-key3', label: 'Key3'}, - {key: 'serviceC-key2', label: 'Key2'}, - {key: 'serviceC-key1', label: 'Key1'} + { key: 'serviceC-key3', label: 'Key3' }, + { key: 'serviceC-key2', label: 'Key2' }, + { key: 'serviceC-key1', label: 'Key1' } ] }, { group: 'servieB', options: [ - {key: 'serviceB-key2', label: 'Key2'}, - {key: 'serviceB-key1', label: 'Key1'}, - {key: 'serviceB-key3', label: 'Key3'} + { key: 'serviceB-key2', label: 'Key2' }, + { key: 'serviceB-key1', label: 'Key1' }, + { key: 'serviceB-key3', label: 'Key3' } ] } ]; - const sortedGroupOptions: GroupOptions[] = [ + const sortedGroupOptions: GroupOptions[] = [ { group: 'servieA', options: [ - {key: 'serviceA-key1', label: 'Key1'}, - {key: 'serviceA-key2', label: 'Key2'}, - {key: 'serviceA-key3', label: 'Key3'} + { key: 'serviceA-key1', label: 'Key1' }, + { key: 'serviceA-key2', label: 'Key2' }, + { key: 'serviceA-key3', label: 'Key3' } ] }, { group: 'servieB', options: [ - {key: 'serviceB-key1', label: 'Key1'}, - {key: 'serviceB-key2', label: 'Key2'}, - {key: 'serviceB-key3', label: 'Key3'} + { key: 'serviceB-key1', label: 'Key1' }, + { key: 'serviceB-key2', label: 'Key2' }, + { key: 'serviceB-key3', label: 'Key3' } ] }, { group: 'servieC', options: [ - {key: 'serviceC-key1', label: 'Key1'}, - {key: 'serviceC-key2', label: 'Key2'}, - {key: 'serviceC-key3', label: 'Key3'} + { key: 'serviceC-key1', label: 'Key1' }, + { key: 'serviceC-key2', label: 'Key2' }, + { key: 'serviceC-key3', label: 'Key3' } ] } ]; From 41bbe0f153ba9e3a1ace836b07512dc551f06e6b Mon Sep 17 00:00:00 2001 From: OgunyemiO Date: Thu, 4 Apr 2024 15:53:21 +0100 Subject: [PATCH 4/7] unit test --- .../generic-filter/generic-filter.component.spec.ts | 1 - .../components/generic-filter/generic-filter.component.ts | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.spec.ts b/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.spec.ts index abfbafe3..a4d84a22 100644 --- a/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.spec.ts +++ b/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.spec.ts @@ -575,7 +575,6 @@ describe('Find location filter config', () => { expect(component.isServiceSelected).toBeTruthy(); }); - describe('group-select dropdown', () => { const groupOptions: GroupOptions[] = [ { diff --git a/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.ts b/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.ts index e9949a26..c0125fc7 100644 --- a/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.ts +++ b/projects/exui-common-lib/src/lib/components/generic-filter/generic-filter.component.ts @@ -222,6 +222,11 @@ export class GenericFilterComponent implements OnInit, OnDestroy { if (field.name === 'user-services') { this.selectedServices = this.getSelectedValuesForFields(this.form.controls, field); this.filterSkillsByServices(this.selectedServices, this.config); + if (this.selectedServices.length) { + this.isServiceSelected = false; + } else { + this.isServiceSelected = true; + } } } From 7c04858d218f89c39ad5d44518821dc00dbf0356 Mon Sep 17 00:00:00 2001 From: OgunyemiO Date: Tue, 16 Apr 2024 17:47:04 +0100 Subject: [PATCH 5/7] filter method altered --- .../src/lib/services/find-person/find-person.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/exui-common-lib/src/lib/services/find-person/find-person.service.ts b/projects/exui-common-lib/src/lib/services/find-person/find-person.service.ts index e3a7ab68..508eb213 100644 --- a/projects/exui-common-lib/src/lib/services/find-person/find-person.service.ts +++ b/projects/exui-common-lib/src/lib/services/find-person/find-person.service.ts @@ -116,7 +116,7 @@ export class FindAPersonService { const people = caseworkers ? this.mapCaseworkers(caseworkers, roleCategory) : []; const finalPeopleList = people.filter(person => person && person.name && person.name.toLowerCase().includes(searchTerm)); return searchOptions.userIncluded ? finalPeopleList.filter(person => person && person.id !== this.assignedUser) - : finalPeopleList.filter(person => person && person.id !== this.userId && person.id !== this.assignedUser); + : finalPeopleList.filter(person => person || person.id.includes(this.userId) && person.id !== this.assignedUser); } public searchJudicial(value: string, serviceId: string): Observable { From cf25780074c9321228de3afde055b1a4cf900506 Mon Sep 17 00:00:00 2001 From: OgunyemiO Date: Fri, 12 Jul 2024 16:34:13 +0100 Subject: [PATCH 6/7] version number change --- package.json | 2 +- projects/exui-common-lib/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2542e2b8..3ca2b9d5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/rpx-xui-common-lib", - "version": "2.0.18-location-search-fix", + "version": "2.0.23-location-search-fix", "engines": { "node": ">=18.19.0" }, diff --git a/projects/exui-common-lib/package.json b/projects/exui-common-lib/package.json index b7203e50..5c5e8b7f 100644 --- a/projects/exui-common-lib/package.json +++ b/projects/exui-common-lib/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/rpx-xui-common-lib", - "version": "2.0.18-location-search-fix", + "version": "2.0.23-location-search-fix", "peerDependencies": { "launchdarkly-js-client-sdk": "^3.3.0", "ngx-pagination": "^3.2.1", From 1b84e451d69dc7d0a0100179ff8e96d36168c3b5 Mon Sep 17 00:00:00 2001 From: Ritesh Dsouza Date: Wed, 17 Jul 2024 12:01:21 +0100 Subject: [PATCH 7/7] version updated --- package.json | 2 +- projects/exui-common-lib/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3ca2b9d5..eacdc147 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/rpx-xui-common-lib", - "version": "2.0.23-location-search-fix", + "version": "2.0.24", "engines": { "node": ">=18.19.0" }, diff --git a/projects/exui-common-lib/package.json b/projects/exui-common-lib/package.json index 5c5e8b7f..db5f3557 100644 --- a/projects/exui-common-lib/package.json +++ b/projects/exui-common-lib/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/rpx-xui-common-lib", - "version": "2.0.23-location-search-fix", + "version": "2.0.24", "peerDependencies": { "launchdarkly-js-client-sdk": "^3.3.0", "ngx-pagination": "^3.2.1",