|
|
@ -114,7 +114,6 @@ export class AxisScaleRowComponent implements ControlValueAccessor, OnInit, Vali |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
writeValue(value: ValueSourceConfig) { |
|
|
writeValue(value: ValueSourceConfig) { |
|
|
console.log("value", value); |
|
|
|
|
|
this.modelValue = value; |
|
|
this.modelValue = value; |
|
|
this.limitForm.patchValue( |
|
|
this.limitForm.patchValue( |
|
|
{ |
|
|
{ |
|
|
@ -147,14 +146,36 @@ export class AxisScaleRowComponent implements ControlValueAccessor, OnInit, Vali |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
validate(): ValidationErrors | null { |
|
|
validate(): ValidationErrors | null { |
|
|
return this.limitForm.valid ? null : { |
|
|
const type = this.limitForm.get('type')?.value; |
|
|
axisLimitForm: { |
|
|
const errors: any = {}; |
|
|
valid: false, |
|
|
|
|
|
errors: this.getFormErrors() |
|
|
if (this.limitForm.invalid) { |
|
|
|
|
|
errors.form = this.getFormErrors(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (type === ValueSourceType.latestKey) { |
|
|
|
|
|
if (!this.latestKeyFormControl.value || this.latestKeyFormControl.invalid) { |
|
|
|
|
|
errors.latestKey = { |
|
|
|
|
|
valid: false |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
} else if (type === ValueSourceType.entity) { |
|
|
|
|
|
if (!this.limitForm.get('entityAlias')?.value) { |
|
|
|
|
|
errors.entityAlias = { |
|
|
|
|
|
valid: false |
|
|
|
|
|
}; |
|
|
} |
|
|
} |
|
|
}; |
|
|
if (!this.entityKeyFormControl.value || this.entityKeyFormControl.invalid) { |
|
|
|
|
|
errors.entityKey = { |
|
|
|
|
|
valid: false |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Object.keys(errors).length ? { axisLimitForm: errors } : null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private getFormErrors(): any { |
|
|
private getFormErrors(): any { |
|
|
const errors: any = {}; |
|
|
const errors: any = {}; |
|
|
Object.keys(this.limitForm.controls).forEach(key => { |
|
|
Object.keys(this.limitForm.controls).forEach(key => { |
|
|
@ -175,6 +196,7 @@ export class AxisScaleRowComponent implements ControlValueAccessor, OnInit, Vali |
|
|
this.entityKeyFormControl.clearValidators(); |
|
|
this.entityKeyFormControl.clearValidators(); |
|
|
} else if (type === ValueSourceType.entity) { |
|
|
} else if (type === ValueSourceType.entity) { |
|
|
this.latestKeyFormControl.clearValidators(); |
|
|
this.latestKeyFormControl.clearValidators(); |
|
|
|
|
|
this.limitForm.get('entityAlias').setValidators([Validators.required]); |
|
|
this.entityKeyFormControl.setValidators([Validators.required]); |
|
|
this.entityKeyFormControl.setValidators([Validators.required]); |
|
|
} else { |
|
|
} else { |
|
|
this.latestKeyFormControl.clearValidators(); |
|
|
this.latestKeyFormControl.clearValidators(); |
|
|
@ -184,6 +206,7 @@ export class AxisScaleRowComponent implements ControlValueAccessor, OnInit, Vali |
|
|
this.entityKeyFormControl.updateValueAndValidity({ emitEvent: false }); |
|
|
this.entityKeyFormControl.updateValueAndValidity({ emitEvent: false }); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private subscribeToTypeChanges() { |
|
|
private subscribeToTypeChanges() { |
|
|
this.limitForm.controls.type.valueChanges |
|
|
this.limitForm.controls.type.valueChanges |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
|