Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/app/shared/forms/planet-step-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ import {
} from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { UntypedFormArray } from '@angular/forms';
import { AbstractControl, FormArray, FormGroup } from '@angular/forms';
import { uniqueId } from '../utils';

type PlanetStepListFormGroup = FormGroup<Record<string, AbstractControl<unknown>>>;
type PlanetStepListFormArray = FormArray<PlanetStepListFormGroup | AbstractControl<unknown>>;

@Injectable({
providedIn: 'root'
})
Expand Down Expand Up @@ -71,7 +74,7 @@ export class PlanetStepListItemComponent {
})
export class PlanetStepListComponent implements AfterContentChecked, OnDestroy {

@Input() steps: any[] | UntypedFormArray;
@Input() steps: any[] | PlanetStepListFormArray;
@Input() nameProp: string;
@Input() defaultName = 'Step';
@Input() ignoreClick = false;
Expand Down Expand Up @@ -122,9 +125,9 @@ export class PlanetStepListComponent implements AfterContentChecked, OnDestroy {
if (listId !== this.listId) {
return;
}
if (this.steps instanceof Array) {
if (Array.isArray(this.steps)) {
this.moveArrayStep(index, direction, this.steps);
} else if (this.steps instanceof UntypedFormArray) {
} else if (this.steps instanceof FormArray) {
this.moveFormArrayStep(index, direction, this.steps);
}
if (Array.isArray(this.steps)) {
Expand All @@ -139,7 +142,7 @@ export class PlanetStepListComponent implements AfterContentChecked, OnDestroy {
}
}

moveFormArrayStep(index, direction, steps: UntypedFormArray) {
moveFormArrayStep(index, direction, steps: PlanetStepListFormArray) {
const step = steps.at(index);
steps.removeAt(index);
if (direction !== 0) {
Expand Down
Loading