partkeepr

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

FieldSelectTrigger.js (1505B)


      1 /**
      2  * A part picker with an attached grid.
      3  */
      4 Ext.define("PartKeepr.Components.Widgets.FieldSelectTrigger", {
      5     extend: "Ext.form.field.Picker",
      6     xtype: 'fieldSelectTrigger',
      7     selectedValue: null,
      8     editable: false,
      9 
     10     config: {
     11         baseEntity: null
     12     },
     13 
     14     /**
     15      * Initializes the component.
     16      */
     17     initComponent: function ()
     18     {
     19         this.callParent();
     20         this.createPicker();
     21 
     22         // Automatically expand field when focused
     23         this.on("focus", function ()
     24         {
     25             this.onTriggerClick();
     26         }, this);
     27     },
     28     createPicker: function ()
     29     {
     30         this.fireEvent("beforeSelect", this);
     31 
     32         this.modelFieldSelector = Ext.create({
     33             xtype: 'modelFieldSelector',
     34             border: false,
     35             sourceModel: this.baseEntity,
     36             useCheckBoxes: false,
     37             flex: 1
     38         });
     39 
     40         this.picker = Ext.create("Ext.panel.Panel", {
     41             shrinkWrapDock: 2,
     42             layout: 'fit',
     43             floating: true,
     44             focusOnToFront: false,
     45             manageHeight: false,
     46             height: 300,
     47             minWidth: 350,
     48             shadow: false,
     49             ownerCmp: this,
     50             items: [this.modelFieldSelector]
     51         });
     52 
     53         this.modelFieldSelector.on("select",
     54             function (selModel, record)
     55             {
     56                 this.setValue(record.data.data.name);
     57                 this.collapse();
     58             }, this);
     59 
     60         return this.picker;
     61     }
     62 });