betodealmeida commented on a change in pull request #5186: Implement a 
React-based table editor
URL: 
https://github.com/apache/incubator-superset/pull/5186#discussion_r206939596
 
 

 ##########
 File path: superset/assets/src/CRUD/Fieldset.jsx
 ##########
 @@ -0,0 +1,48 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Form } from 'react-bootstrap';
+
+import { recurseReactClone } from './utils';
+import Field from './Field';
+
+const propTypes = {
+  children: PropTypes.node,
+  onChange: PropTypes.func,
+  item: PropTypes.object,
+  title: PropTypes.node,
+  compact: PropTypes.bool,
+};
+const defaultProps = {
+  compact: false,
+};
+
+export default class Fieldset extends React.PureComponent {
+  constructor(props) {
+    super(props);
+    this.onChange = this.onChange.bind(this);
+  }
+  onChange(fieldKey, val) {
+    return this.props.onChange({
+      ...this.props.item,
+      [fieldKey]: val,
+    });
+  }
+  render() {
+    const { title } = this.props;
+    const propExtender = field => ({
+      onChange: this.onChange,
+      value: this.props.item[field.props.fieldKey],
+      compact: this.props.compact,
+    });
+    return (
+      <Form componentClass="fieldset" className="CRUD">
+        {title &&
+          <legend>{title}</legend>
+        }
+        {recurseReactClone(this.props.children, Field, propExtender)}
 
 Review comment:
   This is super cool.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to