partkeepr

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

DisplayConfiguration.js (2848B)


      1 Ext.define('PartKeepr.Components.UserPreferences.Preferences.DisplayConfiguration', {
      2     extend: 'PartKeepr.Components.Preferences.PreferenceEditor',
      3 
      4     initComponent: function ()
      5     {
      6         this.showDescriptionsCheckbox = Ext.create("Ext.form.field.Checkbox", {
      7             labelWidth: 120,
      8             hideEmptyLabel: false,
      9             boxLabel: i18n("Show category descriptions (requires reload)")
     10         });
     11 
     12         if (PartKeepr.getApplication().getUserPreference("partkeepr.categorytree.showdescriptions") === false) {
     13             this.showDescriptionsCheckbox.setValue(false);
     14         } else {
     15             this.showDescriptionsCheckbox.setValue(true);
     16         }
     17 
     18         this.compactLayout = Ext.create("Ext.form.field.Radio", {
     19             boxLabel: i18n(
     20                 "Compact Layout") + '<br/> <span class="partkeepr-part-manager-compact"/>',
     21             name: 'rb',
     22             inputValue: 'compact'
     23         });
     24 
     25         this.standardLayout = Ext.create("Ext.form.field.Radio", {
     26             boxLabel: i18n(
     27                 "Standard Layout") + '<br/> <span class="partkeepr-part-manager-standard"/>',
     28             name: 'rb',
     29             inputValue: 'standard'
     30         });
     31 
     32         if (PartKeepr.getApplication().getUserPreference("partkeepr.partmanager.compactlayout", false) === true) {
     33             this.compactLayout.setValue(true);
     34         } else {
     35             this.standardLayout.setValue(true);
     36         }
     37 
     38         this.compactLayoutChooser = Ext.create("Ext.form.RadioGroup", {
     39             fieldLabel: i18n("Part Manager Layout"),
     40             labelWidth: 120,
     41             columns: 2,
     42             width: 400,
     43             vertical: true,
     44             items: [
     45                 this.compactLayout,
     46                 this.standardLayout
     47             ]
     48         });
     49 
     50         this.items = [this.showDescriptionsCheckbox, this.compactLayoutChooser];
     51 
     52         this.callParent();
     53     },
     54     onSave: function ()
     55     {
     56         PartKeepr.getApplication().setUserPreference("partkeepr.categorytree.showdescriptions",
     57             this.showDescriptionsCheckbox.getValue());
     58 
     59         var layout = this.compactLayoutChooser.getValue();
     60         
     61         var compactLayout = false;
     62         
     63         if (layout.rb === "compact") {
     64             compactLayout = true;
     65         }
     66         
     67         var oldCompactLayout = PartKeepr.getApplication().getUserPreference("partkeepr.partmanager.compactlayout", false);
     68         PartKeepr.getApplication().setUserPreference("partkeepr.partmanager.compactlayout", compactLayout);
     69         
     70         if (oldCompactLayout !== compactLayout) {
     71             PartKeepr.getApplication().recreatePartManager();
     72         }
     73 
     74     },
     75     statics: {
     76         iconCls: 'fugue-icon monitor',
     77         title: i18n('Display'),
     78         menuPath: [{iconCls: 'fugue-icon ui-scroll-pane-image', text: i18n("User Interface")}]
     79     }
     80 });