partkeepr

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

FulltextSearch.js (3064B)


      1 Ext.define('PartKeepr.Components.SystemPreferences.Preferences.FulltextSearch', {
      2     extend: 'PartKeepr.Components.Preferences.PreferenceEditor',
      3 
      4     initComponent: function ()
      5     {
      6 
      7         this.fieldSelector = Ext.create("PartKeepr.Components.Widgets.FieldSelector", {
      8             height: 300,
      9             sourceModel: PartKeepr.PartBundle.Entity.Part,
     10             initiallyChecked: PartKeepr.getApplication().getSystemPreference("partkeepr.part.search.fields",
     11                 ["name", "description", "comment", "internalPartNumber"])
     12         });
     13 
     14         this.items = [
     15             {
     16                 xtype: 'fieldcontainer',
     17                 fieldLabel: i18n("Search Mode"),
     18                 defaultType: 'radiofield',
     19                 defaults: {
     20                     flex: 1
     21                 },
     22                 layout: 'vbox',
     23                 items: [
     24                     {
     25                         boxLabel: i18n("Use entered text as-is"),
     26                         name: 'splitMode',
     27                         inputValue: 'full',
     28                         id: 'searchModeFull'
     29                     }, {
     30                         boxLabel: i18n("Separate search terms"),
     31                         name: 'splitMode',
     32                         inputValue: 'split',
     33                         id: 'searchModeSplit'
     34                     }
     35                 ]
     36             },
     37             {
     38                 xtype: "fieldcontainer",
     39                 fieldLabel: i18n("Search Fields"),
     40                 items: [
     41                     {
     42                         style: "padding-top: 4px; padding-bottom: 5px;",
     43                         html: i18n(
     44                             "Select all fields which are searched when entering a search term in the upper-right search field within the part manager"),
     45                         border: false
     46                     }, this.fieldSelector
     47                 ]
     48             }
     49         ];
     50 
     51         this.callParent(arguments);
     52 
     53         if (PartKeepr.getApplication().getSystemPreference("partkeepr.part.search.split", true)) {
     54             this.down("#searchModeFull").setValue(false);
     55             this.down("#searchModeSplit").setValue(true);
     56         } else {
     57             this.down("#searchModeFull").setValue(true);
     58             this.down("#searchModeSplit").setValue(false);
     59         }
     60     },
     61     onSave: function ()
     62     {
     63         var selection = this.fieldSelector.getChecked();
     64         var fields = [];
     65 
     66         for (var i = 0; i < selection.length; i++) {
     67             fields.push(selection[i].data.data.name);
     68         }
     69 
     70         PartKeepr.getApplication().setSystemPreference("partkeepr.part.search.fields", fields);
     71 
     72         if (this.down("#searchModeFull").getValue()) {
     73             PartKeepr.getApplication().setSystemPreference("partkeepr.part.search.split", false);
     74         } else {
     75             PartKeepr.getApplication().setSystemPreference("partkeepr.part.search.split", true);
     76         }
     77     },
     78     statics: {
     79         iconCls: 'fugue-icon magnifier-medium',
     80         title: i18n('Fulltext Search'),
     81         menuPath: [{text: i18n("Search")}]
     82     }
     83 });