@kigi/components 1.8.10 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kigi/components",
3
- "version": "1.8.10",
3
+ "version": "1.9.0",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -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 track by $index"
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,12 +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(value)"
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
- many-favorite="true"
33
32
  label="{{ $ctrl.label }}"></mbg-select>
34
33
  </div>
35
34
  </div>
@@ -53,26 +53,26 @@ class MbgMultiSelectController {
53
53
  })
54
54
  }
55
55
 
56
- onSelect(item?) {
56
+ onSelect() {
57
57
  this.$timeout(() => {
58
- const currentModel = this.searchModel || item
59
- if (currentModel) {
58
+ if (this.searchModel) {
60
59
  this.ngModel = this.ngModel || []
61
60
  if (this.ngModel && typeof this.ngModel[0] === 'string') {
62
61
  if (
63
- this.ngModel.filter((v) => v.toLowerCase() === currentModel.toLowerCase()).length === 0
62
+ this.ngModel.filter((v) => v.toLowerCase() === this.searchModel.toLowerCase())
63
+ .length === 0
64
64
  ) {
65
65
  if (this.inlineMode) {
66
- this.ngModel.unshift(currentModel)
66
+ this.ngModel.unshift(this.searchModel)
67
67
  } else {
68
- this.ngModel.push(currentModel)
68
+ this.ngModel.push(this.searchModel)
69
69
  }
70
70
  }
71
71
  } else {
72
72
  if (this.inlineMode) {
73
- this.ngModel.unshift(currentModel)
73
+ this.ngModel.unshift(this.searchModel)
74
74
  } else {
75
- this.ngModel.push(currentModel)
75
+ this.ngModel.push(this.searchModel)
76
76
  }
77
77
  }
78
78
  this.verifyScroll()
@@ -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) && !this.manyFavorite) {
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
- if (this.manyFavorite) {
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,