@kigi/components 1.4.8 → 1.5.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 +1 -1
- package/src/components/mbg-address/mbg-address.ts +1 -0
- 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 +7 -0
- package/src/components/mbg-select/mbg-select.ts +42 -7
- package/src/components/mbg-status-label/mbg-status-label.ts +4 -0
package/package.json
CHANGED
|
@@ -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,7 @@ class MbgAddressManualController {
|
|
|
35
36
|
public $http,
|
|
36
37
|
public mbgAddressService,
|
|
37
38
|
public EX,
|
|
39
|
+
public notFound,
|
|
38
40
|
) {}
|
|
39
41
|
|
|
40
42
|
$onInit() {
|
|
@@ -104,6 +106,7 @@ class MbgAddressManualController {
|
|
|
104
106
|
if (this.entity && this.entity.zipCode) {
|
|
105
107
|
this.mbgAddressService.getCep(this.entity.zipCode).then((response) => {
|
|
106
108
|
if (response && response.data && response.data.cep) {
|
|
109
|
+
this.notFoundCep = false
|
|
107
110
|
const formalCode = response.data.ibge || ''
|
|
108
111
|
const premisse = this.formatFromPremisse(response.data.logradouro)
|
|
109
112
|
this.entity = {
|
|
@@ -121,6 +124,9 @@ class MbgAddressManualController {
|
|
|
121
124
|
formalCode,
|
|
122
125
|
state: response.data.uf,
|
|
123
126
|
}
|
|
127
|
+
} else {
|
|
128
|
+
this.notFoundCep = true
|
|
129
|
+
this.notFound()
|
|
124
130
|
}
|
|
125
131
|
})
|
|
126
132
|
}
|
|
@@ -166,6 +172,7 @@ MbgAddressManualController['$inject'] = [
|
|
|
166
172
|
'$http',
|
|
167
173
|
'mbgAddressService',
|
|
168
174
|
'EX',
|
|
175
|
+
'notFound',
|
|
169
176
|
]
|
|
170
177
|
|
|
171
178
|
export { MbgAddressManualController }
|
|
@@ -41,6 +41,7 @@ class MbgSelectController {
|
|
|
41
41
|
private fixedOptionId: any
|
|
42
42
|
private fixedValue: string
|
|
43
43
|
private transcludeSize: any
|
|
44
|
+
private getCustomModel: Function
|
|
44
45
|
|
|
45
46
|
constructor(
|
|
46
47
|
public $scope,
|
|
@@ -387,7 +388,7 @@ class MbgSelectController {
|
|
|
387
388
|
}
|
|
388
389
|
|
|
389
390
|
setModel() {
|
|
390
|
-
this.$timeout(() => {
|
|
391
|
+
this.$timeout(async () => {
|
|
391
392
|
if (this.fetch) {
|
|
392
393
|
const currentOption = this.getOptionFocused()
|
|
393
394
|
if (currentOption[0]) {
|
|
@@ -399,10 +400,10 @@ class MbgSelectController {
|
|
|
399
400
|
item = isNaN(this.inputValue) ? this.inputValue : Number(this.inputValue)
|
|
400
401
|
}
|
|
401
402
|
}
|
|
402
|
-
this.updateModelValue(this.ngValue ? item[this.ngValue] : item)
|
|
403
|
+
await this.updateModelValue(this.ngValue ? item[this.ngValue] : item)
|
|
403
404
|
}
|
|
404
405
|
} else {
|
|
405
|
-
this.updateModelValue(this.inputValue)
|
|
406
|
+
await this.updateModelValue(this.inputValue)
|
|
406
407
|
}
|
|
407
408
|
this.executeCallback()
|
|
408
409
|
if (this.onSelect) {
|
|
@@ -419,12 +420,12 @@ class MbgSelectController {
|
|
|
419
420
|
}
|
|
420
421
|
}
|
|
421
422
|
|
|
422
|
-
selectOption(item, isNew?: boolean) {
|
|
423
|
+
async selectOption(item, isNew?: boolean) {
|
|
423
424
|
this.data = []
|
|
424
425
|
this.executeCallback(isNew)
|
|
425
426
|
this.pressEnter = false
|
|
426
427
|
this.hasFocus = false
|
|
427
|
-
this.updateModelValue(this.ngValue ? item[this.ngValue] : item)
|
|
428
|
+
await this.updateModelValue(this.ngValue ? item[this.ngValue] : item)
|
|
428
429
|
if (this.onSelect) {
|
|
429
430
|
this.onSelect({ value: this.ngModel })
|
|
430
431
|
}
|
|
@@ -516,8 +517,41 @@ class MbgSelectController {
|
|
|
516
517
|
}
|
|
517
518
|
|
|
518
519
|
updateModelValue(value) {
|
|
519
|
-
|
|
520
|
-
|
|
520
|
+
return new Promise((resolve) => {
|
|
521
|
+
if (this.getCustomModel) {
|
|
522
|
+
const response: any = this.getCustomModel({ value })
|
|
523
|
+
this.isLoading = true
|
|
524
|
+
if (response && response.then) {
|
|
525
|
+
if (response && response.then) {
|
|
526
|
+
response
|
|
527
|
+
.then((responseCustomModel) => {
|
|
528
|
+
this.ngModel =
|
|
529
|
+
responseCustomModel && responseCustomModel.data
|
|
530
|
+
? responseCustomModel.data
|
|
531
|
+
: responseCustomModel
|
|
532
|
+
this.updateInputValue()
|
|
533
|
+
this.isLoading = false
|
|
534
|
+
resolve(true)
|
|
535
|
+
return
|
|
536
|
+
})
|
|
537
|
+
.catch(() => {
|
|
538
|
+
this.isLoading = false
|
|
539
|
+
resolve(true)
|
|
540
|
+
})
|
|
541
|
+
}
|
|
542
|
+
} else {
|
|
543
|
+
this.ngModel = response
|
|
544
|
+
this.updateInputValue()
|
|
545
|
+
this.isLoading = false
|
|
546
|
+
resolve(true)
|
|
547
|
+
return
|
|
548
|
+
}
|
|
549
|
+
} else {
|
|
550
|
+
this.ngModel = value
|
|
551
|
+
this.updateInputValue()
|
|
552
|
+
resolve(true)
|
|
553
|
+
}
|
|
554
|
+
})
|
|
521
555
|
}
|
|
522
556
|
|
|
523
557
|
updateInputValue() {
|
|
@@ -632,6 +666,7 @@ const mbgSelect = {
|
|
|
632
666
|
fixedOptionId: '=?',
|
|
633
667
|
callbackAddFixedOption: '&?',
|
|
634
668
|
transcludeSize: '=?',
|
|
669
|
+
getCustomModel: '&?',
|
|
635
670
|
},
|
|
636
671
|
controller: MbgSelectController,
|
|
637
672
|
template,
|
|
@@ -47,6 +47,8 @@ class MbgStatusLabelController {
|
|
|
47
47
|
this.label = 'Autorizada'
|
|
48
48
|
break
|
|
49
49
|
case 'CANCELADA':
|
|
50
|
+
case 'CANCELLED':
|
|
51
|
+
case 'CANCELED':
|
|
50
52
|
this.label = 'Cancelada'
|
|
51
53
|
break
|
|
52
54
|
case 'REJEITADA':
|
|
@@ -91,6 +93,8 @@ class MbgStatusLabelController {
|
|
|
91
93
|
case 'REJEITADA':
|
|
92
94
|
case 'PENDING_REJECT':
|
|
93
95
|
case 'REJECTED':
|
|
96
|
+
case 'CANCELLED':
|
|
97
|
+
case 'CANCELED':
|
|
94
98
|
this.labelClass = 'error'
|
|
95
99
|
break
|
|
96
100
|
case 'PASSED_ALONG':
|