@@ -15,12 +15,12 @@ import isObject from 'lodash/isObject';
1515
1616import { Chips } from './models/chips.model' ;
1717import { ChipsItem } from './models/chips-item.model' ;
18- import { DragService } from '../../../core/drag.service' ;
1918import { TranslateService } from '@ngx-translate/core' ;
20- import { Options } from 'sortablejs' ;
2119import { BehaviorSubject , forkJoin } from 'rxjs' ;
2220import { map , take } from 'rxjs/operators' ;
2321import { isNotEmpty } from '../../empty.util' ;
22+ import { CdkDragDrop , moveItemInArray } from '@angular/cdk/drag-drop' ;
23+
2424
2525const TOOLTIP_TEXT_LIMIT = 21 ;
2626@Component ( {
@@ -40,7 +40,6 @@ export class ChipsComponent implements OnChanges {
4040 @Output ( ) change : EventEmitter < any > = new EventEmitter < any > ( ) ;
4141
4242 isDragging : BehaviorSubject < boolean > = new BehaviorSubject < boolean > ( false ) ;
43- options : Options ;
4443 dragged = - 1 ;
4544 tipText$ : BehaviorSubject < string [ ] > = new BehaviorSubject < string [ ] > ( [ ] ) ;
4645
@@ -52,16 +51,7 @@ export class ChipsComponent implements OnChanges {
5251 constructor (
5352 @Inject ( PLATFORM_ID ) protected platformId : string ,
5453 private cdr : ChangeDetectorRef ,
55- private dragService : DragService ,
5654 private translate : TranslateService ) {
57-
58- this . options = {
59- animation : 300 ,
60- chosenClass : 'm-0' ,
61- dragClass : 'm-0' ,
62- filter : '.chips-sort-ignore' ,
63- ghostClass : 'm-0' ,
64- } ;
6555 }
6656
6757 ngOnChanges ( changes : SimpleChanges ) {
@@ -88,14 +78,13 @@ export class ChipsComponent implements OnChanges {
8878 }
8979 }
9080
91- onDragStart ( index ) {
81+ onDrag ( index ) {
9282 this . isDragging . next ( true ) ;
93- this . dragService . overrideDragOverPage ( ) ;
9483 this . dragged = index ;
9584 }
9685
97- onDragEnd ( event ) {
98- this . dragService . allowDragOverPage ( ) ;
86+ onDrop ( event : CdkDragDrop < ChipsItem [ ] > ) {
87+ moveItemInArray ( this . chips . chipsItems . getValue ( ) , event . previousIndex , event . currentIndex ) ;
9988 this . dragged = - 1 ;
10089 this . chips . updateOrder ( ) ;
10190 this . isDragging . next ( false ) ;
@@ -104,6 +93,9 @@ export class ChipsComponent implements OnChanges {
10493 showTooltip ( tooltip : NgbTooltip , index , field ?) {
10594 tooltip . close ( ) ;
10695 let canShowToolTip = true ;
96+ if ( this . isDragging . value ) {
97+ return ;
98+ }
10799 const chipsItem = this . chips . getChipByIndex ( index ) ;
108100 const textToDisplay : string [ ] = [ ] ;
109101 if ( ! chipsItem . editMode && this . dragged === - 1 ) {
0 commit comments