Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-HMCTS committed Jul 22, 2024
2 parents 644a7e7 + bc2245c commit 96979b1
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 65 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/rpx-xui-common-lib",
"version": "2.0.23-find-self-user-search",
"version": "2.0.25",
"engines": {
"node": ">=18.19.0"
},
Expand Down
2 changes: 1 addition & 1 deletion projects/exui-common-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/rpx-xui-common-lib",
"version": "2.0.23-find-self-user-search",
"version": "2.0.25",
"peerDependencies": {
"launchdarkly-js-client-sdk": "^3.3.0",
"ngx-pagination": "^3.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ <h3 [class]="field.titleClasses ? field.titleClasses : 'govuk-heading-s'" style=
></xuilib-find-task-name>
</ng-container>
<ng-container *ngSwitchCase="'find-service'">
<span class="govuk-error-message" *ngIf="isServiceSelected">{{serviceErrorMsg | rpxTranslate}}</span>
<xuilib-find-service (serviceFieldChanged)="inputServiceChanged(field)"
[field]="field"
[form]="form"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -521,7 +521,7 @@ describe('Find location filter config', () => {
],
providers: [
FilterService,
{provide: LocationService, useValue: searchFilterServiceMock}
{ provide: LocationService, useValue: searchFilterServiceMock }
]
})
.compileComponents();
Expand Down Expand Up @@ -557,58 +557,75 @@ 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' }
]
}
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ export class GenericFilterComponent implements OnInit, OnDestroy {
public filteredSkillsByServicesCheckbox: FilterConfigOption[];
public previousSelectedNestedCheckbox: string[] = [];
public formSubmissionEvent$ = new Subject<void>();
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;
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -210,8 +220,13 @@ 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);
if (this.selectedServices.length) {
this.isServiceSelected = false;
} else {
this.isServiceSelected = true;
}
}
}

Expand All @@ -220,7 +235,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;
Expand Down Expand Up @@ -477,12 +492,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 };
}
});
}
Expand All @@ -493,15 +508,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;
});

Expand Down Expand Up @@ -602,10 +617,10 @@ export class GenericFilterComponent implements OnInit, OnDestroy {
const preSelectedSkills: boolean[] = [];

this.filteredSkillsByServicesCheckbox.map((skillsByServices, index) => {
for(let i = 0; i<this._config.preSelectedNestedCheckbox.length; i++) {
for (let i = 0; i < this._config.preSelectedNestedCheckbox.length; i++) {
const skillCopyValue = this._config.preSelectedNestedCheckbox[i];

if(skillCopyValue.toString() === skillsByServices.key.toString()) {
if (skillCopyValue.toString() === skillsByServices.key.toString()) {
preSelectedSkills[index] = true;
break;
} else {
Expand All @@ -614,7 +629,7 @@ export class GenericFilterComponent implements OnInit, OnDestroy {
}
});

if(preSelectedSkills.length > 0) {
if (preSelectedSkills.length > 0) {
preSelectedSkills.forEach((h) => {
(this.form.get('user-skills') as FormArray).push(new FormControl(h));
});
Expand Down Expand Up @@ -655,7 +670,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ export class FindAPersonService {
roleCategory = RoleCategory.CTSC;
}
}
const searchTerm = searchOptions && searchOptions.searchTerm ? searchOptions.searchTerm.toLowerCase() : '';
const people = caseworkers ? this.mapCaseworkers(caseworkers, roleCategory) : [];
const finalPeopleList = people.filter(person => person && person.name && person.name.toLowerCase().includes(searchOptions.searchTerm));
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.assignedUser);
: finalPeopleList.filter(person => person || person.id.includes(this.userId) && person.id !== this.assignedUser);
}

public searchJudicial(value: string, serviceId: string): Observable<JudicialUserModel[]> {
Expand Down

0 comments on commit 96979b1

Please sign in to comment.