GabeLoins commented on a change in pull request #4909: [Explore] Adding Adhoc
Filters
URL:
https://github.com/apache/incubator-superset/pull/4909#discussion_r186576419
##########
File path: superset/assets/src/explore/components/AdhocFilterEditPopover.jsx
##########
@@ -0,0 +1,149 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Button, Popover, Tab, Tabs } from 'react-bootstrap';
+
+import columnType from '../propTypes/columnType';
+import adhocMetricType from '../propTypes/adhocMetricType';
+import AdhocFilter, { EXPRESSION_TYPES } from '../AdhocFilter';
+import AdhocFilterEditPopoverSimpleTabContent from
'./AdhocFilterEditPopoverSimpleTabContent';
+import AdhocFilterEditPopoverSqlTabContent from
'./AdhocFilterEditPopoverSqlTabContent';
+
+const propTypes = {
+ adhocFilter: PropTypes.instanceOf(AdhocFilter).isRequired,
+ onChange: PropTypes.func.isRequired,
+ onClose: PropTypes.func.isRequired,
+ onResize: PropTypes.func.isRequired,
+ options: PropTypes.arrayOf(PropTypes.oneOfType([
+ columnType,
+ PropTypes.shape({ saved_metric_name: PropTypes.string.isRequired }),
+ adhocMetricType,
+ ])).isRequired,
+ datasource: PropTypes.object,
+};
+
+const startingWidth = 300;
+const startingHeight = 190;
+
+export default class AdhocFilterEditPopover extends React.Component {
+ constructor(props) {
+ super(props);
+ this.onSave = this.onSave.bind(this);
+ this.onDragDown = this.onDragDown.bind(this);
+ this.onMouseMove = this.onMouseMove.bind(this);
+ this.onMouseUp = this.onMouseUp.bind(this);
+ this.onAdhocFilterChange = this.onAdhocFilterChange.bind(this);
+
+ this.state = {
+ adhocFilter: this.props.adhocFilter,
+ width: startingWidth,
+ height: startingHeight,
+ };
+ document.addEventListener('mouseup', this.onMouseUp);
+ }
+
+ componentWillUnmount() {
+ document.removeEventListener('mouseup', this.onMouseUp);
+ }
+
+ onAdhocFilterChange(adhocFilter) {
Review comment:
I think since in this case my update isn't dependent on the current state, I
think its slightly more succinct just to pass the object
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]