mirror of https://github.com/abpframework/abp.git
committed by
GitHub
5 changed files with 128 additions and 15 deletions
@ -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[abpFeatureManagementFreeText]', |
|||
exportAs: 'inputAbpFeatureManagementFreeText', |
|||
}) |
|||
export class FreeTextInputDirective { |
|||
_feature: FreeTextType; |
|||
@Input('abpFeatureManagementFreeText') 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; |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
export * from './free-text-input.directive'; |
|||
@ -1,19 +1,22 @@ |
|||
import { CoreModule } from '@abp/ng.core'; |
|||
import { ThemeSharedModule } from '@abp/ng.theme.shared'; |
|||
import { NgModule } from '@angular/core'; |
|||
import { FeatureManagementComponent } from './components/feature-management/feature-management.component'; |
|||
import { NgxsModule } from '@ngxs/store'; |
|||
import { FeatureManagementState } from './states/feature-management.state'; |
|||
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap'; |
|||
import { FreeTextInputDirective } from './directives/free-text-input.directive'; |
|||
import { FeatureManagementComponent } from './components/feature-management/feature-management.component'; |
|||
import { FeatureManagementState } from './states/feature-management.state'; |
|||
|
|||
const exported = [FeatureManagementComponent, FreeTextInputDirective]; |
|||
|
|||
@NgModule({ |
|||
declarations: [FeatureManagementComponent], |
|||
declarations: [...exported], |
|||
imports: [ |
|||
CoreModule, |
|||
ThemeSharedModule, |
|||
NgbNavModule, |
|||
NgxsModule.forFeature([FeatureManagementState]), |
|||
], |
|||
exports: [FeatureManagementComponent], |
|||
exports: [...exported], |
|||
}) |
|||
export class FeatureManagementModule {} |
|||
|
|||
Loading…
Reference in new issue