Properties view JSONForms #1282
Replies: 2 comments 2 replies
-
Hi @quratulain-ali, |
Beta Was this translation helpful? Give feedback.
-
Hi again @quratulain-ali, I had a look and I would suggest to try this approach: I took the person-detail example from https://github.com/eclipse-emfcloud/jsonforms-property-view/tree/master/example as base for this rough guide. First of all, providing the type schema as typeschema.tsimport { JsonSchema } from '@jsonforms/core';
export const typeSchema: JsonSchema = {
$id: '#person',
title: 'Person',
type: 'object',
properties: {
firstName: {
type: 'string',
minLength: 3,
maxLength: 30
},
lastName: {
type: 'string',
minLength: 3,
maxLength: 30
},
registered: {
type: 'boolean'
},
birthDate: {
type: 'string',
format: 'date'
},
personalId: {
type: 'integer',
minimum: 100,
maximum: 5000
},
nationality: {
type: 'string',
enum: ['AUT', 'GBR', 'GER', 'LUX', 'NOR', 'SRB']
},
email: {
type: 'array',
items: {
type: 'string',
format: 'email'
}
}
},
required: ['personalId']
}; In the customized
import { typeSchema as typeSchemaBase } from './typeschema';
...
protected typeschema: JsonSchema;
@postConstruct()
init(): void {
this.typeschema = typeSchemaBase;
}
...
getSchema(_selection: Object, _properties?: Object): Promise<JsonSchema | undefined> {
return Promise.resolve(this.typeschema);
}
@postConstruct()
init(): void {
this.typeschema = typeSchemaBase;
// subscribe to updates and apply new enum values
this.myEnumDataProvider.onUpdate((newEnumList: string[]) => {
this.typeschema.properties!['nationality'].enum = newEnumList;
});
} This last step depends also on your requirements, it could of course also be from an API call, user input, or any other data source. HTH and please don't hesitate to reach out if there's anything more we can discuss or if you have further questions. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I was looking at the
@eclipse-emfcloud/jsonforms-property-view
. I wanted to have a dropdown list to set references of a model element. Following is an excerpt of typeschema.json& uischema.json
Now I want the enum to be populated dynamically not a static list of
foo, bar
.Any leads for this?
Cheers,
Qurat ul ain
Beta Was this translation helpful? Give feedback.
All reactions