mirror of https://github.com/apache/druid.git
fix global filter input (#9567)
* fix global filter input * remove clear * close global filters after clicking apply * add restFilter
This commit is contained in:
parent
73a6baaeb6
commit
6e50d29b4e
|
@ -313,6 +313,7 @@ export interface LoadDataViewState {
|
||||||
selectedFilterIndex: number;
|
selectedFilterIndex: number;
|
||||||
selectedFilter?: DruidFilter;
|
selectedFilter?: DruidFilter;
|
||||||
showGlobalFilter: boolean;
|
showGlobalFilter: boolean;
|
||||||
|
newFilterValue?: Record<string, any>;
|
||||||
|
|
||||||
// for schema
|
// for schema
|
||||||
schemaQueryState: QueryState<{
|
schemaQueryState: QueryState<{
|
||||||
|
@ -2066,7 +2067,7 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
|
||||||
}
|
}
|
||||||
|
|
||||||
renderGlobalFilterControls() {
|
renderGlobalFilterControls() {
|
||||||
const { spec, showGlobalFilter } = this.state;
|
const { spec, showGlobalFilter, newFilterValue } = this.state;
|
||||||
const intervals: string[] = deepGet(spec, 'spec.dataSchema.granularitySpec.intervals');
|
const intervals: string[] = deepGet(spec, 'spec.dataSchema.granularitySpec.intervals');
|
||||||
const { restFilter } = splitFilter(deepGet(spec, 'spec.dataSchema.transformSpec.filter'));
|
const { restFilter } = splitFilter(deepGet(spec, 'spec.dataSchema.transformSpec.filter'));
|
||||||
const hasGlobalFilter = Boolean(intervals || restFilter);
|
const hasGlobalFilter = Boolean(intervals || restFilter);
|
||||||
|
@ -2094,19 +2095,24 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
|
||||||
/>
|
/>
|
||||||
<FormGroup label="Extra filter">
|
<FormGroup label="Extra filter">
|
||||||
<JsonInput
|
<JsonInput
|
||||||
value={restFilter}
|
value={newFilterValue}
|
||||||
onChange={f => {
|
onChange={f => this.setState({ newFilterValue: f })}
|
||||||
const curFilter = splitFilter(
|
|
||||||
deepGet(spec, 'spec.dataSchema.transformSpec.filter'),
|
|
||||||
);
|
|
||||||
const newFilter = joinFilter(deepSet(curFilter, `restFilter`, f));
|
|
||||||
this.updateSpec(deepSet(spec, 'spec.dataSchema.transformSpec.filter', newFilter));
|
|
||||||
}}
|
|
||||||
height="200px"
|
height="200px"
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<div className="control-buttons">
|
<div className="control-buttons">
|
||||||
<Button text="Apply" intent={Intent.PRIMARY} onClick={() => this.queryForFilter()} />
|
<Button
|
||||||
|
text="Apply"
|
||||||
|
intent={Intent.PRIMARY}
|
||||||
|
onClick={() => {
|
||||||
|
const curFilter = splitFilter(
|
||||||
|
deepGet(spec, 'spec.dataSchema.transformSpec.filter'),
|
||||||
|
);
|
||||||
|
const newFilter = joinFilter(deepSet(curFilter, `restFilter`, newFilterValue));
|
||||||
|
this.updateSpec(deepSet(spec, 'spec.dataSchema.transformSpec.filter', newFilter));
|
||||||
|
this.setState({ showGlobalFilter: false, newFilterValue: undefined });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Button text="Cancel" onClick={() => this.setState({ showGlobalFilter: false })} />
|
<Button text="Cancel" onClick={() => this.setState({ showGlobalFilter: false })} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2116,7 +2122,12 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<Button
|
<Button
|
||||||
text={`${hasGlobalFilter ? 'Edit' : 'Add'} global filter`}
|
text={`${hasGlobalFilter ? 'Edit' : 'Add'} global filter`}
|
||||||
onClick={() => this.setState({ showGlobalFilter: true })}
|
onClick={() =>
|
||||||
|
this.setState({
|
||||||
|
showGlobalFilter: true,
|
||||||
|
newFilterValue: restFilter,
|
||||||
|
})
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue