Removing meta fields from card ressource
This commit is contained in:
@@ -12,13 +12,17 @@ type CrudRJSFSchema = RJSFSchema & {
|
|||||||
} | undefined;
|
} | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const meta_fields = ["label", "created_at", "created_by", "updated_at", "updated_by"]
|
||||||
|
|
||||||
export const jsonschemaProvider = {
|
export const jsonschemaProvider = {
|
||||||
getCardResourceSchema: async (resourceName: string): Promise<CrudRJSFSchema> => {
|
getCardResourceSchema: async (resourceName: string): Promise<CrudRJSFSchema> => {
|
||||||
const updateSchema = await getResourceSchema(`${resourceName}Update`);
|
const updateSchema = await getResourceSchema(`${resourceName}Update`);
|
||||||
const readSchema = await getResourceSchema(`${resourceName}Read`);
|
const readSchema = await getResourceSchema(`${resourceName}Read`);
|
||||||
|
|
||||||
for (let prop_name in readSchema.properties) {
|
for (let prop_name in readSchema.properties) {
|
||||||
if (! updateSchema.hasOwnProperty(prop_name)) {
|
if (meta_fields.indexOf(prop_name) > -1) {
|
||||||
|
delete readSchema.properties[prop_name];
|
||||||
|
} else if (! updateSchema.hasOwnProperty(prop_name)) {
|
||||||
if (is_reference(readSchema.properties[prop_name])) {
|
if (is_reference(readSchema.properties[prop_name])) {
|
||||||
let subresourceName = get_reference_name(readSchema.properties[prop_name]);
|
let subresourceName = get_reference_name(readSchema.properties[prop_name]);
|
||||||
readSchema.components.schemas[subresourceName].readOnly = true;
|
readSchema.components.schemas[subresourceName].readOnly = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user