|
@@ -1,16 +1,10 @@
|
|
|
-import {
|
|
|
|
|
- AfterViewInit,
|
|
|
|
|
- Component,
|
|
|
|
|
- ComponentFactory,
|
|
|
|
|
- Input,
|
|
|
|
|
- OnInit,
|
|
|
|
|
- ViewChild,
|
|
|
|
|
- ViewContainerRef,
|
|
|
|
|
-} from '@angular/core';
|
|
|
|
|
-import { FormControl, FormGroup } from '@angular/forms';
|
|
|
|
|
|
|
+import { Component, ComponentFactory, Input, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
|
|
|
|
|
+import { FormGroup } from '@angular/forms';
|
|
|
|
|
+import { Observable } from 'rxjs';
|
|
|
|
|
+import { map } from 'rxjs/operators';
|
|
|
|
|
|
|
|
import { InputComponentConfig } from '../../../common/component-registry-types';
|
|
import { InputComponentConfig } from '../../../common/component-registry-types';
|
|
|
-import { CustomFieldConfig, CustomFieldsFragment } from '../../../common/generated-types';
|
|
|
|
|
|
|
+import { CustomFieldConfig, CustomFieldsFragment, LanguageCode } from '../../../common/generated-types';
|
|
|
import { DataService } from '../../../data/providers/data.service';
|
|
import { DataService } from '../../../data/providers/data.service';
|
|
|
import {
|
|
import {
|
|
|
CustomFieldComponentService,
|
|
CustomFieldComponentService,
|
|
@@ -27,7 +21,7 @@ import {
|
|
|
templateUrl: './custom-field-control.component.html',
|
|
templateUrl: './custom-field-control.component.html',
|
|
|
styleUrls: ['./custom-field-control.component.scss'],
|
|
styleUrls: ['./custom-field-control.component.scss'],
|
|
|
})
|
|
})
|
|
|
-export class CustomFieldControlComponent {
|
|
|
|
|
|
|
+export class CustomFieldControlComponent implements OnInit {
|
|
|
@Input() entityName: CustomFieldEntityName;
|
|
@Input() entityName: CustomFieldEntityName;
|
|
|
@Input('customFieldsFormGroup') formGroup: FormGroup;
|
|
@Input('customFieldsFormGroup') formGroup: FormGroup;
|
|
|
@Input() customField: CustomFieldsFragment;
|
|
@Input() customField: CustomFieldsFragment;
|
|
@@ -37,13 +31,21 @@ export class CustomFieldControlComponent {
|
|
|
hasCustomControl = false;
|
|
hasCustomControl = false;
|
|
|
@ViewChild('customComponentPlaceholder', { read: ViewContainerRef })
|
|
@ViewChild('customComponentPlaceholder', { read: ViewContainerRef })
|
|
|
private customComponentPlaceholder: ViewContainerRef;
|
|
private customComponentPlaceholder: ViewContainerRef;
|
|
|
|
|
+
|
|
|
private customComponentFactory: ComponentFactory<CustomFieldControl> | undefined;
|
|
private customComponentFactory: ComponentFactory<CustomFieldControl> | undefined;
|
|
|
|
|
+ uiLanguage$: Observable<LanguageCode>;
|
|
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
|
private dataService: DataService,
|
|
private dataService: DataService,
|
|
|
private customFieldComponentService: CustomFieldComponentService,
|
|
private customFieldComponentService: CustomFieldComponentService,
|
|
|
) {}
|
|
) {}
|
|
|
|
|
|
|
|
|
|
+ ngOnInit() {
|
|
|
|
|
+ this.uiLanguage$ = this.dataService.client
|
|
|
|
|
+ .uiState()
|
|
|
|
|
+ .stream$.pipe(map(({ uiState }) => uiState.language));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
getFieldDefinition(): CustomFieldConfig & { ui?: InputComponentConfig } {
|
|
getFieldDefinition(): CustomFieldConfig & { ui?: InputComponentConfig } {
|
|
|
const config: CustomFieldsFragment & { ui?: InputComponentConfig } = {
|
|
const config: CustomFieldsFragment & { ui?: InputComponentConfig } = {
|
|
|
...this.customField,
|
|
...this.customField,
|