Skip to content

Commit

Permalink
layout tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jan 10, 2019
1 parent 21c9cc8 commit 88c6223
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
37 changes: 24 additions & 13 deletions superset/assets/src/components/FormRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,43 @@ import { Row, Col } from 'react-bootstrap';
import InfoTooltipWithTrigger from './InfoTooltipWithTrigger';

const STYLE_ROW = { marginTop: '5px', minHeight: '30px' };
const STYLE_RALIGN = { textAlign: 'right' };

const propTypes = {
label: PropTypes.string.isRequired,
tooltip: PropTypes.string,
control: PropTypes.node.isRequired,
isCheckbox: PropTypes.bool,
};

const defaultProps = {
tooltip: null,
isCheckbox: false,
};

export default function FormRow({ label, tooltip, control }) {
export default function FormRow({ label, tooltip, control, isCheckbox }) {
const labelAndTooltip = (
<span>
{label}{' '}
{tooltip &&
<InfoTooltipWithTrigger
placement="top"
label={label}
tooltip={tooltip}
/>}
</span>);
if (isCheckbox) {
return (
<Row style={STYLE_ROW}>
<Col md={4} style={STYLE_RALIGN}>{control}</Col>
<Col md={8}>{labelAndTooltip}</Col>
</Row>);
}
return (
<Row style={STYLE_ROW}>
<Col md={5}>
{label}{' '}
{tooltip &&
<InfoTooltipWithTrigger
placement="top"
label={label}
tooltip={tooltip}
/>}
</Col>
<Col md={7}>{control}</Col>
</Row>
);
<Col md={4} style={STYLE_RALIGN}>{labelAndTooltip}</Col>
<Col md={8}>{control}</Col>
</Row>);
}
FormRow.propTypes = propTypes;
FormRow.defaultProps = defaultProps;
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const defaultProps = {
multiple: true,
};

const STYLE_WIDTH = { width: 450 };
const STYLE_WIDTH = { width: 350 };

export default class FilterBoxItemControl extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -109,6 +109,7 @@ export default class FilterBoxItemControl extends React.Component {
<FormRow
label={t('Sort Ascending')}
tooltip={t('Check for sorting ascending')}
isCheckbox
control={
<CheckboxControl
value={this.state.asc}
Expand All @@ -118,6 +119,7 @@ export default class FilterBoxItemControl extends React.Component {
/>
<FormRow
label={t('Allow Multiple Selections')}
isCheckbox
tooltip={t(
'Multiple selections allowed, otherwise filter ' +
'is limited to a single value')}
Expand All @@ -131,6 +133,7 @@ export default class FilterBoxItemControl extends React.Component {
<FormRow
label={t('Required')}
tooltip={t('User must select a value for this filter')}
isCheckbox
control={
<CheckboxControl
value={!this.state.clearable}
Expand Down
1 change: 0 additions & 1 deletion superset/assets/src/visualizations/FilterBox/FilterBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Button } from 'react-bootstrap';
import { t } from '@superset-ui/translation';

import DateFilterControl from '../../explore/components/controls/DateFilterControl';
import CheckboxControl from '../../explore/components/controls/CheckboxControl';
import ControlRow from '../../explore/components/ControlRow';
import Control from '../../explore/components/Control';
import controls from '../../explore/controls';
Expand Down

0 comments on commit 88c6223

Please sign in to comment.