Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

43 lines
1.2 KiB

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { RuleElementDto } from '@app/shared';
@Component({
selector: 'sqx-generic-action',
styleUrls: ['./generic-action.component.scss'],
templateUrl: './generic-action.component.html'
})
export class GenericActionComponent implements OnChanges {
@Input()
public definition: RuleElementDto;
@Input()
public action: any;
@Input()
public actionForm: FormGroup;
public ngOnChanges(changes: SimpleChanges) {
if (changes['actionForm'] || changes['definition']) {
for (const property of this.definition.properties) {
const validator =
property.isRequired ?
Validators.required :
Validators.nullValidator;
const control = new FormControl('', validator);
this.actionForm.setControl(property.name, control);
}
}
this.actionForm.patchValue(this.action);
}
}