Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Add schema to validation
const ajv = createAjv();
ajv.addSchema(geoschema, 'geographical-location.schema.json');
// Allow json-schema-ref-resolver to resolve same schema
const geoResolver = {
order: 1,
canRead: (file: any) => {
return file.url.indexOf('geographical-location.schema.json') !== -1;
},
read: () => {
return JSON.stringify(geoschema);
}
};
// Add configuration to JSONForms
store.dispatch(
Actions.init(
exampleData[0].data,
exampleData[0].schema,
exampleData[0].uischema,
{
ajv: ajv,
refParserOptions: {
resolve: {
geo: geoResolver
} as any
}
}
)
);
return store;
};
export const renderExample = (
recurrence: 'Daily',
rating: 3
};
const initState: JsonFormsState = {
jsonforms: {
cells: materialCells,
renderers: materialRenderers
}
};
const rootReducer: Reducer = combineReducers({
jsonforms: jsonformsReducer()
});
const store = createStore(rootReducer, initState, devToolsEnhancer({}));
store.dispatch(Actions.init(data, schema, uischema));
// Register custom renderer for the Redux tab
store.dispatch(Actions.registerRenderer(ratingControlTester, RatingControl));
ReactDOM.render(, document.getElementById('root'));
registerServiceWorker();
constructor(ngRedux: NgRedux, devTools: DevToolsExtension) {
let enhancers: any[] = [];
// ... add whatever other enhancers you want.
// You probably only want to expose this tool in devMode.
if (isDevMode() && devTools.isEnabled()) {
enhancers = [...enhancers, devTools.enhancer()];
}
ngRedux.configureStore(rootReducer, initialState, [logger], enhancers);
const example = initialState.examples.data[0];
ngRedux.dispatch(
Actions.init(example.data, example.schema, example.uischema)
);
const uiSchema = {
type: 'HorizontalLayout',
elements: [
{
type: 'Control',
scope: '#/properties/buyer/properties/email'
},
{
type: 'Control',
scope: '#/properties/status'
}
]
};
const itemTester: UISchemaTester = (_schema, schemaPath, _path) => {
{
jsonforms: {
renderers,
fields,
editor: {
imageMapping,
labelMapping,
modelMapping,
uiSchemata,
containerProperties
}
}
}
);
store.dispatch(Actions.init(data, schema, uischema));
return store;
};
const setupStore = (
schema: JsonSchema,
uischema: UISchemaElement,
d: any
) => {
store.dispatch(Actions.init(d, schema, uischema));
return store;
};
onClick={() =>
dispatch(Actions.init(e.data, e.schema, e.uischema))
}
setSelection(selectedNode: JsonFormsTree.Node) {
this.selectedNode = selectedNode;
this.store.dispatch(
Actions.init(
this.selectedNode.jsonforms.data,
this.modelService.getSchemaForNode(this.selectedNode),
this.modelService.getUiSchemaForNode(this.selectedNode),
{
refParserOptions: {
dereference: { circular: 'ignore' }
}
}
)
);
this.renderForms();
}
onClick={() => {
dispatch(Actions.init(e.data, e.schema, e.config.withSort));
}}
>
onChange = (ev: any) => {
const selectedExample = this.ngRedux
.getState()
.examples.data.find(e => e.name === ev.target.value);
this.ngRedux.dispatch(
Actions.init(
selectedExample.data,
selectedExample.schema,
selectedExample.uischema
)
);
this.ngRedux.dispatch(setLocale(this.currentLocale));
};