Adjustements everywhere
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user