From 3051fa8d8d2ff6e28af49592c8b657f0487eacd5 Mon Sep 17 00:00:00 2001 From: Simone Ramundi Date: Thu, 29 Feb 2024 16:12:26 +0100 Subject: [PATCH 01/14] [DURACOM-237] - Added DragDropModule which replaced the SortablejsModule inside form.module.ts --- src/app/shared/form/form.module.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/shared/form/form.module.ts b/src/app/shared/form/form.module.ts index 0bc87bef90..9a60c12f3f 100644 --- a/src/app/shared/form/form.module.ts +++ b/src/app/shared/form/form.module.ts @@ -61,6 +61,7 @@ import { DynamicFormsNGBootstrapUIModule } from '@ng-dynamic-forms/ui-ng-bootstr import { ChipsComponent } from './chips/chips.component'; import { NumberPickerComponent } from './number-picker/number-picker.component'; import { AuthorityConfidenceStateDirective } from './directives/authority-confidence-state.directive'; +import { DragDropModule } from '@angular/cdk/drag-drop'; import { VocabularyTreeviewComponent } from './vocabulary-treeview/vocabulary-treeview.component'; import { VocabularyTreeviewModalComponent } from './vocabulary-treeview-modal/vocabulary-treeview-modal.component'; import { FormBuilderService } from './builder/form-builder.service'; @@ -126,6 +127,7 @@ const DIRECTIVES = [ NgxMaskModule.forRoot(), NgbDatepickerModule, NgbTimepickerModule, + DragDropModule, CdkTreeModule, ...COMPONENTS, ...DIRECTIVES From 3807a3563c93188bf0b31a8ddaee93fe0a33c82c Mon Sep 17 00:00:00 2001 From: Simone Ramundi Date: Thu, 29 Feb 2024 16:14:10 +0100 Subject: [PATCH 02/14] [DURACOM-237] - Refactoring ts based on @angular/cdk/drag-drop --- src/app/shared/form/chips/chips.component.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/app/shared/form/chips/chips.component.ts b/src/app/shared/form/chips/chips.component.ts index 56234e3e8b..d4b1cbf589 100644 --- a/src/app/shared/form/chips/chips.component.ts +++ b/src/app/shared/form/chips/chips.component.ts @@ -5,8 +5,8 @@ import isObject from 'lodash/isObject'; import { Chips } from './models/chips.model'; import { ChipsItem } from './models/chips-item.model'; -import { DragService } from '../../../core/drag.service'; -import { TranslateModule, TranslateService } from '@ngx-translate/core'; +import { TranslateService, TranslateModule } from '@ngx-translate/core'; +import { CdkDragDrop, CdkDragStart, moveItemInArray} from '@angular/cdk/drag-drop'; import { BehaviorSubject } from 'rxjs'; import { AsyncPipe, NgClass, NgForOf, NgIf } from '@angular/common'; import { AuthorityConfidenceStateDirective } from '../directives/authority-confidence-state.directive'; @@ -43,9 +43,7 @@ export class ChipsComponent implements OnChanges { constructor( private cdr: ChangeDetectorRef, - private dragService: DragService, private translate: TranslateService) { - } ngOnChanges(changes: SimpleChanges) { @@ -77,19 +75,14 @@ export class ChipsComponent implements OnChanges { } } - onDragStart(index) { + onDrag(event: CdkDragStart) { this.isDragging.next(true); - this.dragService.overrideDragOverPage(); - this.dragged = index; } - - onDragEnd(event) { - this.dragService.allowDragOverPage(); - this.dragged = -1; + onDrop(event: CdkDragDrop) { + moveItemInArray(this.chips.chipsItems.getValue(), event.previousIndex, event.currentIndex); this.chips.updateOrder(); this.isDragging.next(false); } - showTooltip(tooltip: NgbTooltip, index, field?) { tooltip.close(); const chipsItem = this.chips.getChipByIndex(index); @@ -122,5 +115,4 @@ export class ChipsComponent implements OnChanges { } } - } From 0c80b1a366e01c7554b5f17c67985f185473d527 Mon Sep 17 00:00:00 2001 From: Simone Ramundi Date: Thu, 29 Feb 2024 16:14:32 +0100 Subject: [PATCH 03/14] [DURACOM-237] - Refactoring html based on @angular/cdk/drag-drop --- .../shared/form/chips/chips.component.html | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app/shared/form/chips/chips.component.html b/src/app/shared/form/chips/chips.component.html index 0b8835877d..ac203e4c53 100644 --- a/src/app/shared/form/chips/chips.component.html +++ b/src/app/shared/form/chips/chips.component.html @@ -1,20 +1,17 @@
-