partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

PartFilterPanel.js (38806B)


      1 /**
      2  * Defines the part filter panel.
      3  *
      4  *
      5  */
      6 Ext.define('PartKeepr.PartFilterPanel', {
      7     extend: 'Ext.form.Panel',
      8     alias: 'widget.PartFilterPanel',
      9 
     10     /**
     11      * Define a padding of 10px
     12      */
     13     bodyPadding: '10px',
     14 
     15     /**
     16      * The items are aligned in a wrappable column layout
     17      */
     18     layout: 'column',
     19 
     20     /**
     21      * Automatically scroll the container if the items exceed the container size.
     22      */
     23     autoScroll: true,
     24 
     25     /**
     26      * The applied filters
     27      */
     28     appliedFilters: [],
     29 
     30     /**
     31      * Fixed body background color style
     32      */
     33     //bodyStyle: 'background:#DBDBDB;',
     34 
     35     ui: 'default-framed',
     36     iconCls: "fugue-icon funnel",
     37 
     38     partManager: null,
     39     storageLocationFilter: null,
     40     storageLocationFilterCheckbox: null,
     41     storageLocationContainer: null,
     42     categoryFilter: null,
     43     stockFilter: null,
     44     partsWithoutPrice: null,
     45     distributorOrderNumberFilter: null,
     46     manufacturerPartNumberFilter: null,
     47     createDateField: null,
     48     createDateFilterSelect: null,
     49     createDateFilter: null,
     50     partsWithoutStockRemovals: null,
     51     needsReview: null,
     52     manufacturerFilterCheckbox: null,
     53     manufacturerFilterCombo: null,
     54     manufacturerFilter: null,
     55     distributorFilterCombo: null,
     56     distributorFilter: null,
     57     footprintFilterCheckbox: null,
     58     footprintFilterCombo: null,
     59     footprintFilter: null,
     60     statusFilter: null,
     61     conditionFilter: null,
     62     internalPartNumberFilter: null,
     63     internalIdFilter: null,
     64     commentFilter: null,
     65 
     66     filterControls: [],
     67 
     68     /**
     69      * Initializes the component
     70      */
     71     initComponent: function ()
     72     {
     73 
     74         // Create the filter fields
     75         this.createFilterFields();
     76 
     77         // Creates the left column of the filter panel
     78         this.leftColumn = {
     79             xtype: 'container',
     80             anchor: '100%',
     81             layout: 'anchor',
     82             minWidth: 340,
     83             style: 'margin-right: 10px',
     84             columnWidth: 0.5,
     85             items: [
     86                 this.storageLocationContainer,
     87                 this.categoryFilter,
     88                 this.partsWithoutPrice,
     89                 this.createDateFilter,
     90                 this.partsWithoutStockRemovals,
     91                 this.needsReview,
     92                 this.internalIdFilter
     93             ]
     94         };
     95 
     96         // Creates the right column of the filter panel
     97         this.rightColumn = {
     98             xtype: 'container',
     99             anchor: '100%',
    100             minWidth: 340,
    101             columnWidth: 0.5,
    102             layout: 'anchor',
    103             items: [
    104                 this.stockFilter,
    105                 this.distributorOrderNumberFilter,
    106                 this.distributorFilter,
    107                 this.manufacturerFilter,
    108                 this.manufacturerPartNumberFilter,
    109                 this.footprintFilter,
    110                 this.statusFilter,
    111                 this.conditionFilter,
    112                 this.internalPartNumberFilter,
    113                 this.commentFilter
    114             ]
    115         };
    116 
    117         // Apply both columns to this panel
    118         this.items = [this.leftColumn, this.rightColumn];
    119 
    120         // Create the reset button
    121         this.resetButton = Ext.create("Ext.button.Button", {
    122             text: i18n("Reset"),
    123             handler: this.onReset,
    124             iconCls: 'web-icon cancel',
    125             scope: this
    126         });
    127 
    128         // Create the apply button
    129         this.applyButton = Ext.create("Ext.button.Button", {
    130             text: i18n("Apply"),
    131             iconCls: 'web-icon accept',
    132             handler: this.onApply,
    133             scope: this
    134         });
    135 
    136         // Append both buttons to a toolbar
    137         this.dockedItems = [
    138             {
    139                 xtype: 'toolbar',
    140                 enableOverflow: true,
    141                 dock: 'bottom',
    142                 ui: 'footer',
    143                 defaults: {minWidth: 100},
    144                 items: [this.applyButton, this.resetButton]
    145             }
    146         ];
    147 
    148         this.store.getFilters().on("endupdate", this._onFilterRemove, this);
    149         this.callParent();
    150 
    151         this.down("#idField").on("beforedestroy", this.onBeforeIdFieldDestroy, this.down("#idField"));
    152     },
    153     _onFilterRemove: function ()
    154     {
    155         var filterPlugin;
    156         if (this.suspendRemovals) {
    157             return;
    158         }
    159 
    160         for (var i = 0; i < this.filterControls.length; i++) {
    161             filterPlugin = this.filterControls[i].findPlugin("filter");
    162 
    163             if (filterPlugin instanceof PartKeepr.Util.FilterPlugin) {
    164                 if (!this.store.getFilters().contains(filterPlugin.getFilter())) {
    165                     this.filterControls[i].disableFilter();
    166                 }
    167             }
    168         }
    169 
    170     },
    171     /**
    172      * Applies the parameters from the filter panel to the proxy, then
    173      * reload the store to refresh the grid.
    174      *
    175      * @param none
    176      * @return nothing
    177      */
    178     onApply: function ()
    179     {
    180         var i;
    181 
    182         this.appliedFilters = this.getFilters();
    183 
    184         this.suspendRemovals = true;
    185         if (this.appliedFilters.disableFilters.length !== 0) {
    186             for (i = 0; i < this.appliedFilters.disableFilters.length; i++) {
    187                 this.store.removeFilter(this.appliedFilters.disableFilters[i], true);
    188             }
    189         }
    190 
    191         if (this.appliedFilters.enableFilters.length !== 0) {
    192             for (i = 0; i < this.appliedFilters.enableFilters.length; i++) {
    193                 this.store.addFilter(this.appliedFilters.enableFilters[i], true);
    194             }
    195         }
    196 
    197         this.suspendRemovals = false;
    198 
    199 
    200         this.store.load();
    201     },
    202     /**
    203      * Resets the fields to their original values, then call onApply()
    204      * to reload the store.
    205      */
    206     onReset: function ()
    207     {
    208         this.storageLocationFilter.setValue("");
    209         this.storageLocationFilterCheckbox.setValue(false);
    210 
    211         this.categoryFilter.setValue({category: 'all'});
    212         this.stockFilter.setValue({stock: 'any'});
    213         this.distributorOrderNumberFilter.setValue("");
    214         this.manufacturerPartNumberFilter.setValue("");
    215 
    216         this.createDateFilterSelect.setValue("");
    217         this.createDateField.setValue("");
    218         this.partsWithoutStockRemovals.setValue(false);
    219         this.needsReview.setValue(false);
    220         this.partsWithoutPrice.setValue(false);
    221 
    222         this.distributorFilterCombo.setValue("");
    223         this.distributorFilterCheckbox.setValue(false);
    224 
    225         this.manufacturerFilterCombo.setValue("");
    226         this.manufacturerFilterCheckbox.setValue(false);
    227 
    228         this.footprintFilterCombo.setValue("");
    229         this.footprintFilterCheckbox.setValue(false);
    230 
    231         this.statusFilter.setValue("");
    232 
    233         this.conditionFilter.setValue("");
    234         this.internalPartNumberFilter.setValue("");
    235         this.commentFilter.setValue("");
    236         this.internalIdFilter.setValue("");
    237 
    238         this.onApply();
    239     },
    240     /**
    241      * Creates the filter fields required for this filter panel
    242      */
    243     createFilterFields: function ()
    244     {
    245 
    246         // Create the storage location filter field
    247         this.storageLocationFilter = Ext.create("PartKeepr.StorageLocationComboBox", {
    248             flex: 1,
    249             forceSelection: true,
    250             plugins: [
    251                 Ext.create("PartKeepr.Util.FilterPlugin", {
    252                     getFilterFn: function ()
    253                     {
    254                         return {
    255                             property: 'storageLocation',
    256                             operator: "=",
    257                             value: this.storageLocationFilter.getValue()
    258                         };
    259                     },
    260                     listeners: {
    261                         scope: this,
    262                         disable: function ()
    263                         {
    264                             this.storageLocationFilter.setValue("");
    265                             this.storageLocationFilterCheckbox.setValue(false);
    266 
    267                         }
    268                     },
    269                     scope: this
    270                 })
    271             ],
    272             listeners: {
    273                 select: function (cmp)
    274                 {
    275                     cmp.enableFilter();
    276                     this.storageLocationFilterCheckbox.setValue(true);
    277                 },
    278                 scope: this
    279             }
    280         });
    281 
    282         this.filterControls.push(this.storageLocationFilter);
    283 
    284         this.storageLocationFilterCheckbox = Ext.create("Ext.form.field.Checkbox", {
    285             width: "20px",
    286             listeners: {
    287                 change: function (obj, value)
    288                 {
    289                     if (!value) {
    290                         this.storageLocationFilter.disableFilter();
    291                     }
    292                 },
    293                 scope: this
    294             }
    295         });
    296 
    297         this.storageLocationContainer = Ext.create("Ext.form.FieldContainer", {
    298             layout: 'hbox',
    299             items: [this.storageLocationFilterCheckbox, this.storageLocationFilter],
    300             anchor: '100%',
    301             minWidth: 300,
    302             fieldLabel: i18n("Storage Location")
    303         });
    304 
    305         if (this.partManager !== null) {
    306             // Create the category scope field
    307             this.categoryFilter = Ext.create("Ext.form.RadioGroup", {
    308                 fieldLabel: i18n("Category Scope"),
    309                 plugins: [
    310                     Ext.create("PartKeepr.Util.FilterPlugin", {
    311                         getFilterFn: function ()
    312                         {
    313                             if (this.partManager !== null) {
    314                                 if (this.categoryFilter.getValue().category === "all") {
    315                                     if (this.partManager.getSelectedCategory() !== null) {
    316                                         if (!this.partManager.getSelectedCategory().isRoot()) {
    317                                             return {
    318                                                 id: 'categoryFilter',
    319                                                 property: 'category',
    320                                                 operator: 'IN',
    321                                                 value: this.partManager.getChildrenIds(
    322                                                     this.partManager.getSelectedCategory())
    323                                             };
    324                                         }
    325                                     }
    326                                 } else {
    327                                     var selectedCategory = this.partManager.getSelectedCategory();
    328 
    329                                     if (selectedCategory === null) {
    330                                         selectedCategory = this.partManager.tree.getRootNode().firstChild;
    331                                     }
    332 
    333                                     return {
    334                                         id: 'categoryFilter',
    335                                         property: 'category',
    336                                         operator: '=',
    337                                         value: selectedCategory.getId()
    338                                     };
    339                                 }
    340                             }
    341 
    342                             return {};
    343                         },
    344                         listeners: {
    345                             scope: this,
    346                             disable: function ()
    347                             {
    348                                 if (this.categoryFilter !== null) {
    349                                     this.categoryFilter.setValue({category: "all"});
    350                                 }
    351 
    352                             }
    353                         },
    354                         scope: this
    355                     })
    356                 ],
    357                 listeners: {
    358                     change: function (cmp)
    359                     {
    360                         cmp.enableFilter();
    361                     },
    362                     scope: this
    363                 },
    364                 columns: 1,
    365                 items: [
    366                     {
    367                         boxLabel: i18n("All Subcategories"),
    368                         name: 'category',
    369                         inputValue: "all",
    370                         checked: true
    371                     },
    372                     {
    373                         boxLabel: i18n("Selected Category"),
    374                         name: 'category',
    375                         inputValue: "selected"
    376                     }
    377                 ]
    378             });
    379 
    380             this.filterControls.push(this.categoryFilter);
    381         }
    382 
    383 
    384         // Create the stock level filter field
    385         this.stockFilter = Ext.create("Ext.form.RadioGroup", {
    386             fieldLabel: i18n("Stock Mode"),
    387             columns: 1,
    388             plugins: [
    389                 Ext.create("PartKeepr.Util.FilterPlugin", {
    390                     getFilterFn: function ()
    391                     {
    392                         if (this.stockFilter.getValue().stock !== "any") {
    393                             switch (this.stockFilter.getValue().stock) {
    394                                 case "zero":
    395                                     return {
    396                                         property: 'stockLevel',
    397                                         operator: "=",
    398                                         value: 0
    399                                     };
    400                                 case "nonzero":
    401                                     return {
    402                                         property: 'stockLevel',
    403                                         operator: ">",
    404                                         value: 0
    405                                     };
    406                                 case "below":
    407                                     return {
    408                                         property: 'lowStock',
    409                                         operator: "=",
    410                                         value: true
    411                                     };
    412                             }
    413 
    414                             return {};
    415                         }
    416                     },
    417                     listeners: {
    418                         scope: this,
    419                         disable: function ()
    420                         {
    421                             if (this.categoryFilter !== null) {
    422                                 this.categoryFilter.setValue({stock: "any"});
    423                             }
    424 
    425                         }
    426                     },
    427                     scope: this
    428                 })
    429             ],
    430             listeners: {
    431                 change: function (cmp)
    432                 {
    433                     if (cmp.getValue().stock === "any") {
    434                         cmp.disableFilter();
    435                     } else {
    436                         cmp.enableFilter();
    437                     }
    438                 },
    439                 scope: this
    440             },
    441             items: [
    442                 {
    443                     boxLabel: i18n("Any Stock Level"),
    444                     name: 'stock',
    445                     inputValue: "any",
    446                     checked: true
    447                 }, {
    448                     boxLabel: i18n("Stock Level = 0"),
    449                     name: 'stock',
    450                     inputValue: "zero"
    451                 }, {
    452                     boxLabel: i18n("Stock Level > 0"),
    453                     name: 'stock',
    454                     inputValue: "nonzero"
    455                 }, {
    456                     boxLabel: i18n("Stock Level < Minimum Stock Level"),
    457                     name: 'stock',
    458                     inputValue: "below"
    459                 }
    460             ]
    461         });
    462 
    463         this.filterControls.push(this.stockFilter);
    464 
    465         this.partsWithoutPrice = Ext.create("Ext.form.field.Checkbox", {
    466             fieldLabel: i18n("Item Price"),
    467             boxLabel: i18n("Show Parts without Price only"),
    468             plugins: [
    469                 Ext.create("PartKeepr.Util.FilterPlugin", {
    470                     getFilterFn: function ()
    471                     {
    472                         if (this.partsWithoutPrice.getValue() === true) {
    473                             return {
    474                                 property: 'averagePrice',
    475                                 operator: '=',
    476                                 value: 0
    477                             };
    478                         }
    479 
    480                     },
    481                     listeners: {
    482                         scope: this,
    483                         disable: function ()
    484                         {
    485                             this.partsWithoutPrice.setValue(false);
    486 
    487                         }
    488                     },
    489                     scope: this
    490                 })
    491             ],
    492             listeners: {
    493                 change: function (cmp)
    494                 {
    495                     if (cmp.getValue()) {
    496                         cmp.enableFilter();
    497 
    498                     } else {
    499                         cmp.disableFilter();
    500                     }
    501                 },
    502                 scope: this
    503             },
    504         });
    505 
    506         this.filterControls.push(this.partsWithoutPrice);
    507 
    508         this.distributorOrderNumberFilter = Ext.create("Ext.form.field.Text", {
    509             fieldLabel: i18n("Order Number"),
    510             anchor: '100%',
    511             plugins: [
    512                 Ext.create("PartKeepr.Util.FilterPlugin", {
    513                     getFilterFn: function ()
    514                     {
    515                         return {
    516                             property: 'distributors.orderNumber',
    517                             operator: "LIKE",
    518                             value: "%" + this.distributorOrderNumberFilter.getValue() + "%"
    519                         };
    520                     },
    521                     listeners: {
    522                         scope: this,
    523                         disable: function ()
    524                         {
    525                             this.distributorOrderNumberFilter.setValue("");
    526                         }
    527                     },
    528                     scope: this
    529                 })
    530             ],
    531             listeners: {
    532                 change: function (cmp)
    533                 {
    534                     if (cmp.getValue() !== "") {
    535                         cmp.enableFilter();
    536                     } else {
    537                         cmp.disableFilter();
    538                     }
    539                 },
    540                 scope: this
    541             }
    542         });
    543 
    544         this.filterControls.push(this.distributorOrderNumberFilter);
    545 
    546         this.manufacturerPartNumberFilter = Ext.create("Ext.form.field.Text", {
    547             fieldLabel: i18n("Manufacturer Part Number"),
    548             anchor: '100%',
    549             plugins: [
    550                 Ext.create("PartKeepr.Util.FilterPlugin", {
    551                     getFilterFn: function ()
    552                     {
    553                         return {
    554                             property: 'manufacturers.partNumber',
    555                             operator: "LIKE",
    556                             value: "%" + this.manufacturerPartNumberFilter.getValue() + "%"
    557                         };
    558                     },
    559                     listeners: {
    560                         scope: this,
    561                         disable: function ()
    562                         {
    563                             this.manufacturerPartNumberFilter.setValue("");
    564                         }
    565                     },
    566                     scope: this
    567                 })
    568             ],
    569             listeners: {
    570                 change: function (cmp)
    571                 {
    572                     if (cmp.getValue() !== "") {
    573                         cmp.enableFilter();
    574                     } else {
    575                         cmp.disableFilter();
    576                     }
    577                 },
    578                 scope: this
    579             }
    580         });
    581 
    582         this.filterControls.push(this.manufacturerPartNumberFilter);
    583 
    584         this.createDateField = Ext.create("Ext.form.field.Date", {
    585             flex: 1,
    586             listeners: {
    587                 change: function ()
    588                 {
    589                     if (this.createDateFilterSelect.getValue() !== "" && this.createDateField.getValue() !== "") {
    590                         this.createDateFilter.enableFilter();
    591                     } else {
    592                         this.createDateFilter.disableFilter();
    593                     }
    594 
    595                 },
    596                 scope: this
    597             }
    598         });
    599 
    600         var filter = Ext.create('Ext.data.Store', {
    601             fields: ['type', 'name'],
    602             data: [
    603                 {"type": "<", "name": "before"},
    604                 {"type": ">", "name": "after"},
    605                 {"type": "", "name": "- none -"}
    606             ]
    607         });
    608 
    609         this.createDateFilterSelect = Ext.create('Ext.form.ComboBox', {
    610             store: filter,
    611             queryMode: 'local',
    612             forceSelection: true,
    613             editable: false,
    614             width: 60,
    615             value: '',
    616             triggerAction: 'all',
    617             displayField: 'name',
    618             valueField: 'type',
    619             listeners: {
    620                 select: function ()
    621                 {
    622                     if (this.createDateFilterSelect.getValue() !== "" && this.createDateField.getValue() !== "") {
    623                         this.createDateFilter.enableFilter();
    624                     } else {
    625                         this.createDateFilter.disableFilter();
    626                     }
    627                 },
    628                 scope: this
    629             }
    630         });
    631 
    632         this.createDateFilter = Ext.create({
    633             xtype: 'fieldcontainer',
    634             anchor: '100%',
    635             fieldLabel: i18n("Create date"),
    636             layout: 'hbox',
    637             border: false,
    638             items: [this.createDateFilterSelect, this.createDateField],
    639             plugins: [
    640                 Ext.create("PartKeepr.Util.FilterPlugin", {
    641                     getFilterFn: function ()
    642                     {
    643                         return {
    644                             property: 'createDate',
    645                             operator: this.createDateFilterSelect.getValue(),
    646                             value: this.createDateField.getValue()
    647                         };
    648                     },
    649                     listeners: {
    650                         scope: this,
    651                         disable: function ()
    652                         {
    653                             this.createDateFilterSelect.setValue("");
    654                             this.createDateField.setValue("");
    655                         }
    656                     },
    657                     scope: this
    658                 })
    659             ]
    660         });
    661 
    662         this.filterControls.push(this.createDateFilter);
    663 
    664         this.partsWithoutStockRemovals = Ext.create("Ext.form.field.Checkbox", {
    665             fieldLabel: i18n("Stock Settings"),
    666             boxLabel: i18n("Show Parts without stock removals only"),
    667             plugins: [
    668                 Ext.create("PartKeepr.Util.FilterPlugin", {
    669                     getFilterFn: function ()
    670                     {
    671                         return {
    672                             property: 'removals',
    673                             operator: '=',
    674                             value: false
    675                         };
    676 
    677                     },
    678                     listeners: {
    679                         scope: this,
    680                         disable: function ()
    681                         {
    682                             this.partsWithoutStockRemovals.setValue(false);
    683 
    684                         }
    685                     },
    686                     scope: this
    687                 })
    688             ],
    689             listeners: {
    690                 change: function (cmp)
    691                 {
    692                     if (cmp.getValue()) {
    693                         cmp.enableFilter();
    694 
    695                     } else {
    696                         cmp.disableFilter();
    697                     }
    698                 },
    699                 scope: this
    700             },
    701         });
    702 
    703         this.filterControls.push(this.partsWithoutStockRemovals);
    704 
    705         this.needsReview = Ext.create("Ext.form.field.Checkbox", {
    706             fieldLabel: i18n("Needs Review"),
    707             boxLabel: i18n("Show Parts that need to reviewed only"),
    708             plugins: [
    709                 Ext.create("PartKeepr.Util.FilterPlugin", {
    710                     getFilterFn: function ()
    711                     {
    712                         return {
    713                             property: 'needsReview',
    714                             operator: '=',
    715                             value: true
    716                         };
    717 
    718                     },
    719                     listeners: {
    720                         scope: this,
    721                         disable: function ()
    722                         {
    723                             this.needsReview.setValue(false);
    724 
    725                         }
    726                     },
    727                     scope: this
    728                 })
    729             ],
    730             listeners: {
    731                 change: function (cmp)
    732                 {
    733                     if (cmp.getValue()) {
    734                         cmp.enableFilter();
    735 
    736                     } else {
    737                         cmp.disableFilter();
    738                     }
    739                 },
    740                 scope: this
    741             },
    742         });
    743 
    744         this.filterControls.push(this.needsReview);
    745 
    746         this.manufacturerFilterCheckbox = Ext.create("Ext.form.field.Checkbox", {
    747             width: "20px",
    748             listeners: {
    749                 change: function (obj, value)
    750                 {
    751 
    752                     if (!value) {
    753                         this.manufacturerFilterCombo.disableFilter();
    754                     }
    755                 },
    756                 scope: this
    757             }
    758         });
    759 
    760         this.manufacturerFilterCombo = Ext.create("PartKeepr.ManufacturerComboBox", {
    761             flex: 1,
    762             plugins: [
    763                 Ext.create("PartKeepr.Util.FilterPlugin", {
    764                     getFilterFn: function ()
    765                     {
    766                         return {
    767                             property: 'manufacturers.manufacturer',
    768                             operator: "=",
    769                             value: this.manufacturerFilterCombo.getValue()
    770                         };
    771                     },
    772                     listeners: {
    773                         scope: this,
    774                         disable: function ()
    775                         {
    776                             this.manufacturerFilterCombo.setValue("");
    777                             this.manufacturerFilterCheckbox.setValue(false);
    778 
    779                         }
    780                     },
    781                     scope: this
    782                 })
    783             ],
    784             listeners: {
    785                 select: function (cmp)
    786                 {
    787                     cmp.enableFilter();
    788                     this.manufacturerFilterCheckbox.setValue(true);
    789                 },
    790                 scope: this
    791             }
    792         });
    793 
    794         this.filterControls.push(this.manufacturerFilterCombo);
    795 
    796         this.manufacturerFilter = Ext.create("Ext.form.FieldContainer", {
    797             layout: 'hbox',
    798             items: [this.manufacturerFilterCheckbox, this.manufacturerFilterCombo],
    799             fieldLabel: i18n("Manufacturer")
    800         });
    801 
    802         this.distributorFilterCheckbox = Ext.create("Ext.form.field.Checkbox", {
    803             width: "20px",
    804             listeners: {
    805                 change: function (obj, value)
    806                 {
    807                     if (!value) {
    808                         this.distributorFilterCombo.disableFilter();
    809                     }
    810                 },
    811                 scope: this
    812             }
    813         });
    814 
    815         this.distributorFilterCombo = Ext.create("PartKeepr.DistributorComboBox", {
    816             flex: 1,
    817             plugins: [
    818                 Ext.create("PartKeepr.Util.FilterPlugin", {
    819                     getFilterFn: function ()
    820                     {
    821                         return {
    822                             property: 'distributors.distributor',
    823                             operator: "=",
    824                             value: this.distributorFilterCombo.getValue()
    825                         };
    826                     },
    827                     listeners: {
    828                         scope: this,
    829                         disable: function ()
    830                         {
    831                             this.distributorFilterCombo.setValue("");
    832                             this.distributorFilterCheckbox.setValue(false);
    833 
    834                         }
    835                     },
    836                     scope: this
    837                 })
    838             ],
    839             listeners: {
    840                 select: function (cmp)
    841                 {
    842                     cmp.enableFilter();
    843                     this.distributorFilterCheckbox.setValue(true);
    844                 },
    845                 scope: this
    846             }
    847         });
    848 
    849         this.distributorFilter = Ext.create("Ext.form.FieldContainer", {
    850             layout: 'hbox',
    851             items: [this.distributorFilterCheckbox, this.distributorFilterCombo],
    852             fieldLabel: i18n("Distributor"),
    853 
    854         });
    855 
    856         this.filterControls.push(this.distributorFilterCombo);
    857 
    858         this.footprintFilterCheckbox = Ext.create("Ext.form.field.Checkbox", {
    859             width: "20px",
    860             listeners: {
    861                 change: function (obj, value)
    862                 {
    863                     if (!value) {
    864                         this.footprintFilterCombo.disableFilter();
    865                     }
    866                 },
    867                 scope: this
    868             }
    869         });
    870 
    871         this.footprintFilterCombo = Ext.create("PartKeepr.FootprintComboBox", {
    872             flex: 1,
    873             plugins: [
    874                 Ext.create("PartKeepr.Util.FilterPlugin", {
    875                     getFilterFn: function ()
    876                     {
    877                         return {
    878                             property: 'footprint',
    879                             operator: "=",
    880                             value: this.footprintFilterCombo.getValue()
    881                         };
    882                     },
    883                     listeners: {
    884                         scope: this,
    885                         disable: function ()
    886                         {
    887                             this.footprintFilterCombo.setValue("");
    888                             this.footprintFilterCheckbox.setValue(false);
    889 
    890                         }
    891                     },
    892                     scope: this
    893                 })
    894             ],
    895             listeners: {
    896                 select: function (cmp)
    897                 {
    898                     cmp.enableFilter();
    899                     this.footprintFilterCheckbox.setValue(true);
    900                 },
    901                 scope: this
    902             }
    903         });
    904 
    905         this.filterControls.push(this.footprintFilterCombo);
    906 
    907         this.footprintFilter = Ext.create("Ext.form.FieldContainer", {
    908             layout: 'hbox',
    909             items: [this.footprintFilterCheckbox, this.footprintFilterCombo],
    910             fieldLabel: i18n("Footprint")
    911         });
    912 
    913         /** **/
    914 
    915         this.statusFilter = Ext.create("Ext.form.field.Text", {
    916             fieldLabel: i18n("Status"),
    917             anchor: '100%',
    918             plugins: [
    919                 Ext.create("PartKeepr.Util.FilterPlugin", {
    920                     getFilterFn: function ()
    921                     {
    922                         return {
    923                             property: 'status',
    924                             operator: "LIKE",
    925                             value: "%" + this.statusFilter.getValue() + "%"
    926                         };
    927                     },
    928                     listeners: {
    929                         scope: this,
    930                         disable: function ()
    931                         {
    932                             this.statusFilter.setValue("");
    933                         }
    934                     },
    935                     scope: this
    936                 })
    937             ],
    938             listeners: {
    939                 change: function (cmp)
    940                 {
    941                     if (cmp.getValue() !== "") {
    942                         cmp.enableFilter();
    943                     } else {
    944                         cmp.disableFilter();
    945                     }
    946                 },
    947                 scope: this
    948             }
    949         });
    950 
    951         this.filterControls.push(this.statusFilter);
    952 
    953         this.conditionFilter = Ext.create("Ext.form.field.Text", {
    954             fieldLabel: i18n("Condition"),
    955             anchor: '100%',
    956             plugins: [
    957                 Ext.create("PartKeepr.Util.FilterPlugin", {
    958                     getFilterFn: function ()
    959                     {
    960                         return {
    961                             property: 'partCondition',
    962                             operator: "LIKE",
    963                             value: "%" + this.conditionFilter.getValue() + "%"
    964                         };
    965                     },
    966                     listeners: {
    967                         scope: this,
    968                         disable: function ()
    969                         {
    970                             this.conditionFilter.setValue("");
    971                         }
    972                     },
    973                     scope: this
    974                 })
    975             ],
    976             listeners: {
    977                 change: function (cmp)
    978                 {
    979                     if (cmp.getValue() !== "") {
    980                         cmp.enableFilter();
    981                     } else {
    982                         cmp.disableFilter();
    983                     }
    984                 },
    985                 scope: this
    986             }
    987         });
    988 
    989         this.filterControls.push(this.conditionFilter);
    990 
    991         this.internalPartNumberFilter = Ext.create("Ext.form.field.Text", {
    992             fieldLabel: i18n("Internal Part Number"),
    993             anchor: '100%',
    994             plugins: [
    995                 Ext.create("PartKeepr.Util.FilterPlugin", {
    996                     getFilterFn: function ()
    997                     {
    998                         return {
    999                             property: 'internalPartNumber',
   1000                             operator: "LIKE",
   1001                             value: "%" + this.internalPartNumberFilter.getValue() + "%"
   1002                         };
   1003                     },
   1004                     listeners: {
   1005                         scope: this,
   1006                         disable: function ()
   1007                         {
   1008                             this.internalPartNumberFilter.setValue("");
   1009                         }
   1010                     },
   1011                     scope: this
   1012                 })
   1013             ],
   1014             listeners: {
   1015                 change: function (cmp)
   1016                 {
   1017                     if (cmp.getValue() !== "") {
   1018                         cmp.enableFilter();
   1019                     } else {
   1020                         cmp.disableFilter();
   1021                     }
   1022                 },
   1023                 scope: this
   1024             }
   1025         });
   1026 
   1027         this.filterControls.push(this.internalPartNumberFilter);
   1028 
   1029         this.internalIdFilter = Ext.create("Ext.form.field.Text", {
   1030             fieldLabel: i18n("Internal ID"),
   1031             anchor: '100%',
   1032             itemId: 'idField',
   1033             qtip: i18n(
   1034                 "The first number is the ID in decimal, the second number is the ID in base36. To search in base36 format you need to prefix the search string with #, example: #15y"),
   1035             plugins: [
   1036                 Ext.create("PartKeepr.Util.FilterPlugin", {
   1037                     getFilterFn: function ()
   1038                     {
   1039                         var idstr = this.internalIdFilter.getValue();
   1040                         var idint;
   1041 
   1042                         if (idstr.substring(0, 1) == "#") {
   1043                             idstr = idstr.substring(1);
   1044                             idint = parseInt(idstr, 36);
   1045                         } else {
   1046                             idint = parseInt(idstr, 10);
   1047                         }
   1048                         return {
   1049                             property: 'id',
   1050                             operator: "=",
   1051                             value: idint
   1052                         };
   1053                     },
   1054                     listeners: {
   1055                         scope: this,
   1056                         disable: function ()
   1057                         {
   1058                             this.internalIdFilter.setValue("");
   1059                         }
   1060                     },
   1061                     scope: this
   1062                 })
   1063             ],
   1064             listeners: {
   1065                 render: function (c)
   1066                 {
   1067                     Ext.QuickTips.register({
   1068                         target: c.getEl(),
   1069                         text: c.qtip
   1070                     });
   1071                 },
   1072                 change: function (cmp)
   1073                 {
   1074                     if (cmp.getValue() !== "") {
   1075                         cmp.enableFilter();
   1076                     } else {
   1077                         cmp.disableFilter();
   1078                     }
   1079                 },
   1080                 scope: this
   1081             }
   1082         });
   1083 
   1084         this.filterControls.push(this.internalIdFilter);
   1085 
   1086         this.commentFilter = Ext.create("Ext.form.field.Text", {
   1087             fieldLabel: i18n("Comment"),
   1088             anchor: '100%',
   1089             plugins: [
   1090                 Ext.create("PartKeepr.Util.FilterPlugin", {
   1091                     getFilterFn: function ()
   1092                     {
   1093                         return {
   1094                             property: 'comment',
   1095                             operator: "LIKE",
   1096                             value: "%" + this.commentFilter.getValue() + "%"
   1097                         };
   1098                     },
   1099                     listeners: {
   1100                         scope: this,
   1101                         disable: function ()
   1102                         {
   1103                             this.commentFilter.setValue("");
   1104                         }
   1105                     },
   1106                     scope: this
   1107                 })
   1108             ],
   1109             listeners: {
   1110                 change: function (cmp)
   1111                 {
   1112                     if (cmp.getValue() !== "") {
   1113                         cmp.enableFilter();
   1114                     } else {
   1115                         cmp.disableFilter();
   1116                     }
   1117                 },
   1118                 scope: this
   1119             }
   1120         });
   1121 
   1122         this.filterControls.push(this.commentFilter);
   1123     },
   1124     /**
   1125      * Applies the filter parameters to the passed extraParams object.
   1126      * @param extraParams An object containing the extraParams from a proxy.
   1127      */
   1128     getFilters: function ()
   1129     {
   1130         var enableFilters = [],
   1131             disableFilters = [],
   1132             filterPlugin;
   1133 
   1134         for (var i = 0; i < this.filterControls.length; i++) {
   1135             filterPlugin = this.filterControls[i].findPlugin("filter");
   1136 
   1137             if (filterPlugin instanceof PartKeepr.Util.FilterPlugin) {
   1138                 if (filterPlugin.isEnabled()) {
   1139                     enableFilters.push(this.filterControls[i].findPlugin("filter").getFilter());
   1140                 } else {
   1141                     disableFilters.push(this.filterControls[i].findPlugin("filter").getFilter());
   1142                 }
   1143             }
   1144         }
   1145 
   1146         return {
   1147             disableFilters: disableFilters,
   1148             enableFilters: enableFilters
   1149         };
   1150     },
   1151     /**
   1152      * Unregisters the quick tip immediately prior destroying
   1153      */
   1154     onBeforeIdFieldDestroy: function (field)
   1155     {
   1156         Ext.QuickTips.unregister(field.getEl());
   1157     }
   1158 });