@hmcts/rpx-xui-common-lib 1.9.0-postcode-validation → 1.9.0-route-expected-feature
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.
- package/bundles/hmcts-rpx-xui-common-lib.umd.js +44 -8
- package/bundles/hmcts-rpx-xui-common-lib.umd.js.map +1 -1
- package/bundles/hmcts-rpx-xui-common-lib.umd.min.js +1 -1
- package/bundles/hmcts-rpx-xui-common-lib.umd.min.js.map +1 -1
- package/esm2015/lib/components/write-address/write-address.component.js +41 -6
- package/esm2015/lib/models/address-message.enum.js +3 -2
- package/esm2015/lib/services/address/address.service.js +2 -2
- package/esm2015/lib/services/feature-toggle/feature-toggle.guard.js +2 -2
- package/fesm2015/hmcts-rpx-xui-common-lib.js +44 -8
- package/fesm2015/hmcts-rpx-xui-common-lib.js.map +1 -1
- package/hmcts-rpx-xui-common-lib.metadata.json +1 -1
- package/lib/components/write-address/write-address.component.d.ts +9 -1
- package/lib/models/address-message.enum.d.ts +2 -1
- package/package.json +1 -1
|
@@ -783,7 +783,7 @@
|
|
|
783
783
|
*/
|
|
784
784
|
FeatureToggleGuard.prototype.canActivate = function (route) {
|
|
785
785
|
var _this = this;
|
|
786
|
-
return rxjs.combineLatest
|
|
786
|
+
return rxjs.combineLatest(__spread(route.data.needsFeaturesEnabled.map(function (feature) { return _this.featureToggleService.getValueOnce(feature, false); }))).pipe(operators.map(function (featureStatuses) { return featureStatuses.every(function (status) { return status; }); }), operators.map(function (status) { return (route.data.expectFeatureEnabled !== false && status) || (!route.data.expectFeatureEnabled && !status) || _this.router.parseUrl(route.data.featureDisabledRedirect); }));
|
|
787
787
|
};
|
|
788
788
|
return FeatureToggleGuard;
|
|
789
789
|
}());
|
|
@@ -863,7 +863,8 @@
|
|
|
863
863
|
AddressMessageEnum["NO_STREET_SELECTED"] = "Enter building and street";
|
|
864
864
|
AddressMessageEnum["NO_CITY_SELECTED"] = "Enter town or city";
|
|
865
865
|
AddressMessageEnum["NO_COUNTRY_SELECTED"] = "Enter country";
|
|
866
|
-
AddressMessageEnum["NO_POSTCODE_SELECTED"] = "Enter postcode";
|
|
866
|
+
AddressMessageEnum["NO_POSTCODE_SELECTED"] = "Enter a valid postcode";
|
|
867
|
+
AddressMessageEnum["SELECT_ADDRESS"] = "Select an address";
|
|
867
868
|
AddressMessageEnum["INVALID_POSTCODE"] = "Enter valid postcode";
|
|
868
869
|
})(exports.AddressMessageEnum || (exports.AddressMessageEnum = {}));
|
|
869
870
|
|
|
@@ -1046,7 +1047,7 @@
|
|
|
1046
1047
|
return this.http
|
|
1047
1048
|
.get('/external/addresses?postcode=${postcode}'.replace('${postcode}', postcode), undefined)
|
|
1048
1049
|
.pipe(operators.map(function (res) { return res.results; }))
|
|
1049
|
-
.pipe(operators.map(function (output) { return output.map(function (addresses) { return _this.format(new AddressParser().parse(addresses[AddressType.DPA])); }); }));
|
|
1050
|
+
.pipe(operators.map(function (output) { return output ? output.map(function (addresses) { return _this.format(new AddressParser().parse(addresses[AddressType.DPA])); }) : []; }));
|
|
1050
1051
|
};
|
|
1051
1052
|
AddressService.prototype.format = function (addressModel) {
|
|
1052
1053
|
return this.formatAddressLines(this.shiftAddressLinesUp(addressModel));
|
|
@@ -4854,9 +4855,15 @@
|
|
|
4854
4855
|
this.addressesService = addressesService;
|
|
4855
4856
|
this.internationalMode = false;
|
|
4856
4857
|
this.submissionAttempted = false;
|
|
4858
|
+
this.addressChosen = false;
|
|
4857
4859
|
this.postcodeOptionSelected = new i0.EventEmitter();
|
|
4858
4860
|
this.internationalModeStart = new i0.EventEmitter();
|
|
4859
4861
|
this.ukAddressOptionSelected = new i0.EventEmitter();
|
|
4862
|
+
// indicated what error to display to user
|
|
4863
|
+
this.canSelectAddress = new i0.EventEmitter();
|
|
4864
|
+
// tells parent to reset submission attempted field
|
|
4865
|
+
// only relevant to when user re-clicks find address
|
|
4866
|
+
this.resetSubmission = new i0.EventEmitter();
|
|
4860
4867
|
this.addressField = {
|
|
4861
4868
|
addressLine1: '',
|
|
4862
4869
|
addressLine2: '',
|
|
@@ -4867,9 +4874,11 @@
|
|
|
4867
4874
|
county: ''
|
|
4868
4875
|
};
|
|
4869
4876
|
this.optionErrorsPresent = false;
|
|
4870
|
-
this.
|
|
4877
|
+
this.addressSelectable = false;
|
|
4871
4878
|
this.missingPostcode = false;
|
|
4872
4879
|
this.optionErrorMessage = exports.AddressMessageEnum.NO_OPTION_SELECTED;
|
|
4880
|
+
this.postcodeErrorMessage = exports.AddressMessageEnum.NO_POSTCODE_SELECTED;
|
|
4881
|
+
this.selectErrorMessage = exports.AddressMessageEnum.SELECT_ADDRESS;
|
|
4873
4882
|
}
|
|
4874
4883
|
WriteAddressFieldComponent.prototype.ngOnInit = function () {
|
|
4875
4884
|
if (!this.formGroup.get('address')) {
|
|
@@ -4883,11 +4892,14 @@
|
|
|
4883
4892
|
postcode: new forms.FormControl(''),
|
|
4884
4893
|
addressList: new forms.FormControl('')
|
|
4885
4894
|
});
|
|
4895
|
+
this.setPostcodeForm();
|
|
4886
4896
|
};
|
|
4887
4897
|
WriteAddressFieldComponent.prototype.findAddress = function () {
|
|
4888
4898
|
var _this = this;
|
|
4899
|
+
this.resetSubmission.emit();
|
|
4889
4900
|
if (!this.addressFormGroup.get('postcode').value) {
|
|
4890
4901
|
this.missingPostcode = true;
|
|
4902
|
+
this.canSelectAddress.emit(false);
|
|
4891
4903
|
}
|
|
4892
4904
|
else {
|
|
4893
4905
|
this.missingPostcode = false;
|
|
@@ -4900,6 +4912,7 @@
|
|
|
4900
4912
|
});
|
|
4901
4913
|
_this.addressOptions.unshift(new AddressOption(undefined, _this.defaultLabel(_this.addressOptions.length)));
|
|
4902
4914
|
}, function (error) {
|
|
4915
|
+
// Edited this so that errors not produced if there are no results for a postcode
|
|
4903
4916
|
console.log("An error occurred retrieving addresses for postcode " + postcode_1 + ". " + error);
|
|
4904
4917
|
_this.addressOptions.unshift(new AddressOption(undefined, _this.defaultLabel(_this.addressOptions.length)));
|
|
4905
4918
|
});
|
|
@@ -4908,6 +4921,7 @@
|
|
|
4908
4921
|
};
|
|
4909
4922
|
WriteAddressFieldComponent.prototype.blankAddress = function () {
|
|
4910
4923
|
this.setFormValue();
|
|
4924
|
+
this.resetSubmission.emit();
|
|
4911
4925
|
if (this.internationalMode) {
|
|
4912
4926
|
this.internationalModeStart.emit();
|
|
4913
4927
|
}
|
|
@@ -4928,6 +4942,7 @@
|
|
|
4928
4942
|
return hasAddress;
|
|
4929
4943
|
};
|
|
4930
4944
|
WriteAddressFieldComponent.prototype.addressSelected = function () {
|
|
4945
|
+
this.missingPostcode = false;
|
|
4931
4946
|
this.addressField = this.addressFormGroup.get('addressList').value;
|
|
4932
4947
|
this.addressChosen = true;
|
|
4933
4948
|
this.setFormValue();
|
|
@@ -4942,12 +4957,17 @@
|
|
|
4942
4957
|
if (internationalChange && this.addressFormGroup && this.addressFormGroup.get('ukAddress')) {
|
|
4943
4958
|
this.addressFormGroup.get('ukAddress').patchValue(this.isInternational ? 'no' : 'yes');
|
|
4944
4959
|
}
|
|
4960
|
+
if (!this.addressChosen && this.addressFormGroup && this.addressFormGroup.get('addressList')) {
|
|
4961
|
+
// resets address options on internal back
|
|
4962
|
+
this.addressFormGroup.get('addressList').patchValue(undefined);
|
|
4963
|
+
}
|
|
4945
4964
|
this.checkIfErrorsNeeded();
|
|
4946
4965
|
};
|
|
4947
4966
|
WriteAddressFieldComponent.prototype.checkIfErrorsNeeded = function () {
|
|
4948
|
-
if (this.submissionAttempted && this.
|
|
4967
|
+
if (this.submissionAttempted && this.internationalMode && !this.postcodeLookupVisible()) {
|
|
4949
4968
|
// ensure errors present when submission attmempted on international radio buttons
|
|
4950
4969
|
this.optionErrorsPresent = true;
|
|
4970
|
+
this.optionErrorMessage = exports.AddressMessageEnum.NO_OPTION_SELECTED;
|
|
4951
4971
|
}
|
|
4952
4972
|
else {
|
|
4953
4973
|
this.optionErrorsPresent = false;
|
|
@@ -4961,7 +4981,16 @@
|
|
|
4961
4981
|
this.isInternational = isInternational;
|
|
4962
4982
|
this.ukAddressOptionSelected.emit(this.isInternational);
|
|
4963
4983
|
};
|
|
4984
|
+
WriteAddressFieldComponent.prototype.postcodeErrorPresent = function (isPostcodeField) {
|
|
4985
|
+
var checkForField = isPostcodeField ? !this.addressSelectable : this.addressSelectable;
|
|
4986
|
+
return this.submissionAttempted && checkForField;
|
|
4987
|
+
};
|
|
4988
|
+
WriteAddressFieldComponent.prototype.postcodeLookupVisible = function () {
|
|
4989
|
+
return !this.shouldShowDetailFields() || (!this.startedInternational && !this.addressChosen);
|
|
4990
|
+
};
|
|
4964
4991
|
WriteAddressFieldComponent.prototype.defaultLabel = function (numberOfAddresses) {
|
|
4992
|
+
this.addressSelectable = numberOfAddresses > 0 ? true : false;
|
|
4993
|
+
this.canSelectAddress.emit(this.addressSelectable);
|
|
4965
4994
|
return numberOfAddresses === 0 ? 'No address found'
|
|
4966
4995
|
: "" + numberOfAddresses + (numberOfAddresses === 1 ? ' address ' : ' addresses ') + "found";
|
|
4967
4996
|
};
|
|
@@ -4970,13 +4999,17 @@
|
|
|
4970
4999
|
this.formGroup.get('address').patchValue(this.addressField);
|
|
4971
5000
|
}
|
|
4972
5001
|
};
|
|
5002
|
+
WriteAddressFieldComponent.prototype.setPostcodeForm = function () {
|
|
5003
|
+
var postcodeNeeded = this.isInternational === undefined && this.formGroup.get('address') && this.formGroup.get('address').get('postCode');
|
|
5004
|
+
this.addressFormGroup.get('postcode').patchValue(postcodeNeeded ? this.formGroup.get('address').get('postCode').value : '');
|
|
5005
|
+
};
|
|
4973
5006
|
return WriteAddressFieldComponent;
|
|
4974
5007
|
}());
|
|
4975
5008
|
WriteAddressFieldComponent.decorators = [
|
|
4976
5009
|
{ type: i0.Component, args: [{
|
|
4977
5010
|
selector: 'xuilib-write-address-field',
|
|
4978
|
-
template: "<div class=\"govuk-form-group\" [formGroup]=\"addressFormGroup\" [ngClass]=\"{'govuk-form-group--error': optionErrorsPresent}\">\n <p class=\"govuk-error-message\" *ngIf=\"optionErrorsPresent\">\n <span class=\"govuk-visually-hidden\">Error:</span>{{optionErrorMessage}}\n </p>\n <div *ngIf=\"
|
|
4979
|
-
styles: [".manual-link{cursor:pointer;text-decoration:underline}.manual-link,:host{display:block}"]
|
|
5011
|
+
template: "<div class=\"govuk-form-group\" [formGroup]=\"addressFormGroup\" [ngClass]=\"{'govuk-form-group--error': optionErrorsPresent}\">\n <p class=\"govuk-error-message\" *ngIf=\"optionErrorsPresent\">\n <span class=\"govuk-visually-hidden\">Error:</span>{{optionErrorMessage}}\n </p>\n <div *ngIf=\"postcodeLookupVisible()\">\n <div class=\"govuk-form-group postcodeLookup\" id=\"addressLookup\">\n <label for=\"postcodeInput\">\n <span class=\"govuk-label\"><b>Provide address details</b></span>\n <span class=\"govuk-label\">Enter a UK postcode</span>\n </label>\n <div class=\"govuk-form-group\"\n [ngClass]=\"{'govuk-form-group--error': missingPostcode || postcodeErrorPresent(true)}\">\n <p class=\"govuk-error-message\" *ngIf=\"missingPostcode || postcodeErrorPresent(true)\">\n <span class=\"govuk-visually-hidden\">Error:</span>{{postcodeErrorMessage}}\n </p>\n <input type=\"text\" [ngClass]=\"{'govuk-input--error': missingPostcode}\" id=\"postcodeInput\" name=\"postcode\"\n class=\"govuk-input govuk-!-width-two-thirds postcodeinput inline-block\" formControlName=\"postcode\">\n <button type=\"button\" class=\"govuk-button\" (click)=\"findAddress()\">Find address</button>\n </div>\n </div>\n\n <div class=\"govuk-form-group\"\n *ngIf=\"addressOptions\" id=\"selectAddress\">\n <label class=\"govuk-label\" for=\"addressList\">\n <span class=\"form-label\">Select an address</span>\n </label>\n <div class=\"govuk-form-group\"\n [ngClass]=\"{'govuk-form-group--error': postcodeErrorPresent(false)}\">\n <p class=\"govuk-error-message\" *ngIf=\"postcodeErrorPresent(false)\">\n <span class=\"govuk-visually-hidden\">Error:</span>{{selectErrorMessage}}\n </p>\n <select class=\"form-control govuk-select ccd-dropdown addressList\" id=\"addressList\" name=\"address\"\n formControlName=\"addressList\" (change)=\"addressSelected()\" focusElement>\n <option *ngFor=\"let addressOption of addressOptions\" [ngValue]=\"addressOption.value\">\n {{addressOption.description}}\n </option>\n </select>\n </div>\n </div>\n\n <a class=\"manual-link govuk-link\" *ngIf=\"!shouldShowDetailFields() || (!startedInternational && !addressChosen)\" (click)=\"blankAddress()\"\n href=\"javascript:void(0)\">I can't enter a UK postcode</a>\n </div>\n\n <div class=\"govuk-radios\" data-module=\"govuk-radios\"\n *ngIf=\"shouldShowDetailFields() && internationalMode && startedInternational && !addressChosen\">\n <div class=\"govuk-radios__item\">\n <input class=\"govuk-radios__input\" id=\"yes\" value=\"yes\" name=\"ukAddress\" type=\"radio\" data-aria-controls=\"address-fields\"\n (click)=\"setInternationalAddress(false)\" formControlName=\"ukAddress\">\n <label class=\"govuk-label govuk-radios__label\" for=\"yes\">\n Yes\n </label>\n </div>\n <div class=\"govuk-radios__item\">\n <input class=\"govuk-radios__input\" id=\"no\" value=\"no\" name=\"ukAddress\" type=\"radio\" data-aria-controls=\"address-fields\"\n (click)=\"setInternationalAddress(true)\" formControlName=\"ukAddress\">\n <label class=\"govuk-label govuk-radios__label\" for=\"no\">\n No\n </label>\n </div>\n <div class=\"govuk-radios__conditional\" id=\"address-fields\">\n <xuilib-write-address-inputs *ngIf=\"isInternational !== undefined\" [formGroup]=\"formGroup\" [isInternational]=\"isInternational\"\n [submissionAttempted]=\"submissionAttempted\">\n </xuilib-write-address-inputs>\n </div>\n </div>\n\n <xuilib-write-address-inputs *ngIf=\"shouldShowDetailFields() && (addressChosen || !internationalMode)\"\n [formGroup]=\"formGroup\" [isInternational]=\"false\" [submissionAttempted]=\"submissionAttempted\"></xuilib-write-address-inputs>\n\n</div>",
|
|
5012
|
+
styles: [".manual-link{cursor:pointer;text-decoration:underline;margin-top:10px}.manual-link,:host{display:block}"]
|
|
4980
5013
|
},] }
|
|
4981
5014
|
];
|
|
4982
5015
|
WriteAddressFieldComponent.ctorParameters = function () { return [
|
|
@@ -4988,9 +5021,12 @@
|
|
|
4988
5021
|
isInternational: [{ type: i0.Input }],
|
|
4989
5022
|
submissionAttempted: [{ type: i0.Input }],
|
|
4990
5023
|
startedInternational: [{ type: i0.Input }],
|
|
5024
|
+
addressChosen: [{ type: i0.Input }],
|
|
4991
5025
|
postcodeOptionSelected: [{ type: i0.Output }],
|
|
4992
5026
|
internationalModeStart: [{ type: i0.Output }],
|
|
4993
|
-
ukAddressOptionSelected: [{ type: i0.Output }]
|
|
5027
|
+
ukAddressOptionSelected: [{ type: i0.Output }],
|
|
5028
|
+
canSelectAddress: [{ type: i0.Output }],
|
|
5029
|
+
resetSubmission: [{ type: i0.Output }]
|
|
4994
5030
|
};
|
|
4995
5031
|
|
|
4996
5032
|
var WriteAddressInputsComponent = /** @class */ (function () {
|