@kigi/components 1.27.0-alpha → 1.27.2-alpha
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/package.json
CHANGED
|
@@ -42,6 +42,7 @@ class MbgAddressController {
|
|
|
42
42
|
private GOOGLE_API_KEY = 'AIzaSyB0aH7e6XjWJ-xViji3CuXHBbLuWRALC78'
|
|
43
43
|
private notFoundPremisse
|
|
44
44
|
private capitalize
|
|
45
|
+
private onSinceUpdate: Function
|
|
45
46
|
|
|
46
47
|
constructor(
|
|
47
48
|
public $scope,
|
|
@@ -50,7 +51,7 @@ class MbgAddressController {
|
|
|
50
51
|
public $timeout,
|
|
51
52
|
public mbgAddressService: MbgAddressService,
|
|
52
53
|
public $uibModal,
|
|
53
|
-
) {
|
|
54
|
+
) {}
|
|
54
55
|
|
|
55
56
|
$onInit() {
|
|
56
57
|
if (this.capitalize && this.address) {
|
|
@@ -59,6 +60,7 @@ class MbgAddressController {
|
|
|
59
60
|
if (this.capitalize && this.fullAddress) {
|
|
60
61
|
this.fullAddress = this.capitalizeBool(this.fullAddress || '')
|
|
61
62
|
}
|
|
63
|
+
|
|
62
64
|
this.checkScript()
|
|
63
65
|
this.navigatorData = detect()
|
|
64
66
|
this.navigatorData.currentVersion = Number(
|
|
@@ -93,8 +95,8 @@ class MbgAddressController {
|
|
|
93
95
|
state: this.address.state
|
|
94
96
|
? this.address.state
|
|
95
97
|
: this.address.uf && this.address.uf.initial
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
? this.address.uf.initial
|
|
99
|
+
: '',
|
|
98
100
|
}
|
|
99
101
|
if (this.ngModel) {
|
|
100
102
|
this.ngModel.EX = (this.ngModel.country || '').toLowerCase() !== 'brasil'
|
|
@@ -221,6 +223,7 @@ class MbgAddressController {
|
|
|
221
223
|
this.fullAddress = ''
|
|
222
224
|
this.resetAddress()
|
|
223
225
|
this.updateSteps()
|
|
226
|
+
this.$timeout(() => this.onSinceUpdate())
|
|
224
227
|
}
|
|
225
228
|
|
|
226
229
|
checkModel() {
|
|
@@ -236,10 +239,13 @@ class MbgAddressController {
|
|
|
236
239
|
|
|
237
240
|
createFullName() {
|
|
238
241
|
if (this.address.premisse) {
|
|
239
|
-
this.fullAddress = `${
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
this.fullAddress = `${
|
|
243
|
+
this.address.premisse ? this.address.premisse : this.ngModel.premisse
|
|
244
|
+
} - ${
|
|
245
|
+
this.address.neighbourhood ? this.address.neighbourhood : this.ngModel.neighbourhood
|
|
246
|
+
}, ${this.address.localization ? this.address.localization : this.ngModel.localization} - ${
|
|
247
|
+
this.ngModel.state
|
|
248
|
+
}, ${this.ngModel.country}`
|
|
243
249
|
}
|
|
244
250
|
}
|
|
245
251
|
|
|
@@ -342,24 +348,28 @@ class MbgAddressController {
|
|
|
342
348
|
|
|
343
349
|
async searchAddressByCEP() {
|
|
344
350
|
if (this.address && this.address.zipCode) {
|
|
345
|
-
const response = await this.mbgAddressService.getCep(this.address.zipCode)
|
|
351
|
+
const response = await this.mbgAddressService.getCep(this.address.zipCode)
|
|
346
352
|
|
|
347
353
|
if (response && response.data && response.data.cep) {
|
|
348
|
-
let street,
|
|
354
|
+
let street,
|
|
355
|
+
neighborhood,
|
|
356
|
+
city,
|
|
357
|
+
state,
|
|
358
|
+
ibgeCode = ''
|
|
349
359
|
|
|
350
360
|
if (response.key == 'viacep') {
|
|
351
|
-
street = response.data.logradouro
|
|
352
|
-
neighborhood = response.data.bairro
|
|
353
|
-
city = response.data.localization
|
|
354
|
-
state = response.data.uf
|
|
355
|
-
ibgeCode = response.data.ibge
|
|
361
|
+
street = response.data.logradouro
|
|
362
|
+
neighborhood = response.data.bairro
|
|
363
|
+
city = response.data.localization
|
|
364
|
+
state = response.data.uf
|
|
365
|
+
ibgeCode = response.data.ibge
|
|
356
366
|
} else if (response.key == 'brasilApi') {
|
|
357
|
-
street = response.data.street
|
|
358
|
-
neighborhood = response.data.neighborhood
|
|
359
|
-
city = response.data.city
|
|
360
|
-
state = response.data.state
|
|
367
|
+
street = response.data.street
|
|
368
|
+
neighborhood = response.data.neighborhood
|
|
369
|
+
city = response.data.city
|
|
370
|
+
state = response.data.state
|
|
361
371
|
const responseIbge = await this.mbgAddressService.getIbgeCode(response.data.city)
|
|
362
|
-
ibgeCode =
|
|
372
|
+
ibgeCode = responseIbge && responseIbge.data && responseIbge.data.id.toString()
|
|
363
373
|
}
|
|
364
374
|
|
|
365
375
|
const uf = getStatesBR().filter((state) => state.initial === response.data.uf)[0]
|
|
@@ -369,9 +379,7 @@ class MbgAddressController {
|
|
|
369
379
|
this.address = {
|
|
370
380
|
zipCode: this.address.zipCode.replace('-', ''),
|
|
371
381
|
neighbourhood: neighborhood ? neighborhood.trim() : 'Centro',
|
|
372
|
-
localization: city
|
|
373
|
-
? city
|
|
374
|
-
: (response.data.localidade || '').trim(),
|
|
382
|
+
localization: city ? city : (response.data.localidade || '').trim(),
|
|
375
383
|
premisse: premisse || 'CEP Único',
|
|
376
384
|
number: this.address.number || '',
|
|
377
385
|
information: this.address.information || '',
|
|
@@ -587,6 +595,10 @@ class MbgAddressController {
|
|
|
587
595
|
},
|
|
588
596
|
})
|
|
589
597
|
modal.result.then((response) => {
|
|
598
|
+
this.$timeout(() => {
|
|
599
|
+
this.onSinceUpdate()
|
|
600
|
+
})
|
|
601
|
+
|
|
590
602
|
if (response) {
|
|
591
603
|
response.zipCode = response.zipCode || ''
|
|
592
604
|
this.address.country = response.country || 'Brasil'
|
|
@@ -601,7 +613,7 @@ class MbgAddressController {
|
|
|
601
613
|
}
|
|
602
614
|
}
|
|
603
615
|
|
|
604
|
-
MbgAddressController
|
|
616
|
+
MbgAddressController['$inject'] = [
|
|
605
617
|
'$scope',
|
|
606
618
|
'$element',
|
|
607
619
|
'$attrs',
|
|
@@ -619,6 +631,7 @@ const mbgAddress = {
|
|
|
619
631
|
manualLabel: '@?',
|
|
620
632
|
notFoundPremisse: '&?',
|
|
621
633
|
capitalize: '=?',
|
|
634
|
+
onSinceUpdate: '&?',
|
|
622
635
|
},
|
|
623
636
|
template,
|
|
624
637
|
controller: MbgAddressController,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<div class="mbg-input-wrapper mb-input-text-wrapper"
|
|
2
2
|
ng-if="$ctrl.props">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
<input type="text"
|
|
4
|
+
ng-model="$ctrl.ngModel"
|
|
5
|
+
ng-change="$ctrl.onChange($event)"
|
|
6
|
+
ng-required="$ctrl.ngRequired"
|
|
7
|
+
ng-disabled="$ctrl.ngDisabled"
|
|
8
|
+
ng-blur="$ctrl.ngBlur({ $event })"
|
|
9
|
+
ng-focus="$ctrl.ngFocus({ $event })"
|
|
10
|
+
placeholder="{{ $ctrl.placeholder }}"
|
|
11
|
+
maxlength="{{$ctrl.maxLength}}" />
|
|
11
12
|
</div>
|