Skip to content

Commit 497a63f

Browse files
committed
Update to jsonforms 2.0.0-rc.1
1 parent fe2e047 commit 497a63f

File tree

7 files changed

+132
-114
lines changed

7 files changed

+132
-114
lines changed

package-lock.json

Lines changed: 64 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@jsonforms/core": "^2.0.0-beta.4",
7-
"@jsonforms/material-renderers": "^2.0.0-beta.4",
6+
"@jsonforms/core": "^2.0.0-rc.1",
7+
"@jsonforms/material-renderers": "^2.0.0-rc.1",
88
"react": "^16.2.0",
99
"react-dom": "^16.2.0",
1010
"react-redux": "^5.0.6",

src/App.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import {connect} from 'react-redux';
22
import React, {Component} from 'react';
33
import logo from './logo.svg';
44
import './App.css';
5-
import schema from './schema.json';
6-
import uischema from './uischema.json';
75
import {DispatchRenderer, getData} from '@jsonforms/core';
86

97

@@ -25,10 +23,7 @@ class App extends Component {
2523
</div>
2624

2725
<div className="demoform">
28-
<DispatchRenderer
29-
schema={schema}
30-
uischema={uischema}
31-
/>
26+
<DispatchRenderer />
3227
</div>
3328
</div>
3429
);

src/RatingControl.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as React from 'react';
2+
import {
3+
rankWith,
4+
scopeEndsWith,
5+
mapStateToControlProps,
6+
mapDispatchToControlProps
7+
} from '@jsonforms/core';
8+
import { connect } from 'react-redux';
9+
import { Rating } from './Rating';
10+
11+
export const ratingControlTester = rankWith(Number.MAX_VALUE, scopeEndsWith('rating'));
12+
13+
const RatingControl = ({ data, handleChange, path }) => (
14+
<Rating
15+
value={data}
16+
onClick={ev => handleChange(path, Number(ev.value))}
17+
/>
18+
);
19+
20+
export default connect(
21+
mapStateToControlProps,
22+
mapDispatchToControlProps,
23+
)(RatingControl);

src/index.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,50 @@ import ReactDOM from 'react-dom';
33
import './index.css';
44
import App from './App';
55
import registerServiceWorker from './registerServiceWorker';
6+
import { applyMiddleware, createStore } from 'redux';
7+
import thunk from 'redux-thunk';
68
import { Provider } from 'react-redux';
7-
import { initJsonFormsStore, registerRenderer } from '@jsonforms/core';
89
import schema from './schema.json';
910
import uischema from './uischema.json';
11+
import { Actions, JsonForms, jsonformsReducer } from '@jsonforms/core';
1012
import '@jsonforms/material-renderers';
11-
//import RatingControl, {ratingControlTester} from './rating.control';
13+
import RatingControl, {ratingControlTester} from './RatingControl';
1214

1315
const data = {
14-
'name': 'Send email to Adrian',
15-
'description': 'Confirm if you have passed the subject\nHerby ...',
16-
'done': true,
17-
'recurrence': 'Daily',
18-
'rating': 3,
16+
name: 'Send email to Adrian',
17+
description: 'Confirm if you have passed the subject\nHereby ...',
18+
done: true,
19+
recurrence: 'Daily',
20+
rating: 3,
1921
};
2022

21-
const store = initJsonFormsStore(data, schema, uischema);
23+
const store = createStore(
24+
jsonformsReducer(),
25+
{
26+
jsonforms: {
27+
common: {
28+
data,
29+
schema,
30+
uischema
31+
},
32+
renderers: JsonForms.renderers,
33+
fields: JsonForms.fields
34+
},
35+
},
36+
applyMiddleware(thunk)
37+
);
38+
39+
store.dispatch({
40+
type: Actions.INIT,
41+
data,
42+
schema,
43+
uischema,
44+
});
45+
46+
store.dispatch(Actions.validate());
2247

2348
// Uncomment this line (and respective import) to register our custom renderer
24-
//store.dispatch(registerRenderer(ratingControlTester, RatingControl));
49+
store.dispatch(Actions.registerRenderer(ratingControlTester, RatingControl));
2550

2651
ReactDOM.render(
2752
<Provider store={store}>

src/rating.control.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)