Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using TextAreaControl for WHERE and HAVING clause section #4090

Merged
merged 1 commit into from Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,6 +22,9 @@ const propTypes = {
value: PropTypes.string,
height: PropTypes.number,
language: PropTypes.oneOf([null, 'json', 'html', 'sql', 'markdown']),
minLines: PropTypes.number,
maxLines: PropTypes.number,
offerEditInModal: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -30,6 +33,9 @@ const defaultProps = {
onChange: () => {},
value: '',
height: 250,
minLines: 10,
maxLines: 10,
offerEditInModal: true,
};

export default class TextAreaControl extends React.Component {
Expand All @@ -46,8 +52,8 @@ export default class TextAreaControl extends React.Component {
mode={this.props.language}
theme="textmate"
style={{ border: '1px solid #CCC' }}
minLines={inModal ? 40 : 10}
maxLines={inModal ? 1000 : 10}
minLines={inModal ? 40 : this.props.minLines}
maxLines={inModal ? 1000 : this.props.maxLines}
onChange={this.onAceChange.bind(this)}
width="100%"
editorProps={{ $blockScrolling: true }}
Expand All @@ -73,16 +79,17 @@ export default class TextAreaControl extends React.Component {
<div>
{controlHeader}
{this.renderEditor()}
<ModalTrigger
bsSize="large"
modalTitle={controlHeader}
triggerNode={
<Button bsSize="small" className="m-t-5">
{t('Edit')} <strong>{this.props.language}</strong> {t('in modal')}
</Button>
}
modalBody={this.renderEditor(true)}
/>
{this.props.offerEditInModal &&
<ModalTrigger
bsSize="large"
modalTitle={controlHeader}
triggerNode={
<Button bsSize="small" className="m-t-5">
{t('Edit')} <strong>{this.props.language}</strong> {t('in modal')}
</Button>
}
modalBody={this.renderEditor(true)}
/>}
</div>
);
}
Expand Down
12 changes: 10 additions & 2 deletions superset/assets/javascripts/explore/stores/controls.jsx
Expand Up @@ -910,19 +910,27 @@ export const controls = {
},

where: {
type: 'TextControl',
type: 'TextAreaControl',
label: t('Custom WHERE clause'),
default: '',
language: 'sql',
minLines: 2,
maxLines: 10,
offerEditInModal: false,
description: t('The text in this box gets included in your query\'s WHERE ' +
'clause, as an AND to other criteria. You can include ' +
'complex expression, parenthesis and anything else ' +
'supported by the backend it is directed towards.'),
},

having: {
type: 'TextControl',
type: 'TextAreaControl',
label: t('Custom HAVING clause'),
default: '',
language: 'sql',
minLines: 2,
maxLines: 10,
offerEditInModal: false,
description: t('The text in this box gets included in your query\'s HAVING ' +
'clause, as an AND to other criteria. You can include ' +
'complex expression, parenthesis and anything else ' +
Expand Down