@hmcts/rpx-xui-common-lib 1.6.7-location-integration → 1.6.7-location-filter-improvements

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.
@@ -1130,13 +1130,22 @@
1130
1130
  */
1131
1131
  function (values, field) {
1132
1132
  var e_2, _a;
1133
+ console.log('updatePersonControls', values, field);
1133
1134
  /** @type {?} */
1134
- var keys = Object.keys(values);
1135
+ var keys;
1136
+ if (!values) {
1137
+ keys = Object.keys(this.form.get(field.name).value);
1138
+ }
1139
+ else {
1140
+ keys = Object.keys(values);
1141
+ }
1135
1142
  try {
1136
1143
  for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
1137
1144
  var key = keys_1_1.value;
1138
1145
  if (this.form.get(field.name) && this.form.get(field.name).get(key)) {
1139
- this.form.get(field.name).get(key).patchValue(values[key]);
1146
+ /** @type {?} */
1147
+ var value = values && values[key] ? values[key] : null;
1148
+ this.form.get(field.name).get(key).patchValue(value);
1140
1149
  }
1141
1150
  }
1142
1151
  }
@@ -1613,7 +1622,7 @@
1613
1622
  GenericFilterComponent.decorators = [
1614
1623
  { type: i0.Component, args: [{
1615
1624
  selector: 'xuilib-generic-filter',
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 *ngIf=\"config.showCancelFilterButton\"\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",
1625
+ 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 [disabled]=\"disabled(field, form)\"\n [domain]=\"form.get(field.domainField)?.value\"\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 [locationTitle]=\"field.locationTitle\"\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 *ngIf=\"config.showCancelFilterButton\"\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",
1617
1626
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1618
1627
  encapsulation: i0.ViewEncapsulation.None,
1619
1628
  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}"]
@@ -3820,7 +3829,7 @@
3820
3829
  if (this.singleMode && this.selectedLocations.length > 0) {
3821
3830
  /** @type {?} */
3822
3831
  var location_1 = this.selectedLocations[0];
3823
- this.form.controls.searchTerm.patchValue(location_1.venue_name, { emitEvent: false, onlySelf: true });
3832
+ this.form.controls.searchTerm.patchValue(location_1.site_name, { emitEvent: false, onlySelf: true });
3824
3833
  }
3825
3834
  this.search();
3826
3835
  };
@@ -3848,7 +3857,7 @@
3848
3857
  * @return {?}
3849
3858
  */
3850
3859
  function (location) {
3851
- this.form.controls.searchTerm.patchValue(location.venue_name, { emitEvent: false, onlySelf: true });
3860
+ this.form.controls.searchTerm.patchValue(location.site_name, { emitEvent: false, onlySelf: true });
3852
3861
  this.locationSelected.emit(location);
3853
3862
  };
3854
3863
  /**
@@ -3883,7 +3892,7 @@
3883
3892
  */function (locations) {
3884
3893
  _this.locations = locations;
3885
3894
  _this.cd.markForCheck();
3886
- if (locations.length === 1 && _this.term === locations[0].venue_name && !_this.singleMode) {
3895
+ if (locations.length === 1 && _this.term === locations[0].site_name && !_this.singleMode) {
3887
3896
  _this.locationSelected.emit(locations[0]);
3888
3897
  _this.showAutocomplete = false;
3889
3898
  return;
@@ -3933,13 +3942,13 @@
3933
3942
  return !_this.selectedLocations.map(( /**
3934
3943
  * @param {?} selectedLocation
3935
3944
  * @return {?}
3936
- */function (selectedLocation) { return selectedLocation.epimms_id; })).includes(location.epimms_id) && location.venue_name;
3945
+ */function (selectedLocation) { return selectedLocation.epimms_id; })).includes(location.epimms_id) && location.site_name;
3937
3946
  }));
3938
3947
  };
3939
3948
  SearchLocationComponent.decorators = [
3940
3949
  { type: i0.Component, args: [{
3941
3950
  selector: 'exui-search-location',
3942
- 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.venue_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",
3951
+ 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.site_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",
3943
3952
  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}"]
3944
3953
  }] }
3945
3954
  ];
@@ -3980,7 +3989,7 @@
3980
3989
  this.selectedLocations = [];
3981
3990
  this.submitted = true;
3982
3991
  this.enableAddLocationButton = true;
3983
- this.title = 'Search for a location by name';
3992
+ this.locationTitle = 'Search for a location by name';
3984
3993
  this.locations = [];
3985
3994
  this.tempSelectedLocation = null;
3986
3995
  this.serviceIds = 'SSCS,IA';
@@ -4170,7 +4179,7 @@
4170
4179
  FindLocationComponent.decorators = [
4171
4180
  { type: i0.Component, args: [{
4172
4181
  selector: 'xuilib-find-location',
4173
- 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 (locationInputChanged)=\"onInputChanged($event)\"\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.venue_name }}\n </a>\n </li>\n </ul>\n</div>\n",
4182
+ template: "<div class=\"location-picker-custom\">\n <div class=\"search-location\">\n <div>\n <label id=\"input-selected-location-label\" *ngIf=\"locationTitle\">{{locationTitle}}</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 (locationInputChanged)=\"onInputChanged($event)\"\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.site_name }}\n </a>\n </li>\n </ul>\n</div>\n",
4174
4183
  styles: [""]
4175
4184
  }] }
4176
4185
  ];
@@ -4181,7 +4190,7 @@
4181
4190
  form: [{ type: i0.Input }],
4182
4191
  field: [{ type: i0.Input }],
4183
4192
  fields: [{ type: i0.Input }],
4184
- title: [{ type: i0.Input }],
4193
+ locationTitle: [{ type: i0.Input }],
4185
4194
  searchLocationComponent: [{ type: i0.ViewChild, args: [SearchLocationComponent,] }],
4186
4195
  disabled: [{ type: i0.Input }],
4187
4196
  services: [{ type: i0.Input }]
@@ -4802,8 +4811,8 @@
4802
4811
  this.boldTitle = 'Find the person';
4803
4812
  this.subTitle = 'Type the name of the person and select them.';
4804
4813
  this.domain = PersonRole.ALL;
4814
+ this.findPersonGroup = new forms.FormGroup({});
4805
4815
  this.submitted = true;
4806
- this.disabled = null;
4807
4816
  this.userIncluded = false;
4808
4817
  this.placeholderContent = '';
4809
4818
  this.isNoResultsShown = true;
@@ -4812,14 +4821,22 @@
4812
4821
  this.errorMessage = 'You must select a name';
4813
4822
  this.idValue = '';
4814
4823
  this.services = ['IA'];
4815
- this.isPersonSelectionCompleted = false;
4824
+ this.disabled = null;
4816
4825
  this.showAutocomplete = false;
4817
- this.currentInputValue = '';
4818
- this.chosenPerson = null;
4819
- this.findPersonControl = new forms.FormControl('');
4820
4826
  this.filteredOptions = [];
4821
4827
  this.minSearchCharacters = 2;
4822
4828
  }
4829
+ /**
4830
+ * @return {?}
4831
+ */
4832
+ FindPersonComponent.prototype.ngOnDestroy = /**
4833
+ * @return {?}
4834
+ */
4835
+ function () {
4836
+ if (this.sub) {
4837
+ this.sub.unsubscribe();
4838
+ }
4839
+ };
4823
4840
  /**
4824
4841
  * @return {?}
4825
4842
  */
@@ -4828,17 +4845,16 @@
4828
4845
  */
4829
4846
  function () {
4830
4847
  var _this = this;
4831
- if (!this.findPersonGroup) {
4832
- this.findPersonGroup = new forms.FormGroup({});
4833
- }
4834
- else {
4835
- this.findPersonGroup.addControl('findPersonControl', this.findPersonControl);
4836
- }
4837
- this.findPersonControl.valueChanges.pipe(operators.startWith(''), operators.tap(( /**
4848
+ this.findPersonControl = new forms.FormControl(this.selectedPerson);
4849
+ this.findPersonGroup.addControl('findPersonControl', this.findPersonControl);
4850
+ this.sub = this.findPersonControl.valueChanges.pipe(operators.tap(( /**
4838
4851
  * @return {?}
4839
4852
  */function () { return _this.showAutocomplete = false; })), operators.tap(( /**
4840
4853
  * @return {?}
4841
- */function () { return _this.filteredOptions = []; })), operators.filter(( /**
4854
+ */function () { return _this.filteredOptions = []; })), operators.debounceTime(300), operators.tap(( /**
4855
+ * @param {?} searchTerm
4856
+ * @return {?}
4857
+ */function (searchTerm) { return typeof searchTerm === 'string' ? _this.personSelected.emit(null) : void 0; })), operators.filter(( /**
4842
4858
  * @param {?} searchTerm
4843
4859
  * @return {?}
4844
4860
  */function (searchTerm) { return searchTerm && searchTerm.length > _this.minSearchCharacters; })), operators.switchMap(( /**
@@ -4857,25 +4873,6 @@
4857
4873
  _this.filteredOptions = people;
4858
4874
  _this.cd.detectChanges();
4859
4875
  }));
4860
- this.findPersonControl.setValue(this.selectedPerson);
4861
- };
4862
- /**
4863
- * @param {?} changes
4864
- * @return {?}
4865
- */
4866
- FindPersonComponent.prototype.ngOnChanges = /**
4867
- * @param {?} changes
4868
- * @return {?}
4869
- */
4870
- function (changes) {
4871
- if (changes['domain'] && !changes['domain'].firstChange) {
4872
- this.findPersonControl.setValue(null);
4873
- this.selectedPerson = null;
4874
- }
4875
- if (changes['selectedPerson'] && changes['selectedPerson'].currentValue === '') {
4876
- this.currentInputValue = '';
4877
- this.isPersonSelectionCompleted = false;
4878
- }
4879
4876
  };
4880
4877
  /**
4881
4878
  * @param {?} searchTerm
@@ -4941,23 +4938,8 @@
4941
4938
  * @return {?}
4942
4939
  */
4943
4940
  function (selectedPerson) {
4944
- this.isPersonSelectionCompleted = true;
4945
- this.chosenPerson = selectedPerson;
4946
4941
  this.personSelected.emit(selectedPerson);
4947
- this.findPersonControl.setValue('');
4948
- };
4949
- /**
4950
- * @param {?} currentValue
4951
- * @return {?}
4952
- */
4953
- FindPersonComponent.prototype.updatedVal = /**
4954
- * @param {?} currentValue
4955
- * @return {?}
4956
- */
4957
- function (currentValue) {
4958
- this.currentInputValue = currentValue;
4959
- this.showAutocomplete = !!currentValue && (currentValue.length > this.minSearchCharacters);
4960
- this.isPersonSelectionCompleted = this.getDisplayName(this.chosenPerson) === currentValue;
4942
+ this.findPersonControl.setValue(this.getDisplayName(selectedPerson), { emitEvent: false, onlySelf: true });
4961
4943
  };
4962
4944
  /**
4963
4945
  * @param {?} selectedPerson
@@ -4979,7 +4961,7 @@
4979
4961
  FindPersonComponent.decorators = [
4980
4962
  { type: i0.Component, args: [{
4981
4963
  selector: 'xuilib-find-person',
4982
- 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",
4964
+ 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\"\n formControlName=\"findPersonControl\"\n [matAutocomplete]=\"auto\"\n class=\"govuk-input govuk-!-width-one-third\"\n [placeholder]=\"placeholderContent\"\n [attr.disabled]=\"disabled\">\n <mat-autocomplete autoActiveFirstOption #auto=\"matAutocomplete\" (optionSelected)=\"onSelectionChange($event.option.value)\">\n <mat-option *ngFor=\"let option of filteredOptions\"\n [value]=\"option\"\n [ngClass]=\"{'hide-autocomplete': !showAutocomplete, 'select-option': showUpdatedColor}\">\n {{getDisplayName(option)}}\n </mat-option>\n <mat-option [ngClass]=\"{'select-option': showUpdatedColor}\" *ngIf=\"isNoResultsShown && !filteredOptions.length && showAutocomplete\">No results found</mat-option>\n </mat-autocomplete>\n </fieldset>\n</div>\n",
4983
4965
  styles: [".mat-option:hover{background:#2596be}.mat-option.select-option:hover{background:#1d70b8;color:#fff}.hide-autocomplete{display:none}"]
4984
4966
  }] }
4985
4967
  ];
@@ -4999,7 +4981,6 @@
4999
4981
  findPersonGroup: [{ type: i0.Input }],
5000
4982
  selectedPerson: [{ type: i0.Input }],
5001
4983
  submitted: [{ type: i0.Input }],
5002
- disabled: [{ type: i0.Input }],
5003
4984
  userIncluded: [{ type: i0.Input }],
5004
4985
  placeholderContent: [{ type: i0.Input }],
5005
4986
  isNoResultsShown: [{ type: i0.Input }],
@@ -5007,7 +4988,8 @@
5007
4988
  selectedPersons: [{ type: i0.Input }],
5008
4989
  errorMessage: [{ type: i0.Input }],
5009
4990
  idValue: [{ type: i0.Input }],
5010
- services: [{ type: i0.Input }]
4991
+ services: [{ type: i0.Input }],
4992
+ disabled: [{ type: i0.Input }]
5011
4993
  };
5012
4994
  return FindPersonComponent;
5013
4995
  }());