partkeepr

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

RequiredPartDistributorFields.js (1678B)


      1 Ext.define('PartKeepr.Components.SystemPreferences.Preferences.RequiredPartDistributorFields', {
      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.PartDistributor,
     10             recurseSubModels: false,
     11             excludeFields: [
     12                 "@id"
     13             ],
     14             initiallyChecked: PartKeepr.getApplication().getSystemPreference("partkeepr.partDistributor.requiredFields",
     15                 [])
     16         });
     17 
     18         this.items = [
     19             {
     20                 xtype: "fieldcontainer",
     21                 fieldLabel: i18n("Required Fields"),
     22                 items: [
     23                     {
     24                         border: false,
     25                         html: "The field <strong>Distributor</strong> is always required.",
     26                         style: "padding-top: 4px; padding-bottom: 5px;"
     27                     },
     28                     this.fieldSelector
     29                 ]
     30             }
     31         ];
     32 
     33         this.callParent(arguments);
     34     },
     35     onSave: function ()
     36     {
     37         var selection = this.fieldSelector.getChecked();
     38         var fields = [];
     39 
     40         for (var i = 0; i < selection.length; i++) {
     41             fields.push(selection[i].data.data.name);
     42         }
     43 
     44         PartKeepr.getApplication().setSystemPreference("partkeepr.partDistributor.requiredFields", fields);
     45     },
     46     statics: {
     47         iconCls: 'fugue-icon block--plus',
     48         title: i18n('Part Distributor'),
     49         menuPath: [{text: i18n("Required Fields")}]
     50     }
     51 });