@bpost/bp-address-auto-complete-by-component 1.1.25 → 1.1.26

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.
@@ -1756,7 +1756,7 @@ class StreetComponent {
1756
1756
  ngOnChanges(changes) {
1757
1757
  if (changes) {
1758
1758
  if (changes.hasOwnProperty('autofillData') && changes.autofillData.currentValue !== null && changes.autofillData.currentValue !== undefined) {
1759
- this.searchText = this.autofillData.streetName;
1759
+ this.searchText = this.loadAutoFillParams(changes.autofillData.currentValue);
1760
1760
  this.setSelectedAddress(this.autofillData.selectedAddress);
1761
1761
  }
1762
1762
  else {
@@ -1984,6 +1984,21 @@ class StreetComponent {
1984
1984
  }
1985
1985
  return concatStr;
1986
1986
  }
1987
+ loadAutoFillParams(autoFillData) {
1988
+ let concatStr = '';
1989
+ if (autoFillData !== null) {
1990
+ if (autoFillData.hasOwnProperty('postalCode') && this.isString(autoFillData.postalCode)) {
1991
+ this.postalCode = autoFillData.postalCode;
1992
+ }
1993
+ if (autoFillData.hasOwnProperty('municipalityName') && this.isString(autoFillData.municipalityName)) {
1994
+ this.locality = autoFillData.municipalityName;
1995
+ }
1996
+ if (autoFillData.hasOwnProperty('streetName') && this.isString(autoFillData.streetName)) {
1997
+ concatStr = autoFillData.streetName;
1998
+ }
1999
+ }
2000
+ return concatStr;
2001
+ }
1987
2002
  isString(val) {
1988
2003
  if (val === null || val === undefined) {
1989
2004
  return false;
@@ -2614,8 +2629,7 @@ class StreetNumberComponent {
2614
2629
  ngOnChanges(changes) {
2615
2630
  if (changes) {
2616
2631
  if (changes.hasOwnProperty('autofillData') && changes.autofillData.currentValue !== null && changes.autofillData.currentValue !== undefined) {
2617
- this.searchText = this.autofillData.streetNumber;
2618
- this.addressIsComplete = this.autofillData.isCompleteStreetNumber;
2632
+ this.searchText = this.loadAutoFillParams(changes.autofillData.currentValue);
2619
2633
  this.setSelectedAddress(this.autofillData.selectedAddress);
2620
2634
  }
2621
2635
  else {
@@ -2836,6 +2850,28 @@ class StreetNumberComponent {
2836
2850
  }
2837
2851
  return concatStr;
2838
2852
  }
2853
+ loadAutoFillParams(autoFillData) {
2854
+ let concatStr = '';
2855
+ if (autoFillData !== null) {
2856
+ if (autoFillData.hasOwnProperty('postalCode') && this.isString(autoFillData.postalCode)) {
2857
+ this.postalCode = autoFillData.postalCode;
2858
+ }
2859
+ if (autoFillData.hasOwnProperty('municipalityName') && this.isString(autoFillData.municipalityName)) {
2860
+ this.locality = autoFillData.municipalityName;
2861
+ }
2862
+ if (autoFillData.hasOwnProperty('streetName') && this.isString(autoFillData.streetName)) {
2863
+ this.streetName = autoFillData.streetName;
2864
+ }
2865
+ if (autoFillData.hasOwnProperty('streetNumber')
2866
+ && this.isString(autoFillData.streetNumber)) {
2867
+ concatStr = autoFillData.streetNumber;
2868
+ }
2869
+ if (autoFillData.hasOwnProperty('isCompleteStreetNumber')) {
2870
+ this.addressIsComplete = this.autofillData.isCompleteStreetNumber;
2871
+ }
2872
+ }
2873
+ return concatStr;
2874
+ }
2839
2875
  isString(val) {
2840
2876
  if (val === null || val === undefined) {
2841
2877
  return false;
@@ -3448,7 +3484,7 @@ class StreetNumberComponent {
3448
3484
  return this.searchText && this.searchText.length > 0;
3449
3485
  }
3450
3486
  onClearStreetNumberInput(focus, emit = true) {
3451
- console.warn('street number :: clearInput');
3487
+ // console.warn('street number :: clearInput');
3452
3488
  this.clearWidget();
3453
3489
  this.resetArrowSelectedIndex();
3454
3490
  this.previousIndex = -1;
@@ -3690,8 +3726,7 @@ class BoxNumberComponent {
3690
3726
  ngOnChanges(changes) {
3691
3727
  if (changes) {
3692
3728
  if (changes.hasOwnProperty('autofillData') && changes.autofillData.currentValue !== null && changes.autofillData.currentValue !== undefined) {
3693
- this.searchText = this.autofillData.boxNumber;
3694
- this.addressIsValidated = this.autofillData.isCompleteBoxNumber;
3729
+ this.searchText = this.loadAutoFillParams(changes.autofillData.currentValue);
3695
3730
  this.setSelectedAddress(this.autofillData.selectedAddress);
3696
3731
  }
3697
3732
  else {
@@ -3888,6 +3923,32 @@ class BoxNumberComponent {
3888
3923
  }
3889
3924
  return concatStr;
3890
3925
  }
3926
+ loadAutoFillParams(autoFillData) {
3927
+ let concatStr = '';
3928
+ if (autoFillData !== null) {
3929
+ if (autoFillData.hasOwnProperty('postalCode') && this.isString(autoFillData.postalCode)) {
3930
+ this.postalCode = autoFillData.postalCode;
3931
+ }
3932
+ if (autoFillData.hasOwnProperty('municipalityName') && this.isString(autoFillData.municipalityName)) {
3933
+ this.locality = autoFillData.municipalityName;
3934
+ }
3935
+ if (autoFillData.hasOwnProperty('streetName') && this.isString(autoFillData.streetName)) {
3936
+ this.streetName = autoFillData.streetName;
3937
+ }
3938
+ if (autoFillData.hasOwnProperty('streetNumber')
3939
+ && this.isString(autoFillData.streetNumber)) {
3940
+ this.streetNumber = autoFillData.streetNumber;
3941
+ }
3942
+ if (autoFillData.hasOwnProperty('boxNumber')
3943
+ && this.isString(autoFillData.boxNumber)) {
3944
+ concatStr = autoFillData.boxNumber;
3945
+ }
3946
+ if (autoFillData.hasOwnProperty('isCompleteBoxNumber')) {
3947
+ this.addressIsValidated = this.autofillData.isCompleteBoxNumber;
3948
+ }
3949
+ }
3950
+ return concatStr;
3951
+ }
3891
3952
  isString(val) {
3892
3953
  if (val === null || val === undefined) {
3893
3954
  return false;
@@ -4790,6 +4851,7 @@ class LibAddressAutocompleteByComponentComponent {
4790
4851
  console.log('lib::widget detected prefilling', this.addressParams);
4791
4852
  }
4792
4853
  this.addressParams.minLevel = /*4*/ ADDRESSLEVEL.LOCALITY;
4854
+ this.minLevel = this.addressParams.minLevel;
4793
4855
  // this.localityPrefillData = this.addressParams; // as any as PrefillData;
4794
4856
  this.localityPrefillData = new PrefillData(this.addressParams);
4795
4857
  // Object.assign(this.localityPrefillData, this.addressParams);
@@ -5039,7 +5101,7 @@ class LibAddressAutocompleteByComponentComponent {
5039
5101
  if (this.showDebugMessageToConsole) {
5040
5102
  console.log('notifyAddressComplete', this.selectedAddress, 'nis9InResponse:' + this.nis9InResponse, typeof this.nis9InResponse);
5041
5103
  }
5042
- if (this.selectedAddress && !this.autocompleteLocality.prefilling) {
5104
+ if (this.selectedAddress) {
5043
5105
  let isCompleteStreetNumber = false;
5044
5106
  let isCompleteBoxNumber = false;
5045
5107
  if (this.selectedAddress.hasOwnProperty('isComplete') && this.selectedAddress.isComplete) {
@@ -5111,6 +5173,7 @@ class LibAddressAutocompleteByComponentComponent {
5111
5173
  this.autocompleteBoxNb.searchText = '';
5112
5174
  this.autocompleteBoxNb.streetNumber = '';
5113
5175
  this.autocompleteBoxNb.clearInput(false, false);
5176
+ this.boxNumberAutofillData = null;
5114
5177
  }
5115
5178
  // Street number
5116
5179
  this.streetNumber = '';
@@ -5121,6 +5184,7 @@ class LibAddressAutocompleteByComponentComponent {
5121
5184
  this.autocompleteStreetNb.searchText = '';
5122
5185
  this.autocompleteStreetNb.streetName = '';
5123
5186
  this.autocompleteStreetNb.onClearStreetNumberInput(false, false);
5187
+ this.streetNumberAutofillData = null;
5124
5188
  }
5125
5189
  // Street name
5126
5190
  this.street = '';
@@ -5130,12 +5194,14 @@ class LibAddressAutocompleteByComponentComponent {
5130
5194
  }
5131
5195
  this.autocompleteStreet.searchText = '';
5132
5196
  this.autocompleteStreet.clearInput(false, false);
5197
+ this.streetNameAutofillData = null;
5133
5198
  }
5134
5199
  // Locality
5135
5200
  this.locality = '';
5136
5201
  if (this.autocompleteLocality) {
5137
5202
  this.autocompleteLocality.searchText = '';
5138
5203
  this.autocompleteLocality.clearInput(false, false);
5204
+ this.autofillData = null;
5139
5205
  }
5140
5206
  nextAddress = null;
5141
5207
  }
@@ -5146,6 +5212,7 @@ class LibAddressAutocompleteByComponentComponent {
5146
5212
  this.autocompleteBoxNb.searchText = '';
5147
5213
  this.autocompleteBoxNb.streetNumber = '';
5148
5214
  this.autocompleteBoxNb.clearInput(false, false);
5215
+ this.boxNumberAutofillData = null;
5149
5216
  }
5150
5217
  // Street number
5151
5218
  this.streetNumber = '';
@@ -5153,12 +5220,14 @@ class LibAddressAutocompleteByComponentComponent {
5153
5220
  this.autocompleteStreetNb.searchText = '';
5154
5221
  this.autocompleteStreetNb.streetName = '';
5155
5222
  this.autocompleteStreetNb.onClearStreetNumberInput(false, false);
5223
+ this.streetNumberAutofillData = null;
5156
5224
  }
5157
5225
  // Street name
5158
5226
  this.street = '';
5159
5227
  if (this.autocompleteStreet) {
5160
5228
  this.autocompleteStreet.searchText = '';
5161
5229
  this.autocompleteStreet.clearInput(false, false);
5230
+ this.streetNameAutofillData = null;
5162
5231
  }
5163
5232
  nextAddress = null;
5164
5233
  }
@@ -5169,6 +5238,7 @@ class LibAddressAutocompleteByComponentComponent {
5169
5238
  this.autocompleteBoxNb.searchText = '';
5170
5239
  this.autocompleteBoxNb.streetNumber = '';
5171
5240
  this.autocompleteBoxNb.clearInput(false, false);
5241
+ this.boxNumberAutofillData = null;
5172
5242
  }
5173
5243
  // Street number
5174
5244
  this.streetNumber = '';
@@ -5176,6 +5246,7 @@ class LibAddressAutocompleteByComponentComponent {
5176
5246
  this.autocompleteStreetNb.searchText = '';
5177
5247
  // this.autocompleteStreetNb.streetName = '';
5178
5248
  this.autocompleteStreetNb.onClearStreetNumberInput(false, false);
5249
+ this.streetNumberAutofillData = null;
5179
5250
  }
5180
5251
  nextAddress = null;
5181
5252
  }
@@ -5187,6 +5258,7 @@ class LibAddressAutocompleteByComponentComponent {
5187
5258
  // this.autocompleteBoxNb.streetNumber = '';
5188
5259
  this.autocompleteBoxNb.clearInput(false, false);
5189
5260
  }
5261
+ this.boxNumberAutofillData = null;
5190
5262
  // Attention: if not-in-list don't reset the address, just modify it
5191
5263
  const addressIsNotInList = nextAddress !== undefined && nextAddress !== null
5192
5264
  && nextAddress.hasOwnProperty('not-in-list') && nextAddress['not-in-list'] === true
@@ -5430,6 +5502,10 @@ class LibAddressAutocompleteByComponentComponent {
5430
5502
  this.autocompleteStreet.locality = '';
5431
5503
  this.autocompleteStreetNb.streetName = '';
5432
5504
  this.autocompleteBoxNb.streetNumber = '';
5505
+ this.autofillData = null;
5506
+ this.streetNameAutofillData = null;
5507
+ this.streetNumberAutofillData = null;
5508
+ this.boxNumberAutofillData = null;
5433
5509
  }
5434
5510
  }
5435
5511
  quitPrefillMode() {
@@ -5584,6 +5660,27 @@ class LibAddressAutocompleteByComponentComponent {
5584
5660
  this.selectedAddress.isCompleteNotificationDone = true;
5585
5661
  this.notifyAddressComplete();
5586
5662
  }
5663
+ if (address && level) {
5664
+ setTimeout(() => {
5665
+ switch (level) {
5666
+ case 4: // Locality filled -> focus street
5667
+ if (address.streetName && this.autocompleteStreet && this.autocompleteStreet.streetSearchInput) {
5668
+ this.autocompleteStreet.streetSearchInput.nativeElement.focus();
5669
+ }
5670
+ break;
5671
+ case 3: // Street filled -> focus street number
5672
+ if (address.houseNumber && this.autocompleteStreetNb && this.autocompleteStreetNb.streetNumberSearchInput) {
5673
+ this.autocompleteStreetNb.streetNumberSearchInput.nativeElement.focus();
5674
+ }
5675
+ break;
5676
+ case 2: // Street number filled -> focus box number
5677
+ if ((address.boxNumber || this.streetNumberAutofillData) && this.autocompleteBoxNb && this.autocompleteBoxNb.boxNumberSearchInput) {
5678
+ this.autocompleteBoxNb.boxNumberSearchInput.nativeElement.focus();
5679
+ }
5680
+ break;
5681
+ }
5682
+ }, 0);
5683
+ }
5587
5684
  }
5588
5685
  setAddressStreetNumber(streetNumber) {
5589
5686
  if (this.showDebugMessageToConsole) {
@@ -5680,6 +5777,9 @@ class LibAddressAutocompleteByComponentComponent {
5680
5777
  this.streetParams = this.addressParams;
5681
5778
  }
5682
5779
  */
5780
+ this.streetNameAutofillData = null;
5781
+ this.streetNumberAutofillData = null;
5782
+ this.boxNumberAutofillData = null;
5683
5783
  const data = event.prefillData;
5684
5784
  if (event.prefillData.prefillMunicipalityPerfectMatchFound === true) {
5685
5785
  const suggestion = data.prefillMunicipalityPerfectMatchSuggestion;
@@ -5718,7 +5818,19 @@ class LibAddressAutocompleteByComponentComponent {
5718
5818
  this.streetPrefillData = this.prefillData;
5719
5819
  }
5720
5820
  */
5721
- this.streetPrefillData = this.prefillData;
5821
+ if (address.streetName) {
5822
+ this.setAddress(address, ADDRESSLEVEL.LOCALITY);
5823
+ this.minLevel = ADDRESSLEVEL.STREET;
5824
+ const streetNumber = this.prefillData.parameters.streetNumber;
5825
+ const boxNumber = this.prefillData.parameters.boxNumber;
5826
+ if (boxNumber && !address.boxNumber) {
5827
+ this.prefillData.parameters.minLevel = ADDRESSLEVEL.BOX_NUMBER;
5828
+ this.boxNumberPrefillData = this.prefillData;
5829
+ }
5830
+ }
5831
+ else {
5832
+ this.streetPrefillData = this.prefillData;
5833
+ }
5722
5834
  }
5723
5835
  else {
5724
5836
  // const cpAndLocality = this.prefillData.parameters.postalCode + this.prefillData.parameters.municipalityName;
@@ -5753,7 +5865,7 @@ class LibAddressAutocompleteByComponentComponent {
5753
5865
  this.addressParams.minLevel = ADDRESSLEVEL.STREET_NUMBER;
5754
5866
  // this.localityPrefillData = this.addressParams; // as any as PrefillData;
5755
5867
  // this.localityPrefillData = new PrefillData(this.addressParams);
5756
- // Object.assign(this.localityPrefillData, this.addressParams);
5868
+ // Object.assign(this.localityPrefillData, this.addressParams);
5757
5869
  this.prefillData = event.prefillData;
5758
5870
  this.prefillData.ts = new Date();
5759
5871
  this.prefillData.parameters.minLevel = ADDRESSLEVEL.STREET_NUMBER;
@@ -5801,7 +5913,13 @@ class LibAddressAutocompleteByComponentComponent {
5801
5913
  if (this.showDebugMessageToConsole) {
5802
5914
  console.warn('lib::street: prefill - transmitting prefill data for streetNumber :', this.prefillData);
5803
5915
  }
5804
- this.streetNumberPrefillData = this.prefillData;
5916
+ if (address.houseNumber) {
5917
+ this.setAddress(address, ADDRESSLEVEL.STREET);
5918
+ this.minLevel = ADDRESSLEVEL.STREET_NUMBER;
5919
+ }
5920
+ else {
5921
+ this.streetNumberPrefillData = this.prefillData;
5922
+ }
5805
5923
  }
5806
5924
  else {
5807
5925
  const prefillStreetName = this.prefillData.parameters.streetName;
@@ -5932,7 +6050,7 @@ class LibAddressAutocompleteByComponentComponent {
5932
6050
  const address = suggestion.address;
5933
6051
  this.updateStreetNumber(address);
5934
6052
  this.autocompleteStreetNb.selectedAddress = address;
5935
- const addressIsComplete = address && address.hasOwnProperty('isComplete') && address.isComplete === true ? true : false;
6053
+ const addressIsComplete = address && address.hasOwnProperty('isComplete') && !address.hasOwnProperty('boxNumber') && address.isComplete === true ? true : false;
5936
6054
  const addressIsNotInList = address && address.hasOwnProperty('not-in-list') && address['not-in-list'] === true ? true : false;
5937
6055
  if (addressIsComplete && !addressIsNotInList) {
5938
6056
  // found address - perfect matchat street number level