diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html index 9cdc06401c1..d66ad6c344f 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html @@ -1,17 +1,13 @@ - - + - + -
+
- + @@ -103,7 +99,7 @@ [class.is-invalid]="typeahead.classList.contains('is-invalid')" class="form-control" /> - +
@@ -143,11 +139,14 @@ >
-
- + diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts index ec1ba4ea1bf..e18c0ab8a4c 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts @@ -60,7 +60,7 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { asterisk = ''; - containerClassName = 'mb-3 form-group' + containerClassName = 'mb-3 form-group'; options$: Observable[]> = of([]); @@ -136,6 +136,7 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { ngAfterViewInit() { if (this.first && this.fieldRef) { this.fieldRef.nativeElement.focus(); + this.cdRef.detectChanges(); } } @@ -213,7 +214,7 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { this.validators = validators(this.data); this.setAsterisk(); } - if(className !== undefined){ + if (className !== undefined) { this.containerClassName = className; } diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts index 14de1a94f46..af0ae767d7f 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts @@ -9,6 +9,7 @@ import { PropContributorCallback, PropContributorCallbacks, PropData, + PropDisplayTextResolver, PropList, PropPredicate, Props, @@ -69,6 +70,7 @@ export class FormProp extends Prop { readonly template?: Type; readonly className?: string; readonly group?: FormPropGroup | undefined; + readonly displayTextResolver?: PropDisplayTextResolver; constructor(options: FormPropOptions) { super( @@ -93,6 +95,7 @@ export class FormProp extends Prop { this.id = options.id || options.name; const defaultValue = options.defaultValue; this.defaultValue = isFalsyValue(defaultValue) ? defaultValue : defaultValue || null; + this.displayTextResolver = options.displayTextResolver; } static create(options: FormPropOptions) { @@ -128,6 +131,7 @@ export type FormPropOptions = O.Optional< | 'defaultValue' | 'options' | 'id' + | 'displayTextResolver' >; export type CreateFormPropDefaults = Record[]>; diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts index 3799c419a73..456a280ba85 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts @@ -35,6 +35,7 @@ export abstract class Prop { public readonly isExtra = false, public readonly template?: Type, public readonly className?: string, + public readonly displayTextResolver?: PropDisplayTextResolver, ) { this.displayName = this.displayName || this.name; } @@ -42,6 +43,7 @@ export abstract class Prop { export type PropCallback = (data: Omit, 'data'>, auxData?: any) => R; export type PropPredicate = (data?: Omit, 'data'>, auxData?: any) => boolean; +export type PropDisplayTextResolver = (data?: Omit, 'data'>) => string; export abstract class PropsFactory> { protected abstract _ctor: Type;