@kigi/components 1.62.2-beta.1 → 1.62.2
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
|
@@ -51,8 +51,7 @@ class MbgAddressController {
|
|
|
51
51
|
public $timeout,
|
|
52
52
|
public mbgAddressService: MbgAddressService,
|
|
53
53
|
public $uibModal,
|
|
54
|
-
) {
|
|
55
|
-
}
|
|
54
|
+
) {}
|
|
56
55
|
|
|
57
56
|
$onInit() {
|
|
58
57
|
if (this.capitalize && this.address) {
|
|
@@ -96,8 +95,8 @@ class MbgAddressController {
|
|
|
96
95
|
state: this.address.state
|
|
97
96
|
? this.address.state
|
|
98
97
|
: this.address.uf && this.address.uf.initial
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
? this.address.uf.initial
|
|
99
|
+
: '',
|
|
101
100
|
}
|
|
102
101
|
if (this.ngModel) {
|
|
103
102
|
this.ngModel.EX = (this.ngModel.country || '').toLowerCase() !== 'brasil'
|
|
@@ -153,38 +152,65 @@ class MbgAddressController {
|
|
|
153
152
|
}
|
|
154
153
|
|
|
155
154
|
afterLoad() {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
)
|
|
160
|
-
|
|
155
|
+
const inputPlace = this.$element.find('.input-place')[0]
|
|
156
|
+
const autocomplete = new google.maps.places.Autocomplete(inputPlace, { types: ['address'] })
|
|
157
|
+
|
|
158
|
+
autocomplete.setFields(['address_component', 'geometry'])
|
|
159
|
+
|
|
161
160
|
autocomplete.addListener('place_changed', () => {
|
|
162
161
|
this.$timeout(() => {
|
|
163
162
|
const place = autocomplete.getPlace()
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
163
|
+
|
|
164
|
+
if (!place.address_components) return
|
|
165
|
+
|
|
166
|
+
const newAddress: any = {
|
|
167
|
+
country: 'Brasil',
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
for (const component of place.address_components) {
|
|
171
|
+
const types = component.types || []
|
|
172
|
+
const longName = component.long_name || ''
|
|
173
|
+
const shortName = component.short_name || ''
|
|
174
|
+
|
|
175
|
+
if (types.includes('route')) {
|
|
176
|
+
newAddress.premisse = longName
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (
|
|
180
|
+
types.includes('sublocality_level_1') ||
|
|
181
|
+
types.includes('sublocality') ||
|
|
182
|
+
types.includes('neighborhood')
|
|
183
|
+
) {
|
|
184
|
+
newAddress.neighbourhood = longName
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (types.includes('administrative_area_level_2')) {
|
|
188
|
+
newAddress.localization = longName
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (types.includes('administrative_area_level_1')) {
|
|
192
|
+
newAddress.uf = { name: longName, initial: shortName }
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (types.includes('country')) {
|
|
196
|
+
newAddress.country = longName
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (types.includes('postal_code')) {
|
|
200
|
+
newAddress.zipCode = longName.replace(/-/g, '')
|
|
186
201
|
}
|
|
187
202
|
}
|
|
203
|
+
|
|
204
|
+
this.address = newAddress
|
|
205
|
+
|
|
206
|
+
this.focusInputNumber()
|
|
207
|
+
|
|
208
|
+
const hasAddressData = newAddress.uf && newAddress.localization && newAddress.premisse
|
|
209
|
+
const missingZip = !newAddress.zipCode
|
|
210
|
+
|
|
211
|
+
if (hasAddressData && missingZip) {
|
|
212
|
+
this.searchAddressInfo()
|
|
213
|
+
}
|
|
188
214
|
})
|
|
189
215
|
})
|
|
190
216
|
}
|
|
@@ -372,7 +398,6 @@ class MbgAddressController {
|
|
|
372
398
|
const responseIbge = await this.mbgAddressService.getIbgeCode(response.data.city)
|
|
373
399
|
ibgeCode = responseIbge && responseIbge.data && responseIbge.data.id.toString()
|
|
374
400
|
}
|
|
375
|
-
|
|
376
401
|
const uf = getStatesBR().filter((state) => {
|
|
377
402
|
const currUf = state.initial || state
|
|
378
403
|
const resUf = response.data.uf || response.data.state
|
|
@@ -12,8 +12,6 @@ class MbgInputPhoneController {
|
|
|
12
12
|
private maxLength: number
|
|
13
13
|
|
|
14
14
|
constructor(public $scope, public $element, public $attrs) {
|
|
15
|
-
this.phoneNumberMask = this.enableCountryCode ? 'countryCode' : 'areaCode'
|
|
16
|
-
this.maxLength = this.maxLength ? this.maxLength : this.enableCountryCode ? 19 : 15
|
|
17
15
|
if ($attrs.ngRequired === '') {
|
|
18
16
|
this.ngRequired = true
|
|
19
17
|
}
|
|
@@ -25,6 +23,14 @@ class MbgInputPhoneController {
|
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
|
|
26
|
+
$onInit() {
|
|
27
|
+
this.phoneNumberMask = this.enableCountryCode ? 'countryCode' : 'areaCode'
|
|
28
|
+
|
|
29
|
+
if (!this.maxLength) {
|
|
30
|
+
this.maxLength = this.enableCountryCode ? 19 : 15
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
onChange() {
|
|
29
35
|
if (this.ngChange) {
|
|
30
36
|
this.ngChange({})
|