@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
@@ -839,7 +839,7 @@
839
839
  * @param {?} values
840
840
  * @return {?}
841
841
  */
842
- function getCheckBoxesValues(options, values) {
842
+ function getValues(options, values) {
843
843
  return options.reduce(( /**
844
844
  * @param {?} acc
845
845
  * @param {?} option
@@ -1069,7 +1069,7 @@
1069
1069
  * @param {?} form
1070
1070
  * @return {?}
1071
1071
  */
1072
- GenericFilterComponent.prototype.selectChanged =
1072
+ GenericFilterComponent.prototype.fieldChanged =
1073
1073
  // when domain changes ensure that person field is reset
1074
1074
  /**
1075
1075
  * @param {?} field
@@ -1077,47 +1077,28 @@
1077
1077
  * @return {?}
1078
1078
  */
1079
1079
  function (field, form) {
1080
- if (field.findPersonField) {
1081
- /** @type {?} */
1082
- var currentField = this.config.fields.find(( /**
1083
- * @param {?} f
1084
- * @return {?}
1085
- */function (f) { return f.name === field.findPersonField; }));
1086
- if (currentField) {
1087
- currentField.domain = form.get(field.name).value;
1080
+ var e_1, _a;
1081
+ // TODO - Do similar with jurisdiction/service for caseworkers by services
1082
+ if (field.changeResetFields && field.changeResetFields.length) {
1083
+ try {
1084
+ for (var _b = __values(field.changeResetFields), _c = _b.next(); !_c.done; _c = _b.next()) {
1085
+ var resetField = _c.value;
1086
+ this.resetField(resetField, form);
1087
+ }
1088
+ }
1089
+ catch (e_1_1) {
1090
+ e_1 = { error: e_1_1 };
1091
+ }
1092
+ finally {
1093
+ try {
1094
+ if (_c && !_c.done && (_a = _b.return))
1095
+ _a.call(_b);
1096
+ }
1097
+ finally {
1098
+ if (e_1)
1099
+ throw e_1.error;
1100
+ }
1088
1101
  }
1089
- this.removePersonField(field);
1090
- }
1091
- };
1092
- /**
1093
- * @param {?} field
1094
- * @return {?}
1095
- */
1096
- GenericFilterComponent.prototype.radiosChanged = /**
1097
- * @param {?} field
1098
- * @return {?}
1099
- */
1100
- function (field) {
1101
- if (field.findPersonField) {
1102
- this.form.get('findPersonControl').setValue(null);
1103
- this.removePersonField(field);
1104
- }
1105
- };
1106
- /**
1107
- * @param {?} field
1108
- * @return {?}
1109
- */
1110
- GenericFilterComponent.prototype.removePersonField = /**
1111
- * @param {?} field
1112
- * @return {?}
1113
- */
1114
- function (field) {
1115
- if (this.form.get(field.findPersonField)) {
1116
- this.form.get(field.findPersonField).get('domain').setValue(null);
1117
- this.form.get(field.findPersonField).get('email').setValue(null);
1118
- this.form.get(field.findPersonField).get('id').setValue(null);
1119
- this.form.get(field.findPersonField).get('name').setValue(null);
1120
- this.form.get(field.findPersonField).get('knownAs').setValue(null);
1121
1102
  }
1122
1103
  };
1123
1104
  /**
@@ -1135,6 +1116,7 @@
1135
1116
  var settings = __assign({}, this.settings, { reset: true });
1136
1117
  this.filterService.persist(settings, this.config.persistence);
1137
1118
  this.filterService.givenErrors.next(null);
1119
+ this.submitted = false;
1138
1120
  };
1139
1121
  /**
1140
1122
  * @param {?} values
@@ -1147,7 +1129,7 @@
1147
1129
  * @return {?}
1148
1130
  */
1149
1131
  function (values, field) {
1150
- var e_1, _a;
1132
+ var e_2, _a;
1151
1133
  /** @type {?} */
1152
1134
  var keys = Object.keys(values);
1153
1135
  try {
@@ -1158,8 +1140,8 @@
1158
1140
  }
1159
1141
  }
1160
1142
  }
1161
- catch (e_1_1) {
1162
- e_1 = { error: e_1_1 };
1143
+ catch (e_2_1) {
1144
+ e_2 = { error: e_2_1 };
1163
1145
  }
1164
1146
  finally {
1165
1147
  try {
@@ -1167,8 +1149,8 @@
1167
1149
  _a.call(keys_1);
1168
1150
  }
1169
1151
  finally {
1170
- if (e_1)
1171
- throw e_1.error;
1152
+ if (e_2)
1153
+ throw e_2.error;
1172
1154
  }
1173
1155
  }
1174
1156
  };
@@ -1251,6 +1233,61 @@
1251
1233
  }
1252
1234
  }));
1253
1235
  };
1236
+ /**
1237
+ * @private
1238
+ * @param {?} resetField
1239
+ * @param {?} form
1240
+ * @return {?}
1241
+ */
1242
+ GenericFilterComponent.prototype.resetField = /**
1243
+ * @private
1244
+ * @param {?} resetField
1245
+ * @param {?} form
1246
+ * @return {?}
1247
+ */
1248
+ function (resetField, form) {
1249
+ var e_3, _a;
1250
+ /** @type {?} */
1251
+ var control = form.get(resetField);
1252
+ /** @type {?} */
1253
+ var defaultValue = this.config.cancelSetting.fields.find(( /**
1254
+ * @param {?} f
1255
+ * @return {?}
1256
+ */function (f) { return f.name === resetField; }));
1257
+ if (control instanceof forms.FormArray) {
1258
+ for (var i = 0; i < control.length; i++) {
1259
+ control.removeAt(i);
1260
+ }
1261
+ }
1262
+ else if (control instanceof forms.FormGroup) {
1263
+ /** @type {?} */
1264
+ var keys = Object.keys(control.value);
1265
+ try {
1266
+ for (var keys_2 = __values(keys), keys_2_1 = keys_2.next(); !keys_2_1.done; keys_2_1 = keys_2.next()) {
1267
+ var key = keys_2_1.value;
1268
+ this.resetField(key, control);
1269
+ }
1270
+ }
1271
+ catch (e_3_1) {
1272
+ e_3 = { error: e_3_1 };
1273
+ }
1274
+ finally {
1275
+ try {
1276
+ if (keys_2_1 && !keys_2_1.done && (_a = keys_2.return))
1277
+ _a.call(keys_2);
1278
+ }
1279
+ finally {
1280
+ if (e_3)
1281
+ throw e_3.error;
1282
+ }
1283
+ }
1284
+ }
1285
+ else if (control instanceof forms.FormControl) {
1286
+ /** @type {?} */
1287
+ var value = defaultValue && defaultValue.value && defaultValue.value.length ? defaultValue.value[0] : null;
1288
+ control.setValue(value);
1289
+ }
1290
+ };
1254
1291
  /**
1255
1292
  * @private
1256
1293
  * @param {?} filter
@@ -1298,7 +1335,7 @@
1298
1335
  * @return {?}
1299
1336
  */
1300
1337
  function (config, settings, reset) {
1301
- var e_2, _a;
1338
+ var e_4, _a;
1302
1339
  /** @type {?} */
1303
1340
  var findPersonControl = this.form ? this.form.get('findPersonControl') : null;
1304
1341
  this.form = this.fb.group({});
@@ -1360,7 +1397,7 @@
1360
1397
  }
1361
1398
  // if field updates find person component set the initial domain
1362
1399
  if (field.findPersonField) {
1363
- this_1.selectChanged(field, this_1.form);
1400
+ this_1.fieldChanged(field, this_1.form);
1364
1401
  }
1365
1402
  }
1366
1403
  };
@@ -1371,8 +1408,8 @@
1371
1408
  _loop_1(field);
1372
1409
  }
1373
1410
  }
1374
- catch (e_2_1) {
1375
- e_2 = { error: e_2_1 };
1411
+ catch (e_4_1) {
1412
+ e_4 = { error: e_4_1 };
1376
1413
  }
1377
1414
  finally {
1378
1415
  try {
@@ -1380,8 +1417,8 @@
1380
1417
  _a.call(_b);
1381
1418
  }
1382
1419
  finally {
1383
- if (e_2)
1384
- throw e_2.error;
1420
+ if (e_4)
1421
+ throw e_4.error;
1385
1422
  }
1386
1423
  }
1387
1424
  };
@@ -1398,7 +1435,7 @@
1398
1435
  * @return {?}
1399
1436
  */
1400
1437
  function (field, settings) {
1401
- var e_3, _a;
1438
+ var e_5, _a;
1402
1439
  /** @type {?} */
1403
1440
  var validators = GenericFilterComponent.addFormValidators(field);
1404
1441
  /** @type {?} */
@@ -1428,8 +1465,8 @@
1428
1465
  _loop_2(option);
1429
1466
  }
1430
1467
  }
1431
- catch (e_3_1) {
1432
- e_3 = { error: e_3_1 };
1468
+ catch (e_5_1) {
1469
+ e_5 = { error: e_5_1 };
1433
1470
  }
1434
1471
  finally {
1435
1472
  try {
@@ -1437,8 +1474,8 @@
1437
1474
  _a.call(_b);
1438
1475
  }
1439
1476
  finally {
1440
- if (e_3)
1441
- throw e_3.error;
1477
+ if (e_5)
1478
+ throw e_5.error;
1442
1479
  }
1443
1480
  }
1444
1481
  return formArray;
@@ -1456,7 +1493,7 @@
1456
1493
  * @return {?}
1457
1494
  */
1458
1495
  function (field, settings) {
1459
- var e_4, _a;
1496
+ var e_6, _a;
1460
1497
  /** @type {?} */
1461
1498
  var validators = GenericFilterComponent.addFormValidators(field);
1462
1499
  /** @type {?} */
@@ -1468,23 +1505,25 @@
1468
1505
  * @param {?} f
1469
1506
  * @return {?}
1470
1507
  */function (f) { return f.name === field.name; }));
1471
- try {
1472
- for (var _b = __values(defaultValues.value), _c = _b.next(); !_c.done; _c = _b.next()) {
1473
- var defaultValue = _c.value;
1474
- formArray.push(new forms.FormControl(defaultValue));
1475
- }
1476
- }
1477
- catch (e_4_1) {
1478
- e_4 = { error: e_4_1 };
1479
- }
1480
- finally {
1508
+ if (defaultValues) {
1481
1509
  try {
1482
- if (_c && !_c.done && (_a = _b.return))
1483
- _a.call(_b);
1510
+ for (var _b = __values(defaultValues.value), _c = _b.next(); !_c.done; _c = _b.next()) {
1511
+ var defaultValue = _c.value;
1512
+ formArray.push(new forms.FormControl(defaultValue));
1513
+ }
1514
+ }
1515
+ catch (e_6_1) {
1516
+ e_6 = { error: e_6_1 };
1484
1517
  }
1485
1518
  finally {
1486
- if (e_4)
1487
- throw e_4.error;
1519
+ try {
1520
+ if (_c && !_c.done && (_a = _b.return))
1521
+ _a.call(_b);
1522
+ }
1523
+ finally {
1524
+ if (e_6)
1525
+ throw e_6.error;
1526
+ }
1488
1527
  }
1489
1528
  }
1490
1529
  }
@@ -1519,7 +1558,7 @@
1519
1558
  return { value: values, name: name };
1520
1559
  }
1521
1560
  else {
1522
- return { value: getCheckBoxesValues(field.options, values), name: name };
1561
+ return { value: getValues(field.options, values), name: name };
1523
1562
  }
1524
1563
  }
1525
1564
  else {
@@ -1538,7 +1577,7 @@
1538
1577
  * @return {?}
1539
1578
  */
1540
1579
  function (form) {
1541
- var e_5, _a;
1580
+ var e_7, _a;
1542
1581
  /** @type {?} */
1543
1582
  var errors = [];
1544
1583
  try {
@@ -1554,8 +1593,8 @@
1554
1593
  }
1555
1594
  }
1556
1595
  }
1557
- catch (e_5_1) {
1558
- e_5 = { error: e_5_1 };
1596
+ catch (e_7_1) {
1597
+ e_7 = { error: e_7_1 };
1559
1598
  }
1560
1599
  finally {
1561
1600
  try {
@@ -1563,8 +1602,8 @@
1563
1602
  _a.call(_b);
1564
1603
  }
1565
1604
  finally {
1566
- if (e_5)
1567
- throw e_5.error;
1605
+ if (e_7)
1606
+ throw e_7.error;
1568
1607
  }
1569
1608
  }
1570
1609
  if (errors.length) {
@@ -1574,7 +1613,7 @@
1574
1613
  GenericFilterComponent.decorators = [
1575
1614
  { type: i0.Component, args: [{
1576
1615
  selector: 'xuilib-generic-filter',
1577
- 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",
1616
+ 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",
1578
1617
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1579
1618
  encapsulation: i0.ViewEncapsulation.None,
1580
1619
  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}"]
@@ -3666,322 +3705,150 @@
3666
3705
 
3667
3706
  /**
3668
3707
  * @fileoverview added by tsickle
3669
- * Generated from: lib/components/find-location/find-location.component.ts
3708
+ * Generated from: lib/services/locations/location.service.ts
3670
3709
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3671
3710
  */
3672
- var FindLocationComponent = /** @class */ (function () {
3673
- function FindLocationComponent() {
3674
- this.selectedLocations = [];
3711
+ var LocationService = /** @class */ (function () {
3712
+ function LocationService(http) {
3713
+ this.http = http;
3714
+ }
3715
+ /**
3716
+ * @description getAllLocations from service Ids/location type/search term
3717
+ * @param serviceIds: SSCS | SSCS,IA split with ','
3718
+ * @param locationType: optional | hearing | case_management
3719
+ * @param searchTerm: any search term for postcode | site name | venue name |court name | court address etc.
3720
+ * @return Observable<LocationByEPIMSModel[]>: Array of locationModel in Observable
3721
+ */
3722
+ /**
3723
+ * \@description getAllLocations from service Ids/location type/search term
3724
+ * @param {?} serviceIds
3725
+ * @param {?} locationType
3726
+ * @param {?} searchTerm
3727
+ * @return {?} Observable<LocationByEPIMSModel[]>: Array of locationModel in Observable
3728
+ */
3729
+ LocationService.prototype.getAllLocations = /**
3730
+ * \@description getAllLocations from service Ids/location type/search term
3731
+ * @param {?} serviceIds
3732
+ * @param {?} locationType
3733
+ * @param {?} searchTerm
3734
+ * @return {?} Observable<LocationByEPIMSModel[]>: Array of locationModel in Observable
3735
+ */
3736
+ function (serviceIds, locationType, searchTerm) {
3737
+ return this.http.get("api/locations/getLocations?serviceIds=" + serviceIds + "&locationType=" + locationType + "&searchTerm=" + searchTerm);
3738
+ };
3739
+ LocationService.decorators = [
3740
+ { type: i0.Injectable, args: [{
3741
+ providedIn: 'root'
3742
+ },] }
3743
+ ];
3744
+ /** @nocollapse */
3745
+ LocationService.ctorParameters = function () {
3746
+ return [
3747
+ { type: i1.HttpClient }
3748
+ ];
3749
+ };
3750
+ /** @nocollapse */ LocationService.ngInjectableDef = i0.defineInjectable({ factory: function LocationService_Factory() { return new LocationService(i0.inject(i1.HttpClient)); }, token: LocationService, providedIn: "root" });
3751
+ return LocationService;
3752
+ }());
3753
+
3754
+ /**
3755
+ * @fileoverview added by tsickle
3756
+ * Generated from: lib/components/search-location/search-location.component.ts
3757
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3758
+ */
3759
+ var SearchLocationComponent = /** @class */ (function () {
3760
+ function SearchLocationComponent(locationService, fb, cd) {
3761
+ this.locationService = locationService;
3762
+ this.fb = fb;
3763
+ this.cd = cd;
3764
+ this.disabled = null;
3765
+ this.singleMode = false;
3766
+ this.locationType = '';
3767
+ this.serviceIds = '';
3675
3768
  this.submitted = true;
3769
+ this.delay = 500;
3770
+ this.showAutocomplete = false;
3676
3771
  this.locations = [];
3677
- this.locationsForm = new forms.FormArray([]);
3678
- this.serviceIds = 'SSCS,IA';
3679
- this.pServices = [];
3772
+ this.locationSelected = new i0.EventEmitter();
3773
+ this.minSearchCharacters = 3;
3774
+ this.term = '';
3775
+ this.pSelectedLocations = [];
3776
+ this.pReset = true;
3777
+ this.form = this.fb.group({
3778
+ searchTerm: ['']
3779
+ });
3680
3780
  }
3681
- Object.defineProperty(FindLocationComponent.prototype, "services", {
3781
+ Object.defineProperty(SearchLocationComponent.prototype, "reset", {
3682
3782
  get: /**
3683
3783
  * @return {?}
3684
3784
  */ function () {
3685
- return this.pServices;
3785
+ return this.pReset;
3686
3786
  },
3687
3787
  set: /**
3688
3788
  * @param {?} value
3689
3789
  * @return {?}
3690
3790
  */ function (value) {
3691
- var _this = this;
3692
- this.pServices = value;
3693
- /** @type {?} */
3694
- var field = this.fields.find(( /**
3695
- * @param {?} f
3696
- * @return {?}
3697
- */function (f) { return f.name === _this.field.findPersonField; }));
3698
- if (field) {
3699
- this.serviceIds = getCheckBoxesValues(field.options, value).filter(( /**
3700
- * @param {?} x
3701
- * @return {?}
3702
- */function (x) { return x !== 'services_all'; })).join(',');
3703
- }
3791
+ this.pReset = value;
3792
+ this.resetSearchTerm();
3793
+ },
3794
+ enumerable: true,
3795
+ configurable: true
3796
+ });
3797
+ Object.defineProperty(SearchLocationComponent.prototype, "selectedLocations", {
3798
+ get: /**
3799
+ * @return {?}
3800
+ */ function () {
3801
+ return this.pSelectedLocations;
3802
+ },
3803
+ set: /**
3804
+ * @param {?} value
3805
+ * @return {?}
3806
+ */ function (value) {
3807
+ this.pSelectedLocations = value;
3704
3808
  },
3705
3809
  enumerable: true,
3706
3810
  configurable: true
3707
3811
  });
3708
3812
  /**
3709
- * @private
3710
- * @param {?} selectedLocations
3711
- * @param {?} formArray
3712
3813
  * @return {?}
3713
3814
  */
3714
- FindLocationComponent.initForm = /**
3715
- * @private
3716
- * @param {?} selectedLocations
3717
- * @param {?} formArray
3815
+ SearchLocationComponent.prototype.ngOnInit = /**
3718
3816
  * @return {?}
3719
3817
  */
3720
- function (selectedLocations, formArray) {
3721
- var e_1, _a;
3722
- try {
3723
- for (var selectedLocations_1 = __values(selectedLocations), selectedLocations_1_1 = selectedLocations_1.next(); !selectedLocations_1_1.done; selectedLocations_1_1 = selectedLocations_1.next()) {
3724
- var location_1 = selectedLocations_1_1.value;
3725
- formArray.push(new forms.FormControl(location_1));
3726
- }
3727
- }
3728
- catch (e_1_1) {
3729
- e_1 = { error: e_1_1 };
3730
- }
3731
- finally {
3732
- try {
3733
- if (selectedLocations_1_1 && !selectedLocations_1_1.done && (_a = selectedLocations_1.return))
3734
- _a.call(selectedLocations_1);
3735
- }
3736
- finally {
3737
- if (e_1)
3738
- throw e_1.error;
3739
- }
3818
+ function () {
3819
+ if (this.singleMode && this.selectedLocations.length > 0) {
3820
+ /** @type {?} */
3821
+ var location_1 = this.selectedLocations[0];
3822
+ this.form.controls.searchTerm.patchValue(location_1.court_name, { emitEvent: false, onlySelf: true });
3740
3823
  }
3741
- return formArray;
3824
+ this.search();
3742
3825
  };
3743
3826
  /**
3827
+ * @param {?} term
3744
3828
  * @return {?}
3745
3829
  */
3746
- FindLocationComponent.prototype.ngOnInit = /**
3830
+ SearchLocationComponent.prototype.filter = /**
3831
+ * @param {?} term
3747
3832
  * @return {?}
3748
3833
  */
3749
- function () {
3750
- this.locationsForm = FindLocationComponent.initForm(this.selectedLocations, this.locationsForm);
3834
+ function (term) {
3835
+ var _this = this;
3836
+ this.getLocations(term).pipe(operators.map(( /**
3837
+ * @param {?} locations
3838
+ * @return {?}
3839
+ */function (locations) { return _this.removeSelectedLocations(locations); })));
3751
3840
  };
3752
3841
  /**
3842
+ * @param {?} location
3753
3843
  * @return {?}
3754
3844
  */
3755
- FindLocationComponent.prototype.addLocation = /**
3756
- * @return {?}
3757
- */
3758
- function () {
3759
- if (this.locations && this.locations.length) {
3760
- /** @type {?} */
3761
- var locationsForm = this.locationsForm;
3762
- this.selectedLocations = ( /** @type {?} */(this.locationsForm.value));
3763
- /** @type {?} */
3764
- var formArray = ( /** @type {?} */(this.form.get(this.field.name)));
3765
- /** @type {?} */
3766
- var lastSavedValue = this.selectedLocations[this.selectedLocations.length - 1];
3767
- FindLocationComponent.initForm([lastSavedValue], formArray);
3768
- locationsForm.at(this.selectedLocations.length - 1).setValue(null);
3769
- }
3770
- this.locations = [];
3771
- };
3772
- /**
3773
- * @param {?} location
3774
- * @return {?}
3775
- */
3776
- FindLocationComponent.prototype.removeLocation = /**
3777
- * @param {?} location
3778
- * @return {?}
3779
- */
3780
- function (location) {
3781
- if (location.epims_id) {
3782
- this.selectedLocations = this.selectedLocations.filter(( /**
3783
- * @param {?} selectedLocation
3784
- * @return {?}
3785
- */function (selectedLocation) { return selectedLocation.epims_id !== location.epims_id; }));
3786
- /** @type {?} */
3787
- var formArray = ( /** @type {?} */(this.form.get(this.field.name)));
3788
- /** @type {?} */
3789
- var index = (( /** @type {?} */(formArray.value))).findIndex(( /**
3790
- * @param {?} selectedLocation
3791
- * @return {?}
3792
- */function (selectedLocation) { return selectedLocation.epims_id === location.epims_id; }));
3793
- if (index > -1) {
3794
- formArray.removeAt(index);
3795
- }
3796
- }
3797
- };
3798
- /**
3799
- * @param {?} location
3800
- * @return {?}
3801
- */
3802
- FindLocationComponent.prototype.onLocationSelected = /**
3803
- * @param {?} location
3845
+ SearchLocationComponent.prototype.onSelectionChange = /**
3846
+ * @param {?} location
3804
3847
  * @return {?}
3805
3848
  */
3806
3849
  function (location) {
3807
- if (location && location.epims_id) {
3808
- this.locations = __spread(this.locations, [location]);
3809
- }
3810
- };
3811
- FindLocationComponent.decorators = [
3812
- { type: i0.Component, args: [{
3813
- selector: 'xuilib-find-location',
3814
- 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",
3815
- styles: [""]
3816
- }] }
3817
- ];
3818
- FindLocationComponent.propDecorators = {
3819
- selectedLocations: [{ type: i0.Input }],
3820
- submitted: [{ type: i0.Input }],
3821
- form: [{ type: i0.Input }],
3822
- field: [{ type: i0.Input }],
3823
- fields: [{ type: i0.Input }],
3824
- services: [{ type: i0.Input }]
3825
- };
3826
- return FindLocationComponent;
3827
- }());
3828
-
3829
- /**
3830
- * @fileoverview added by tsickle
3831
- * Generated from: lib/services/locations/location.service.ts
3832
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3833
- */
3834
- var LocationService = /** @class */ (function () {
3835
- function LocationService(http) {
3836
- this.http = http;
3837
- }
3838
- /**
3839
- * @description getAllLocations from service Ids/location type/search term
3840
- * @param serviceIds: SSCS | SSCS,IA split with ','
3841
- * @param locationType: optional | hearing | case_management
3842
- * @param searchTerm: any search term for postcode | site name | venue name |court name | court address etc.
3843
- * @return Observable<LocationByEPIMSModel[]>: Array of locationModel in Observable
3844
- */
3845
- /**
3846
- * \@description getAllLocations from service Ids/location type/search term
3847
- * @param {?} serviceIds
3848
- * @param {?} locationType
3849
- * @param {?} searchTerm
3850
- * @return {?} Observable<LocationByEPIMSModel[]>: Array of locationModel in Observable
3851
- */
3852
- LocationService.prototype.getAllLocations = /**
3853
- * \@description getAllLocations from service Ids/location type/search term
3854
- * @param {?} serviceIds
3855
- * @param {?} locationType
3856
- * @param {?} searchTerm
3857
- * @return {?} Observable<LocationByEPIMSModel[]>: Array of locationModel in Observable
3858
- */
3859
- function (serviceIds, locationType, searchTerm) {
3860
- return this.http.get("api/locations/getLocations?serviceIds=" + serviceIds + "&locationType=" + locationType + "&searchTerm=" + searchTerm);
3861
- };
3862
- LocationService.decorators = [
3863
- { type: i0.Injectable, args: [{
3864
- providedIn: 'root'
3865
- },] }
3866
- ];
3867
- /** @nocollapse */
3868
- LocationService.ctorParameters = function () {
3869
- return [
3870
- { type: i1.HttpClient }
3871
- ];
3872
- };
3873
- /** @nocollapse */ LocationService.ngInjectableDef = i0.defineInjectable({ factory: function LocationService_Factory() { return new LocationService(i0.inject(i1.HttpClient)); }, token: LocationService, providedIn: "root" });
3874
- return LocationService;
3875
- }());
3876
-
3877
- /**
3878
- * @fileoverview added by tsickle
3879
- * Generated from: lib/components/search-location/search-location.component.ts
3880
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3881
- */
3882
- var SearchLocationComponent = /** @class */ (function () {
3883
- function SearchLocationComponent(locationService, fb, cd) {
3884
- this.locationService = locationService;
3885
- this.fb = fb;
3886
- this.cd = cd;
3887
- this.disabled = null;
3888
- this.locationType = '';
3889
- this.serviceIds = '';
3890
- this.submitted = true;
3891
- this.delay = 500;
3892
- this.showAutocomplete = false;
3893
- this.locations = [];
3894
- this.locationSelected = new i0.EventEmitter();
3895
- this.term = '';
3896
- this.readyAfterContent = false;
3897
- this.minSearchCharacters = 3;
3898
- this.pSelectedLocations = [];
3899
- this.findLocationFormGroup = this.fb.group({
3900
- findLocationFormControl: [null],
3901
- locationSelectedFormControl: [null]
3902
- });
3903
- }
3904
- Object.defineProperty(SearchLocationComponent.prototype, "selectedLocations", {
3905
- get: /**
3906
- * @return {?}
3907
- */ function () {
3908
- return this.pSelectedLocations;
3909
- },
3910
- set: /**
3911
- * @param {?} value
3912
- * @return {?}
3913
- */ function (value) {
3914
- this.pSelectedLocations = value;
3915
- this.showAutocomplete = false;
3916
- },
3917
- enumerable: true,
3918
- configurable: true
3919
- });
3920
- /**
3921
- * @return {?}
3922
- */
3923
- SearchLocationComponent.prototype.ngAfterContentInit = /**
3924
- * @return {?}
3925
- */
3926
- function () {
3927
- this.readyAfterContent = true;
3928
- };
3929
- /**
3930
- * @return {?}
3931
- */
3932
- SearchLocationComponent.prototype.ngOnInit = /**
3933
- * @return {?}
3934
- */
3935
- function () {
3936
- if (this.control) {
3937
- if (this.findLocationFormGroup && this.findLocationFormGroup.controls) {
3938
- this.findLocationFormGroup.controls.locationSelectedFormControl = this.control;
3939
- }
3940
- }
3941
- this.search();
3942
- };
3943
- /**
3944
- * @return {?}
3945
- */
3946
- SearchLocationComponent.prototype.onKeyDown = /**
3947
- * @return {?}
3948
- */
3949
- function () {
3950
- this.locationSelected.emit();
3951
- };
3952
- /**
3953
- * @param {?} term
3954
- * @return {?}
3955
- */
3956
- SearchLocationComponent.prototype.filter = /**
3957
- * @param {?} term
3958
- * @return {?}
3959
- */
3960
- function (term) {
3961
- var _this = this;
3962
- this.getLocations(term).pipe(operators.map(( /**
3963
- * @param {?} locations
3964
- * @return {?}
3965
- */function (locations) { return _this.removeSelectedLocations(locations); })));
3966
- };
3967
- /**
3968
- * @param {?=} selection
3969
- * @return {?}
3970
- */
3971
- SearchLocationComponent.prototype.onSelectionChange = /**
3972
- * @param {?=} selection
3973
- * @return {?}
3974
- */
3975
- function (selection) {
3976
- if (this.findLocationFormGroup.controls.locationSelectedFormControl instanceof forms.FormArray) {
3977
- (( /** @type {?} */(this.findLocationFormGroup.controls.locationSelectedFormControl))).push(new forms.FormControl(selection));
3978
- }
3979
- else {
3980
- this.findLocationFormGroup.controls.locationSelectedFormControl.setValue(selection);
3981
- }
3982
- this.showAutocomplete = false;
3983
- this.locationSelected.emit(selection);
3984
- this.locations = [];
3850
+ this.form.controls.searchTerm.patchValue(location.court_name, { emitEvent: false, onlySelf: true });
3851
+ this.locationSelected.emit(location);
3985
3852
  };
3986
3853
  /**
3987
3854
  * @return {?}
@@ -3991,12 +3858,10 @@
3991
3858
  */
3992
3859
  function () {
3993
3860
  var _this = this;
3994
- this.findLocationFormGroup.controls.findLocationFormControl.valueChanges
3861
+ this.form.controls.searchTerm.valueChanges
3995
3862
  .pipe(operators.tap(( /**
3996
3863
  * @return {?}
3997
3864
  */function () { return _this.locations = []; })), operators.tap(( /**
3998
- * @return {?}
3999
- */function () { return _this.showAutocomplete = false; })), operators.tap(( /**
4000
3865
  * @param {?} term
4001
3866
  * @return {?}
4002
3867
  */function (term) { return _this.term = term; })), operators.filter(( /**
@@ -4014,13 +3879,10 @@
4014
3879
  */function (locations) {
4015
3880
  _this.locations = locations;
4016
3881
  _this.cd.markForCheck();
4017
- if (locations.length === 1 && _this.term === locations[0].court_name) {
4018
- if (_this.findLocationFormGroup.controls.locationSelectedFormControl instanceof forms.FormGroup) {
4019
- _this.findLocationFormGroup.controls.locationSelectedFormControl.setValue(locations[0]);
4020
- _this.locationSelected.emit(locations[0]);
4021
- _this.showAutocomplete = false;
4022
- return;
4023
- }
3882
+ if (locations.length === 1 && _this.term === locations[0].court_name && !_this.singleMode) {
3883
+ _this.locationSelected.emit(locations[0]);
3884
+ _this.showAutocomplete = false;
3885
+ return;
4024
3886
  }
4025
3887
  _this.showAutocomplete = true;
4026
3888
  }));
@@ -4039,23 +3901,11 @@
4039
3901
  /**
4040
3902
  * @return {?}
4041
3903
  */
4042
- SearchLocationComponent.prototype.getControlCourtNameValue = /**
3904
+ SearchLocationComponent.prototype.resetSearchTerm = /**
4043
3905
  * @return {?}
4044
3906
  */
4045
3907
  function () {
4046
- if (this.findLocationFormGroup.controls.locationSelectedFormControl instanceof forms.FormArray) {
4047
- /** @type {?} */
4048
- var formArray = ( /** @type {?} */(this.findLocationFormGroup.controls.locationSelectedFormControl));
4049
- if (formArray.length > 0) {
4050
- /** @type {?} */
4051
- var value = formArray.value[formArray.length - 1];
4052
- return value ? formArray.value[formArray.length - 1].court_name : null;
4053
- }
4054
- }
4055
- else {
4056
- return this.findLocationFormGroup && this.findLocationFormGroup.controls && this.findLocationFormGroup.controls.locationSelectedFormControl.value ?
4057
- (( /** @type {?} */(this.findLocationFormGroup.controls.locationSelectedFormControl.value))).court_name : '';
4058
- }
3908
+ this.form.controls.searchTerm.patchValue('', { emitEvent: false, onlySelf: true });
4059
3909
  };
4060
3910
  /**
4061
3911
  * @private
@@ -4069,6 +3919,9 @@
4069
3919
  */
4070
3920
  function (locations) {
4071
3921
  var _this = this;
3922
+ if (this.singleMode) {
3923
+ return locations;
3924
+ }
4072
3925
  return locations.filter(( /**
4073
3926
  * @param {?} location
4074
3927
  * @return {?}
@@ -4082,8 +3935,8 @@
4082
3935
  SearchLocationComponent.decorators = [
4083
3936
  { type: i0.Component, args: [{
4084
3937
  selector: 'exui-search-location',
4085
- 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",
4086
- 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}"]
3938
+ 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",
3939
+ 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}"]
4087
3940
  }] }
4088
3941
  ];
4089
3942
  /** @nocollapse */
@@ -4097,19 +3950,226 @@
4097
3950
  SearchLocationComponent.propDecorators = {
4098
3951
  control: [{ type: i0.Input }],
4099
3952
  disabled: [{ type: i0.Input }],
3953
+ singleMode: [{ type: i0.Input }],
4100
3954
  locationType: [{ type: i0.Input }],
4101
3955
  serviceIds: [{ type: i0.Input }],
4102
3956
  submitted: [{ type: i0.Input }],
4103
3957
  delay: [{ type: i0.Input }],
4104
- findLocationFormGroup: [{ type: i0.Input }],
3958
+ form: [{ type: i0.Input }],
4105
3959
  showAutocomplete: [{ type: i0.Input }],
4106
3960
  locations: [{ type: i0.Input }],
4107
3961
  locationSelected: [{ type: i0.Output }],
3962
+ reset: [{ type: i0.Input }],
4108
3963
  selectedLocations: [{ type: i0.Input }]
4109
3964
  };
4110
3965
  return SearchLocationComponent;
4111
3966
  }());
4112
3967
 
3968
+ /**
3969
+ * @fileoverview added by tsickle
3970
+ * Generated from: lib/components/find-location/find-location.component.ts
3971
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3972
+ */
3973
+ var FindLocationComponent = /** @class */ (function () {
3974
+ function FindLocationComponent() {
3975
+ this.selectedLocations = [];
3976
+ this.submitted = true;
3977
+ this.enableAddLocationButton = true;
3978
+ this.title = 'Search for a location by name';
3979
+ this.locations = [];
3980
+ this.tempSelectedLocation = null;
3981
+ this.serviceIds = 'SSCS,IA';
3982
+ this.pServices = [];
3983
+ this.pDisabled = false;
3984
+ }
3985
+ Object.defineProperty(FindLocationComponent.prototype, "disabled", {
3986
+ get: /**
3987
+ * @return {?}
3988
+ */ function () {
3989
+ return this.pDisabled;
3990
+ },
3991
+ set: /**
3992
+ * @param {?} value
3993
+ * @return {?}
3994
+ */ function (value) {
3995
+ if (value) {
3996
+ this.searchLocationComponent.resetSearchTerm();
3997
+ this.removeSelectedValues();
3998
+ }
3999
+ this.pDisabled = value;
4000
+ },
4001
+ enumerable: true,
4002
+ configurable: true
4003
+ });
4004
+ Object.defineProperty(FindLocationComponent.prototype, "services", {
4005
+ get: /**
4006
+ * @return {?}
4007
+ */ function () {
4008
+ return this.pServices;
4009
+ },
4010
+ set: /**
4011
+ * @param {?} value
4012
+ * @return {?}
4013
+ */ function (value) {
4014
+ var _this = this;
4015
+ this.pServices = value;
4016
+ /** @type {?} */
4017
+ var field = this.fields.find(( /**
4018
+ * @param {?} f
4019
+ * @return {?}
4020
+ */function (f) { return f.name === _this.field.findLocationField; }));
4021
+ if (field) {
4022
+ if (typeof value === 'string') {
4023
+ this.serviceIds = value;
4024
+ }
4025
+ else {
4026
+ this.serviceIds = getValues(field.options, value).filter(( /**
4027
+ * @param {?} x
4028
+ * @return {?}
4029
+ */function (x) { return x !== 'services_all'; })).join(',');
4030
+ }
4031
+ }
4032
+ },
4033
+ enumerable: true,
4034
+ configurable: true
4035
+ });
4036
+ /**
4037
+ * @return {?}
4038
+ */
4039
+ FindLocationComponent.prototype.addLocation = /**
4040
+ * @return {?}
4041
+ */
4042
+ function () {
4043
+ if (this.tempSelectedLocation) {
4044
+ this.selectedLocations = __spread(this.selectedLocations, [this.tempSelectedLocation]);
4045
+ this.addSelectedLocationsToForm([this.tempSelectedLocation]);
4046
+ this.tempSelectedLocation = null;
4047
+ this.locations = [];
4048
+ this.searchLocationComponent.resetSearchTerm();
4049
+ }
4050
+ };
4051
+ /**
4052
+ * @param {?} location
4053
+ * @return {?}
4054
+ */
4055
+ FindLocationComponent.prototype.removeLocation = /**
4056
+ * @param {?} location
4057
+ * @return {?}
4058
+ */
4059
+ function (location) {
4060
+ if (location.epims_id) {
4061
+ this.selectedLocations = this.selectedLocations.filter(( /**
4062
+ * @param {?} selectedLocation
4063
+ * @return {?}
4064
+ */function (selectedLocation) { return selectedLocation.epims_id !== location.epims_id; }));
4065
+ /** @type {?} */
4066
+ var formArray = ( /** @type {?} */(this.form.get(this.field.name)));
4067
+ /** @type {?} */
4068
+ var index = (( /** @type {?} */(formArray.value))).findIndex(( /**
4069
+ * @param {?} selectedLocation
4070
+ * @return {?}
4071
+ */function (selectedLocation) { return selectedLocation.epims_id === location.epims_id; }));
4072
+ if (index > -1) {
4073
+ formArray.removeAt(index);
4074
+ }
4075
+ }
4076
+ };
4077
+ /**
4078
+ * @param {?} location
4079
+ * @return {?}
4080
+ */
4081
+ FindLocationComponent.prototype.onLocationSelected = /**
4082
+ * @param {?} location
4083
+ * @return {?}
4084
+ */
4085
+ function (location) {
4086
+ if (this.field.maxSelected === 1) {
4087
+ this.removeSelectedValues();
4088
+ this.addSelectedLocationsToForm([location]);
4089
+ }
4090
+ else {
4091
+ if (!this.selectedLocations.find(( /**
4092
+ * @param {?} x
4093
+ * @return {?}
4094
+ */function (x) { return x.epims_id === location.epims_id; }))) {
4095
+ if (location.epims_id) {
4096
+ this.tempSelectedLocation = location;
4097
+ }
4098
+ }
4099
+ }
4100
+ };
4101
+ /**
4102
+ * @private
4103
+ * @return {?}
4104
+ */
4105
+ FindLocationComponent.prototype.removeSelectedValues = /**
4106
+ * @private
4107
+ * @return {?}
4108
+ */
4109
+ function () {
4110
+ /** @type {?} */
4111
+ var formArray = ( /** @type {?} */(this.form.get(this.field.name)));
4112
+ for (var i = 0; i < formArray.length; i++) {
4113
+ formArray.removeAt(i);
4114
+ }
4115
+ this.selectedLocations = [];
4116
+ };
4117
+ /**
4118
+ * @private
4119
+ * @param {?} locations
4120
+ * @return {?}
4121
+ */
4122
+ FindLocationComponent.prototype.addSelectedLocationsToForm = /**
4123
+ * @private
4124
+ * @param {?} locations
4125
+ * @return {?}
4126
+ */
4127
+ function (locations) {
4128
+ var e_1, _a;
4129
+ /** @type {?} */
4130
+ var formArray = ( /** @type {?} */(this.form.get(this.field.name)));
4131
+ try {
4132
+ for (var locations_1 = __values(locations), locations_1_1 = locations_1.next(); !locations_1_1.done; locations_1_1 = locations_1.next()) {
4133
+ var location_1 = locations_1_1.value;
4134
+ formArray.push(new forms.FormControl(location_1));
4135
+ }
4136
+ }
4137
+ catch (e_1_1) {
4138
+ e_1 = { error: e_1_1 };
4139
+ }
4140
+ finally {
4141
+ try {
4142
+ if (locations_1_1 && !locations_1_1.done && (_a = locations_1.return))
4143
+ _a.call(locations_1);
4144
+ }
4145
+ finally {
4146
+ if (e_1)
4147
+ throw e_1.error;
4148
+ }
4149
+ }
4150
+ };
4151
+ FindLocationComponent.decorators = [
4152
+ { type: i0.Component, args: [{
4153
+ selector: 'xuilib-find-location',
4154
+ 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",
4155
+ styles: [""]
4156
+ }] }
4157
+ ];
4158
+ FindLocationComponent.propDecorators = {
4159
+ selectedLocations: [{ type: i0.Input }],
4160
+ submitted: [{ type: i0.Input }],
4161
+ enableAddLocationButton: [{ type: i0.Input }],
4162
+ form: [{ type: i0.Input }],
4163
+ field: [{ type: i0.Input }],
4164
+ fields: [{ type: i0.Input }],
4165
+ title: [{ type: i0.Input }],
4166
+ searchLocationComponent: [{ type: i0.ViewChild, args: [SearchLocationComponent,] }],
4167
+ disabled: [{ type: i0.Input }],
4168
+ services: [{ type: i0.Input }]
4169
+ };
4170
+ return FindLocationComponent;
4171
+ }());
4172
+
4113
4173
  /**
4114
4174
  * @fileoverview added by tsickle
4115
4175
  * Generated from: lib/components/pagination/pagination.component.ts
@@ -4402,6 +4462,45 @@
4402
4462
  return RadioFilterFieldConfig;
4403
4463
  }());
4404
4464
 
4465
+ /**
4466
+ * @fileoverview added by tsickle
4467
+ * Generated from: lib/gov-ui/util/session-storage/session-storage-utils.ts
4468
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4469
+ */
4470
+ /** @type {?} */
4471
+ var getAllCaseworkersFromServices = ( /**
4472
+ * @param {?} caseworkersByService
4473
+ * @return {?}
4474
+ */function (caseworkersByService) {
4475
+ /** @type {?} */
4476
+ var allCaseworkers = [];
4477
+ caseworkersByService.forEach(( /**
4478
+ * @param {?} caseworkerListByService
4479
+ * @return {?}
4480
+ */function (caseworkerListByService) {
4481
+ allCaseworkers = allCaseworkers.concat(caseworkerListByService.caseworkers);
4482
+ }));
4483
+ return allCaseworkers;
4484
+ });
4485
+ /** @type {?} */
4486
+ var getSessionStorageKeyForServiceId = ( /**
4487
+ * @param {?} serviceId
4488
+ * @return {?}
4489
+ */function (serviceId) {
4490
+ return serviceId + "-caseworkers";
4491
+ });
4492
+ /** @type {?} */
4493
+ var setCaseworkers = ( /**
4494
+ * @param {?} serviceId
4495
+ * @param {?} caseworkers
4496
+ * @param {?} sessionStorageService
4497
+ * @return {?}
4498
+ */function (serviceId, caseworkers, sessionStorageService) {
4499
+ /** @type {?} */
4500
+ var sessionKey = getSessionStorageKeyForServiceId(serviceId);
4501
+ sessionStorageService.setItem(sessionKey, JSON.stringify(caseworkers));
4502
+ });
4503
+
4405
4504
  /**
4406
4505
  * @fileoverview added by tsickle
4407
4506
  * Generated from: lib/services/session-storage/session-storage.service.ts
@@ -4542,32 +4641,56 @@
4542
4641
  var userInfo = JSON.parse(userInfoStr);
4543
4642
  this.userId = userInfo.id ? userInfo.id : userInfo.uid;
4544
4643
  }
4545
- if (!this.sessionStorageService.getItem(FindAPersonService.caseworkersKey)) {
4546
- this.http.get('/workallocation2/caseworker').pipe(operators.tap(( /**
4547
- * @param {?} caseworkerList
4548
- * @return {?}
4549
- */function (caseworkerList) { return _this.sessionStorageService.setItem(FindAPersonService.caseworkersKey, JSON.stringify(caseworkerList)); })));
4550
- }
4551
- /** @type {?} */
4552
- var caseworkers = JSON.parse(this.sessionStorageService.getItem(FindAPersonService.caseworkersKey));
4553
4644
  /** @type {?} */
4554
- var roleCategory = RoleCategory.ALL;
4555
- if (!(searchOptions.jurisdiction === PersonRole.ALL)) {
4556
- roleCategory = searchOptions.jurisdiction === PersonRole.CASEWORKER ? RoleCategory.CASEWORKER : RoleCategory.ADMIN;
4557
- }
4645
+ var fullServices = searchOptions.services;
4558
4646
  /** @type {?} */
4559
- var people = caseworkers ? this.mapCaseworkers(caseworkers, roleCategory) : [];
4647
+ var storedServices = [];
4560
4648
  /** @type {?} */
4561
- var searchTerm = searchOptions && searchOptions.searchTerm ? searchOptions.searchTerm.toLowerCase() : '';
4649
+ var newServices = [];
4562
4650
  /** @type {?} */
4563
- var finalPeopleList = people.filter(( /**
4564
- * @param {?} person
4651
+ var storedCaseworkersByService = [];
4652
+ fullServices.forEach(( /**
4653
+ * @param {?} serviceId
4565
4654
  * @return {?}
4566
- */function (person) { return person && person.name && person.name.toLowerCase().includes(searchTerm); }));
4567
- return searchOptions.userIncluded ? rxjs.of(finalPeopleList) : rxjs.of(finalPeopleList.filter(( /**
4568
- * @param {?} person
4655
+ */function (serviceId) {
4656
+ /** @type {?} */
4657
+ var serviceKey = getSessionStorageKeyForServiceId(serviceId);
4658
+ if (_this.sessionStorageService.getItem(serviceKey)) {
4659
+ storedServices.push(serviceId);
4660
+ storedCaseworkersByService.push({ service: serviceId, caseworkers: JSON.parse(_this.sessionStorageService.getItem(serviceKey)) });
4661
+ }
4662
+ else {
4663
+ newServices.push(serviceId);
4664
+ }
4665
+ }));
4666
+ // if all services are stored then return the stored caseworkers by service
4667
+ if (storedServices.length === fullServices.length) {
4668
+ /** @type {?} */
4669
+ var storedCaseworkers = getAllCaseworkersFromServices(storedCaseworkersByService);
4670
+ return rxjs.of(this.searchInCaseworkers(storedCaseworkers, searchOptions));
4671
+ }
4672
+ // all serviceIds passed in as node layer getting used anyway and caseworkers also stored there
4673
+ return this.http.post('/workallocation2/retrieveCaseWorkersForServices', { fullServices: fullServices }).pipe(operators.tap(( /**
4674
+ * @param {?} caseworkersByService
4569
4675
  * @return {?}
4570
- */function (person) { return person && person.id !== _this.userId; })));
4676
+ */function (caseworkersByService) {
4677
+ caseworkersByService.forEach(( /**
4678
+ * @param {?} caseworkerListByService
4679
+ * @return {?}
4680
+ */function (caseworkerListByService) {
4681
+ // for any new service, ensure that they are then stored in the session
4682
+ if (newServices.includes(caseworkerListByService.service)) {
4683
+ setCaseworkers(caseworkerListByService.service, caseworkerListByService.caseworkers, _this.sessionStorageService);
4684
+ }
4685
+ }));
4686
+ })), operators.map(( /**
4687
+ * @param {?} caseworkersByService
4688
+ * @return {?}
4689
+ */function (caseworkersByService) {
4690
+ /** @type {?} */
4691
+ var givenCaseworkers = getAllCaseworkersFromServices(caseworkersByService);
4692
+ return _this.searchInCaseworkers(givenCaseworkers, searchOptions);
4693
+ })));
4571
4694
  };
4572
4695
  /**
4573
4696
  * @param {?} caseworkers
@@ -4599,6 +4722,37 @@
4599
4722
  }));
4600
4723
  return people;
4601
4724
  };
4725
+ /**
4726
+ * @param {?} caseworkers
4727
+ * @param {?} searchOptions
4728
+ * @return {?}
4729
+ */
4730
+ FindAPersonService.prototype.searchInCaseworkers = /**
4731
+ * @param {?} caseworkers
4732
+ * @param {?} searchOptions
4733
+ * @return {?}
4734
+ */
4735
+ function (caseworkers, searchOptions) {
4736
+ var _this = this;
4737
+ /** @type {?} */
4738
+ var roleCategory = RoleCategory.ALL;
4739
+ if (!(searchOptions.userRole === PersonRole.ALL)) {
4740
+ roleCategory = searchOptions.userRole === PersonRole.CASEWORKER ? RoleCategory.CASEWORKER : RoleCategory.ADMIN;
4741
+ }
4742
+ /** @type {?} */
4743
+ var searchTerm = searchOptions && searchOptions.searchTerm ? searchOptions.searchTerm.toLowerCase() : '';
4744
+ /** @type {?} */
4745
+ var people = caseworkers ? this.mapCaseworkers(caseworkers, roleCategory) : [];
4746
+ /** @type {?} */
4747
+ var finalPeopleList = people.filter(( /**
4748
+ * @param {?} person
4749
+ * @return {?}
4750
+ */function (person) { return person && person.name && person.name.toLowerCase().includes(searchTerm); }));
4751
+ return searchOptions.userIncluded ? finalPeopleList : finalPeopleList.filter(( /**
4752
+ * @param {?} person
4753
+ * @return {?}
4754
+ */function (person) { return person && person.id !== _this.userId; }));
4755
+ };
4602
4756
  FindAPersonService.caseworkersKey = 'caseworkers';
4603
4757
  FindAPersonService.decorators = [
4604
4758
  { type: i0.Injectable, args: [{
@@ -4622,8 +4776,9 @@
4622
4776
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4623
4777
  */
4624
4778
  var FindPersonComponent = /** @class */ (function () {
4625
- function FindPersonComponent(findPersonService) {
4779
+ function FindPersonComponent(findPersonService, cd) {
4626
4780
  this.findPersonService = findPersonService;
4781
+ this.cd = cd;
4627
4782
  this.personSelected = new i0.EventEmitter();
4628
4783
  this.boldTitle = 'Find the person';
4629
4784
  this.subTitle = 'Type the name of the person and select them.';
@@ -4632,16 +4787,18 @@
4632
4787
  this.disabled = null;
4633
4788
  this.userIncluded = false;
4634
4789
  this.placeholderContent = '';
4635
- this.isNoResultsShown = false;
4790
+ this.isNoResultsShown = true;
4636
4791
  this.showUpdatedColor = false;
4637
4792
  this.selectedPersons = [];
4638
4793
  this.errorMessage = 'You must select a name';
4639
4794
  this.idValue = '';
4795
+ this.services = ['IA'];
4640
4796
  this.isPersonSelectionCompleted = false;
4641
4797
  this.showAutocomplete = false;
4642
4798
  this.currentInputValue = '';
4643
- this.choosenPerson = ( /** @type {?} */({}));
4644
- this.findPersonControl = new forms.FormControl();
4799
+ this.chosenPerson = null;
4800
+ this.findPersonControl = new forms.FormControl('');
4801
+ this.filteredOptions = [];
4645
4802
  this.minSearchCharacters = 2;
4646
4803
  }
4647
4804
  /**
@@ -4658,12 +4815,29 @@
4658
4815
  else {
4659
4816
  this.findPersonGroup.addControl('findPersonControl', this.findPersonControl);
4660
4817
  }
4661
- this.filteredOptions = this.findPersonControl.valueChanges.pipe(operators.startWith(''), operators.switchMap(( /**
4818
+ this.findPersonControl.valueChanges.pipe(operators.startWith(''), operators.tap(( /**
4819
+ * @return {?}
4820
+ */function () { return _this.showAutocomplete = false; })), operators.tap(( /**
4821
+ * @return {?}
4822
+ */function () { return _this.filteredOptions = []; })), operators.filter(( /**
4823
+ * @param {?} searchTerm
4824
+ * @return {?}
4825
+ */function (searchTerm) { return searchTerm && searchTerm.length > _this.minSearchCharacters; })), operators.switchMap(( /**
4662
4826
  * @param {?} searchTerm
4663
4827
  * @return {?}
4664
4828
  */function (searchTerm) {
4665
- return _this.filter(searchTerm || '');
4666
- })));
4829
+ return _this.filter(searchTerm).pipe(operators.tap(( /**
4830
+ * @return {?}
4831
+ */function () { return _this.showAutocomplete = true; })), operators.catchError(( /**
4832
+ * @return {?}
4833
+ */function () { return _this.filteredOptions = []; })));
4834
+ }))).subscribe(( /**
4835
+ * @param {?} people
4836
+ * @return {?}
4837
+ */function (people) {
4838
+ _this.filteredOptions = people;
4839
+ _this.cd.detectChanges();
4840
+ }));
4667
4841
  this.findPersonControl.setValue(this.selectedPerson);
4668
4842
  };
4669
4843
  /**
@@ -4695,9 +4869,9 @@
4695
4869
  function (searchTerm) {
4696
4870
  var _this = this;
4697
4871
  /** @type {?} */
4698
- var findJudicialPeople = this.findPersonService.find({ searchTerm: searchTerm, jurisdiction: this.domain });
4872
+ var findJudicialPeople = this.findPersonService.find({ searchTerm: searchTerm, userRole: this.domain, services: this.services });
4699
4873
  /** @type {?} */
4700
- var findCaseworkersOrAdmins = this.findPersonService.findCaseworkers({ searchTerm: searchTerm, jurisdiction: this.domain });
4874
+ var findCaseworkersOrAdmins = this.findPersonService.findCaseworkers({ searchTerm: searchTerm, userRole: this.domain, services: this.services });
4701
4875
  if (searchTerm && searchTerm.length > this.minSearchCharacters) {
4702
4876
  switch (this.domain) {
4703
4877
  case PersonRole.JUDICIAL: {
@@ -4733,24 +4907,25 @@
4733
4907
  return findCaseworkersOrAdmins;
4734
4908
  }
4735
4909
  default: {
4736
- return rxjs.of();
4910
+ return rxjs.of([]);
4737
4911
  }
4738
4912
  }
4739
4913
  }
4740
- return rxjs.of();
4914
+ return rxjs.of([]);
4741
4915
  };
4742
4916
  /**
4743
- * @param {?=} selectedPerson
4917
+ * @param {?} selectedPerson
4744
4918
  * @return {?}
4745
4919
  */
4746
4920
  FindPersonComponent.prototype.onSelectionChange = /**
4747
- * @param {?=} selectedPerson
4921
+ * @param {?} selectedPerson
4748
4922
  * @return {?}
4749
4923
  */
4750
4924
  function (selectedPerson) {
4751
4925
  this.isPersonSelectionCompleted = true;
4752
- this.choosenPerson = selectedPerson;
4926
+ this.chosenPerson = selectedPerson;
4753
4927
  this.personSelected.emit(selectedPerson);
4928
+ this.findPersonControl.setValue('');
4754
4929
  };
4755
4930
  /**
4756
4931
  * @param {?} currentValue
@@ -4763,7 +4938,7 @@
4763
4938
  function (currentValue) {
4764
4939
  this.currentInputValue = currentValue;
4765
4940
  this.showAutocomplete = !!currentValue && (currentValue.length > this.minSearchCharacters);
4766
- this.isPersonSelectionCompleted = (this.getDisplayName(this.choosenPerson) === currentValue) ? true : false;
4941
+ this.isPersonSelectionCompleted = this.getDisplayName(this.chosenPerson) === currentValue;
4767
4942
  };
4768
4943
  /**
4769
4944
  * @param {?} selectedPerson
@@ -4774,6 +4949,9 @@
4774
4949
  * @return {?}
4775
4950
  */
4776
4951
  function (selectedPerson) {
4952
+ if (!selectedPerson) {
4953
+ return '';
4954
+ }
4777
4955
  if (selectedPerson.domain === PersonRole.JUDICIAL && selectedPerson.knownAs) {
4778
4956
  return selectedPerson.knownAs + "(" + selectedPerson.email + ")";
4779
4957
  }
@@ -4782,14 +4960,15 @@
4782
4960
  FindPersonComponent.decorators = [
4783
4961
  { type: i0.Component, args: [{
4784
4962
  selector: 'xuilib-find-person',
4785
- 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",
4963
+ 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",
4786
4964
  styles: [".mat-option:hover{background:#2596be}.mat-option.select-option:hover{background:#1d70b8;color:#fff}.hide-autocomplete{display:none}"]
4787
4965
  }] }
4788
4966
  ];
4789
4967
  /** @nocollapse */
4790
4968
  FindPersonComponent.ctorParameters = function () {
4791
4969
  return [
4792
- { type: FindAPersonService }
4970
+ { type: FindAPersonService },
4971
+ { type: i0.ChangeDetectorRef }
4793
4972
  ];
4794
4973
  };
4795
4974
  FindPersonComponent.propDecorators = {
@@ -4808,7 +4987,8 @@
4808
4987
  showUpdatedColor: [{ type: i0.Input }],
4809
4988
  selectedPersons: [{ type: i0.Input }],
4810
4989
  errorMessage: [{ type: i0.Input }],
4811
- idValue: [{ type: i0.Input }]
4990
+ idValue: [{ type: i0.Input }],
4991
+ services: [{ type: i0.Input }]
4812
4992
  };
4813
4993
  return FindPersonComponent;
4814
4994
  }());
@@ -5889,7 +6069,8 @@
5889
6069
  forms.ReactiveFormsModule,
5890
6070
  i2$2.RouterModule.forChild([]),
5891
6071
  autocomplete.MatAutocompleteModule,
5892
- material.MatTabsModule
6072
+ material.MatTabsModule,
6073
+ material.MatInputModule
5893
6074
  ],
5894
6075
  providers: [
5895
6076
  { provide: windowToken, useFactory: ɵ0 }