@hmcts/rpx-xui-common-lib 1.9.0-address-non-postcode-2 → 1.9.0-address-lookup-full
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 +42 -7
- 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 +40 -6
- package/esm2015/lib/models/address-message.enum.js +3 -2
- package/esm2015/lib/services/address/address.service.js +2 -2
- package/fesm2015/hmcts-rpx-xui-common-lib.js +42 -7
- 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 +8 -1
- package/lib/models/address-message.enum.d.ts +2 -1
- package/package.json +1 -1
|
@@ -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
|
})(exports.AddressMessageEnum || (exports.AddressMessageEnum = {}));
|
|
868
869
|
|
|
869
870
|
var AddressOption = /** @class */ (function () {
|
|
@@ -1045,7 +1046,7 @@
|
|
|
1045
1046
|
return this.http
|
|
1046
1047
|
.get('/external/addresses?postcode=${postcode}'.replace('${postcode}', postcode), undefined)
|
|
1047
1048
|
.pipe(operators.map(function (res) { return res.results; }))
|
|
1048
|
-
.pipe(operators.map(function (output) { return output.map(function (addresses) { return _this.format(new AddressParser().parse(addresses[AddressType.DPA])); }); }));
|
|
1049
|
+
.pipe(operators.map(function (output) { return output ? output.map(function (addresses) { return _this.format(new AddressParser().parse(addresses[AddressType.DPA])); }) : []; }));
|
|
1049
1050
|
};
|
|
1050
1051
|
AddressService.prototype.format = function (addressModel) {
|
|
1051
1052
|
return this.formatAddressLines(this.shiftAddressLinesUp(addressModel));
|
|
@@ -4853,9 +4854,15 @@
|
|
|
4853
4854
|
this.addressesService = addressesService;
|
|
4854
4855
|
this.internationalMode = false;
|
|
4855
4856
|
this.submissionAttempted = false;
|
|
4857
|
+
this.addressChosen = false;
|
|
4856
4858
|
this.postcodeOptionSelected = new i0.EventEmitter();
|
|
4857
4859
|
this.internationalModeStart = new i0.EventEmitter();
|
|
4858
4860
|
this.ukAddressOptionSelected = new i0.EventEmitter();
|
|
4861
|
+
// indicated what error to display to user
|
|
4862
|
+
this.canSelectAddress = new i0.EventEmitter();
|
|
4863
|
+
// tells parent to reset submission attempted field
|
|
4864
|
+
// only relevant to when user re-clicks find address
|
|
4865
|
+
this.resetSubmission = new i0.EventEmitter();
|
|
4859
4866
|
this.addressField = {
|
|
4860
4867
|
addressLine1: '',
|
|
4861
4868
|
addressLine2: '',
|
|
@@ -4866,9 +4873,11 @@
|
|
|
4866
4873
|
county: ''
|
|
4867
4874
|
};
|
|
4868
4875
|
this.optionErrorsPresent = false;
|
|
4869
|
-
this.
|
|
4876
|
+
this.addressSelectable = false;
|
|
4870
4877
|
this.missingPostcode = false;
|
|
4871
4878
|
this.optionErrorMessage = exports.AddressMessageEnum.NO_OPTION_SELECTED;
|
|
4879
|
+
this.postcodeErrorMessage = exports.AddressMessageEnum.NO_POSTCODE_SELECTED;
|
|
4880
|
+
this.selectErrorMessage = exports.AddressMessageEnum.SELECT_ADDRESS;
|
|
4872
4881
|
}
|
|
4873
4882
|
WriteAddressFieldComponent.prototype.ngOnInit = function () {
|
|
4874
4883
|
if (!this.formGroup.get('address')) {
|
|
@@ -4885,8 +4894,10 @@
|
|
|
4885
4894
|
};
|
|
4886
4895
|
WriteAddressFieldComponent.prototype.findAddress = function () {
|
|
4887
4896
|
var _this = this;
|
|
4897
|
+
this.resetSubmission.emit();
|
|
4888
4898
|
if (!this.addressFormGroup.get('postcode').value) {
|
|
4889
4899
|
this.missingPostcode = true;
|
|
4900
|
+
this.canSelectAddress.emit(false);
|
|
4890
4901
|
}
|
|
4891
4902
|
else {
|
|
4892
4903
|
this.missingPostcode = false;
|
|
@@ -4899,6 +4910,7 @@
|
|
|
4899
4910
|
});
|
|
4900
4911
|
_this.addressOptions.unshift(new AddressOption(undefined, _this.defaultLabel(_this.addressOptions.length)));
|
|
4901
4912
|
}, function (error) {
|
|
4913
|
+
// Edited this so that errors not produced if there are no results for a postcode
|
|
4902
4914
|
console.log("An error occurred retrieving addresses for postcode " + postcode_1 + ". " + error);
|
|
4903
4915
|
_this.addressOptions.unshift(new AddressOption(undefined, _this.defaultLabel(_this.addressOptions.length)));
|
|
4904
4916
|
});
|
|
@@ -4907,6 +4919,7 @@
|
|
|
4907
4919
|
};
|
|
4908
4920
|
WriteAddressFieldComponent.prototype.blankAddress = function () {
|
|
4909
4921
|
this.setFormValue();
|
|
4922
|
+
this.resetSubmission.emit();
|
|
4910
4923
|
if (this.internationalMode) {
|
|
4911
4924
|
this.internationalModeStart.emit();
|
|
4912
4925
|
}
|
|
@@ -4927,6 +4940,7 @@
|
|
|
4927
4940
|
return hasAddress;
|
|
4928
4941
|
};
|
|
4929
4942
|
WriteAddressFieldComponent.prototype.addressSelected = function () {
|
|
4943
|
+
this.missingPostcode = false;
|
|
4930
4944
|
this.addressField = this.addressFormGroup.get('addressList').value;
|
|
4931
4945
|
this.addressChosen = true;
|
|
4932
4946
|
this.setFormValue();
|
|
@@ -4934,15 +4948,24 @@
|
|
|
4934
4948
|
};
|
|
4935
4949
|
WriteAddressFieldComponent.prototype.ngOnChanges = function (changes) {
|
|
4936
4950
|
var addressChange = changes['addressField'];
|
|
4951
|
+
var internationalChange = changes['isInternational'];
|
|
4937
4952
|
if (addressChange) {
|
|
4938
4953
|
this.setFormValue();
|
|
4939
4954
|
}
|
|
4955
|
+
if (internationalChange && this.addressFormGroup && this.addressFormGroup.get('ukAddress')) {
|
|
4956
|
+
this.addressFormGroup.get('ukAddress').patchValue(this.isInternational ? 'no' : 'yes');
|
|
4957
|
+
}
|
|
4958
|
+
if (!this.addressChosen && this.addressFormGroup && this.addressFormGroup.get('addressList')) {
|
|
4959
|
+
// resets address options on internal back
|
|
4960
|
+
this.addressFormGroup.get('addressList').patchValue(undefined);
|
|
4961
|
+
}
|
|
4940
4962
|
this.checkIfErrorsNeeded();
|
|
4941
4963
|
};
|
|
4942
4964
|
WriteAddressFieldComponent.prototype.checkIfErrorsNeeded = function () {
|
|
4943
|
-
if (this.submissionAttempted && this.
|
|
4965
|
+
if (this.submissionAttempted && this.internationalMode && !this.postcodeLookupVisible()) {
|
|
4944
4966
|
// ensure errors present when submission attmempted on international radio buttons
|
|
4945
4967
|
this.optionErrorsPresent = true;
|
|
4968
|
+
this.optionErrorMessage = exports.AddressMessageEnum.NO_OPTION_SELECTED;
|
|
4946
4969
|
}
|
|
4947
4970
|
else {
|
|
4948
4971
|
this.optionErrorsPresent = false;
|
|
@@ -4956,7 +4979,16 @@
|
|
|
4956
4979
|
this.isInternational = isInternational;
|
|
4957
4980
|
this.ukAddressOptionSelected.emit(this.isInternational);
|
|
4958
4981
|
};
|
|
4982
|
+
WriteAddressFieldComponent.prototype.postcodeErrorPresent = function (isPostcodeField) {
|
|
4983
|
+
var checkForField = isPostcodeField ? !this.addressSelectable : this.addressSelectable;
|
|
4984
|
+
return this.submissionAttempted && checkForField;
|
|
4985
|
+
};
|
|
4986
|
+
WriteAddressFieldComponent.prototype.postcodeLookupVisible = function () {
|
|
4987
|
+
return !this.shouldShowDetailFields() || (!this.startedInternational && !this.addressChosen);
|
|
4988
|
+
};
|
|
4959
4989
|
WriteAddressFieldComponent.prototype.defaultLabel = function (numberOfAddresses) {
|
|
4990
|
+
this.addressSelectable = numberOfAddresses > 0 ? true : false;
|
|
4991
|
+
this.canSelectAddress.emit(this.addressSelectable);
|
|
4960
4992
|
return numberOfAddresses === 0 ? 'No address found'
|
|
4961
4993
|
: "" + numberOfAddresses + (numberOfAddresses === 1 ? ' address ' : ' addresses ') + "found";
|
|
4962
4994
|
};
|
|
@@ -4970,8 +5002,8 @@
|
|
|
4970
5002
|
WriteAddressFieldComponent.decorators = [
|
|
4971
5003
|
{ type: i0.Component, args: [{
|
|
4972
5004
|
selector: 'xuilib-write-address-field',
|
|
4973
|
-
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=\"
|
|
4974
|
-
styles: [".manual-link{cursor:pointer;text-decoration:underline}.manual-link,:host{display:block}"]
|
|
5005
|
+
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>",
|
|
5006
|
+
styles: [".manual-link{cursor:pointer;text-decoration:underline;margin-top:10px}.manual-link,:host{display:block}"]
|
|
4975
5007
|
},] }
|
|
4976
5008
|
];
|
|
4977
5009
|
WriteAddressFieldComponent.ctorParameters = function () { return [
|
|
@@ -4983,9 +5015,12 @@
|
|
|
4983
5015
|
isInternational: [{ type: i0.Input }],
|
|
4984
5016
|
submissionAttempted: [{ type: i0.Input }],
|
|
4985
5017
|
startedInternational: [{ type: i0.Input }],
|
|
5018
|
+
addressChosen: [{ type: i0.Input }],
|
|
4986
5019
|
postcodeOptionSelected: [{ type: i0.Output }],
|
|
4987
5020
|
internationalModeStart: [{ type: i0.Output }],
|
|
4988
|
-
ukAddressOptionSelected: [{ type: i0.Output }]
|
|
5021
|
+
ukAddressOptionSelected: [{ type: i0.Output }],
|
|
5022
|
+
canSelectAddress: [{ type: i0.Output }],
|
|
5023
|
+
resetSubmission: [{ type: i0.Output }]
|
|
4989
5024
|
};
|
|
4990
5025
|
|
|
4991
5026
|
var WriteAddressInputsComponent = /** @class */ (function () {
|