mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[DURACOM-237] - Refactoring ts based on @angular/cdk/drag-drop
This commit is contained in:
@@ -5,8 +5,8 @@ import isObject from 'lodash/isObject';
|
|||||||
|
|
||||||
import { Chips } from './models/chips.model';
|
import { Chips } from './models/chips.model';
|
||||||
import { ChipsItem } from './models/chips-item.model';
|
import { ChipsItem } from './models/chips-item.model';
|
||||||
import { DragService } from '../../../core/drag.service';
|
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
||||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
import { CdkDragDrop, CdkDragStart, moveItemInArray} from '@angular/cdk/drag-drop';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { AsyncPipe, NgClass, NgForOf, NgIf } from '@angular/common';
|
import { AsyncPipe, NgClass, NgForOf, NgIf } from '@angular/common';
|
||||||
import { AuthorityConfidenceStateDirective } from '../directives/authority-confidence-state.directive';
|
import { AuthorityConfidenceStateDirective } from '../directives/authority-confidence-state.directive';
|
||||||
@@ -43,9 +43,7 @@ export class ChipsComponent implements OnChanges {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
private dragService: DragService,
|
|
||||||
private translate: TranslateService) {
|
private translate: TranslateService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
@@ -77,19 +75,14 @@ export class ChipsComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDragStart(index) {
|
onDrag(event: CdkDragStart<ChipsItem[]>) {
|
||||||
this.isDragging.next(true);
|
this.isDragging.next(true);
|
||||||
this.dragService.overrideDragOverPage();
|
|
||||||
this.dragged = index;
|
|
||||||
}
|
}
|
||||||
|
onDrop(event: CdkDragDrop<ChipsItem[]>) {
|
||||||
onDragEnd(event) {
|
moveItemInArray(this.chips.chipsItems.getValue(), event.previousIndex, event.currentIndex);
|
||||||
this.dragService.allowDragOverPage();
|
|
||||||
this.dragged = -1;
|
|
||||||
this.chips.updateOrder();
|
this.chips.updateOrder();
|
||||||
this.isDragging.next(false);
|
this.isDragging.next(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
showTooltip(tooltip: NgbTooltip, index, field?) {
|
showTooltip(tooltip: NgbTooltip, index, field?) {
|
||||||
tooltip.close();
|
tooltip.close();
|
||||||
const chipsItem = this.chips.getChipByIndex(index);
|
const chipsItem = this.chips.getChipByIndex(index);
|
||||||
@@ -122,5 +115,4 @@ export class ChipsComponent implements OnChanges {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user