@kigi/components 1.4.8 → 1.4.9
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
|
@@ -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,
|