@hmcts/rpx-xui-common-lib 1.4.29-date-component-common-validation → 1.4.29-fix-search-location-dropdown

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.
@@ -1017,7 +1017,9 @@
1017
1017
  fields: this.getSelectedValues(form.value, this.config)
1018
1018
  };
1019
1019
  this.filterService.givenErrors.next(null);
1020
- this.filterService.persist(this.settings, this.config.persistence);
1020
+ /** @type {?} */
1021
+ var settings = __assign({}, this.settings, { reset: false });
1022
+ this.filterService.persist(settings, this.config.persistence);
1021
1023
  }
1022
1024
  else {
1023
1025
  this.emitFormErrors(form);
@@ -1092,7 +1094,9 @@
1092
1094
  if (this.config && this.config.cancelSetting) {
1093
1095
  this._settings.fields = JSON.parse(JSON.stringify(this.config.cancelSetting.fields));
1094
1096
  }
1095
- this.filterService.persist(this.settings, this.config.persistence);
1097
+ /** @type {?} */
1098
+ var settings = __assign({}, this.settings, { reset: true });
1099
+ this.filterService.persist(settings, this.config.persistence);
1096
1100
  this.filterService.givenErrors.next(null);
1097
1101
  };
1098
1102
  /**
@@ -3660,6 +3664,15 @@
3660
3664
  if (this.control) {
3661
3665
  if (this.findLocationFormGroup && this.findLocationFormGroup.controls) {
3662
3666
  this.findLocationFormGroup.controls.locationSelectedFormControl = this.control;
3667
+ this.findLocationFormGroup.controls.locationSelectedFormControl.valueChanges.subscribe(( /**
3668
+ * @param {?} value
3669
+ * @return {?}
3670
+ */function (value) {
3671
+ if (!value) {
3672
+ console.log('reset form control');
3673
+ _this.findLocationFormGroup.controls.findLocationFormControl.setValue('');
3674
+ }
3675
+ }));
3663
3676
  }
3664
3677
  }
3665
3678
  this.keyUpSubject$.pipe(operators.debounceTime(500)).subscribe(( /**
@@ -3667,6 +3680,22 @@
3667
3680
  * @return {?}
3668
3681
  */function (searchValue) { return _this.search(( /** @type {?} */(searchValue))); }));
3669
3682
  };
3683
+ /**
3684
+ * @return {?}
3685
+ */
3686
+ SearchLocationComponent.prototype.onFocus = /**
3687
+ * @return {?}
3688
+ */
3689
+ function () {
3690
+ if (this.findLocationFormGroup && this.findLocationFormGroup.controls) {
3691
+ /** @type {?} */
3692
+ var value = this.findLocationFormGroup.controls.findLocationFormControl.value ? this.findLocationFormGroup.controls.findLocationFormControl.value : '';
3693
+ if (!value) {
3694
+ this.showAutocomplete = false;
3695
+ }
3696
+ this.search(value);
3697
+ }
3698
+ };
3670
3699
  /**
3671
3700
  * @param {?} event
3672
3701
  * @return {?}
@@ -3698,7 +3727,7 @@
3698
3727
  return !selectedLocations.map(( /**
3699
3728
  * @param {?} selectedLocation
3700
3729
  * @return {?}
3701
- */function (selectedLocation) { return selectedLocation.epims_id; })).includes(location.epims_id);
3730
+ */function (selectedLocation) { return selectedLocation.epims_id; })).includes(location.epims_id) && location.court_name;
3702
3731
  }));
3703
3732
  })));
3704
3733
  }))) : rxjs.of([]);
@@ -3762,6 +3791,10 @@
3762
3791
  */
3763
3792
  function (currentValue) {
3764
3793
  this.showAutocomplete = !!currentValue && (currentValue.length >= this.minSearchCharacters);
3794
+ if (!currentValue || !currentValue.length) {
3795
+ this.findLocationFormGroup.controls.locationSelectedFormControl.markAsPristine();
3796
+ this.findLocationFormGroup.controls.locationSelectedFormControl.reset();
3797
+ }
3765
3798
  if (this.showAutocomplete) {
3766
3799
  this.filter(currentValue);
3767
3800
  }
@@ -3801,8 +3834,8 @@
3801
3834
  SearchLocationComponent.decorators = [
3802
3835
  { type: i0.Component, args: [{
3803
3836
  selector: 'exui-search-location',
3804
- template: "<div class=\"auto-complete-container\">\n <div class=\"autocomplete__wrapper\"> \n <input \n [formControl]=\"findLocationFormGroup.controls.findLocationFormControl\"\n [matAutocomplete]=\"auto\"\n (keyup)=\"onKeyUp($event)\"\n aria-expanded=\"false\" \n aria-owns=\"input-selected-location__listbox\" \n aria-autocomplete=\"both\" \n autocomplete=\"off\" \n class=\"autocomplete__input autocomplete__input--default search-box\"\n [attr.disabled]=\"!disabled ? null: disabled\"\n [value]=\"getControlCourtNameValue()\"\n id=\"input-selected-location\">\n <mat-autocomplete class=\"mat-autocomplete-panel-extend\" autoActiveFirstOption #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let location of locationSource$ | async\"\n [value]=\"getDisplayName(location)\"\n (onSelectionChange)=\"onSelectionChange(location)\"\n [ngClass]=\"{'hide-autocomplete': !showAutocomplete}\">\n {{ getDisplayName(location) }}\n </mat-option>\n </mat-autocomplete>\n </div>\n</div>\n",
3805
- 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:16px;line-height:1.25}.autocomplete__hint,.autocomplete__option{padding:5px}@media (min-width:641px){.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:19px;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{width:50%;display:inline-block;margin-right:4px}"]
3837
+ template: "<div class=\"auto-complete-container\">\n <div class=\"autocomplete__wrapper\"> \n <input \n [formControl]=\"findLocationFormGroup.controls.findLocationFormControl\"\n [matAutocomplete]=\"auto\"\n (focus)=\"onFocus()\"\n (keyup)=\"onKeyUp($event)\"\n aria-expanded=\"false\" \n aria-owns=\"input-selected-location__listbox\" \n aria-autocomplete=\"both\" \n autocomplete=\"off\" \n class=\"autocomplete__input autocomplete__input--default search-box\"\n [attr.disabled]=\"!disabled ? null: disabled\"\n [value]=\"getControlCourtNameValue()\"\n #inputSelectedLocation>\n <mat-autocomplete class=\"mat-autocomplete-panel-extend\" autoActiveFirstOption #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let location of locationSource$ | async\"\n [value]=\"getDisplayName(location)\"\n (onSelectionChange)=\"onSelectionChange(location)\"\n [ngClass]=\"{'hide-autocomplete': !showAutocomplete}\">\n {{ getDisplayName(location) }}\n </mat-option>\n <mat-option *ngIf=\"!(locationSource$ | async)?.length && showAutocomplete\">{{ 'No results found' }}</mat-option>\n </mat-autocomplete>\n </div>\n</div>\n",
3838
+ 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}"]
3806
3839
  }] }
3807
3840
  ];
3808
3841
  /** @nocollapse */
@@ -3818,7 +3851,10 @@
3818
3851
  locationType: [{ type: i0.Input }],
3819
3852
  selectedLocations$: [{ type: i0.Input }],
3820
3853
  serviceIds: [{ type: i0.Input }],
3821
- submitted: [{ type: i0.Input }]
3854
+ submitted: [{ type: i0.Input }],
3855
+ showAutocomplete: [{ type: i0.Input }],
3856
+ locations$: [{ type: i0.Input }],
3857
+ autoCompleteInputBox: [{ type: i0.ViewChild, args: ['inputSelectedLocation', { read: i0.ElementRef },] }]
3822
3858
  };
3823
3859
  return SearchLocationComponent;
3824
3860
  }());
@@ -4539,11 +4575,11 @@
4539
4575
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4540
4576
  */
4541
4577
  /*
4542
- * Gov UK Date Component
4543
- * Responsible for displaying 3 input fields:
4544
- * day / month / year
4545
- * displaying errorMessage messages
4546
- * */
4578
+ * Gov UK Date Component
4579
+ * Responsible for displaying 3 input fields:
4580
+ * day / month / year
4581
+ * displaying errorMessage messages
4582
+ * */
4547
4583
  var GovUkDateComponent = /** @class */ (function () {
4548
4584
  function GovUkDateComponent() {
4549
4585
  }
@@ -4554,72 +4590,17 @@
4554
4590
  * @return {?}
4555
4591
  */
4556
4592
  function () {
4557
- this.day = this.config.id + "_day";
4558
- this.month = this.config.id + "_month";
4559
- this.year = this.config.id + "_year";
4560
- /** @type {?} */
4561
- var dateValidator = this.DateValidator();
4562
- this.formGroup.get(this.day).setValidators(dateValidator);
4563
- };
4564
- /**
4565
- * @private
4566
- * @param {?} d
4567
- * @param {?} month
4568
- * @return {?}
4569
- */
4570
- GovUkDateComponent.prototype.isValidDate = /**
4571
- * @private
4572
- * @param {?} d
4573
- * @param {?} month
4574
- * @return {?}
4575
- */
4576
- function (d, month) {
4577
- /** @type {?} */
4578
- var dateCheck = d instanceof Date && !isNaN(d.getTime());
4579
- /** @type {?} */
4580
- var leapYearCheck = d.getMonth() === month;
4581
- return dateCheck && leapYearCheck;
4582
- };
4583
- /**
4584
- * @return {?}
4585
- */
4586
- GovUkDateComponent.prototype.DateValidator = /**
4587
- * @return {?}
4588
- */
4589
- function () {
4590
- var _this = this;
4591
- /** @type {?} */
4592
- var res = ( /**
4593
- * @return {?}
4594
- */function () {
4595
- /** @type {?} */
4596
- var day = _this.formGroup.get(_this.day).value;
4597
- /** @type {?} */
4598
- var month = _this.formGroup.get(_this.month).value - 1;
4599
- /** @type {?} */
4600
- var year = _this.formGroup.get(_this.year).value;
4601
- /** @type {?} */
4602
- var isValid = _this.isValidDate(new Date(year, month, day), month);
4603
- if (!isValid) {
4604
- return { isValid: false, errorType: 'DATE_VALIDATION_FAILED' };
4605
- }
4606
- else {
4607
- return;
4608
- }
4609
- });
4610
- return res;
4611
4593
  };
4612
4594
  GovUkDateComponent.decorators = [
4613
4595
  { type: i0.Component, args: [{
4614
4596
  selector: 'xuilib-gov-uk-date',
4615
- template: "<div #form=\"ngForm\" class=\"govuk-form-group\" [ngClass]=\"{'govuk-form-group--error': errorMessage?.isInvalid}\" [formGroup]=\"formGroup\">\n <div class=\"date-input-container\">\n <xuilib-gov-uk-fieldset\n [config]=\"{\n legend: config.label || 'Date component',\n classes: config.classes || 'govuk-label--m',\n id: config.id,\n hint: config.hint != null ? config.hint : 'For example, 12 11 2007',\n isPageHeading: config.isPageHeading || false}\"\n [errorMessage]=\"errorMessage\">\n <xuilib-gov-uk-error-message\n [config]=\"{id: 'passport'}\"\n *ngIf=\"errorMessage\"\n [errorMessage]=\"errorMessage\">\n </xuilib-gov-uk-error-message>\n <div class=\"govuk-date-input\" [id]=\"config.id+'-date'\">\n <div class=\"govuk-date-input__item\">\n <div class=\"govuk-form-group\">\n <xuilib-gov-label\n [config]=\"{label: 'Day', name: config.id+'-day', id: config.id+'-day', classes: 'govuk-date-input__label'}\">\n </xuilib-gov-label>\n <input class=\"govuk-input govuk-date-input__input govuk-input--width-2\"\n [ngClass]=\"{'govuk-input--error': errorMessage?.isInvalid}\"\n [id]=\"config.id\"\n [name]=\"config.id+'-day'\" type=\"number\" value=\"\" pattern=\"[0-9]*\"\n [formControlName]=\"config.id+'_day'\">\n </div>\n </div>\n <div class=\"govuk-date-input__item\">\n <div class=\"govuk-form-group\">\n <xuilib-gov-label\n [config]=\"{label: 'Month', name: config.id+'-month', id: config.id+'-month', classes: 'govuk-date-input__label'}\">\n </xuilib-gov-label>\n <input class=\"govuk-input govuk-date-input__input govuk-input--width-2\"\n [ngClass]=\"{'govuk-input--error': errorMessage?.isInvalid}\"\n [id]=\"config.id+'-month'\"\n [name]=\"config.id+'-month'\" type=\"number\" value=\"\" pattern=\"[0-9]*\"\n [formControlName]=\"config.id+'_month'\">\n </div>\n </div>\n <div class=\"govuk-date-input__item\">\n <div class=\"govuk-form-group\">\n <xuilib-gov-label\n [config]=\"{label: 'Year', name: config.id+'-year', id: config.id+'-year', classes: 'govuk-date-input__label'}\">\n </xuilib-gov-label>\n <input class=\"govuk-input govuk-date-input__input govuk-input--width-4\"\n [ngClass]=\"{'govuk-input--error': errorMessage?.isInvalid}\"\n [id]=\"config.id+'-year'\"\n [name]=\"config.id+'-year'\" type=\"number\" value=\"\" pattern=\"[0-9]*\"\n [formControlName]=\"config.id+'_year'\">\n </div>\n </div>\n </div>\n </xuilib-gov-uk-fieldset>\n </div>\n</div>\n",
4597
+ template: "<div class=\"govuk-form-group\" [ngClass]=\"{'govuk-form-group--error': errorMessage?.isInvalid}\" [formGroup]=\"formGroup\">\n <div class=\"date-input-container\">\n <xuilib-gov-uk-fieldset\n [config]=\"{\n legend: config.label || 'Date component',\n classes: config.classes || 'govuk-label--m',\n id: config.id,\n hint: config.hint != null ? config.hint : 'For example, 12 11 2007',\n isPageHeading: config.isPageHeading || false}\"\n [errorMessage]=\"errorMessage\">\n <xuilib-gov-uk-error-message\n [config]=\"{id: 'passport'}\"\n *ngIf=\"errorMessage\"\n [errorMessage]=\"errorMessage\">\n </xuilib-gov-uk-error-message>\n\n <div class=\"govuk-date-input\" [id]=\"config.id+'-date'\">\n <div class=\"govuk-date-input__item\">\n <div class=\"govuk-form-group\">\n <xuilib-gov-label\n [config]=\"{label: 'Day', name: config.id+'-day', id: config.id+'-day', classes: 'govuk-date-input__label'}\">\n </xuilib-gov-label>\n <input class=\"govuk-input govuk-date-input__input govuk-input--width-2\"\n [ngClass]=\"{'govuk-input--error': errorMessage?.isInvalid}\"\n [id]=\"config.id\"\n [name]=\"config.id+'-day'\" type=\"number\" value=\"\" pattern=\"[0-9]*\"\n [formControlName]=\"config.id+'_day'\">\n </div>\n </div>\n <div class=\"govuk-date-input__item\">\n <div class=\"govuk-form-group\">\n <xuilib-gov-label\n [config]=\"{label: 'Month', name: config.id+'-month', id: config.id+'-month', classes: 'govuk-date-input__label'}\">\n </xuilib-gov-label>\n <input class=\"govuk-input govuk-date-input__input govuk-input--width-2\"\n [ngClass]=\"{'govuk-input--error': errorMessage?.isInvalid}\"\n [id]=\"config.id+'-month'\"\n [name]=\"config.id+'-month'\" type=\"number\" value=\"\" pattern=\"[0-9]*\"\n [formControlName]=\"config.id+'_month'\">\n </div>\n </div>\n <div class=\"govuk-date-input__item\">\n <div class=\"govuk-form-group\">\n <xuilib-gov-label\n [config]=\"{label: 'Year', name: config.id+'-year', id: config.id+'-year', classes: 'govuk-date-input__label'}\">\n </xuilib-gov-label>\n <input class=\"govuk-input govuk-date-input__input govuk-input--width-4\"\n [ngClass]=\"{'govuk-input--error': errorMessage?.isInvalid}\"\n [id]=\"config.id+'-year'\"\n [name]=\"config.id+'-year'\" type=\"number\" value=\"\" pattern=\"[0-9]*\"\n [formControlName]=\"config.id+'_year'\">\n </div>\n </div>\n </div>\n </xuilib-gov-uk-fieldset>\n </div>\n</div>\n",
4616
4598
  styles: [".govuk-form-group .date-input-container{margin-bottom:30px}.govuk-form-group .date-input-container .govuk-date-input .govuk-date-input__item .govuk-form-group{margin-bottom:0}"]
4617
4599
  }] }
4618
4600
  ];
4619
4601
  /** @nocollapse */
4620
4602
  GovUkDateComponent.ctorParameters = function () { return []; };
4621
4603
  GovUkDateComponent.propDecorators = {
4622
- form: [{ type: i0.ViewChild, args: ['form',] }],
4623
4604
  config: [{ type: i0.Input }],
4624
4605
  errorMessage: [{ type: i0.Input }],
4625
4606
  formGroup: [{ type: i0.Input }]