mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
[explorev2] adding support for client side validators on controls (#1920)
* Adding support for client side validators on controls * Applying validators to more fields * Addressing comments
This commit is contained in:
committed by
GitHub
parent
fc74fbeeaa
commit
470a6e9d76
@@ -27,7 +27,6 @@ class ControlPanelsContainer extends React.Component {
|
||||
this.fieldOverrides = this.fieldOverrides.bind(this);
|
||||
this.getFieldData = this.getFieldData.bind(this);
|
||||
this.removeAlert = this.removeAlert.bind(this);
|
||||
this.onChange = this.onChange.bind(this);
|
||||
}
|
||||
componentWillMount() {
|
||||
const datasource_id = this.props.form_data.datasource;
|
||||
@@ -44,14 +43,8 @@ class ControlPanelsContainer extends React.Component {
|
||||
}
|
||||
}
|
||||
}
|
||||
onChange(name, value) {
|
||||
this.props.actions.setFieldValue(this.props.datasource_type, name, value);
|
||||
}
|
||||
getFieldData(fs) {
|
||||
const fieldOverrides = this.fieldOverrides();
|
||||
if (!this.props.fields) {
|
||||
return null;
|
||||
}
|
||||
let fieldData = this.props.fields[fs] || {};
|
||||
if (fieldOverrides.hasOwnProperty(fs)) {
|
||||
const overrideData = fieldOverrides[fs];
|
||||
@@ -100,13 +93,14 @@ class ControlPanelsContainer extends React.Component {
|
||||
{section.fieldSetRows.map((fieldSets, i) => (
|
||||
<FieldSetRow
|
||||
key={`fieldsetrow-${i}`}
|
||||
fields={fieldSets.map(field => (
|
||||
fields={fieldSets.map(fieldName => (
|
||||
<FieldSet
|
||||
name={field}
|
||||
key={`field-${field}`}
|
||||
onChange={this.onChange}
|
||||
value={this.props.form_data[field]}
|
||||
{...this.getFieldData(field)}
|
||||
name={fieldName}
|
||||
key={`field-${fieldName}`}
|
||||
value={this.props.form_data[fieldName]}
|
||||
validationErrors={this.props.fields[fieldName].validationErrors}
|
||||
actions={this.props.actions}
|
||||
{...this.getFieldData(fieldName)}
|
||||
/>
|
||||
))}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user