forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2eeecb3
commit aafa2ac
Showing
4 changed files
with
108 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
frontend/src/metabase/query_builder/parameters/ParameterTypePicker.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* @flow */ | ||
import React, { Component, PropTypes } from "react"; | ||
|
||
import { PARAMETER_SECTIONS } from "metabase/meta/Dashboard"; | ||
import type { ParameterOption } from "metabase/meta/types/Dashboard"; | ||
|
||
import _ from "underscore"; | ||
|
||
export default class ParameterTypePicker extends Component { | ||
props: { | ||
onChange: (option: ParameterOption) => {} | ||
}; | ||
state: { | ||
section?: string | ||
}; | ||
|
||
constructor(props: any, context: any) { | ||
super(props, context); | ||
this.state = {}; | ||
} | ||
|
||
render() { | ||
const { section } = this.state; | ||
const { onChange } = this.props; | ||
if (section == null) { | ||
return <ParameterOptionsSectionsPane sections={PARAMETER_SECTIONS} onSelectSection={(section) => { | ||
let { options } = _.findWhere(PARAMETER_SECTIONS, { id: section.id }); | ||
if (options.length === 1) { | ||
onChange(options[0]); | ||
} else { | ||
this.setState({ section: section.id }); | ||
} | ||
}} /> | ||
} else { | ||
let { options } = _.findWhere(PARAMETER_SECTIONS, { id: section }); | ||
return <ParameterOptionsPane options={options} onSelectOption={(option) => { onChange(option); } }/> | ||
} | ||
} | ||
} | ||
|
||
const ParameterOptionsSection = ({ section, onClick }) => | ||
<li onClick={onClick} className="p1 px2 cursor-pointer brand-hover"> | ||
<div className="text-brand text-bold">{section.name}</div> | ||
<div>{section.description}</div> | ||
</li> | ||
|
||
const ParameterOptionsSectionsPane = ({ sections, onSelectSection }) => | ||
<div className="pb2"> | ||
<h3 className="p2">What do you want to filter?</h3> | ||
<ul> | ||
{ sections.map(section => | ||
<ParameterOptionsSection section={section} onClick={() => onSelectSection(section) }/> | ||
)} | ||
</ul> | ||
</div> | ||
|
||
const ParameterOptionItem = ({ option, onClick }) => | ||
<li onClick={onClick} className="p1 px2 cursor-pointer brand-hover"> | ||
<div className="text-brand text-bold">{option.name}</div> | ||
<div>{option.description}</div> | ||
</li> | ||
|
||
const ParameterOptionsPane = ({ options, onSelectOption }) => | ||
<div className="pb2"> | ||
<h3 className="p2">What kind of filter?</h3> | ||
<ul> | ||
{ options.map(option => | ||
<ParameterOptionItem option={option} onClick={() => onSelectOption(option)} /> | ||
)} | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters