Skip to content

Commit

Permalink
fix(Simput): Provide widget bundle for simput
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Apr 13, 2018
1 parent ab8006a commit 889f4d7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"homepage": "https://github.com/CASL/VeraInView#readme",
"main": "./dist/VeraInView.html",
"files": [
"dist/VeraInView.html",
"dist/*",
"src/*",
"README.md",
"LICENSE"
],
Expand Down
32 changes: 32 additions & 0 deletions src/simput/CellEditor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import PropTypes from 'prop-types';

export default class CellEditor extends React.Component {
constructor(props) {
super(props);

this.onChange = this.onChange.bind(this);
}
onChange() {
console.log(this.props);
}

render() {
return <div onClick={this.onChange}>Cell editor {this.props.data}</div>;
}
}

CellEditor.propTypes = {
data: PropTypes.object.isRequired,
// help: PropTypes.string,
// name: PropTypes.string,
// onChange: PropTypes.func.isRequired,
// show: PropTypes.func.isRequired,
// ui: PropTypes.object.isRequired,
// viewData: PropTypes.object.isRequired,
};

CellEditor.defaultProps = {
// name: '',
// help: '',
};
23 changes: 23 additions & 0 deletions src/simput/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import CellEditor from './CellEditor';

function registerLocalEditors(Simput) {
if (Simput && Simput.updateWidgetMapping) {
Simput.updateWidgetMapping(
'rod-cell-editor',
(prop, viewData, onChange) => (
<CellEditor
key={prop.data.id}
data={prop.data}
ui={prop.ui}
viewData={viewData}
show={prop.show}
onChange={onChange || prop.onChange}
/>
)
);
}
}

const Simput = (typeof window === 'undefined' ? {} : window).Simput;
registerLocalEditors(Simput);

0 comments on commit 889f4d7

Please sign in to comment.