Sha256: 95e4e269b9c0c3d40f0a4f036c7ee50865793abc005657f785761c7050455cb3

Contents?: true

Size: 1.66 KB

Versions: 29

Compression:

Stored size: 1.66 KB

Contents

{
  initComponent: function() {
    this.callParent();
    this.buildFormFromQuery(this.presetQuery);

    this.onAddCondition();

  },

  // Will probably need to be performance-optimized in the future, as recreating the fields is expensive
  buildFormFromQuery: function(query) {
    this.onClearAll();
    Ext.each(query, function(f){
      f.ownerCt = this;
      this.insert(this.items.length - 1, Ext.createByAlias('widget.netzkebasepacksearchpanelconditionfield', f));
    }, this);
    this.doLayout();
  },

  onAddCondition: function() {
    var condField = Ext.createByAlias('widget.netzkebasepacksearchpanelconditionfield', {ownerCt: this});
    condField.on('configured', function() {
      this.onAddCondition();
    }, this, {single: true});
    this.add(condField);
    this.doLayout();
    this.fireEvent('fieldsnumberchange');
  },

  onReset: function() {
    this.items.each(function(f){
      if (f.valueField) {f.clearValue();}
    });
  },

  onClearAll: function() {
    this.eachConfiguredField(function(f) {
      this.remove(f);
    }, this);

    this.fireEvent('fieldsnumberchange');
  },

  // Returns each condition field which has attribute selected
  eachConfiguredField: function(fn, scope) {
    this.items.each(function(f, i) {
      if (this.items.last() !== f) {
        fn.call(scope || f, f);
      }
    }, this);
  },

  // When "all" is "true", also includes the fields with empty values
  getQuery: function(all) {
    var query = [];
    this.eachConfiguredField(function(f){
      if (f.valueIsSet() || all) {
        var cond = f.buildValue();
        if (all) {cond.attrType = f.attrType;}
        query.push(cond);
      }
    });
    return query;
  }
}

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
netzke-basepack-0.12.9 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.8 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.7 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.6 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.5 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.4 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.3 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.2 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.1 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.11.2 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.11.1 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.0 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.0.rc1 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.12.0.beta lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.11.0 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.10.1 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.10.0 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.9.0 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.10.0.rc2 lib/netzke/basepack/search_panel/javascripts/search_panel.js
netzke-basepack-0.9.0.rc1 lib/netzke/basepack/search_panel/javascripts/search_panel.js