Skip to content

Commit

Permalink
disable cdk drag properly
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Jan 28, 2025
1 parent 881e88f commit b65441f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*ngFor="let item of getFormControlArray().controls!; index as i; trackBy: trackByFn"
[formGroupName]="i"
cdkDrag
[cdkDragDisabled]="!movable"
>
<div class="drag-drop-dots" *ngIf="movable">
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
FormArray,
FormArrayName,
FormControl,
FormGroup
FormGroup, Validators
} from '@angular/forms';
import { Observable, ReplaySubject } from 'rxjs';

Expand All @@ -33,7 +33,7 @@ export interface Item {
export class ActionPlanComponent implements AfterContentInit {
@Input() onDelete?: (index: number) => Observable<any>;

@Input() movable = true;
@Input() movable = false;

@ViewChildren('listItem')
listItems!: QueryList<ElementRef>;
Expand Down Expand Up @@ -90,7 +90,8 @@ export class ActionPlanComponent implements AfterContentInit {

addNewItem(item?: Item) {
const newFormGroup = new FormGroup({
item: new FormControl<string>(item?.item || ''),
item: new FormControl<string>(item?.item || '', [Validators.minLength(2),
Validators.required]),
id: new FormControl<number | undefined>(item?.id || undefined),
isChecked: new FormControl<boolean>(item?.isChecked || false)
} as FormControlsOf<Item>);
Expand Down

0 comments on commit b65441f

Please sign in to comment.