import Ember from 'ember';

export default Ember.Controller.extend({
  tz: jstz.determine().name(),
  search: null,
  interval: 'day',
  prefix: '0/',
  region: 'world',
  start_at: moment().subtract(29, 'days').format('YYYY-MM-DD'),
  end_at: moment().format('YYYY-MM-DD'),
  query: JSON.stringify({
    condition: 'AND',
    rules: [{
      field: 'gatekeeper_denied_code',
      id: 'gatekeeper_denied_code',
      input: 'select',
      operator: 'is_null',
      type: 'string',
      value: null,
    }],
  }),
  beta_analytics: false,

  actions: {
    submit() {
      let query = this.get('query');
      query.beginPropertyChanges();

      if($('#filter_type_advanced').css('display') === 'none') {
        query.set('params.search', '');
        query.set('params.query', JSON.stringify($('#query_builder').queryBuilder('getRules')));
      } else {
        query.set('params.query', '');
        query.set('params.search', $('#filter_form input[name=search]').val());
      }

      query.endPropertyChanges();
    },
  },
});

@@ -103,20 +103,18 @@
 search: 
-null
+''
 ,%0A  inte
@@ -566,82 +566,8 @@
 ) %7B%0A
-      let query = this.get('query');%0A      query.beginPropertyChanges();%0A%0A
     
@@ -635,34 +635,26 @@
         
-query
+this
 .set('
-params.
 search',
@@ -667,34 +667,26 @@
         
-query
+this
 .set('
-params.
 query', 
@@ -771,34 +771,26 @@
         
-query
+this
 .set('
-params.
 query', 
@@ -806,26 +806,18 @@
     
-query
+this
 .set('
-params.
 sear
@@ -877,43 +877,8 @@
    %7D
-%0A%0A      query.endPropertyChanges();
 %0A   

Fix submitting query builder form params.