@hmcts/rpx-xui-common-lib 1.6.1-adding-location-filter-bugfix → 1.6.1-all-work-filter

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/bundles/hmcts-rpx-xui-common-lib.umd.js +607 -426
  2. package/bundles/hmcts-rpx-xui-common-lib.umd.js.map +1 -1
  3. package/bundles/hmcts-rpx-xui-common-lib.umd.min.js +1 -1
  4. package/bundles/hmcts-rpx-xui-common-lib.umd.min.js.map +1 -1
  5. package/esm2015/lib/components/find-location/find-location.component.js +98 -44
  6. package/esm2015/lib/components/find-person/find-person.component.js +59 -24
  7. package/esm2015/lib/components/generic-filter/generic-filter-utils.js +2 -2
  8. package/esm2015/lib/components/generic-filter/generic-filter.component.js +49 -42
  9. package/esm2015/lib/components/search-location/search-location.component.js +53 -67
  10. package/esm2015/lib/exui-common-lib.module.js +4 -3
  11. package/esm2015/lib/gov-ui/models/isession-storage.interface.js +24 -0
  12. package/esm2015/lib/gov-ui/util/session-storage/session-storage-utils.js +58 -0
  13. package/esm2015/lib/models/filter.model.js +9 -1
  14. package/esm2015/lib/models/person.model.js +11 -1
  15. package/esm2015/lib/models/search-options.model.js +4 -2
  16. package/esm2015/lib/services/find-person/find-person.service.js +77 -24
  17. package/esm5/lib/components/find-location/find-location.component.js +122 -64
  18. package/esm5/lib/components/find-person/find-person.component.js +59 -25
  19. package/esm5/lib/components/generic-filter/generic-filter-utils.js +2 -2
  20. package/esm5/lib/components/generic-filter/generic-filter.component.js +98 -71
  21. package/esm5/lib/components/search-location/search-location.component.js +59 -75
  22. package/esm5/lib/exui-common-lib.module.js +4 -3
  23. package/esm5/lib/gov-ui/models/isession-storage.interface.js +24 -0
  24. package/esm5/lib/gov-ui/util/session-storage/session-storage-utils.js +58 -0
  25. package/esm5/lib/models/filter.model.js +9 -1
  26. package/esm5/lib/models/person.model.js +11 -1
  27. package/esm5/lib/models/search-options.model.js +4 -2
  28. package/esm5/lib/services/find-person/find-person.service.js +83 -24
  29. package/fesm2015/hmcts-rpx-xui-common-lib.js +425 -268
  30. package/fesm2015/hmcts-rpx-xui-common-lib.js.map +1 -1
  31. package/fesm5/hmcts-rpx-xui-common-lib.js +532 -348
  32. package/fesm5/hmcts-rpx-xui-common-lib.js.map +1 -1
  33. package/hmcts-rpx-xui-common-lib.metadata.json +1 -1
  34. package/lib/components/find-location/find-location.component.d.ts +11 -6
  35. package/lib/components/find-person/find-person.component.d.ts +10 -8
  36. package/lib/components/generic-filter/generic-filter-utils.d.ts +2 -2
  37. package/lib/components/generic-filter/generic-filter.component.d.ts +2 -3
  38. package/lib/components/search-location/search-location.component.d.ts +9 -9
  39. package/lib/gov-ui/models/isession-storage.interface.d.ts +4 -0
  40. package/lib/gov-ui/util/session-storage/session-storage-utils.d.ts +6 -0
  41. package/lib/models/filter.model.d.ts +4 -0
  42. package/lib/models/person.model.d.ts +4 -0
  43. package/lib/models/search-options.model.d.ts +2 -1
  44. package/lib/services/find-person/find-person.service.d.ts +2 -2
  45. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- import { MatTabsModule } from '@angular/material';
1
+ import { MatInputModule, MatTabsModule } from '@angular/material';
2
2
  import { MatAutocompleteModule } from '@angular/material/autocomplete';
3
3
  import { HttpClient } from '@angular/common/http';
4
- import { FormBuilder, FormControl, FormGroup, Validators, FormArray, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
- import { __values, __spread, __assign, __read } from 'tslib';
4
+ import { FormArray, FormBuilder, FormControl, FormGroup, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
+ import { __spread, __values, __assign, __read } from 'tslib';
6
6
  import { initialize } from 'launchdarkly-js-client-sdk';
7
7
  import { formatDate, DOCUMENT, CommonModule } from '@angular/common';
8
8
  import { Title } from '@angular/platform-browser';
@@ -11,7 +11,7 @@ import { Keepalive } from '@ng-idle/keepalive';
11
11
  import { RouterModule, Router, NavigationEnd } from '@angular/router';
12
12
  import { Component, EventEmitter, Input, Output, ViewEncapsulation, Injectable, Directive, TemplateRef, ViewContainerRef, ElementRef, Inject, ChangeDetectorRef, InjectionToken, defineInjectable, inject, ViewChild, ChangeDetectionStrategy, NgModule } from '@angular/core';
13
13
  import { BehaviorSubject, of, zip, combineLatest, Subject } from 'rxjs';
14
- import { distinctUntilChanged, map, debounceTime, filter, mergeMap, tap, startWith, switchMap, delay } from 'rxjs/operators';
14
+ import { distinctUntilChanged, map, debounceTime, filter, mergeMap, tap, catchError, startWith, switchMap, delay } from 'rxjs/operators';
15
15
 
16
16
  /**
17
17
  * @fileoverview added by tsickle
@@ -795,7 +795,7 @@ function maxSelectedValidator(max) {
795
795
  * @param {?} values
796
796
  * @return {?}
797
797
  */
798
- function getCheckBoxesValues(options, values) {
798
+ function getValues(options, values) {
799
799
  return options.reduce((/**
800
800
  * @param {?} acc
801
801
  * @param {?} option
@@ -1032,7 +1032,7 @@ var GenericFilterComponent = /** @class */ (function () {
1032
1032
  * @param {?} form
1033
1033
  * @return {?}
1034
1034
  */
1035
- GenericFilterComponent.prototype.selectChanged =
1035
+ GenericFilterComponent.prototype.fieldChanged =
1036
1036
  // when domain changes ensure that person field is reset
1037
1037
  /**
1038
1038
  * @param {?} field
@@ -1040,48 +1040,22 @@ var GenericFilterComponent = /** @class */ (function () {
1040
1040
  * @return {?}
1041
1041
  */
1042
1042
  function (field, form) {
1043
- if (field.findPersonField) {
1044
- /** @type {?} */
1045
- var currentField = this.config.fields.find((/**
1046
- * @param {?} f
1047
- * @return {?}
1048
- */
1049
- function (f) { return f.name === field.findPersonField; }));
1050
- if (currentField) {
1051
- currentField.domain = form.get(field.name).value;
1043
+ var e_1, _a;
1044
+ // TODO - Do similar with jurisdiction/service for caseworkers by services
1045
+ if (field.changeResetFields && field.changeResetFields.length) {
1046
+ try {
1047
+ for (var _b = __values(field.changeResetFields), _c = _b.next(); !_c.done; _c = _b.next()) {
1048
+ var resetField = _c.value;
1049
+ this.resetField(resetField, form);
1050
+ }
1051
+ }
1052
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1053
+ finally {
1054
+ try {
1055
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1056
+ }
1057
+ finally { if (e_1) throw e_1.error; }
1052
1058
  }
1053
- this.removePersonField(field);
1054
- }
1055
- };
1056
- /**
1057
- * @param {?} field
1058
- * @return {?}
1059
- */
1060
- GenericFilterComponent.prototype.radiosChanged = /**
1061
- * @param {?} field
1062
- * @return {?}
1063
- */
1064
- function (field) {
1065
- if (field.findPersonField) {
1066
- this.form.get('findPersonControl').setValue(null);
1067
- this.removePersonField(field);
1068
- }
1069
- };
1070
- /**
1071
- * @param {?} field
1072
- * @return {?}
1073
- */
1074
- GenericFilterComponent.prototype.removePersonField = /**
1075
- * @param {?} field
1076
- * @return {?}
1077
- */
1078
- function (field) {
1079
- if (this.form.get(field.findPersonField)) {
1080
- this.form.get(field.findPersonField).get('domain').setValue(null);
1081
- this.form.get(field.findPersonField).get('email').setValue(null);
1082
- this.form.get(field.findPersonField).get('id').setValue(null);
1083
- this.form.get(field.findPersonField).get('name').setValue(null);
1084
- this.form.get(field.findPersonField).get('knownAs').setValue(null);
1085
1059
  }
1086
1060
  };
1087
1061
  /**
@@ -1099,6 +1073,7 @@ var GenericFilterComponent = /** @class */ (function () {
1099
1073
  var settings = __assign({}, this.settings, { reset: true });
1100
1074
  this.filterService.persist(settings, this.config.persistence);
1101
1075
  this.filterService.givenErrors.next(null);
1076
+ this.submitted = false;
1102
1077
  };
1103
1078
  /**
1104
1079
  * @param {?} values
@@ -1111,7 +1086,7 @@ var GenericFilterComponent = /** @class */ (function () {
1111
1086
  * @return {?}
1112
1087
  */
1113
1088
  function (values, field) {
1114
- var e_1, _a;
1089
+ var e_2, _a;
1115
1090
  /** @type {?} */
1116
1091
  var keys = Object.keys(values);
1117
1092
  try {
@@ -1122,12 +1097,12 @@ var GenericFilterComponent = /** @class */ (function () {
1122
1097
  }
1123
1098
  }
1124
1099
  }
1125
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1100
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1126
1101
  finally {
1127
1102
  try {
1128
1103
  if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
1129
1104
  }
1130
- finally { if (e_1) throw e_1.error; }
1105
+ finally { if (e_2) throw e_2.error; }
1131
1106
  }
1132
1107
  };
1133
1108
  /**
@@ -1215,6 +1190,56 @@ var GenericFilterComponent = /** @class */ (function () {
1215
1190
  }
1216
1191
  }));
1217
1192
  };
1193
+ /**
1194
+ * @private
1195
+ * @param {?} resetField
1196
+ * @param {?} form
1197
+ * @return {?}
1198
+ */
1199
+ GenericFilterComponent.prototype.resetField = /**
1200
+ * @private
1201
+ * @param {?} resetField
1202
+ * @param {?} form
1203
+ * @return {?}
1204
+ */
1205
+ function (resetField, form) {
1206
+ var e_3, _a;
1207
+ /** @type {?} */
1208
+ var control = form.get(resetField);
1209
+ /** @type {?} */
1210
+ var defaultValue = this.config.cancelSetting.fields.find((/**
1211
+ * @param {?} f
1212
+ * @return {?}
1213
+ */
1214
+ function (f) { return f.name === resetField; }));
1215
+ if (control instanceof FormArray) {
1216
+ for (var i = 0; i < control.length; i++) {
1217
+ control.removeAt(i);
1218
+ }
1219
+ }
1220
+ else if (control instanceof FormGroup) {
1221
+ /** @type {?} */
1222
+ var keys = Object.keys(control.value);
1223
+ try {
1224
+ for (var keys_2 = __values(keys), keys_2_1 = keys_2.next(); !keys_2_1.done; keys_2_1 = keys_2.next()) {
1225
+ var key = keys_2_1.value;
1226
+ this.resetField(key, control);
1227
+ }
1228
+ }
1229
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1230
+ finally {
1231
+ try {
1232
+ if (keys_2_1 && !keys_2_1.done && (_a = keys_2.return)) _a.call(keys_2);
1233
+ }
1234
+ finally { if (e_3) throw e_3.error; }
1235
+ }
1236
+ }
1237
+ else if (control instanceof FormControl) {
1238
+ /** @type {?} */
1239
+ var value = defaultValue && defaultValue.value && defaultValue.value.length ? defaultValue.value[0] : null;
1240
+ control.setValue(value);
1241
+ }
1242
+ };
1218
1243
  /**
1219
1244
  * @private
1220
1245
  * @param {?} filter
@@ -1262,7 +1287,7 @@ var GenericFilterComponent = /** @class */ (function () {
1262
1287
  * @return {?}
1263
1288
  */
1264
1289
  function (config, settings, reset) {
1265
- var e_2, _a;
1290
+ var e_4, _a;
1266
1291
  /** @type {?} */
1267
1292
  var findPersonControl = this.form ? this.form.get('findPersonControl') : null;
1268
1293
  this.form = this.fb.group({});
@@ -1326,7 +1351,7 @@ var GenericFilterComponent = /** @class */ (function () {
1326
1351
  }
1327
1352
  // if field updates find person component set the initial domain
1328
1353
  if (field.findPersonField) {
1329
- this_1.selectChanged(field, this_1.form);
1354
+ this_1.fieldChanged(field, this_1.form);
1330
1355
  }
1331
1356
  }
1332
1357
  };
@@ -1337,12 +1362,12 @@ var GenericFilterComponent = /** @class */ (function () {
1337
1362
  _loop_1(field);
1338
1363
  }
1339
1364
  }
1340
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1365
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1341
1366
  finally {
1342
1367
  try {
1343
1368
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1344
1369
  }
1345
- finally { if (e_2) throw e_2.error; }
1370
+ finally { if (e_4) throw e_4.error; }
1346
1371
  }
1347
1372
  };
1348
1373
  /**
@@ -1358,7 +1383,7 @@ var GenericFilterComponent = /** @class */ (function () {
1358
1383
  * @return {?}
1359
1384
  */
1360
1385
  function (field, settings) {
1361
- var e_3, _a;
1386
+ var e_5, _a;
1362
1387
  /** @type {?} */
1363
1388
  var validators = GenericFilterComponent.addFormValidators(field);
1364
1389
  /** @type {?} */
@@ -1390,12 +1415,12 @@ var GenericFilterComponent = /** @class */ (function () {
1390
1415
  _loop_2(option);
1391
1416
  }
1392
1417
  }
1393
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1418
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1394
1419
  finally {
1395
1420
  try {
1396
1421
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1397
1422
  }
1398
- finally { if (e_3) throw e_3.error; }
1423
+ finally { if (e_5) throw e_5.error; }
1399
1424
  }
1400
1425
  return formArray;
1401
1426
  };
@@ -1412,7 +1437,7 @@ var GenericFilterComponent = /** @class */ (function () {
1412
1437
  * @return {?}
1413
1438
  */
1414
1439
  function (field, settings) {
1415
- var e_4, _a;
1440
+ var e_6, _a;
1416
1441
  /** @type {?} */
1417
1442
  var validators = GenericFilterComponent.addFormValidators(field);
1418
1443
  /** @type {?} */
@@ -1425,18 +1450,20 @@ var GenericFilterComponent = /** @class */ (function () {
1425
1450
  * @return {?}
1426
1451
  */
1427
1452
  function (f) { return f.name === field.name; }));
1428
- try {
1429
- for (var _b = __values(defaultValues.value), _c = _b.next(); !_c.done; _c = _b.next()) {
1430
- var defaultValue = _c.value;
1431
- formArray.push(new FormControl(defaultValue));
1432
- }
1433
- }
1434
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1435
- finally {
1453
+ if (defaultValues) {
1436
1454
  try {
1437
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1455
+ for (var _b = __values(defaultValues.value), _c = _b.next(); !_c.done; _c = _b.next()) {
1456
+ var defaultValue = _c.value;
1457
+ formArray.push(new FormControl(defaultValue));
1458
+ }
1459
+ }
1460
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1461
+ finally {
1462
+ try {
1463
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1464
+ }
1465
+ finally { if (e_6) throw e_6.error; }
1438
1466
  }
1439
- finally { if (e_4) throw e_4.error; }
1440
1467
  }
1441
1468
  }
1442
1469
  return formArray;
@@ -1472,7 +1499,7 @@ var GenericFilterComponent = /** @class */ (function () {
1472
1499
  return { value: values, name: name };
1473
1500
  }
1474
1501
  else {
1475
- return { value: getCheckBoxesValues(field.options, values), name: name };
1502
+ return { value: getValues(field.options, values), name: name };
1476
1503
  }
1477
1504
  }
1478
1505
  else {
@@ -1491,7 +1518,7 @@ var GenericFilterComponent = /** @class */ (function () {
1491
1518
  * @return {?}
1492
1519
  */
1493
1520
  function (form) {
1494
- var e_5, _a;
1521
+ var e_7, _a;
1495
1522
  /** @type {?} */
1496
1523
  var errors = [];
1497
1524
  try {
@@ -1507,12 +1534,12 @@ var GenericFilterComponent = /** @class */ (function () {
1507
1534
  }
1508
1535
  }
1509
1536
  }
1510
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1537
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1511
1538
  finally {
1512
1539
  try {
1513
1540
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1514
1541
  }
1515
- finally { if (e_5) throw e_5.error; }
1542
+ finally { if (e_7) throw e_7.error; }
1516
1543
  }
1517
1544
  if (errors.length) {
1518
1545
  this.filterService.givenErrors.next(errors);
@@ -1521,7 +1548,7 @@ var GenericFilterComponent = /** @class */ (function () {
1521
1548
  GenericFilterComponent.decorators = [
1522
1549
  { type: Component, args: [{
1523
1550
  selector: 'xuilib-generic-filter',
1524
- template: "<form [formGroup]=\"form\" (ngSubmit)=\"applyFilter(form)\">\n <div class=\"contain-classes\" *ngFor=\"let field of config.fields\">\n <hr *ngIf=\"field.lineBreakBefore\" class=\"govuk-section-break govuk-section-break--visible elevated-break\">\n <div class=\"govuk-form-group xui-generic-filter\"\n [hidden]=\"hidden(field, form)\"\n [id]=\"field.name\"\n [ngClass]=\"{'form-group-error': submitted && (form.get(field.name).errors?.minLength || form.get(field.name).errors?.maxLength)}\">\n <h3 *ngIf=\"field.title\" class=\"govuk-heading-s\">{{field.title}}</h3>\n <p class=\"govuk-body\" *ngIf=\"field.subTitle\">{{field.subTitle}}</p>\n <span [id]=\"field.name + '-error'\" class=\"govuk-error-message\" *ngIf=\"field.displayMinSelectedError && submitted && form.get(field.name).errors?.minLength\">\n <span class=\"govuk-visually-hidden\">Error:</span> {{field.minSelectedError}}\n </span>\n <span [id]=\"field.name + '-error'\" class=\"govuk-error-message\" *ngIf=\"field.displayMaxSelectedError && submitted && form.get(field.name).errors?.maxLength\">\n <span class=\"govuk-visually-hidden\">Error:</span> {{field.maxSelectedError}}\n </span>\n <div class=\"govuk-body\" [ngSwitch]=\"field.type\">\n <ng-container *ngSwitchCase=\"'select'\">\n <select class=\"govuk-select\" (change)=\"selectChanged(field, form)\" [attr.disabled]=\"disabled(field, form)\" [name]=\"'select_' + field.name\" [id]=\"'select_' + field.name\" [formControlName]=\"field.name\">\n <option disabled selected hidden value=\"\">{{field.disabledText}}</option>\n <option class=\"govuk-radios__item\" *ngFor=\"let item of field.options\" [value]=\"item.key\">{{item.label}}</option>\n </select>\n </ng-container>\n <ng-container *ngSwitchCase=\"'checkbox'\">\n <div class=\"govuk-checkboxes govuk-checkboxes--small\" [formGroupName]=\"field.name\" [attr.field]=\"field.name\" [id]=\"'checkbox_' + field.name\">\n <div *ngFor=\"let item of field.options; let i = index\" class=\"govuk-checkboxes__item\">\n <input type=\"checkbox\" class=\"govuk-checkboxes__input\"\n [attr.disabled]=\"disabled(field, form)\"\n [formControlName]=\"i\"\n (change)=\"toggleSelectAll($event, form, item, field)\"\n [value]=\"item.key\" [id]=\"'checkbox_' + item.key\"\n [name]=\"'checkbox_' + item.key\"\n />\n <label\n [for]=\"'checkbox_' + item.key\"\n class=\"govuk-label govuk-checkboxes__label\"\n [ngClass]=\"{'govuk-!-font-weight-bold': item.selectAll}\"\n >{{item.label}}</label>\n </div>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'checkbox-large'\">\n <div class=\"govuk-checkboxes\" [formGroupName]=\"field.name\" [attr.field]=\"field.name\" [id]=\"'checkbox_' + field.name\">\n <div *ngFor=\"let item of field.options; let i = index\" class=\"govuk-checkboxes__item\">\n <input type=\"checkbox\" class=\"govuk-checkboxes__input\"\n [attr.disabled]=\"disabled(field, form)\"\n [formControlName]=\"i\"\n (change)=\"toggleSelectAll($event, form, item, field)\"\n [value]=\"item.key\" [id]=\"'checkbox_' + item.key\"\n [name]=\"'checkbox_' + item.key\"\n />\n <label\n [for]=\"'checkbox_' + item.key\"\n class=\"govuk-label govuk-checkboxes__label\"\n [ngClass]=\"{'govuk-!-font-weight-bold': item.selectAll}\"\n >{{item.label}}</label>\n </div>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'radio'\">\n <div class=\"govuk-radios\">\n <div *ngFor=\"let item of field.options\" class=\"govuk-radios__item\">\n <input type=\"radio\"\n [formControlName]=\"field.name\"\n [id]=\"'radio_' + item.key\"\n [attr.disabled]=\"disabled(field, form)\"\n [checked]=\"item.key === form.get(field.name).value\"\n class=\"govuk-radios__input\"\n [value]=\"item.key\"\n (change)=\"radiosChanged(field)\"\n />\n <label [for]=\"'radio_' + item.key\" class=\"govuk-label govuk-radios__label\">{{item.label}}</label>\n </div>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'find-person'\">\n <xuilib-find-person subTitle=\"\" (personSelected)=\"updatePersonControls($event, field)\"\n [submitted]=\"submitted\"\n [disabled]=\"disabled(field, form)\"\n [domain]=\"field.domain\"\n [findPersonGroup]=\"form\"\n [selectedPerson]=\"form.get(field.name)?.value?.email\"\n [userIncluded]=\"false\"\n ></xuilib-find-person>\n </ng-container>\n <ng-container *ngSwitchCase=\"'find-location'\">\n <xuilib-find-location [form]=\"form\"\n [fields]=\"config.fields\"\n [selectedLocations]=\"form.get(field.name)?.value\"\n [submitted]=\"submitted\"\n [services]=\"form.get(field.findPersonField)?.value\"\n [field]=\"field\"\n ></xuilib-find-location>\n </ng-container>\n </div>\n </div>\n </div>\n <hr class=\"govuk-section-break govuk-section-break--m govuk-section-break--visible\"/>\n <div class=\"govuk-grid-row\">\n <div class=\"govuk-grid-column-full\">\n <button\n class=\"govuk-button govuk-!-margin-right-1 govuk-!-margin-bottom-0\"\n type=\"submit\"\n id=\"applyFilter\"\n [disabled]=\"config.enableDisabledButton && form.invalid\"\n >{{config.applyButtonText || 'Apply'}}</button>\n <button\n class=\"govuk-button govuk-button--secondary govuk-!-margin-bottom-0\"\n type=\"button\"\n id=\"cancelFilter\"\n (click)=\"cancelFilter()\">{{ config.cancelButtonText || 'Cancel'}}</button>\n </div>\n </div>\n</form>\n",
1551
+ template: "<form [formGroup]=\"form\" (ngSubmit)=\"applyFilter(form)\">\n <div class=\"contain-classes\" *ngFor=\"let field of config.fields\">\n <hr *ngIf=\"field.lineBreakBefore\" class=\"govuk-section-break govuk-section-break--visible elevated-break\">\n <div class=\"govuk-form-group xui-generic-filter\"\n [hidden]=\"hidden(field, form)\"\n [id]=\"field.name\"\n [ngClass]=\"{'form-group-error': submitted && (form.get(field.name).errors?.minLength || form.get(field.name).errors?.maxLength)}\">\n <h3 *ngIf=\"field.title\" class=\"govuk-heading-s\">{{field.title}}</h3>\n <p class=\"govuk-body\" *ngIf=\"field.subTitle\">{{field.subTitle}}</p>\n <span [id]=\"field.name + '-error'\" class=\"govuk-error-message\" *ngIf=\"field.displayMinSelectedError && submitted && form.get(field.name).errors?.minLength\">\n <span class=\"govuk-visually-hidden\">Error:</span> {{field.minSelectedError}}\n </span>\n <span [id]=\"field.name + '-error'\" class=\"govuk-error-message\" *ngIf=\"field.displayMaxSelectedError && submitted && form.get(field.name).errors?.maxLength\">\n <span class=\"govuk-visually-hidden\">Error:</span> {{field.maxSelectedError}}\n </span>\n <div class=\"govuk-body\" [ngSwitch]=\"field.type\">\n <ng-container *ngSwitchCase=\"'select'\">\n <select class=\"govuk-select\" (change)=\"fieldChanged(field, form)\" [attr.disabled]=\"disabled(field, form)\" [name]=\"'select_' + field.name\" [id]=\"'select_' + field.name\" [formControlName]=\"field.name\">\n <option disabled selected hidden value=\"\">{{field.disabledText}}</option>\n <option class=\"govuk-radios__item\" *ngFor=\"let item of field.options\" [value]=\"item.key\">{{item.label}}</option>\n </select>\n </ng-container>\n <ng-container *ngSwitchCase=\"'checkbox'\">\n <div class=\"govuk-checkboxes govuk-checkboxes--small\" [formGroupName]=\"field.name\" [attr.field]=\"field.name\" [id]=\"'checkbox_' + field.name\">\n <div *ngFor=\"let item of field.options; let i = index\" class=\"govuk-checkboxes__item\">\n <input type=\"checkbox\" class=\"govuk-checkboxes__input\"\n [attr.disabled]=\"disabled(field, form)\"\n [formControlName]=\"i\"\n (change)=\"toggleSelectAll($event, form, item, field)\"\n [value]=\"item.key\" [id]=\"'checkbox_' + item.key\"\n [name]=\"'checkbox_' + item.key\"\n />\n <label\n [for]=\"'checkbox_' + item.key\"\n class=\"govuk-label govuk-checkboxes__label\"\n [ngClass]=\"{'govuk-!-font-weight-bold': item.selectAll}\"\n >{{item.label}}</label>\n </div>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'checkbox-large'\">\n <div class=\"govuk-checkboxes\" [formGroupName]=\"field.name\" [attr.field]=\"field.name\" [id]=\"'checkbox_' + field.name\">\n <div *ngFor=\"let item of field.options; let i = index\" class=\"govuk-checkboxes__item\">\n <input type=\"checkbox\" class=\"govuk-checkboxes__input\"\n [attr.disabled]=\"disabled(field, form)\"\n [formControlName]=\"i\"\n (change)=\"toggleSelectAll($event, form, item, field)\"\n [value]=\"item.key\" [id]=\"'checkbox_' + item.key\"\n [name]=\"'checkbox_' + item.key\"\n />\n <label\n [for]=\"'checkbox_' + item.key\"\n class=\"govuk-label govuk-checkboxes__label\"\n [ngClass]=\"{'govuk-!-font-weight-bold': item.selectAll}\"\n >{{item.label}}</label>\n </div>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'radio'\">\n <div class=\"govuk-radios\">\n <div *ngFor=\"let item of field.options\" class=\"govuk-radios__item\">\n <input type=\"radio\"\n [formControlName]=\"field.name\"\n [id]=\"'radio_' + item.key\"\n [attr.disabled]=\"disabled(field, form)\"\n [checked]=\"item.key === form.get(field.name).value\"\n class=\"govuk-radios__input\"\n [value]=\"item.key\"\n (change)=\"fieldChanged(field, form)\"\n />\n <label [for]=\"'radio_' + item.key\" class=\"govuk-label govuk-radios__label\">{{item.label}}</label>\n </div>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'find-person'\">\n <xuilib-find-person subTitle=\"\" (personSelected)=\"updatePersonControls($event, field)\"\n [submitted]=\"submitted\"\n [domain]=\"form.get(field.domainField)?.value\"\n [findPersonGroup]=\"form\"\n [selectedPerson]=\"form.get(field.name)?.value?.email\"\n [disabled]=\"disabled(field, form)\"\n [userIncluded]=\"false\"\n ></xuilib-find-person>\n </ng-container>\n <ng-container *ngSwitchCase=\"'find-location'\">\n <xuilib-find-location [form]=\"form\"\n [fields]=\"config.fields\"\n [title]=\"field.title\"\n [enableAddLocationButton]=\"field.enableAddLocationButton\"\n [disabled]=\"disabled(field, form)\"\n [selectedLocations]=\"form.get(field.name)?.value\"\n [submitted]=\"submitted\"\n [services]=\"form.get(field.findLocationField)?.value\"\n [field]=\"field\"\n ></xuilib-find-location>\n </ng-container>\n </div>\n </div>\n </div>\n <hr class=\"govuk-section-break govuk-section-break--m govuk-section-break--visible\"/>\n <div class=\"govuk-grid-row\">\n <div class=\"govuk-grid-column-full\">\n <button\n class=\"govuk-button govuk-!-margin-right-1 govuk-!-margin-bottom-0\"\n type=\"submit\"\n id=\"applyFilter\"\n [disabled]=\"config.enableDisabledButton && form.invalid\"\n >{{config.applyButtonText || 'Apply'}}</button>\n <button\n class=\"govuk-button govuk-button--secondary govuk-!-margin-bottom-0\"\n type=\"button\"\n id=\"cancelFilter\"\n (click)=\"cancelFilter()\">{{ config.cancelButtonText || 'Cancel'}}</button>\n </div>\n </div>\n</form>\n",
1525
1552
  changeDetection: ChangeDetectionStrategy.OnPush,
1526
1553
  encapsulation: ViewEncapsulation.None,
1527
1554
  styles: [".contain-classes .elevated-break{position:relative;top:-10px}.contain-classes .xui-generic-filter .select-all{margin-bottom:10px}.contain-classes .xui-generic-filter .govuk-checkboxes{display:flex;flex-wrap:wrap}.contain-classes .xui-generic-filter .govuk-checkboxes>div{flex-grow:1;flex-shrink:0}"]
@@ -3568,168 +3595,6 @@ var CookieBannerComponent = /** @class */ (function () {
3568
3595
  return CookieBannerComponent;
3569
3596
  }());
3570
3597
 
3571
- /**
3572
- * @fileoverview added by tsickle
3573
- * Generated from: lib/components/find-location/find-location.component.ts
3574
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3575
- */
3576
- var FindLocationComponent = /** @class */ (function () {
3577
- function FindLocationComponent() {
3578
- this.selectedLocations = [];
3579
- this.submitted = true;
3580
- this.locations = [];
3581
- this.locationsForm = new FormArray([]);
3582
- this.serviceIds = 'SSCS,IA';
3583
- this.pServices = [];
3584
- }
3585
- Object.defineProperty(FindLocationComponent.prototype, "services", {
3586
- get: /**
3587
- * @return {?}
3588
- */
3589
- function () {
3590
- return this.pServices;
3591
- },
3592
- set: /**
3593
- * @param {?} value
3594
- * @return {?}
3595
- */
3596
- function (value) {
3597
- var _this = this;
3598
- this.pServices = value;
3599
- /** @type {?} */
3600
- var field = this.fields.find((/**
3601
- * @param {?} f
3602
- * @return {?}
3603
- */
3604
- function (f) { return f.name === _this.field.findPersonField; }));
3605
- if (field) {
3606
- this.serviceIds = getCheckBoxesValues(field.options, value).filter((/**
3607
- * @param {?} x
3608
- * @return {?}
3609
- */
3610
- function (x) { return x !== 'services_all'; })).join(',');
3611
- }
3612
- },
3613
- enumerable: true,
3614
- configurable: true
3615
- });
3616
- /**
3617
- * @private
3618
- * @param {?} selectedLocations
3619
- * @param {?} formArray
3620
- * @return {?}
3621
- */
3622
- FindLocationComponent.initForm = /**
3623
- * @private
3624
- * @param {?} selectedLocations
3625
- * @param {?} formArray
3626
- * @return {?}
3627
- */
3628
- function (selectedLocations, formArray) {
3629
- var e_1, _a;
3630
- try {
3631
- for (var selectedLocations_1 = __values(selectedLocations), selectedLocations_1_1 = selectedLocations_1.next(); !selectedLocations_1_1.done; selectedLocations_1_1 = selectedLocations_1.next()) {
3632
- var location_1 = selectedLocations_1_1.value;
3633
- formArray.push(new FormControl(location_1));
3634
- }
3635
- }
3636
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3637
- finally {
3638
- try {
3639
- if (selectedLocations_1_1 && !selectedLocations_1_1.done && (_a = selectedLocations_1.return)) _a.call(selectedLocations_1);
3640
- }
3641
- finally { if (e_1) throw e_1.error; }
3642
- }
3643
- return formArray;
3644
- };
3645
- /**
3646
- * @return {?}
3647
- */
3648
- FindLocationComponent.prototype.ngOnInit = /**
3649
- * @return {?}
3650
- */
3651
- function () {
3652
- this.locationsForm = FindLocationComponent.initForm(this.selectedLocations, this.locationsForm);
3653
- };
3654
- /**
3655
- * @return {?}
3656
- */
3657
- FindLocationComponent.prototype.addLocation = /**
3658
- * @return {?}
3659
- */
3660
- function () {
3661
- if (this.locations && this.locations.length) {
3662
- /** @type {?} */
3663
- var locationsForm = this.locationsForm;
3664
- this.selectedLocations = (/** @type {?} */ (this.locationsForm.value));
3665
- /** @type {?} */
3666
- var formArray = (/** @type {?} */ (this.form.get(this.field.name)));
3667
- /** @type {?} */
3668
- var lastSavedValue = this.selectedLocations[this.selectedLocations.length - 1];
3669
- FindLocationComponent.initForm([lastSavedValue], formArray);
3670
- locationsForm.at(this.selectedLocations.length - 1).setValue(null);
3671
- }
3672
- this.locations = [];
3673
- };
3674
- /**
3675
- * @param {?} location
3676
- * @return {?}
3677
- */
3678
- FindLocationComponent.prototype.removeLocation = /**
3679
- * @param {?} location
3680
- * @return {?}
3681
- */
3682
- function (location) {
3683
- if (location.epims_id) {
3684
- this.selectedLocations = this.selectedLocations.filter((/**
3685
- * @param {?} selectedLocation
3686
- * @return {?}
3687
- */
3688
- function (selectedLocation) { return selectedLocation.epims_id !== location.epims_id; }));
3689
- /** @type {?} */
3690
- var formArray = (/** @type {?} */ (this.form.get(this.field.name)));
3691
- /** @type {?} */
3692
- var index = ((/** @type {?} */ (formArray.value))).findIndex((/**
3693
- * @param {?} selectedLocation
3694
- * @return {?}
3695
- */
3696
- function (selectedLocation) { return selectedLocation.epims_id === location.epims_id; }));
3697
- if (index > -1) {
3698
- formArray.removeAt(index);
3699
- }
3700
- }
3701
- };
3702
- /**
3703
- * @param {?} location
3704
- * @return {?}
3705
- */
3706
- FindLocationComponent.prototype.onLocationSelected = /**
3707
- * @param {?} location
3708
- * @return {?}
3709
- */
3710
- function (location) {
3711
- if (location && location.epims_id) {
3712
- this.locations = __spread(this.locations, [location]);
3713
- }
3714
- };
3715
- FindLocationComponent.decorators = [
3716
- { type: Component, args: [{
3717
- selector: 'xuilib-find-location',
3718
- template: "<div class=\"location-picker-custom\">\n <div class=\"search-location\">\n <div>\n <label id=\"input-selected-location-label\">Search for a location by name</label>\n </div>\n <exui-search-location class=\"search-location\"\n (locationSelected)=\"onLocationSelected($event)\"\n [selectedLocations]=\"selectedLocations\"\n [control]=\"locationsForm\"\n [locations]=\"locations\"\n [delay]=\"300\"\n [disabled]=false\n [serviceIds]=\"serviceIds\"\n [locationType]=\"'case-management'\"></exui-search-location>\n <a href=\"javascript:void(0)\" (click)=\"addLocation()\" class=\"govuk-button\" data-module=\"govuk-button\">\n Add location\n </a>\n </div>\n <ul *ngIf=\"selectedLocations.length\" class=\"hmcts-filter-tags selection-container\">\n <li class=\"location-selection\" *ngFor=\"let selection of selectedLocations\">\n <a class=\"hmcts-filter__tag\" (click)=\"removeLocation(selection)\" href=\"javascript:void(0)\">\n {{ selection.court_name }}\n </a>\n </li>\n </ul>\n</div>\n",
3719
- styles: [""]
3720
- }] }
3721
- ];
3722
- FindLocationComponent.propDecorators = {
3723
- selectedLocations: [{ type: Input }],
3724
- submitted: [{ type: Input }],
3725
- form: [{ type: Input }],
3726
- field: [{ type: Input }],
3727
- fields: [{ type: Input }],
3728
- services: [{ type: Input }]
3729
- };
3730
- return FindLocationComponent;
3731
- }());
3732
-
3733
3598
  /**
3734
3599
  * @fileoverview added by tsickle
3735
3600
  * Generated from: lib/services/locations/location.service.ts
@@ -3787,6 +3652,7 @@ var SearchLocationComponent = /** @class */ (function () {
3787
3652
  this.fb = fb;
3788
3653
  this.cd = cd;
3789
3654
  this.disabled = null;
3655
+ this.singleMode = false;
3790
3656
  this.locationType = '';
3791
3657
  this.serviceIds = '';
3792
3658
  this.submitted = true;
@@ -3794,15 +3660,32 @@ var SearchLocationComponent = /** @class */ (function () {
3794
3660
  this.showAutocomplete = false;
3795
3661
  this.locations = [];
3796
3662
  this.locationSelected = new EventEmitter();
3797
- this.term = '';
3798
- this.readyAfterContent = false;
3799
3663
  this.minSearchCharacters = 3;
3664
+ this.term = '';
3800
3665
  this.pSelectedLocations = [];
3801
- this.findLocationFormGroup = this.fb.group({
3802
- findLocationFormControl: [null],
3803
- locationSelectedFormControl: [null]
3666
+ this.pReset = true;
3667
+ this.form = this.fb.group({
3668
+ searchTerm: ['']
3804
3669
  });
3805
3670
  }
3671
+ Object.defineProperty(SearchLocationComponent.prototype, "reset", {
3672
+ get: /**
3673
+ * @return {?}
3674
+ */
3675
+ function () {
3676
+ return this.pReset;
3677
+ },
3678
+ set: /**
3679
+ * @param {?} value
3680
+ * @return {?}
3681
+ */
3682
+ function (value) {
3683
+ this.pReset = value;
3684
+ this.resetSearchTerm();
3685
+ },
3686
+ enumerable: true,
3687
+ configurable: true
3688
+ });
3806
3689
  Object.defineProperty(SearchLocationComponent.prototype, "selectedLocations", {
3807
3690
  get: /**
3808
3691
  * @return {?}
@@ -3816,7 +3699,6 @@ var SearchLocationComponent = /** @class */ (function () {
3816
3699
  */
3817
3700
  function (value) {
3818
3701
  this.pSelectedLocations = value;
3819
- this.showAutocomplete = false;
3820
3702
  },
3821
3703
  enumerable: true,
3822
3704
  configurable: true
@@ -3824,37 +3706,19 @@ var SearchLocationComponent = /** @class */ (function () {
3824
3706
  /**
3825
3707
  * @return {?}
3826
3708
  */
3827
- SearchLocationComponent.prototype.ngAfterContentInit = /**
3709
+ SearchLocationComponent.prototype.ngOnInit = /**
3828
3710
  * @return {?}
3829
3711
  */
3830
3712
  function () {
3831
- this.readyAfterContent = true;
3713
+ if (this.singleMode && this.selectedLocations.length > 0) {
3714
+ /** @type {?} */
3715
+ var location_1 = this.selectedLocations[0];
3716
+ this.form.controls.searchTerm.patchValue(location_1.court_name, { emitEvent: false, onlySelf: true });
3717
+ }
3718
+ this.search();
3832
3719
  };
3833
3720
  /**
3834
- * @return {?}
3835
- */
3836
- SearchLocationComponent.prototype.ngOnInit = /**
3837
- * @return {?}
3838
- */
3839
- function () {
3840
- if (this.control) {
3841
- if (this.findLocationFormGroup && this.findLocationFormGroup.controls) {
3842
- this.findLocationFormGroup.controls.locationSelectedFormControl = this.control;
3843
- }
3844
- }
3845
- this.search();
3846
- };
3847
- /**
3848
- * @return {?}
3849
- */
3850
- SearchLocationComponent.prototype.onKeyDown = /**
3851
- * @return {?}
3852
- */
3853
- function () {
3854
- this.locationSelected.emit();
3855
- };
3856
- /**
3857
- * @param {?} term
3721
+ * @param {?} term
3858
3722
  * @return {?}
3859
3723
  */
3860
3724
  SearchLocationComponent.prototype.filter = /**
@@ -3870,23 +3734,16 @@ var SearchLocationComponent = /** @class */ (function () {
3870
3734
  function (locations) { return _this.removeSelectedLocations(locations); })));
3871
3735
  };
3872
3736
  /**
3873
- * @param {?=} selection
3737
+ * @param {?} location
3874
3738
  * @return {?}
3875
3739
  */
3876
3740
  SearchLocationComponent.prototype.onSelectionChange = /**
3877
- * @param {?=} selection
3741
+ * @param {?} location
3878
3742
  * @return {?}
3879
3743
  */
3880
- function (selection) {
3881
- if (this.findLocationFormGroup.controls.locationSelectedFormControl instanceof FormArray) {
3882
- ((/** @type {?} */ (this.findLocationFormGroup.controls.locationSelectedFormControl))).push(new FormControl(selection));
3883
- }
3884
- else {
3885
- this.findLocationFormGroup.controls.locationSelectedFormControl.setValue(selection);
3886
- }
3887
- this.showAutocomplete = false;
3888
- this.locationSelected.emit(selection);
3889
- this.locations = [];
3744
+ function (location) {
3745
+ this.form.controls.searchTerm.patchValue(location.court_name, { emitEvent: false, onlySelf: true });
3746
+ this.locationSelected.emit(location);
3890
3747
  };
3891
3748
  /**
3892
3749
  * @return {?}
@@ -3896,14 +3753,11 @@ var SearchLocationComponent = /** @class */ (function () {
3896
3753
  */
3897
3754
  function () {
3898
3755
  var _this = this;
3899
- this.findLocationFormGroup.controls.findLocationFormControl.valueChanges
3756
+ this.form.controls.searchTerm.valueChanges
3900
3757
  .pipe(tap((/**
3901
3758
  * @return {?}
3902
3759
  */
3903
3760
  function () { return _this.locations = []; })), tap((/**
3904
- * @return {?}
3905
- */
3906
- function () { return _this.showAutocomplete = false; })), tap((/**
3907
3761
  * @param {?} term
3908
3762
  * @return {?}
3909
3763
  */
@@ -3926,13 +3780,10 @@ var SearchLocationComponent = /** @class */ (function () {
3926
3780
  function (locations) {
3927
3781
  _this.locations = locations;
3928
3782
  _this.cd.markForCheck();
3929
- if (locations.length === 1 && _this.term === locations[0].court_name) {
3930
- if (_this.findLocationFormGroup.controls.locationSelectedFormControl instanceof FormGroup) {
3931
- _this.findLocationFormGroup.controls.locationSelectedFormControl.setValue(locations[0]);
3932
- _this.locationSelected.emit(locations[0]);
3933
- _this.showAutocomplete = false;
3934
- return;
3935
- }
3783
+ if (locations.length === 1 && _this.term === locations[0].court_name && !_this.singleMode) {
3784
+ _this.locationSelected.emit(locations[0]);
3785
+ _this.showAutocomplete = false;
3786
+ return;
3936
3787
  }
3937
3788
  _this.showAutocomplete = true;
3938
3789
  }));
@@ -3951,23 +3802,11 @@ var SearchLocationComponent = /** @class */ (function () {
3951
3802
  /**
3952
3803
  * @return {?}
3953
3804
  */
3954
- SearchLocationComponent.prototype.getControlCourtNameValue = /**
3805
+ SearchLocationComponent.prototype.resetSearchTerm = /**
3955
3806
  * @return {?}
3956
3807
  */
3957
3808
  function () {
3958
- if (this.findLocationFormGroup.controls.locationSelectedFormControl instanceof FormArray) {
3959
- /** @type {?} */
3960
- var formArray = (/** @type {?} */ (this.findLocationFormGroup.controls.locationSelectedFormControl));
3961
- if (formArray.length > 0) {
3962
- /** @type {?} */
3963
- var value = formArray.value[formArray.length - 1];
3964
- return value ? formArray.value[formArray.length - 1].court_name : null;
3965
- }
3966
- }
3967
- else {
3968
- return this.findLocationFormGroup && this.findLocationFormGroup.controls && this.findLocationFormGroup.controls.locationSelectedFormControl.value ?
3969
- ((/** @type {?} */ (this.findLocationFormGroup.controls.locationSelectedFormControl.value))).court_name : '';
3970
- }
3809
+ this.form.controls.searchTerm.patchValue('', { emitEvent: false, onlySelf: true });
3971
3810
  };
3972
3811
  /**
3973
3812
  * @private
@@ -3981,6 +3820,9 @@ var SearchLocationComponent = /** @class */ (function () {
3981
3820
  */
3982
3821
  function (locations) {
3983
3822
  var _this = this;
3823
+ if (this.singleMode) {
3824
+ return locations;
3825
+ }
3984
3826
  return locations.filter((/**
3985
3827
  * @param {?} location
3986
3828
  * @return {?}
@@ -3994,8 +3836,8 @@ var SearchLocationComponent = /** @class */ (function () {
3994
3836
  SearchLocationComponent.decorators = [
3995
3837
  { type: Component, args: [{
3996
3838
  selector: 'exui-search-location',
3997
- template: "<div class=\"auto-complete-container\">\n <div *ngIf=\"readyAfterContent\" class=\"autocomplete__wrapper\">\n <input\n [formControl]=\"findLocationFormGroup.controls.findLocationFormControl\"\n [matAutocomplete]=\"autoSearchLocation\"\n (keydown)=\"onKeyDown()\"\n class=\"autocomplete__input autocomplete__input--default search-box\"\n [attr.disabled]=\"!disabled ? null: disabled\"\n [value]=\"getControlCourtNameValue()\">\n <mat-autocomplete class=\"mat-autocomplete-panel-extend\" autoActiveFirstOption #autoSearchLocation=\"matAutocomplete\">\n <mat-option *ngFor=\"let location of locations\"\n [value]=\"location.court_name\"\n (onSelectionChange)=\"onSelectionChange(location)\">\n {{ location.court_name }}\n </mat-option>\n <mat-option *ngIf=\"!locations.length && showAutocomplete && term.length >= this.minSearchCharacters\">No results found</mat-option>\n </mat-autocomplete>\n </div>\n</div>\n\n\n",
3998
- styles: [".autocomplete__input{-webkit-appearance:none;border:2px solid #0b0c0c;border-radius:0;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;margin-bottom:0;width:100%;background-color:transparent;position:relative}.autocomplete__hint{color:#b1b4b6;position:absolute}.autocomplete__input--default{padding:5px}.autocomplete__input--focused{outline:#fd0 solid 3px;outline-offset:0;box-shadow:inset 0 0 0 2px}.autocomplete__input--show-all-values{padding:5px 34px 5px 5px;cursor:pointer}.autocomplete__dropdown-arrow-down{z-index:-1;display:inline-block;position:absolute;right:8px;width:24px;height:24px;top:10px}.autocomplete__menu{background-color:#fff;border:2px solid #0b0c0c;border-top:0;color:#0b0c0c;margin:0;max-height:342px;overflow-x:hidden;padding:0;width:100%;width:calc(100% - 4px)}.autocomplete__menu--visible{display:block}.autocomplete__menu--hidden{display:none}.autocomplete__menu--overlay{box-shadow:rgba(0,0,0,.256863) 0 2px 6px;left:0;position:absolute;top:100%;z-index:100}.autocomplete__menu--inline{position:relative}.autocomplete__option{border-bottom:solid #b1b4b6;border-width:1px 0;cursor:pointer;display:block;position:relative}.autocomplete__option>*{pointer-events:none}.autocomplete__option:first-of-type{border-top-width:0}.autocomplete__option:last-of-type{border-bottom-width:0}.autocomplete__option--odd{background-color:#fafafa}.autocomplete__option--focused,.autocomplete__option:hover{background-color:#1d70b8;border-color:#1d70b8;color:#fff;outline:0}.autocomplete__option--no-results{background-color:#fafafa;color:#646b6f;cursor:not-allowed}.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:13px;line-height:1.25}.autocomplete__hint,.autocomplete__option{padding:5px}@media (min-width:641px){.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:13px;line-height:1.31579}}.div-action{display:inline-block}.add-location{display:inline}.remove-location-button{margin:5px}.hide-autocomplete{display:none}.auto-complete-container{min-width:550px;display:inline-block;margin-right:4px}.autocomplete__input{line-height:24px;font-size:19px}"]
3839
+ template: "<div class=\"auto-complete-container\">\n <input\n [formControl]=\"form.controls.searchTerm\"\n [matAutocomplete]=\"autoSearchLocation\"\n class=\"govuk-input\"\n [attr.disabled]=\"disabled\">\n <mat-autocomplete class=\"mat-autocomplete-panel-extend\" autoActiveFirstOption #autoSearchLocation=\"matAutocomplete\">\n <mat-option *ngFor=\"let location of locations\"\n (onSelectionChange)=\"onSelectionChange(location)\">\n {{ location.court_name }}\n </mat-option>\n <mat-option *ngIf=\"!locations.length && showAutocomplete && term && term.length >= this.minSearchCharacters\">No results found</mat-option>\n </mat-autocomplete>\n</div>\n",
3840
+ styles: [".autocomplete__input--show-all-values{padding:5px 34px 5px 5px;cursor:pointer}.autocomplete__dropdown-arrow-down{z-index:-1;display:inline-block;position:absolute;right:8px;width:24px;height:24px;top:10px}.autocomplete__menu{background-color:#fff;border:2px solid #0b0c0c;border-top:0;color:#0b0c0c;margin:0;max-height:342px;overflow-x:hidden;padding:0;width:100%;width:calc(100% - 4px)}.autocomplete__menu--visible{display:block}.autocomplete__menu--hidden{display:none}.autocomplete__menu--overlay{box-shadow:rgba(0,0,0,.256863) 0 2px 6px;left:0;position:absolute;top:100%;z-index:100}.autocomplete__menu--inline{position:relative}.autocomplete__option{border-bottom:solid #b1b4b6;border-width:1px 0;cursor:pointer;display:block;position:relative}.autocomplete__option>*{pointer-events:none}.autocomplete__option:first-of-type{border-top-width:0}.autocomplete__option:last-of-type{border-bottom-width:0}.autocomplete__option--odd{background-color:#fafafa}.autocomplete__option--focused,.autocomplete__option:hover{background-color:#1d70b8;border-color:#1d70b8;color:#fff;outline:0}.autocomplete__option--no-results{background-color:#fafafa;color:#646b6f;cursor:not-allowed}.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:13px;line-height:1.25}.autocomplete__hint,.autocomplete__option{padding:5px}@media (min-width:641px){.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:13px;line-height:1.31579}}.div-action{display:inline-block}.add-location{display:inline}.remove-location-button{margin:5px}.hide-autocomplete{display:none}.auto-complete-container{min-width:550px;display:inline-block;margin-right:4px}.autocomplete__input{line-height:24px;font-size:19px}"]
3999
3841
  }] }
4000
3842
  ];
4001
3843
  /** @nocollapse */
@@ -4007,19 +3849,229 @@ var SearchLocationComponent = /** @class */ (function () {
4007
3849
  SearchLocationComponent.propDecorators = {
4008
3850
  control: [{ type: Input }],
4009
3851
  disabled: [{ type: Input }],
3852
+ singleMode: [{ type: Input }],
4010
3853
  locationType: [{ type: Input }],
4011
3854
  serviceIds: [{ type: Input }],
4012
3855
  submitted: [{ type: Input }],
4013
3856
  delay: [{ type: Input }],
4014
- findLocationFormGroup: [{ type: Input }],
3857
+ form: [{ type: Input }],
4015
3858
  showAutocomplete: [{ type: Input }],
4016
3859
  locations: [{ type: Input }],
4017
3860
  locationSelected: [{ type: Output }],
3861
+ reset: [{ type: Input }],
4018
3862
  selectedLocations: [{ type: Input }]
4019
3863
  };
4020
3864
  return SearchLocationComponent;
4021
3865
  }());
4022
3866
 
3867
+ /**
3868
+ * @fileoverview added by tsickle
3869
+ * Generated from: lib/components/find-location/find-location.component.ts
3870
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3871
+ */
3872
+ var FindLocationComponent = /** @class */ (function () {
3873
+ function FindLocationComponent() {
3874
+ this.selectedLocations = [];
3875
+ this.submitted = true;
3876
+ this.enableAddLocationButton = true;
3877
+ this.title = 'Search for a location by name';
3878
+ this.locations = [];
3879
+ this.tempSelectedLocation = null;
3880
+ this.serviceIds = 'SSCS,IA';
3881
+ this.pServices = [];
3882
+ this.pDisabled = false;
3883
+ }
3884
+ Object.defineProperty(FindLocationComponent.prototype, "disabled", {
3885
+ get: /**
3886
+ * @return {?}
3887
+ */
3888
+ function () {
3889
+ return this.pDisabled;
3890
+ },
3891
+ set: /**
3892
+ * @param {?} value
3893
+ * @return {?}
3894
+ */
3895
+ function (value) {
3896
+ if (value) {
3897
+ this.searchLocationComponent.resetSearchTerm();
3898
+ this.removeSelectedValues();
3899
+ }
3900
+ this.pDisabled = value;
3901
+ },
3902
+ enumerable: true,
3903
+ configurable: true
3904
+ });
3905
+ Object.defineProperty(FindLocationComponent.prototype, "services", {
3906
+ get: /**
3907
+ * @return {?}
3908
+ */
3909
+ function () {
3910
+ return this.pServices;
3911
+ },
3912
+ set: /**
3913
+ * @param {?} value
3914
+ * @return {?}
3915
+ */
3916
+ function (value) {
3917
+ var _this = this;
3918
+ this.pServices = value;
3919
+ /** @type {?} */
3920
+ var field = this.fields.find((/**
3921
+ * @param {?} f
3922
+ * @return {?}
3923
+ */
3924
+ function (f) { return f.name === _this.field.findLocationField; }));
3925
+ if (field) {
3926
+ if (typeof value === 'string') {
3927
+ this.serviceIds = value;
3928
+ }
3929
+ else {
3930
+ this.serviceIds = getValues(field.options, value).filter((/**
3931
+ * @param {?} x
3932
+ * @return {?}
3933
+ */
3934
+ function (x) { return x !== 'services_all'; })).join(',');
3935
+ }
3936
+ }
3937
+ },
3938
+ enumerable: true,
3939
+ configurable: true
3940
+ });
3941
+ /**
3942
+ * @return {?}
3943
+ */
3944
+ FindLocationComponent.prototype.addLocation = /**
3945
+ * @return {?}
3946
+ */
3947
+ function () {
3948
+ if (this.tempSelectedLocation) {
3949
+ this.selectedLocations = __spread(this.selectedLocations, [this.tempSelectedLocation]);
3950
+ this.addSelectedLocationsToForm([this.tempSelectedLocation]);
3951
+ this.tempSelectedLocation = null;
3952
+ this.locations = [];
3953
+ this.searchLocationComponent.resetSearchTerm();
3954
+ }
3955
+ };
3956
+ /**
3957
+ * @param {?} location
3958
+ * @return {?}
3959
+ */
3960
+ FindLocationComponent.prototype.removeLocation = /**
3961
+ * @param {?} location
3962
+ * @return {?}
3963
+ */
3964
+ function (location) {
3965
+ if (location.epims_id) {
3966
+ this.selectedLocations = this.selectedLocations.filter((/**
3967
+ * @param {?} selectedLocation
3968
+ * @return {?}
3969
+ */
3970
+ function (selectedLocation) { return selectedLocation.epims_id !== location.epims_id; }));
3971
+ /** @type {?} */
3972
+ var formArray = (/** @type {?} */ (this.form.get(this.field.name)));
3973
+ /** @type {?} */
3974
+ var index = ((/** @type {?} */ (formArray.value))).findIndex((/**
3975
+ * @param {?} selectedLocation
3976
+ * @return {?}
3977
+ */
3978
+ function (selectedLocation) { return selectedLocation.epims_id === location.epims_id; }));
3979
+ if (index > -1) {
3980
+ formArray.removeAt(index);
3981
+ }
3982
+ }
3983
+ };
3984
+ /**
3985
+ * @param {?} location
3986
+ * @return {?}
3987
+ */
3988
+ FindLocationComponent.prototype.onLocationSelected = /**
3989
+ * @param {?} location
3990
+ * @return {?}
3991
+ */
3992
+ function (location) {
3993
+ if (this.field.maxSelected === 1) {
3994
+ this.removeSelectedValues();
3995
+ this.addSelectedLocationsToForm([location]);
3996
+ }
3997
+ else {
3998
+ if (!this.selectedLocations.find((/**
3999
+ * @param {?} x
4000
+ * @return {?}
4001
+ */
4002
+ function (x) { return x.epims_id === location.epims_id; }))) {
4003
+ if (location.epims_id) {
4004
+ this.tempSelectedLocation = location;
4005
+ }
4006
+ }
4007
+ }
4008
+ };
4009
+ /**
4010
+ * @private
4011
+ * @return {?}
4012
+ */
4013
+ FindLocationComponent.prototype.removeSelectedValues = /**
4014
+ * @private
4015
+ * @return {?}
4016
+ */
4017
+ function () {
4018
+ /** @type {?} */
4019
+ var formArray = (/** @type {?} */ (this.form.get(this.field.name)));
4020
+ for (var i = 0; i < formArray.length; i++) {
4021
+ formArray.removeAt(i);
4022
+ }
4023
+ this.selectedLocations = [];
4024
+ };
4025
+ /**
4026
+ * @private
4027
+ * @param {?} locations
4028
+ * @return {?}
4029
+ */
4030
+ FindLocationComponent.prototype.addSelectedLocationsToForm = /**
4031
+ * @private
4032
+ * @param {?} locations
4033
+ * @return {?}
4034
+ */
4035
+ function (locations) {
4036
+ var e_1, _a;
4037
+ /** @type {?} */
4038
+ var formArray = (/** @type {?} */ (this.form.get(this.field.name)));
4039
+ try {
4040
+ for (var locations_1 = __values(locations), locations_1_1 = locations_1.next(); !locations_1_1.done; locations_1_1 = locations_1.next()) {
4041
+ var location_1 = locations_1_1.value;
4042
+ formArray.push(new FormControl(location_1));
4043
+ }
4044
+ }
4045
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
4046
+ finally {
4047
+ try {
4048
+ if (locations_1_1 && !locations_1_1.done && (_a = locations_1.return)) _a.call(locations_1);
4049
+ }
4050
+ finally { if (e_1) throw e_1.error; }
4051
+ }
4052
+ };
4053
+ FindLocationComponent.decorators = [
4054
+ { type: Component, args: [{
4055
+ selector: 'xuilib-find-location',
4056
+ template: "<div class=\"location-picker-custom\">\n <div class=\"search-location\">\n <div>\n <label id=\"input-selected-location-label\" *ngIf=\"title\">{{title}}</label>\n </div>\n <exui-search-location class=\"search-location\"\n [locations]=\"locations\"\n [selectedLocations]=\"selectedLocations\"\n [singleMode]=\"field.maxSelected === 1\"\n [delay]=\"300\"\n [disabled]=\"disabled\"\n [serviceIds]=\"serviceIds\"\n (locationSelected)=\"onLocationSelected($event)\"\n [locationType]=\"'case-management'\"></exui-search-location>\n <a href=\"javascript:void(0)\" (click)=\"addLocation()\" class=\"govuk-button\" data-module=\"govuk-button\" *ngIf=\"enableAddLocationButton\">\n Add location\n </a>\n </div>\n <ul class=\"hmcts-filter-tags selection-container\" *ngIf=\"field.maxSelected != 1\">\n <li class=\"location-selection\" *ngFor=\"let selection of selectedLocations\">\n <a class=\"hmcts-filter__tag\" (click)=\"removeLocation(selection)\" href=\"javascript:void(0)\">\n {{ selection.court_name }}\n </a>\n </li>\n </ul>\n</div>\n",
4057
+ styles: [""]
4058
+ }] }
4059
+ ];
4060
+ FindLocationComponent.propDecorators = {
4061
+ selectedLocations: [{ type: Input }],
4062
+ submitted: [{ type: Input }],
4063
+ enableAddLocationButton: [{ type: Input }],
4064
+ form: [{ type: Input }],
4065
+ field: [{ type: Input }],
4066
+ fields: [{ type: Input }],
4067
+ title: [{ type: Input }],
4068
+ searchLocationComponent: [{ type: ViewChild, args: [SearchLocationComponent,] }],
4069
+ disabled: [{ type: Input }],
4070
+ services: [{ type: Input }]
4071
+ };
4072
+ return FindLocationComponent;
4073
+ }());
4074
+
4023
4075
  /**
4024
4076
  * @fileoverview added by tsickle
4025
4077
  * Generated from: lib/components/pagination/pagination.component.ts
@@ -4366,6 +4418,49 @@ var RadioFilterFieldConfig = /** @class */ (function () {
4366
4418
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4367
4419
  */
4368
4420
 
4421
+ /**
4422
+ * @fileoverview added by tsickle
4423
+ * Generated from: lib/gov-ui/util/session-storage/session-storage-utils.ts
4424
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4425
+ */
4426
+ /** @type {?} */
4427
+ var getAllCaseworkersFromServices = (/**
4428
+ * @param {?} caseworkersByService
4429
+ * @return {?}
4430
+ */
4431
+ function (caseworkersByService) {
4432
+ /** @type {?} */
4433
+ var allCaseworkers = [];
4434
+ caseworkersByService.forEach((/**
4435
+ * @param {?} caseworkerListByService
4436
+ * @return {?}
4437
+ */
4438
+ function (caseworkerListByService) {
4439
+ allCaseworkers = allCaseworkers.concat(caseworkerListByService.caseworkers);
4440
+ }));
4441
+ return allCaseworkers;
4442
+ });
4443
+ /** @type {?} */
4444
+ var getSessionStorageKeyForServiceId = (/**
4445
+ * @param {?} serviceId
4446
+ * @return {?}
4447
+ */
4448
+ function (serviceId) {
4449
+ return serviceId + "-caseworkers";
4450
+ });
4451
+ /** @type {?} */
4452
+ var setCaseworkers = (/**
4453
+ * @param {?} serviceId
4454
+ * @param {?} caseworkers
4455
+ * @param {?} sessionStorageService
4456
+ * @return {?}
4457
+ */
4458
+ function (serviceId, caseworkers, sessionStorageService) {
4459
+ /** @type {?} */
4460
+ var sessionKey = getSessionStorageKeyForServiceId(serviceId);
4461
+ sessionStorageService.setItem(sessionKey, JSON.stringify(caseworkers));
4462
+ });
4463
+
4369
4464
  /**
4370
4465
  * @fileoverview added by tsickle
4371
4466
  * Generated from: lib/services/session-storage/session-storage.service.ts
@@ -4504,35 +4599,60 @@ var FindAPersonService = /** @class */ (function () {
4504
4599
  var userInfo = JSON.parse(userInfoStr);
4505
4600
  this.userId = userInfo.id ? userInfo.id : userInfo.uid;
4506
4601
  }
4507
- if (!this.sessionStorageService.getItem(FindAPersonService.caseworkersKey)) {
4508
- this.http.get('/workallocation2/caseworker').pipe(tap((/**
4509
- * @param {?} caseworkerList
4510
- * @return {?}
4511
- */
4512
- function (caseworkerList) { return _this.sessionStorageService.setItem(FindAPersonService.caseworkersKey, JSON.stringify(caseworkerList)); })));
4513
- }
4514
4602
  /** @type {?} */
4515
- var caseworkers = JSON.parse(this.sessionStorageService.getItem(FindAPersonService.caseworkersKey));
4603
+ var fullServices = searchOptions.services;
4516
4604
  /** @type {?} */
4517
- var roleCategory = RoleCategory.ALL;
4518
- if (!(searchOptions.jurisdiction === PersonRole.ALL)) {
4519
- roleCategory = searchOptions.jurisdiction === PersonRole.CASEWORKER ? RoleCategory.CASEWORKER : RoleCategory.ADMIN;
4520
- }
4605
+ var storedServices = [];
4521
4606
  /** @type {?} */
4522
- var people = caseworkers ? this.mapCaseworkers(caseworkers, roleCategory) : [];
4523
- /** @type {?} */
4524
- var searchTerm = searchOptions && searchOptions.searchTerm ? searchOptions.searchTerm.toLowerCase() : '';
4607
+ var newServices = [];
4525
4608
  /** @type {?} */
4526
- var finalPeopleList = people.filter((/**
4527
- * @param {?} person
4609
+ var storedCaseworkersByService = [];
4610
+ fullServices.forEach((/**
4611
+ * @param {?} serviceId
4528
4612
  * @return {?}
4529
4613
  */
4530
- function (person) { return person && person.name && person.name.toLowerCase().includes(searchTerm); }));
4531
- return searchOptions.userIncluded ? of(finalPeopleList) : of(finalPeopleList.filter((/**
4532
- * @param {?} person
4614
+ function (serviceId) {
4615
+ /** @type {?} */
4616
+ var serviceKey = getSessionStorageKeyForServiceId(serviceId);
4617
+ if (_this.sessionStorageService.getItem(serviceKey)) {
4618
+ storedServices.push(serviceId);
4619
+ storedCaseworkersByService.push({ service: serviceId, caseworkers: JSON.parse(_this.sessionStorageService.getItem(serviceKey)) });
4620
+ }
4621
+ else {
4622
+ newServices.push(serviceId);
4623
+ }
4624
+ }));
4625
+ // if all services are stored then return the stored caseworkers by service
4626
+ if (storedServices.length === fullServices.length) {
4627
+ /** @type {?} */
4628
+ var storedCaseworkers = getAllCaseworkersFromServices(storedCaseworkersByService);
4629
+ return of(this.searchInCaseworkers(storedCaseworkers, searchOptions));
4630
+ }
4631
+ // all serviceIds passed in as node layer getting used anyway and caseworkers also stored there
4632
+ return this.http.post('/workallocation2/retrieveCaseWorkersForServices', { fullServices: fullServices }).pipe(tap((/**
4633
+ * @param {?} caseworkersByService
4533
4634
  * @return {?}
4534
4635
  */
4535
- function (person) { return person && person.id !== _this.userId; })));
4636
+ function (caseworkersByService) {
4637
+ caseworkersByService.forEach((/**
4638
+ * @param {?} caseworkerListByService
4639
+ * @return {?}
4640
+ */
4641
+ function (caseworkerListByService) {
4642
+ // for any new service, ensure that they are then stored in the session
4643
+ if (newServices.includes(caseworkerListByService.service)) {
4644
+ setCaseworkers(caseworkerListByService.service, caseworkerListByService.caseworkers, _this.sessionStorageService);
4645
+ }
4646
+ }));
4647
+ })), map((/**
4648
+ * @param {?} caseworkersByService
4649
+ * @return {?}
4650
+ */
4651
+ function (caseworkersByService) {
4652
+ /** @type {?} */
4653
+ var givenCaseworkers = getAllCaseworkersFromServices(caseworkersByService);
4654
+ return _this.searchInCaseworkers(givenCaseworkers, searchOptions);
4655
+ })));
4536
4656
  };
4537
4657
  /**
4538
4658
  * @param {?} caseworkers
@@ -4565,6 +4685,39 @@ var FindAPersonService = /** @class */ (function () {
4565
4685
  }));
4566
4686
  return people;
4567
4687
  };
4688
+ /**
4689
+ * @param {?} caseworkers
4690
+ * @param {?} searchOptions
4691
+ * @return {?}
4692
+ */
4693
+ FindAPersonService.prototype.searchInCaseworkers = /**
4694
+ * @param {?} caseworkers
4695
+ * @param {?} searchOptions
4696
+ * @return {?}
4697
+ */
4698
+ function (caseworkers, searchOptions) {
4699
+ var _this = this;
4700
+ /** @type {?} */
4701
+ var roleCategory = RoleCategory.ALL;
4702
+ if (!(searchOptions.userRole === PersonRole.ALL)) {
4703
+ roleCategory = searchOptions.userRole === PersonRole.CASEWORKER ? RoleCategory.CASEWORKER : RoleCategory.ADMIN;
4704
+ }
4705
+ /** @type {?} */
4706
+ var searchTerm = searchOptions && searchOptions.searchTerm ? searchOptions.searchTerm.toLowerCase() : '';
4707
+ /** @type {?} */
4708
+ var people = caseworkers ? this.mapCaseworkers(caseworkers, roleCategory) : [];
4709
+ /** @type {?} */
4710
+ var finalPeopleList = people.filter((/**
4711
+ * @param {?} person
4712
+ * @return {?}
4713
+ */
4714
+ function (person) { return person && person.name && person.name.toLowerCase().includes(searchTerm); }));
4715
+ return searchOptions.userIncluded ? finalPeopleList : finalPeopleList.filter((/**
4716
+ * @param {?} person
4717
+ * @return {?}
4718
+ */
4719
+ function (person) { return person && person.id !== _this.userId; }));
4720
+ };
4568
4721
  FindAPersonService.caseworkersKey = 'caseworkers';
4569
4722
  FindAPersonService.decorators = [
4570
4723
  { type: Injectable, args: [{
@@ -4586,8 +4739,9 @@ var FindAPersonService = /** @class */ (function () {
4586
4739
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4587
4740
  */
4588
4741
  var FindPersonComponent = /** @class */ (function () {
4589
- function FindPersonComponent(findPersonService) {
4742
+ function FindPersonComponent(findPersonService, cd) {
4590
4743
  this.findPersonService = findPersonService;
4744
+ this.cd = cd;
4591
4745
  this.personSelected = new EventEmitter();
4592
4746
  this.boldTitle = 'Find the person';
4593
4747
  this.subTitle = 'Type the name of the person and select them.';
@@ -4596,16 +4750,18 @@ var FindPersonComponent = /** @class */ (function () {
4596
4750
  this.disabled = null;
4597
4751
  this.userIncluded = false;
4598
4752
  this.placeholderContent = '';
4599
- this.isNoResultsShown = false;
4753
+ this.isNoResultsShown = true;
4600
4754
  this.showUpdatedColor = false;
4601
4755
  this.selectedPersons = [];
4602
4756
  this.errorMessage = 'You must select a name';
4603
4757
  this.idValue = '';
4758
+ this.services = ['IA'];
4604
4759
  this.isPersonSelectionCompleted = false;
4605
4760
  this.showAutocomplete = false;
4606
4761
  this.currentInputValue = '';
4607
- this.choosenPerson = (/** @type {?} */ ({}));
4608
- this.findPersonControl = new FormControl();
4762
+ this.chosenPerson = null;
4763
+ this.findPersonControl = new FormControl('');
4764
+ this.filteredOptions = [];
4609
4765
  this.minSearchCharacters = 2;
4610
4766
  }
4611
4767
  /**
@@ -4622,13 +4778,34 @@ var FindPersonComponent = /** @class */ (function () {
4622
4778
  else {
4623
4779
  this.findPersonGroup.addControl('findPersonControl', this.findPersonControl);
4624
4780
  }
4625
- this.filteredOptions = this.findPersonControl.valueChanges.pipe(startWith(''), switchMap((/**
4781
+ this.findPersonControl.valueChanges.pipe(startWith(''), tap((/**
4782
+ * @return {?}
4783
+ */
4784
+ function () { return _this.showAutocomplete = false; })), tap((/**
4785
+ * @return {?}
4786
+ */
4787
+ function () { return _this.filteredOptions = []; })), filter((/**
4626
4788
  * @param {?} searchTerm
4627
4789
  * @return {?}
4628
4790
  */
4629
- function (searchTerm) {
4630
- return _this.filter(searchTerm || '');
4631
- })));
4791
+ function (searchTerm) { return searchTerm && searchTerm.length > _this.minSearchCharacters; })), switchMap((/**
4792
+ * @param {?} searchTerm
4793
+ * @return {?}
4794
+ */
4795
+ function (searchTerm) { return _this.filter(searchTerm).pipe(tap((/**
4796
+ * @return {?}
4797
+ */
4798
+ function () { return _this.showAutocomplete = true; })), catchError((/**
4799
+ * @return {?}
4800
+ */
4801
+ function () { return _this.filteredOptions = []; }))); }))).subscribe((/**
4802
+ * @param {?} people
4803
+ * @return {?}
4804
+ */
4805
+ function (people) {
4806
+ _this.filteredOptions = people;
4807
+ _this.cd.detectChanges();
4808
+ }));
4632
4809
  this.findPersonControl.setValue(this.selectedPerson);
4633
4810
  };
4634
4811
  /**
@@ -4660,9 +4837,9 @@ var FindPersonComponent = /** @class */ (function () {
4660
4837
  function (searchTerm) {
4661
4838
  var _this = this;
4662
4839
  /** @type {?} */
4663
- var findJudicialPeople = this.findPersonService.find({ searchTerm: searchTerm, jurisdiction: this.domain });
4840
+ var findJudicialPeople = this.findPersonService.find({ searchTerm: searchTerm, userRole: this.domain, services: this.services });
4664
4841
  /** @type {?} */
4665
- var findCaseworkersOrAdmins = this.findPersonService.findCaseworkers({ searchTerm: searchTerm, jurisdiction: this.domain });
4842
+ var findCaseworkersOrAdmins = this.findPersonService.findCaseworkers({ searchTerm: searchTerm, userRole: this.domain, services: this.services });
4666
4843
  if (searchTerm && searchTerm.length > this.minSearchCharacters) {
4667
4844
  switch (this.domain) {
4668
4845
  case PersonRole.JUDICIAL: {
@@ -4702,24 +4879,25 @@ var FindPersonComponent = /** @class */ (function () {
4702
4879
  return findCaseworkersOrAdmins;
4703
4880
  }
4704
4881
  default: {
4705
- return of();
4882
+ return of([]);
4706
4883
  }
4707
4884
  }
4708
4885
  }
4709
- return of();
4886
+ return of([]);
4710
4887
  };
4711
4888
  /**
4712
- * @param {?=} selectedPerson
4889
+ * @param {?} selectedPerson
4713
4890
  * @return {?}
4714
4891
  */
4715
4892
  FindPersonComponent.prototype.onSelectionChange = /**
4716
- * @param {?=} selectedPerson
4893
+ * @param {?} selectedPerson
4717
4894
  * @return {?}
4718
4895
  */
4719
4896
  function (selectedPerson) {
4720
4897
  this.isPersonSelectionCompleted = true;
4721
- this.choosenPerson = selectedPerson;
4898
+ this.chosenPerson = selectedPerson;
4722
4899
  this.personSelected.emit(selectedPerson);
4900
+ this.findPersonControl.setValue('');
4723
4901
  };
4724
4902
  /**
4725
4903
  * @param {?} currentValue
@@ -4732,7 +4910,7 @@ var FindPersonComponent = /** @class */ (function () {
4732
4910
  function (currentValue) {
4733
4911
  this.currentInputValue = currentValue;
4734
4912
  this.showAutocomplete = !!currentValue && (currentValue.length > this.minSearchCharacters);
4735
- this.isPersonSelectionCompleted = (this.getDisplayName(this.choosenPerson) === currentValue) ? true : false;
4913
+ this.isPersonSelectionCompleted = this.getDisplayName(this.chosenPerson) === currentValue;
4736
4914
  };
4737
4915
  /**
4738
4916
  * @param {?} selectedPerson
@@ -4743,6 +4921,9 @@ var FindPersonComponent = /** @class */ (function () {
4743
4921
  * @return {?}
4744
4922
  */
4745
4923
  function (selectedPerson) {
4924
+ if (!selectedPerson) {
4925
+ return '';
4926
+ }
4746
4927
  if (selectedPerson.domain === PersonRole.JUDICIAL && selectedPerson.knownAs) {
4747
4928
  return selectedPerson.knownAs + "(" + selectedPerson.email + ")";
4748
4929
  }
@@ -4751,13 +4932,14 @@ var FindPersonComponent = /** @class */ (function () {
4751
4932
  FindPersonComponent.decorators = [
4752
4933
  { type: Component, args: [{
4753
4934
  selector: 'xuilib-find-person',
4754
- template: "<h1 class=\"govuk-heading-l\" *ngIf=\"title && title.length\">\n <span class=\"govuk-caption-l\">{{title}}</span>\n {{boldTitle}}\n</h1>\n<div class=\"govuk-form-group\" [formGroup]=\"findPersonGroup\"\n [ngClass]=\"{'form-group-error': !findPersonGroup.valid && submitted}\">\n <fieldset class=\"govuk-fieldset\" aria-describedby=\"sub-title-hint\">\n <div id=\"sub-title-hint\" class=\"govuk-hint\" *ngIf=\"subTitle && subTitle.length\">\n {{subTitle}}\n </div>\n <span id=\"validation-error\" class=\"govuk-error-message\" *ngIf=\"findPersonGroup && findPersonGroup.errors\">\n <span class=\"govuk-visually-hidden\">Error:</span>{{findPersonGroup.errors.error ? findPersonGroup.errors.error : errorMessage}}\n </span>\n <input id=\"inputSelectPerson{{idValue}}\" type=\"text\" aria-label=\"select a person\" matInput\n formControlName=\"findPersonControl\"\n [matAutocomplete]=\"auto\"\n class=\"govuk-input govuk-!-width-one-third\"\n (ngModelChange)=\"updatedVal($event)\"\n [placeholder]=\"placeholderContent\"\n [attr.disabled]=\"disabled\"\n [value]=\"selectedPerson\">\n <mat-autocomplete autoActiveFirstOption #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let option of filteredOptions | async\"\n [value]=\"getDisplayName(option)\"\n (onSelectionChange)=\"onSelectionChange(option)\"\n [ngClass]=\"{'hide-autocomplete': !showAutocomplete, 'select-option': showUpdatedColor}\">\n {{getDisplayName(option)}}\n </mat-option>\n <mat-option [ngClass]=\"{'select-option': showUpdatedColor}\" *ngIf=\"isNoResultsShown && currentInputValue && currentInputValue.length && !(filteredOptions | async)?.length && showAutocomplete\">{{ 'No results found' }}</mat-option>\n </mat-autocomplete>\n </fieldset>\n</div>\n",
4935
+ template: "<h1 class=\"govuk-heading-l\" *ngIf=\"title && title.length\">\n <span class=\"govuk-caption-l\">{{title}}</span>\n {{boldTitle}}\n</h1>\n<div class=\"govuk-form-group\" [formGroup]=\"findPersonGroup\"\n [ngClass]=\"{'form-group-error': findPersonGroup.get('findPersonControl').invalid && submitted}\">\n <fieldset class=\"govuk-fieldset\" aria-describedby=\"sub-title-hint\">\n <div id=\"sub-title-hint\" class=\"govuk-hint\" *ngIf=\"subTitle && subTitle.length\">\n {{subTitle}}\n </div>\n <span id=\"validation-error\" class=\"govuk-error-message\" *ngIf=\"findPersonGroup && findPersonGroup.errors\">\n <span class=\"govuk-visually-hidden\">Error:</span>{{findPersonGroup.errors.error ? findPersonGroup.errors.error : errorMessage}}\n </span>\n <input id=\"inputSelectPerson{{idValue}}\" type=\"text\" aria-label=\"select a person\" matInput\n formControlName=\"findPersonControl\"\n [matAutocomplete]=\"auto\"\n class=\"govuk-input govuk-!-width-one-third\"\n (ngModelChange)=\"updatedVal($event)\"\n [placeholder]=\"placeholderContent\"\n [attr.disabled]=\"disabled\"\n [value]=\"selectedPerson\">\n <mat-autocomplete autoActiveFirstOption #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let option of filteredOptions\"\n [value]=\"getDisplayName(option)\"\n (onSelectionChange)=\"onSelectionChange(option)\"\n [ngClass]=\"{'hide-autocomplete': !showAutocomplete, 'select-option': showUpdatedColor}\">\n {{getDisplayName(option)}}\n </mat-option>\n <mat-option [ngClass]=\"{'select-option': showUpdatedColor}\" *ngIf=\"isNoResultsShown && currentInputValue && currentInputValue.length > minSearchCharacters && !filteredOptions.length && showAutocomplete\">No results found</mat-option>\n </mat-autocomplete>\n </fieldset>\n</div>\n",
4755
4936
  styles: [".mat-option:hover{background:#2596be}.mat-option.select-option:hover{background:#1d70b8;color:#fff}.hide-autocomplete{display:none}"]
4756
4937
  }] }
4757
4938
  ];
4758
4939
  /** @nocollapse */
4759
4940
  FindPersonComponent.ctorParameters = function () { return [
4760
- { type: FindAPersonService }
4941
+ { type: FindAPersonService },
4942
+ { type: ChangeDetectorRef }
4761
4943
  ]; };
4762
4944
  FindPersonComponent.propDecorators = {
4763
4945
  personSelected: [{ type: Output }],
@@ -4775,7 +4957,8 @@ var FindPersonComponent = /** @class */ (function () {
4775
4957
  showUpdatedColor: [{ type: Input }],
4776
4958
  selectedPersons: [{ type: Input }],
4777
4959
  errorMessage: [{ type: Input }],
4778
- idValue: [{ type: Input }]
4960
+ idValue: [{ type: Input }],
4961
+ services: [{ type: Input }]
4779
4962
  };
4780
4963
  return FindPersonComponent;
4781
4964
  }());
@@ -5858,7 +6041,8 @@ var ExuiCommonLibModule = /** @class */ (function () {
5858
6041
  ReactiveFormsModule,
5859
6042
  RouterModule.forChild([]),
5860
6043
  MatAutocompleteModule,
5861
- MatTabsModule
6044
+ MatTabsModule,
6045
+ MatInputModule
5862
6046
  ],
5863
6047
  providers: [
5864
6048
  { provide: windowToken, useFactory: ɵ0 }