diff --git a/projects/common/components/input-elements/drop-list.component.ts b/projects/common/components/input-elements/drop-list.component.ts index d0252c5ccf1e4025a3ac15ec22b53d449d858827..10a66e32b64b7454f0714ac3d2916801a0276ca9 100644 --- a/projects/common/components/input-elements/drop-list.component.ts +++ b/projects/common/components/input-elements/drop-list.component.ts @@ -1,13 +1,11 @@ -// eslint-disable-next-line max-classes-per-file import { - Component, Input, Pipe, PipeTransform + Component, Input } from '@angular/core'; import { - CdkDrag, CdkDragDrop, CdkDragEnd, CdkDragStart, CdkDropList, moveItemInArray, transferArrayItem + CdkDrag, CdkDragDrop, CdkDragStart, CdkDropList, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop'; import { DropListElement } from 'common/models/elements/input-elements/drop-list'; import { DragNDropValueObject } from 'common/models/elements/element'; -import { FormGroup } from '@angular/forms'; import { FormElementComponent } from '../../directives/form-element-component.directive'; @Component({ @@ -37,7 +35,7 @@ import { FormElementComponent } from '../../directives/form-element-component.di [class.errors]="elementFormControl.errors && elementFormControl.touched" (focusout)="elementFormControl.markAsTouched()"> <ng-container *ngFor="let dropListValueElement of - (parentForm | dropListValueElements: elementModel.value: elementFormControl.value) let index = index;"> + parentForm ? elementFormControl.value : elementModel.value; let index = index;"> <div *ngIf="!dropListValueElement.imgSrc" class="list-item" cdkDrag [cdkDragData]="dropListValueElement" @@ -138,6 +136,7 @@ export class DropListComponent extends FormElementComponent { } } + /* Move element within the same list to a new index position. */ static isReorderDrop(event: CdkDragDrop<any>): boolean { return event.previousContainer === event.container; } @@ -146,6 +145,7 @@ export class DropListComponent extends FormElementComponent { return event.previousContainer.data.elementModel.copyOnDrop; } + /* Put a copied element back to the source list. */ static isPutBack(event: CdkDragDrop<any>): boolean { return event.container.data.elementModel.copyOnDrop && DropListComponent.isItemIDAlreadyPresent(event.item.data.id, event.container.data.elementFormControl.value); @@ -178,12 +178,3 @@ export class DropListComponent extends FormElementComponent { } } -@Pipe({ - name: 'dropListValueElements' -}) -export class DropListValueElementsPipe implements PipeTransform { - transform(parentForm: FormGroup, elementModelValue: DragNDropValueObject[], elementFormValue: DragNDropValueObject[]) - : DragNDropValueObject[] { - return parentForm ? elementFormValue : elementModelValue; - } -} diff --git a/projects/common/shared.module.ts b/projects/common/shared.module.ts index 7b8002ace3d4fde05e9d7aebcf3e04bcb5770c13..ffd85fbbf4959373df068b8eb704befb6c49db12 100644 --- a/projects/common/shared.module.ts +++ b/projects/common/shared.module.ts @@ -52,7 +52,7 @@ import { } from './components/compound-elements/likert/likert-radio-button-group.component'; import { ImageMagnifierComponent } from './components/media-elements/image-magnifier.component'; import { RadioGroupImagesComponent } from './components/input-elements/radio-group-images.component'; -import { DropListComponent, DropListValueElementsPipe } from './components/input-elements/drop-list.component'; +import { DropListComponent } from './components/input-elements/drop-list.component'; import { ClozeComponent } from './components/compound-elements/cloze/cloze.component'; import { SliderComponent } from './components/input-elements/slider.component'; import { SpellCorrectComponent } from './components/input-elements/spell-correct.component'; @@ -120,7 +120,6 @@ import { GetValuePipe, MathFieldComponent } from './components/input-elements/ma ImageMagnifierComponent, RadioGroupImagesComponent, DropListComponent, - DropListValueElementsPipe, ClozeComponent, HotspotImageComponent, SliderComponent,