betodealmeida commented on a change in pull request #4981: Make time filter 
more usable
URL: 
https://github.com/apache/incubator-superset/pull/4981#discussion_r189730436
 
 

 ##########
 File path: 
superset/assets/src/explore/components/controls/DateFilterControl.jsx
 ##########
 @@ -28,172 +51,265 @@ const propTypes = {
 const defaultProps = {
   animation: true,
   onChange: () => {},
-  value: '',
+  value: 'Last week',
 };
 
+
 export default class DateFilterControl extends React.Component {
   constructor(props) {
     super(props);
-    const value = props.value || '';
+    const value = props.value || defaultProps.value;
     this.state = {
+      type: TYPES[0],
+
+      // for range
       num: '7',
-      grain: 'days',
-      rel: 'ago',
-      dttm: '',
-      type: 'free',
-      free: '',
+      grain: TIME_GRAIN_OPTIONS[3],
+      rel: RELATIVE_TIME_OPTIONS[0],
+      common: COMMON_TIME_FRAMES[0],
+
+      // for start:end(includes freeform)
+      since: DEFAULT_SINCE,
+      until: DEFAULT_UNTIL,
+      isFreeform: {},
     };
-    const words = value.split(' ');
-    if (words.length >= 3 && RELATIVE_TIME_OPTIONS.indexOf(words[2]) >= 0) {
-      this.state.num = words[0];
-      this.state.grain = words[1];
-      this.state.rel = words[2];
-      this.state.type = 'rel';
-    } else if (moment(value).isValid()) {
-      this.state.dttm = value;
-      this.state.type = 'fix';
+    if (value.indexOf(SEPARATOR) >= 0) {
+      this.state.type = 'startend';
 
 Review comment:
   Good point, let me fix this. 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to