Adding a read only resource schema

This commit is contained in:
2025-05-01 22:43:40 +02:00
parent 3942c54ad9
commit 6683d60be5

View File

@@ -32,6 +32,21 @@ export const jsonschemaProvider = {
return readSchema
},
getReadOnlyResourceSchema: async (resourceName: string): Promise<CrudRJSFSchema> => {
const updateSchema = await getResourceSchema(`${resourceName}Update`);
const readSchema = await getResourceSchema(`${resourceName}Read`);
for (let prop_name in readSchema.properties) {
if (updateSchema.hasOwnProperty(prop_name)) {
delete readSchema.properties[prop_name];
} else {
readSchema.properties[prop_name].readOnly = true;
}
}
return readSchema
},
getUpdateResourceSchema: async (resourceName: string): Promise<CrudRJSFSchema> => {
return getResourceSchema(`${resourceName}Update`)
},