Adding Date and working on fereign keys
This commit is contained in:
34
front/app/src/common/crud/crud-formly-jsonschema.service.ts
Normal file
34
front/app/src/common/crud/crud-formly-jsonschema.service.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { FormlyJsonschema } from "@ngx-formly/core/json-schema";
|
||||
import { FormlyJsonschemaOptions } from "@ngx-formly/core/json-schema/formly-json-schema.service";
|
||||
import { FormlyFieldConfig } from "@ngx-formly/core";
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import {JsonschemasService } from "./jsonschemas.service";
|
||||
import {Observable, map, tap} from "rxjs";
|
||||
import {Injectable} from "@angular/core";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CrudFormlyJsonschemaService extends FormlyJsonschema {
|
||||
constructor(private jsonSchemasService: JsonschemasService) {
|
||||
super();
|
||||
}
|
||||
|
||||
override toFieldConfig(schema: JSONSchema7, options?: FormlyJsonschemaOptions): FormlyFieldConfig {
|
||||
return super.toFieldConfig(schema, options);
|
||||
}
|
||||
|
||||
getCreateFields(resourceName: string): Observable<FormlyFieldConfig> {
|
||||
return this.jsonSchemasService.getCreateResource(resourceName).pipe(
|
||||
map((schemas: any) => this.toFieldConfig(schemas)),
|
||||
tap(console.log),
|
||||
)
|
||||
}
|
||||
|
||||
getUpdateFields(resourceName: string): Observable<FormlyFieldConfig> {
|
||||
return this.jsonSchemasService.getUpdateResource(resourceName).pipe(
|
||||
map((schemas: any) => this.toFieldConfig(schemas)),
|
||||
tap(console.log),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user