@kigi/components 1.8.9 → 1.8.10

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.9",
3
+ "version": "1.8.10",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -4,10 +4,9 @@ import { mbgListColumn } from './components/mbg-list-column/mbg-list-column'
4
4
  import { mbgListRow } from './components/mbg-list-row/mbg-list-row'
5
5
 
6
6
  const mbgListModule = angular
7
- .module('mbg.components.mbgList', [])
8
- .component('mbgList', mbgList)
9
- .component('mbgListColumn', mbgListColumn)
10
- .component('mbgListRow', mbgListRow)
11
- .name
7
+ .module('mbg.components.mbgList', [])
8
+ .component('mbgList', mbgList)
9
+ .component('mbgListColumn', mbgListColumn)
10
+ .component('mbgListRow', mbgListRow).name
12
11
 
13
12
  export { mbgListModule }
@@ -30,7 +30,8 @@
30
30
  </td>
31
31
  <td ng-if="$ctrl.radio && !$row.isAdicional">
32
32
  <mbg-radio ng-model="$ctrl.selectedMap[$ctrl.removeCircularJson($row.$json)]"
33
- ng-change="$ctrl.toogleRadio($ctrl.removeCircularJson($row.$json))"></mbg-radio>
33
+ ng-change="$ctrl.toogleRadio($ctrl.removeCircularJson($row.$json))"
34
+ ng-if="!$ctrl.checkboxIf || $ctrl.checkboxIf({ $row: $row })"></mbg-radio>
34
35
  </td>
35
36
  <td ng-repeat="column in $ctrl.columns"
36
37
  ng-if="!$row.isAdicional && !column.hidden"
@@ -209,7 +209,13 @@ export class MbgListController {
209
209
  handleClickRow(row, index) {
210
210
  if (this.rowsAdicional !== index && (this.checkbox || this.radio) && this.enableOnSelectByRow) {
211
211
  if (this.radio) {
212
- this.toogleRadio(row.$json)
212
+ if (this.checkboxIf) {
213
+ if (this.checkboxIf({ $row: row })) {
214
+ this.toogleRadio(row.$json)
215
+ }
216
+ } else {
217
+ this.toogleRadio(row.$json)
218
+ }
213
219
  } else {
214
220
  if (this.checkboxIf) {
215
221
  if (this.checkboxIf({ $row: row })) {
@@ -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 track by $index"
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,11 +24,12 @@
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(value)"
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"
32
33
  label="{{ $ctrl.label }}"></mbg-select>
33
34
  </div>
34
35
  </div>
@@ -53,26 +53,26 @@ class MbgMultiSelectController {
53
53
  })
54
54
  }
55
55
 
56
- onSelect() {
56
+ onSelect(item?) {
57
57
  this.$timeout(() => {
58
- if (this.searchModel) {
58
+ const currentModel = this.searchModel || item
59
+ if (currentModel) {
59
60
  this.ngModel = this.ngModel || []
60
61
  if (this.ngModel && typeof this.ngModel[0] === 'string') {
61
62
  if (
62
- this.ngModel.filter((v) => v.toLowerCase() === this.searchModel.toLowerCase())
63
- .length === 0
63
+ this.ngModel.filter((v) => v.toLowerCase() === currentModel.toLowerCase()).length === 0
64
64
  ) {
65
65
  if (this.inlineMode) {
66
- this.ngModel.unshift(this.searchModel)
66
+ this.ngModel.unshift(currentModel)
67
67
  } else {
68
- this.ngModel.push(this.searchModel)
68
+ this.ngModel.push(currentModel)
69
69
  }
70
70
  }
71
71
  } else {
72
72
  if (this.inlineMode) {
73
- this.ngModel.unshift(this.searchModel)
73
+ this.ngModel.unshift(currentModel)
74
74
  } else {
75
- this.ngModel.push(this.searchModel)
75
+ this.ngModel.push(currentModel)
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,6 +44,7 @@ class MbgSelectController {
44
44
  private transcludeSize: any
45
45
  private getCustomModel: Function
46
46
  private capitalize
47
+ private manyFavorite: boolean
47
48
 
48
49
  constructor(
49
50
  public $scope,
@@ -52,7 +53,7 @@ class MbgSelectController {
52
53
  public $timeout,
53
54
  public $compile,
54
55
  public $transclude,
55
- ) { }
56
+ ) {}
56
57
 
57
58
  $onInit() {
58
59
  this.fixedValue = this.ngValue || 'id'
@@ -430,6 +431,12 @@ class MbgSelectController {
430
431
  this.executeCallback(isNew)
431
432
  this.pressEnter = false
432
433
  this.hasFocus = false
434
+ if (item instanceof Array) {
435
+ if (this.onSelect) {
436
+ item.forEach((i) => this.onSelect({ value: i }))
437
+ return
438
+ }
439
+ }
433
440
  await this.updateModelValue(this.ngValue ? item[this.ngValue] : item)
434
441
  if (this.onSelect) {
435
442
  this.onSelect({ value: this.ngModel })
@@ -599,8 +606,19 @@ class MbgSelectController {
599
606
  favorite(evt, item) {
600
607
  evt.preventDefault()
601
608
  evt.stopPropagation()
602
- if (this.isFavorite(item)) {
609
+ if (this.isFavorite(item) && !this.manyFavorite) {
603
610
  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
+ }
604
622
  } else {
605
623
  MbgCookie.set(this.getFavoriteKey(), item)
606
624
  }
@@ -621,7 +639,11 @@ class MbgSelectController {
621
639
 
622
640
  isFavorite(item) {
623
641
  const favorite = MbgCookie.get(this.getFavoriteKey())
624
- return favorite && angular.equals(favorite, item)
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
+ }
625
647
  }
626
648
 
627
649
  async fixedOption(evt, item) {
@@ -672,7 +694,8 @@ const mbgSelect = {
672
694
  callbackAddFixedOption: '&?',
673
695
  transcludeSize: '=?',
674
696
  getCustomModel: '&?',
675
- capitalize: '=?'
697
+ capitalize: '=?',
698
+ manyFavorite: '=?',
676
699
  },
677
700
  controller: MbgSelectController,
678
701
  template,