partkeepr

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

ProjectRunEditor.js (2917B)


      1 /**
      2  * Represents the project editor view
      3  */
      4 Ext.define('PartKeepr.ProjectRunEditor', {
      5     extend: 'PartKeepr.Editor',
      6     alias: 'widget.ProjectRunEditor',
      7 
      8     defaults: {
      9         anchor: '100%',
     10         labelWidth: 110
     11     },
     12     enableButtons: false,
     13     layout: {
     14         type: 'vbox',
     15         align: 'stretch',
     16         pack: 'start'
     17     },
     18 
     19     /**
     20      * Initializes the component
     21      */
     22     initComponent: function ()
     23     {
     24         /**
     25          * Due to an ExtJS issue, we need to delay the event
     26          * for a bit.
     27          *
     28          * @todo Fix this in a cleaner way
     29          */
     30         this.on("startEdit", this.onEditStart, this, {
     31             delay: 200
     32         });
     33 
     34         var config = {};
     35 
     36         // Build the initial (empty) store for the project parts
     37         Ext.Object.merge(config, {
     38             autoLoad: false,
     39             model: "PartKeepr.ProjectBundle.Entity.ProjectRunPart",
     40             autoSync: false, // Do not change. If true, new (empty) records would be immediately committed to the database.
     41             remoteFilter: false,
     42             remoteSort: false
     43         });
     44 
     45         this.store = Ext.create('Ext.data.Store', config);
     46 
     47         this.partGrid = Ext.create("Ext.grid.Panel", {
     48             columns: [
     49                 {
     50                     header: i18n("Part Name"),
     51                     renderer: function (r, v, rec)
     52                     {
     53                         if (rec.getPart() !== null) {
     54                             return rec.getPart().get("name");
     55                         }
     56                         return "";
     57                     }
     58                 }, {
     59                     header: i18n("Qty"),
     60                     dataIndex: 'quantity'
     61                 }, {
     62                     header: i18n("Lot Number"),
     63                     dataIndex: 'lotNumber'
     64                 }
     65 
     66             ],
     67             store: this.store
     68         });
     69 
     70         var container = Ext.create("Ext.form.FieldContainer", {
     71             fieldLabel: i18n("Project Parts"),
     72             labelWidth: 110,
     73             layout: 'fit',
     74             flex: 1,
     75             items: this.partGrid
     76         });
     77 
     78         this.items = [
     79             {
     80                 xtype: 'displayfield',
     81                 itemId: 'projectName',
     82                 height: 20,
     83                 fieldLabel: i18n("Project Name")
     84             }, {
     85                 xtype: 'datefield',
     86                 name: 'runDateTime',
     87                 fieldLabel: i18n("Run Date/Time"),
     88                 readOnly: true
     89             },
     90             container
     91         ];
     92         this.callParent();
     93 
     94     },
     95     /**
     96      * Bind the store as soon as the view was rendered.
     97      *
     98      * @todo This is a hack, because invocation of this method is delayed.
     99      */
    100     onEditStart: function ()
    101     {
    102         var store = this.record.parts();
    103         this.partGrid.bindStore(store);
    104 
    105         this.down("#projectName").setValue(this.record.get("project.name"));
    106     }
    107 });