Sha256: b2f5d7d5d56201a7a43682b7dfe483e5a82be699bb35f80352e0e7df433338c1

Contents?: true

Size: 1.69 KB

Versions: 6

Compression:

Stored size: 1.69 KB

Contents

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

    this.netzkeOnAddCondition();

  },

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

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

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

  netzkeOnClearAll: 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.type = f.type;}
        query.push(cond);
      }
    });
    return query;
  }
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
netzke-basepack-1.0.1.0 lib/netzke/basepack/search_panel/client/search_panel.js
netzke-basepack-1.0.0.1 lib/netzke/basepack/search_panel/client/search_panel.js
netzke-basepack-1.0.0.0 lib/netzke/basepack/search_panel/client/search_panel.js
netzke-basepack-1.0.0.0.pre3 lib/netzke/basepack/search_panel/client/search_panel.js
netzke-basepack-1.0.0.0.pre2 lib/netzke/basepack/search_panel/client/search_panel.js
netzke-basepack-1.0.0.0.pre lib/netzke/basepack/search_panel/client/search_panel.js