@kigi/components 1.5.1 → 1.5.4
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 +1 -1
- package/src/components/mbg-address/mbg-address.ts +13 -1
- package/src/components/mbg-address/modals/mbg-address-manual/mbg-address-manual.html +2 -2
- package/src/components/mbg-address/modals/mbg-address-manual/mbg-address-manual.ts +12 -0
- package/src/components/mbg-repasse/mbg-repasse.ts +2 -2
package/package.json
CHANGED
|
@@ -39,6 +39,7 @@ class MbgAddressController {
|
|
|
39
39
|
public manualLabel
|
|
40
40
|
public fullAddress
|
|
41
41
|
private GOOGLE_API_KEY = 'AIzaSyB0aH7e6XjWJ-xViji3CuXHBbLuWRALC78'
|
|
42
|
+
private notFoundPremisse
|
|
42
43
|
|
|
43
44
|
constructor(
|
|
44
45
|
public $scope,
|
|
@@ -340,6 +341,13 @@ class MbgAddressController {
|
|
|
340
341
|
formalCode,
|
|
341
342
|
uf,
|
|
342
343
|
}
|
|
344
|
+
if (!premisse) {
|
|
345
|
+
if (this.notFoundPremisse) {
|
|
346
|
+
this.notFoundPremisse()
|
|
347
|
+
}
|
|
348
|
+
this.openModalManual(false, this.address)
|
|
349
|
+
return
|
|
350
|
+
}
|
|
343
351
|
this.updateSteps()
|
|
344
352
|
this.createFullName()
|
|
345
353
|
this.$timeout(() => this.focusInputNumber())
|
|
@@ -525,7 +533,7 @@ class MbgAddressController {
|
|
|
525
533
|
return str
|
|
526
534
|
}
|
|
527
535
|
|
|
528
|
-
openModalManual(EX: boolean = false) {
|
|
536
|
+
openModalManual(EX: boolean = false, address?) {
|
|
529
537
|
const modal = this.$uibModal.open({
|
|
530
538
|
animation: true,
|
|
531
539
|
template: MbgAddressManualTemplate,
|
|
@@ -533,13 +541,16 @@ class MbgAddressController {
|
|
|
533
541
|
controllerAs: '$ctrl',
|
|
534
542
|
size: 'md',
|
|
535
543
|
resolve: {
|
|
544
|
+
address: () => address,
|
|
536
545
|
EX,
|
|
546
|
+
notFound: () => this.notFound,
|
|
537
547
|
},
|
|
538
548
|
})
|
|
539
549
|
modal.result.then((response) => {
|
|
540
550
|
if (response) {
|
|
541
551
|
response.zipCode = response.zipCode || ''
|
|
542
552
|
this.address.country = response.country || 'Brasil'
|
|
553
|
+
this.address.premisse = response.premisse || this.address.premisse
|
|
543
554
|
this.ngModel = response
|
|
544
555
|
if (!EX) {
|
|
545
556
|
this.$timeout(() => this.searchAddressInfo(JSON.parse(JSON.stringify(response))))
|
|
@@ -565,6 +576,7 @@ const mbgAddress = {
|
|
|
565
576
|
cepClass: '=?',
|
|
566
577
|
onFinishFocusElement: '@?',
|
|
567
578
|
manualLabel: '@?',
|
|
579
|
+
notFoundPremisse: '&?',
|
|
568
580
|
},
|
|
569
581
|
template,
|
|
570
582
|
controller: MbgAddressController,
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
<div class="mbg-input-wrapper input-cep-wrapper">
|
|
32
32
|
<input autocomplete="{{ $ctrl.autocompleteValue }}"
|
|
33
33
|
autocorrect="{{ $ctrl.autocompleteValue }}"
|
|
34
|
-
ng-class="{'mbg-error': !$ctrl.entity.zipCode && $ctrl.inputErrors}"
|
|
35
|
-
mbg-error="!$ctrl.entity.zipCode"
|
|
34
|
+
ng-class="{'mbg-error': (!$ctrl.entity.zipCode && $ctrl.inputErrors) || $ctrl.notFoundCep}"
|
|
35
|
+
mbg-error="!$ctrl.entity.zipCode || $ctrl.notFoundCep"
|
|
36
36
|
mbg-error-when="$ctrl.inputErrors"
|
|
37
37
|
mbg-error-message="É necessário informar o CEP"
|
|
38
38
|
spellcheck="false"
|
|
@@ -27,6 +27,7 @@ class MbgAddressManualController {
|
|
|
27
27
|
public entity: any = {}
|
|
28
28
|
public countries: any[]
|
|
29
29
|
public inputErrors: boolean = false
|
|
30
|
+
public notFoundCep: boolean = false
|
|
30
31
|
|
|
31
32
|
constructor(
|
|
32
33
|
public $scope,
|
|
@@ -35,6 +36,8 @@ class MbgAddressManualController {
|
|
|
35
36
|
public $http,
|
|
36
37
|
public mbgAddressService,
|
|
37
38
|
public EX,
|
|
39
|
+
public notFound,
|
|
40
|
+
public address,
|
|
38
41
|
) {}
|
|
39
42
|
|
|
40
43
|
$onInit() {
|
|
@@ -42,6 +45,9 @@ class MbgAddressManualController {
|
|
|
42
45
|
this.createAutocompleteDisabled()
|
|
43
46
|
this.loadStates()
|
|
44
47
|
this.loadCountries()
|
|
48
|
+
if (this.address) {
|
|
49
|
+
this.entity = this.address
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
validateLenth() {
|
|
@@ -104,6 +110,7 @@ class MbgAddressManualController {
|
|
|
104
110
|
if (this.entity && this.entity.zipCode) {
|
|
105
111
|
this.mbgAddressService.getCep(this.entity.zipCode).then((response) => {
|
|
106
112
|
if (response && response.data && response.data.cep) {
|
|
113
|
+
this.notFoundCep = false
|
|
107
114
|
const formalCode = response.data.ibge || ''
|
|
108
115
|
const premisse = this.formatFromPremisse(response.data.logradouro)
|
|
109
116
|
this.entity = {
|
|
@@ -121,6 +128,9 @@ class MbgAddressManualController {
|
|
|
121
128
|
formalCode,
|
|
122
129
|
state: response.data.uf,
|
|
123
130
|
}
|
|
131
|
+
} else {
|
|
132
|
+
this.notFoundCep = true
|
|
133
|
+
this.notFound()
|
|
124
134
|
}
|
|
125
135
|
})
|
|
126
136
|
}
|
|
@@ -166,6 +176,8 @@ MbgAddressManualController['$inject'] = [
|
|
|
166
176
|
'$http',
|
|
167
177
|
'mbgAddressService',
|
|
168
178
|
'EX',
|
|
179
|
+
'notFound',
|
|
180
|
+
'address',
|
|
169
181
|
]
|
|
170
182
|
|
|
171
183
|
export { MbgAddressManualController }
|
|
@@ -56,7 +56,7 @@ class MbgRepasseController {
|
|
|
56
56
|
handleNgModel() {
|
|
57
57
|
this.$timeout(() => {
|
|
58
58
|
this.ngModel['conditions'] = this.conditions
|
|
59
|
-
.filter((cond) => cond.field && cond.operator && cond.selected)
|
|
59
|
+
.filter((cond) => cond.field && cond.operator && cond.selected !== undefined)
|
|
60
60
|
.map((condition) => {
|
|
61
61
|
return {
|
|
62
62
|
field: condition.field.type,
|
|
@@ -65,7 +65,7 @@ class MbgRepasseController {
|
|
|
65
65
|
}
|
|
66
66
|
})
|
|
67
67
|
this.ngModel['applies'] = this.applies
|
|
68
|
-
.filter((app) => app.field && app.selected)
|
|
68
|
+
.filter((app) => app.field && app.selected !== undefined)
|
|
69
69
|
.map((apply) => {
|
|
70
70
|
return {
|
|
71
71
|
field: apply.field.type,
|