mirror of https://github.com/abpframework/abp
parent
5a56d91a42
commit
e8d4617e10
@ -0,0 +1,38 @@
|
||||
import { Directive, Input, HostBinding } from '@angular/core';
|
||||
|
||||
// TODO: improve this type
|
||||
export interface FreeTextType {
|
||||
valueType: {
|
||||
validator: {
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export const INPUT_TYPES = {
|
||||
numeric: 'number',
|
||||
default: 'text',
|
||||
};
|
||||
|
||||
@Directive({
|
||||
selector: 'input[abpFreeText]',
|
||||
exportAs: 'inputAbpFreeText',
|
||||
})
|
||||
export class FreeTextInputDirective {
|
||||
_feature: FreeTextType;
|
||||
@Input('abpFreeText') set feature(val: FreeTextType) {
|
||||
this._feature = val;
|
||||
this.setInputType();
|
||||
}
|
||||
|
||||
get feature() {
|
||||
return this._feature;
|
||||
}
|
||||
|
||||
@HostBinding('type') type: string;
|
||||
|
||||
private setInputType() {
|
||||
const validatorType = this.feature?.valueType?.validator?.name.toLowerCase();
|
||||
this.type = INPUT_TYPES[validatorType] ?? INPUT_TYPES.default;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue