|
|
@ -18,12 +18,12 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core'; |
|
|
import { |
|
|
import { |
|
|
AbstractControl, |
|
|
AbstractControl, |
|
|
ControlValueAccessor, |
|
|
ControlValueAccessor, |
|
|
|
|
|
NG_VALIDATORS, |
|
|
|
|
|
NG_VALUE_ACCESSOR, |
|
|
UntypedFormArray, |
|
|
UntypedFormArray, |
|
|
UntypedFormBuilder, |
|
|
UntypedFormBuilder, |
|
|
UntypedFormControl, |
|
|
UntypedFormControl, |
|
|
UntypedFormGroup, |
|
|
UntypedFormGroup, |
|
|
NG_VALIDATORS, |
|
|
|
|
|
NG_VALUE_ACCESSOR, |
|
|
|
|
|
Validator, |
|
|
Validator, |
|
|
Validators |
|
|
Validators |
|
|
} from '@angular/forms'; |
|
|
} from '@angular/forms'; |
|
|
@ -104,6 +104,9 @@ export class EntityTypesVersionCreateComponent extends PageComponent implements |
|
|
this.entityTypesVersionCreateFormGroup.disable({emitEvent: false}); |
|
|
this.entityTypesVersionCreateFormGroup.disable({emitEvent: false}); |
|
|
} else { |
|
|
} else { |
|
|
this.entityTypesVersionCreateFormGroup.enable({emitEvent: false}); |
|
|
this.entityTypesVersionCreateFormGroup.enable({emitEvent: false}); |
|
|
|
|
|
(this.entityTypesVersionCreateFormGroup.get('entityTypes') as UntypedFormArray).controls.forEach( |
|
|
|
|
|
control => this.updateEntityTypeValidators(control) |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -147,7 +150,7 @@ export class EntityTypesVersionCreateComponent extends PageComponent implements |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
this.updateEntityTypeValidators(entityTypeControl); |
|
|
this.updateEntityTypeValidators(entityTypeControl); |
|
|
entityTypeControl.get('config').get('allEntities').valueChanges.subscribe(() => { |
|
|
entityTypeControl.get('config.allEntities').valueChanges.subscribe(() => { |
|
|
this.updateEntityTypeValidators(entityTypeControl); |
|
|
this.updateEntityTypeValidators(entityTypeControl); |
|
|
}); |
|
|
}); |
|
|
return entityTypeControl; |
|
|
return entityTypeControl; |
|
|
@ -229,7 +232,7 @@ export class EntityTypesVersionCreateComponent extends PageComponent implements |
|
|
allowedEntityTypes(entityTypeControl?: AbstractControl): Array<EntityType> { |
|
|
allowedEntityTypes(entityTypeControl?: AbstractControl): Array<EntityType> { |
|
|
let res = [...exportableEntityTypes]; |
|
|
let res = [...exportableEntityTypes]; |
|
|
const currentEntityType: EntityType = entityTypeControl?.get('entityType')?.value; |
|
|
const currentEntityType: EntityType = entityTypeControl?.get('entityType')?.value; |
|
|
const value: [{entityType: string, config: EntityTypeVersionCreateConfig}] = |
|
|
const value: [{entityType: string; config: EntityTypeVersionCreateConfig}] = |
|
|
this.entityTypesVersionCreateFormGroup.get('entityTypes').value || []; |
|
|
this.entityTypesVersionCreateFormGroup.get('entityTypes').value || []; |
|
|
const usedEntityTypes = value.map(val => val.entityType).filter(val => val); |
|
|
const usedEntityTypes = value.map(val => val.entityType).filter(val => val); |
|
|
res = res.filter(entityType => !usedEntityTypes.includes(entityType) || entityType === currentEntityType); |
|
|
res = res.filter(entityType => !usedEntityTypes.includes(entityType) || entityType === currentEntityType); |
|
|
@ -237,7 +240,7 @@ export class EntityTypesVersionCreateComponent extends PageComponent implements |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private updateModel() { |
|
|
private updateModel() { |
|
|
const value: [{entityType: string, config: EntityTypeVersionCreateConfig}] = |
|
|
const value: [{entityType: string; config: EntityTypeVersionCreateConfig}] = |
|
|
this.entityTypesVersionCreateFormGroup.get('entityTypes').value || []; |
|
|
this.entityTypesVersionCreateFormGroup.get('entityTypes').value || []; |
|
|
let modelValue: {[entityType: string]: EntityTypeVersionCreateConfig} = null; |
|
|
let modelValue: {[entityType: string]: EntityTypeVersionCreateConfig} = null; |
|
|
if (value && value.length) { |
|
|
if (value && value.length) { |
|
|
|