|
@@ -77,7 +77,7 @@ export class DynaformComponent implements OnInit {
|
|
|
|
|
|
const path = [...this.path];
|
|
|
const metaDataKeysExpected = this.controlNames.join(',');
|
|
|
- while (path.length && metaDataKeysExpected !== Object.keys(this.formMetaData).join(',')) {
|
|
|
+ while (path.length && metaDataKeysExpected !== this.getContolKeysCSVFromMetadata(this.formMetaData)) {
|
|
|
const branch = path.pop();
|
|
|
this.formMetaData = this.formMetaData[branch].meta;
|
|
|
}
|
|
@@ -86,15 +86,12 @@ export class DynaformComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
- const metaDataKeys = Object.entries(this.formMetaData)
|
|
|
- .filter(([key, val]) => !(<StringMap>val).noFormControls)
|
|
|
- .reduce((acc, [key]) => [...acc, key], [])
|
|
|
- .join(',');
|
|
|
- if (metaDataKeys !== metaDataKeysExpected) {
|
|
|
+ const metaDataKeysFound = this.getContolKeysCSVFromMetadata(this.formMetaData);
|
|
|
+ if (metaDataKeysFound !== metaDataKeysExpected) {
|
|
|
throw new Error(`
|
|
|
Dynaform can't match FormGroup's controls with metadata
|
|
|
Expected ${metaDataKeysExpected}
|
|
|
- Got ${metaDataKeys}`
|
|
|
+ Got ${metaDataKeysFound}`
|
|
|
);
|
|
|
}
|
|
|
}
|
|
@@ -119,7 +116,6 @@ export class DynaformComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
getTemplateContext(controlName: string): DynarowContext {
|
|
|
-
|
|
|
return {
|
|
|
control: this.formGroup.get(controlName),
|
|
|
meta: this.formMetaData[controlName]
|
|
@@ -132,7 +128,6 @@ export class DynaformComponent implements OnInit {
|
|
|
|
|
|
getValidationErrors() {
|
|
|
if (!this.formGroup.valid) {
|
|
|
-
|
|
|
const errorsFlat = SuperForm.getAllErrorsFlat(this.formGroup);
|
|
|
return errorsFlat;
|
|
|
}
|
|
@@ -140,7 +135,19 @@ export class DynaformComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
handle(val) {
|
|
|
+ console.log('Dynaform Component', val);
|
|
|
this.call.emit(val);
|
|
|
}
|
|
|
|
|
|
+ private getContolKeysCSVFromMetadata(metadata): string {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return Object.entries(metadata)
|
|
|
+ .filter(([key, val]) => !(<StringMap>val).noFormControls)
|
|
|
+ .reduce((acc, [key]) => [...acc, key], [])
|
|
|
+ .join(',');
|
|
|
+ }
|
|
|
+
|
|
|
}
|