Browse Source

add data record as token on Extensible-form-prop

pull/13700/head
Mahmut Gundogdu 4 years ago
parent
commit
dde4e9df46
  1. 12
      npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts
  2. 4
      npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensions.token.ts

12
npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts

@ -1,3 +1,4 @@
import { FORM_PROP, FORM_PROP_DATA } from './../../tokens/extensions.token';
import {ABP, AbpValidators, ConfigStateService, TrackByService} from '@abp/ng.core';
import {
AfterViewInit,
@ -30,8 +31,7 @@ import {FormProp} from '../../models/form-props';
import {PropData} from '../../models/props';
import {selfFactory} from '../../utils/factory.util';
import {addTypeaheadTextSuffix} from '../../utils/typeahead.util';
import {FORM_PROP_DATA_STREAM} from "../../tokens/extensions.token";
@Component({
selector: 'abp-extensible-form-prop',
templateUrl: './extensible-form-prop.component.html',
@ -181,16 +181,20 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit {
}
}
ngOnChanges({prop}: SimpleChanges) {
ngOnChanges({prop,data}: SimpleChanges) {
const currentProp = prop?.currentValue as FormProp;
const {options, readonly, disabled, validators, template} = currentProp || {};
if (template) {
this.injectorForCustomComponent = Injector.create({
providers: [
{
provide: FORM_PROP_DATA_STREAM,
provide: FORM_PROP,
useValue: currentProp
},
{
provide: FORM_PROP_DATA,
useValue: (data?.currentValue as PropData)?.record
},
{ provide: ControlContainer, useExisting: FormGroupDirective }
],
parent: this.injector,

4
npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensions.token.ts

@ -4,6 +4,7 @@ import { ExtensionsService } from '../services/extensions.service';
import { Observable } from 'rxjs';
import { ePropType } from '../enums/props.enum';
import {FormProp} from "../models/form-props";
import { PropData } from '../models/props';
export const EXTENSIONS_IDENTIFIER = new InjectionToken<string>('EXTENSIONS_IDENTIFIER');
export type ActionKeys = Extract<'entityActions' | 'toolbarActions', keyof ExtensionsService>;
@ -26,4 +27,5 @@ export const ENTITY_PROP_TYPE_CLASSES = new InjectionToken<EntityPropTypeClass>(
},
);
export const FORM_PROP_DATA_STREAM = new InjectionToken<FormProp>('FORM_PROP_DATA_STREAM');
export const EXTENSIONS_FORM_PROP = new InjectionToken<FormProp>('EXTENSIONS_FORM_PROP');
export const EXTENSIONS_FORM_PROP_DATA = new InjectionToken<unknown>('EXTENSIONS_FORM_PROP_DATA');

Loading…
Cancel
Save