Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ицкович Алексей Анатольевич committed Feb 25, 2024
1 parent 6936cd9 commit a1f0082
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,4 @@
</mat-form-field>

<configurator-linear-values [displayWith]="displayWith" [options]="data.rValues" label="Value" formControlName="parameters"/>
<!-- <mat-form-field appearance="outline">-->
<!-- <mat-label>Value</mat-label>-->
<!-- <input-->
<!-- formControlName="parameters"-->
<!-- matInput-->
<!-- placeholder="..."-->
<!-- type="number"-->
<!-- >-->
<!-- </mat-form-field>-->
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class ExpressionComponent implements OnInit, OnDestroy {
)
.subscribe((data) => {
this.onChange({
expression: [this.makeAction(data.left), data.operand!, this.makeAction(data.right)],
expression: [data.left as LinearValues, data.operand!, data.right as LinearValues],
operator: data.operator,
});
});
Expand Down Expand Up @@ -147,22 +147,6 @@ export class ExpressionComponent implements OnInit, OnDestroy {
}
}
}

private makeAction(value: LinearValues<Action> | null | undefined): LinearValues<Action> | null {
const zero: Action | string | number | undefined | null = value?.[0];
if (typeof zero === 'string' || typeof zero === 'number') {
return [{
parentId: `${zero}`,
title: `${zero}`,
parameters: [zero],
template: '{0}',
isUserInput: true,
// @ts-ignore
}, value[1], value[2]]
}

return value ?? null;
}
}

interface Option {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class LinearValuesComponent implements ControlValueAccessor, OnInit, OnDe
displayWith: ((value: any) => string) | null = null;

public readonly linearFrom = new FormGroup({
value: new FormControl<Action | undefined>(undefined, [Validators.required]),
value: new FormControl<Action | null | string | number>(null, [Validators.required]),
alpha: new FormControl<number>(1),
betta: new FormControl<number>(0),
})
Expand All @@ -57,7 +57,17 @@ export class LinearValuesComponent implements ControlValueAccessor, OnInit, OnDe
this.linearFrom.valueChanges.pipe(
takeUntil(this.destroy$),
).subscribe(data => {
this.onChange([data.value ?? null, data.alpha ?? 1, data.betta ?? 0]);
let value = data.value;
if (value && (typeof value === 'string' || typeof value === 'number')) {
value = {
parentId: `${value}`,
title: `${value}`,
parameters: [],
template: '{0}',
isUserInput: true,
};
}
this.onChange([value as Action, data.alpha ?? 1, data.betta ?? 0]);
})
}

Expand Down

0 comments on commit a1f0082

Please sign in to comment.