Adjustements everywhere

This commit is contained in:
2023-01-26 14:58:16 +01:00
parent ac744604ed
commit 012c80d29e
13 changed files with 125 additions and 59 deletions

View File

@@ -20,12 +20,14 @@ export class CrudFormlyJsonschemaService extends FormlyJsonschema {
}
getCreateFields(resourceName: string): Observable<FormlyFieldConfig> {
resourceName = resourceName.charAt(0).toUpperCase() + resourceName.slice(1);
return this.jsonSchemasService.getCreateResource(resourceName).pipe(
map((schemas: any) => this.toFieldConfig(schemas)),
)
}
getUpdateFields(resourceName: string): Observable<FormlyFieldConfig> {
resourceName = resourceName.charAt(0).toUpperCase() + resourceName.slice(1);
return this.jsonSchemasService.getUpdateResource(resourceName).pipe(
map((schemas: any) => this.toFieldConfig(schemas)),
)
@@ -35,8 +37,16 @@ export class CrudFormlyJsonschemaService extends FormlyJsonschema {
export class CrudFormlyJsonschemaOptions implements FormlyJsonschemaOptions {
map = (field: any, schema: any) => {
if (schema.hasOwnProperty('foreignKey')) {
field.type = "foreign-key";
field.foreignKey = schema['foreignKey'];
} else if (schema.format === 'date-time') {
field.type = "datetime";
} else if (schema.format === 'date') {
field.type = "date";
} else if (schema.hasOwnProperty('enum') && schema.enum.length == 1 && schema.enum[0] == schema.default ) {
field.type = "hidden";
}
return field;
}
}