|
|
@ -23,21 +23,21 @@ export class CellComponent implements AfterViewInit {
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.checkIfValid();
|
|
|
|
this.checkIfValid();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} // number | string | boolean | { start: string; end: string; };
|
|
|
|
}
|
|
|
|
get value(): any {
|
|
|
|
get value(): any {
|
|
|
|
return this._value;
|
|
|
|
return this._value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_value: any;
|
|
|
|
_value: number | string | boolean;
|
|
|
|
|
|
|
|
|
|
|
|
rangeForm: FormGroup;
|
|
|
|
|
|
|
|
minValue: number;
|
|
|
|
|
|
|
|
maxValue: number;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Output() valueChange = new EventEmitter<
|
|
|
|
@Output() valueChange = new EventEmitter<number | string | boolean>();
|
|
|
|
number | string | boolean | { start: string; end: string }
|
|
|
|
|
|
|
|
>();
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
@Input()
|
|
|
|
editable = false;
|
|
|
|
set editable(value: boolean) {
|
|
|
|
|
|
|
|
this._editable = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
get editable(): boolean {
|
|
|
|
|
|
|
|
return this._editable;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_editable = false;
|
|
|
|
_inputType = 'text';
|
|
|
|
_inputType = 'text';
|
|
|
|
get inputType(): string {
|
|
|
|
get inputType(): string {
|
|
|
|
return this._inputType;
|
|
|
|
return this._inputType;
|
|
|
@ -48,7 +48,17 @@ export class CellComponent implements AfterViewInit {
|
|
|
|
this.getHtmlInputType(type);
|
|
|
|
this.getHtmlInputType(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@Input()
|
|
|
|
@Input()
|
|
|
|
required = false;
|
|
|
|
set required(value) {
|
|
|
|
|
|
|
|
this._required = value;
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
|
|
|
this.input?.control?.markAsTouched();
|
|
|
|
|
|
|
|
this.checkIfValid();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
get required(): boolean {
|
|
|
|
|
|
|
|
return this._required;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_required = false;
|
|
|
|
@Input()
|
|
|
|
@Input()
|
|
|
|
link: string = null;
|
|
|
|
link: string = null;
|
|
|
|
@Input()
|
|
|
|
@Input()
|
|
|
@ -73,13 +83,12 @@ export class CellComponent implements AfterViewInit {
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
this.value === undefined &&
|
|
|
|
|
|
|
|
this.inputType === 'Boolean' &&
|
|
|
|
this.inputType === 'Boolean' &&
|
|
|
|
this.editable
|
|
|
|
this.editable
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.change(false);
|
|
|
|
this.change(false);
|
|
|
|
}, 0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -98,21 +107,6 @@ export class CellComponent implements AfterViewInit {
|
|
|
|
this.htmlInputType = 'date';
|
|
|
|
this.htmlInputType = 'date';
|
|
|
|
} else if (type === 'DateRange') {
|
|
|
|
} else if (type === 'DateRange') {
|
|
|
|
this.htmlInputType = 'dateRange';
|
|
|
|
this.htmlInputType = 'dateRange';
|
|
|
|
} else if (type === 'NumRange') {
|
|
|
|
|
|
|
|
this.htmlInputType = 'numberRange';
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
!this.value ||
|
|
|
|
|
|
|
|
this.value.min === undefined ||
|
|
|
|
|
|
|
|
this.value.max === undefined
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
this.value = { min: null, max: null };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.rangeForm = new FormGroup({
|
|
|
|
|
|
|
|
minValue: new FormControl(),
|
|
|
|
|
|
|
|
maxValue: new FormControl(),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.rangeForm.controls['minValue'].markAsTouched();
|
|
|
|
|
|
|
|
this.rangeForm.controls['maxValue'].markAsTouched();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -144,41 +138,6 @@ export class CellComponent implements AfterViewInit {
|
|
|
|
this.valueChange.emit(this.value);
|
|
|
|
this.valueChange.emit(this.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
minValueChange(event) {
|
|
|
|
|
|
|
|
this.value.min = Math.abs(this.toNumber(event.target.value));
|
|
|
|
|
|
|
|
this.valueChange.emit(this.value);
|
|
|
|
|
|
|
|
this.checkIfRangeIsValid();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
maxValueChange(event) {
|
|
|
|
|
|
|
|
this.value.max = Math.abs(this.toNumber(event.target.value));
|
|
|
|
|
|
|
|
this.valueChange.emit(this.value);
|
|
|
|
|
|
|
|
this.checkIfRangeIsValid();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkIfRangeIsValid() {
|
|
|
|
|
|
|
|
if (this.value.min === null || this.value.max === null) {
|
|
|
|
|
|
|
|
this.setRangeError(false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.value.min <= this.value.max) {
|
|
|
|
|
|
|
|
this.setRangeError(false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setRangeError(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setRangeError(error: boolean): void {
|
|
|
|
|
|
|
|
this.validityChange.emit(!error);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
|
|
|
this.rangeForm.controls['minValue'].setErrors({ rangeError: true });
|
|
|
|
|
|
|
|
this.rangeForm.controls['maxValue'].setErrors({ rangeError: true });
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.rangeForm.controls['minValue'].setErrors(null);
|
|
|
|
|
|
|
|
this.rangeForm.controls['maxValue'].setErrors(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
transformDate(date) {
|
|
|
|
transformDate(date) {
|
|
|
|
return this.datepipe.transform(date, 'yyyy-MM-dd');
|
|
|
|
return this.datepipe.transform(date, 'yyyy-MM-dd');
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -189,11 +148,4 @@ export class CellComponent implements AfterViewInit {
|
|
|
|
this.validityChange.emit(this.isValid);
|
|
|
|
this.validityChange.emit(this.isValid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
toNumber(str: string): number {
|
|
|
|
|
|
|
|
if (str === '') {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return +str;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|