@kigi/components 1.8.11 → 1.9.0
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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
ng-class="{'disabled': $ctrl.ngDisabled, 'inline-mode-wrapper': $ctrl.inlineMode}">
|
|
4
4
|
<div class="mbg-multi-select-content">
|
|
5
5
|
<ul class="items-selected">
|
|
6
|
-
<li ng-repeat="item in $ctrl.ngModel
|
|
6
|
+
<li ng-repeat="item in $ctrl.ngModel"
|
|
7
7
|
draggable="true">
|
|
8
8
|
<label data-text="{{ $ctrl.label ? item[$ctrl.label] : item }}"
|
|
9
9
|
ng-style="{width: $ctrl.widthEllipsis && $ctrl.inlineMode ? $ctrl.widthEllipsis : 'auto'}">{{
|
|
@@ -24,13 +24,11 @@
|
|
|
24
24
|
fetch="$ctrl.fetch({ query })"
|
|
25
25
|
ng-disabled="$ctrl.ngDisabled"
|
|
26
26
|
ignore-items="$ctrl.ngModel"
|
|
27
|
-
on-select="$ctrl.onSelect(
|
|
27
|
+
on-select="$ctrl.onSelect()"
|
|
28
28
|
ng-blur="$ctrl.ngBlur({ $event })"
|
|
29
29
|
ng-focus="$ctrl.ngFocus({ $event })"
|
|
30
30
|
placeholder="{{ $ctrl.placeholder }}"
|
|
31
31
|
enable-add="$ctrl.enableAdd"
|
|
32
|
-
enable-favorite="$ctrl.enableFavorite"
|
|
33
|
-
many-favorite="true"
|
|
34
32
|
label="{{ $ctrl.label }}"></mbg-select>
|
|
35
33
|
</div>
|
|
36
34
|
</div>
|
|
@@ -19,7 +19,6 @@ class MbgMultiSelectController {
|
|
|
19
19
|
private enableAdd: boolean
|
|
20
20
|
private inlineMode: boolean
|
|
21
21
|
private widthEllipsis: string
|
|
22
|
-
private enableFavorite: boolean
|
|
23
22
|
|
|
24
23
|
constructor(public $scope, public $element, public $attrs, public $timeout) {}
|
|
25
24
|
|
|
@@ -54,26 +53,26 @@ class MbgMultiSelectController {
|
|
|
54
53
|
})
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
onSelect(
|
|
56
|
+
onSelect() {
|
|
58
57
|
this.$timeout(() => {
|
|
59
|
-
|
|
60
|
-
if (currentModel) {
|
|
58
|
+
if (this.searchModel) {
|
|
61
59
|
this.ngModel = this.ngModel || []
|
|
62
60
|
if (this.ngModel && typeof this.ngModel[0] === 'string') {
|
|
63
61
|
if (
|
|
64
|
-
this.ngModel.filter((v) => v.toLowerCase() ===
|
|
62
|
+
this.ngModel.filter((v) => v.toLowerCase() === this.searchModel.toLowerCase())
|
|
63
|
+
.length === 0
|
|
65
64
|
) {
|
|
66
65
|
if (this.inlineMode) {
|
|
67
|
-
this.ngModel.unshift(
|
|
66
|
+
this.ngModel.unshift(this.searchModel)
|
|
68
67
|
} else {
|
|
69
|
-
this.ngModel.push(
|
|
68
|
+
this.ngModel.push(this.searchModel)
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
} else {
|
|
73
72
|
if (this.inlineMode) {
|
|
74
|
-
this.ngModel.unshift(
|
|
73
|
+
this.ngModel.unshift(this.searchModel)
|
|
75
74
|
} else {
|
|
76
|
-
this.ngModel.push(
|
|
75
|
+
this.ngModel.push(this.searchModel)
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
this.verifyScroll()
|
|
@@ -243,7 +242,6 @@ const mbgMultiSelect = {
|
|
|
243
242
|
ngDisabled: '=?',
|
|
244
243
|
inlineMode: '=?',
|
|
245
244
|
widthEllipsis: '@?',
|
|
246
|
-
enableFavorite: '=?',
|
|
247
245
|
},
|
|
248
246
|
template,
|
|
249
247
|
controller: MbgMultiSelectController,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Capitalize } from '@kigi/components/src/helpers/capitalize'
|
|
1
|
+
import { Capitalize } from '@kigi/components/src/helpers/capitalize';
|
|
2
2
|
import * as angular from 'angular'
|
|
3
3
|
import './mbg-select.scss'
|
|
4
4
|
import template from './mbg-select.html'
|
|
@@ -44,7 +44,6 @@ class MbgSelectController {
|
|
|
44
44
|
private transcludeSize: any
|
|
45
45
|
private getCustomModel: Function
|
|
46
46
|
private capitalize
|
|
47
|
-
private manyFavorite: boolean
|
|
48
47
|
|
|
49
48
|
constructor(
|
|
50
49
|
public $scope,
|
|
@@ -53,7 +52,7 @@ class MbgSelectController {
|
|
|
53
52
|
public $timeout,
|
|
54
53
|
public $compile,
|
|
55
54
|
public $transclude,
|
|
56
|
-
) {}
|
|
55
|
+
) { }
|
|
57
56
|
|
|
58
57
|
$onInit() {
|
|
59
58
|
this.fixedValue = this.ngValue || 'id'
|
|
@@ -431,12 +430,6 @@ class MbgSelectController {
|
|
|
431
430
|
this.executeCallback(isNew)
|
|
432
431
|
this.pressEnter = false
|
|
433
432
|
this.hasFocus = false
|
|
434
|
-
if (item instanceof Array) {
|
|
435
|
-
if (this.onSelect) {
|
|
436
|
-
item.forEach((i) => this.onSelect({ value: i }))
|
|
437
|
-
return
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
433
|
await this.updateModelValue(this.ngValue ? item[this.ngValue] : item)
|
|
441
434
|
if (this.onSelect) {
|
|
442
435
|
this.onSelect({ value: this.ngModel })
|
|
@@ -606,19 +599,8 @@ class MbgSelectController {
|
|
|
606
599
|
favorite(evt, item) {
|
|
607
600
|
evt.preventDefault()
|
|
608
601
|
evt.stopPropagation()
|
|
609
|
-
if (this.isFavorite(item)
|
|
602
|
+
if (this.isFavorite(item)) {
|
|
610
603
|
MbgCookie.set(this.getFavoriteKey(), null)
|
|
611
|
-
} else if (this.manyFavorite) {
|
|
612
|
-
if (this.isFavorite(item)) {
|
|
613
|
-
const favorite = MbgCookie.get(this.getFavoriteKey())
|
|
614
|
-
const index = favorite.findIndex((i) => i.id == item.id)
|
|
615
|
-
favorite.splice(index, 1)
|
|
616
|
-
MbgCookie.set(this.getFavoriteKey(), favorite)
|
|
617
|
-
} else {
|
|
618
|
-
const favorite = MbgCookie.get(this.getFavoriteKey())
|
|
619
|
-
const favoriteArray = favorite ? (favorite instanceof Array ? favorite : [favorite]) : []
|
|
620
|
-
MbgCookie.set(this.getFavoriteKey(), [...favoriteArray, item])
|
|
621
|
-
}
|
|
622
604
|
} else {
|
|
623
605
|
MbgCookie.set(this.getFavoriteKey(), item)
|
|
624
606
|
}
|
|
@@ -639,11 +621,7 @@ class MbgSelectController {
|
|
|
639
621
|
|
|
640
622
|
isFavorite(item) {
|
|
641
623
|
const favorite = MbgCookie.get(this.getFavoriteKey())
|
|
642
|
-
|
|
643
|
-
return favorite && (favorite || []).find((i) => i && i.id == item.id)
|
|
644
|
-
} else {
|
|
645
|
-
return favorite && angular.equals(favorite, item)
|
|
646
|
-
}
|
|
624
|
+
return favorite && angular.equals(favorite, item)
|
|
647
625
|
}
|
|
648
626
|
|
|
649
627
|
async fixedOption(evt, item) {
|
|
@@ -694,8 +672,7 @@ const mbgSelect = {
|
|
|
694
672
|
callbackAddFixedOption: '&?',
|
|
695
673
|
transcludeSize: '=?',
|
|
696
674
|
getCustomModel: '&?',
|
|
697
|
-
capitalize: '=?'
|
|
698
|
-
manyFavorite: '=?',
|
|
675
|
+
capitalize: '=?'
|
|
699
676
|
},
|
|
700
677
|
controller: MbgSelectController,
|
|
701
678
|
template,
|