partkeepr

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

PartInfoGrid.js (3042B)


      1 Ext.define("PartKeepr.Components.Part.PartInfoGrid", {
      2     extend: "Ext.grid.property.Grid",
      3 
      4     sortableColumns: false,
      5 
      6     fieldConfigs: {
      7         "category.name": {
      8             displayName: i18n("Category Name")
      9         },
     10         stockLevel: {
     11             displayName: i18n("Stock Level")
     12         },
     13         minStockLevel: {
     14             displayName: i18n("Minimum Stock Level")
     15         },
     16         "footprint.name": {
     17             displayName: i18n("Footprint")
     18         },
     19         "storageLocation.name": {
     20             displayName: i18n("Storage Location")
     21         },
     22         comment: {
     23             displayName: i18n("Comment")
     24         },
     25         createDate: {
     26             displayName: i18n("Create Date"),
     27             type: 'date'
     28         },
     29         status: {
     30             displayName: i18n("Status")
     31         },
     32         partCondition: {
     33             displayName: i18n("Condition")
     34         },
     35         needsReview: {
     36             displayName: i18n("Needs Review"),
     37             type: 'boolean'
     38         },
     39         internalPartNumber: {
     40             displayName: i18n("Internal Part Number")
     41         },
     42         projectNames: {
     43             displayName: i18n("Used in Projects")
     44         },
     45         "@id": {
     46             displayName: i18n("Internal ID"),
     47             renderer: function (value)
     48             {
     49                 var values = value.split("/");
     50                 var idstr = values[values.length - 1];
     51                 var idint = parseInt(idstr);
     52                 return idstr + " (#" + idint.toString(36) + ")";
     53             }
     54         }
     55     },
     56 
     57     shortFieldConfigs: {
     58         "name": {
     59             displayName: i18n("Name")
     60         },
     61         "description": {
     62             displayName: i18n("Description")
     63         },
     64         "category.name": {
     65             displayName: i18n("Category Name")
     66         },
     67         stockLevel: {
     68             displayName: i18n("Stock Level")
     69         },
     70         "footprint.name": {
     71             displayName: i18n("Footprint")
     72         },
     73         "storageLocation.name": {
     74             displayName: i18n("Storage Location")
     75         },
     76         comment: {
     77             displayName: i18n("Comment")
     78         },
     79         internalPartNumber: {
     80             displayName: i18n("Internal Part Number")
     81         }
     82     },
     83 
     84     listeners: {
     85         'beforeedit': function ()
     86         {
     87             return false;
     88         }
     89     },
     90     hideHeaders: true,
     91     nameColumnWidth: 150,
     92     cls: 'x-wrappable-grid',
     93 
     94     mode: 'full',
     95 
     96     initComponent: function ()
     97     {
     98         if (this.mode === "full") {
     99             this.sourceConfig = this.fieldConfigs;
    100         } else {
    101             this.sourceConfig = this.shortFieldConfigs;
    102         }
    103 
    104         this.callParent(arguments);
    105     },
    106     applyFromPart: function (record)
    107     {
    108         var values = {}, value;
    109 
    110         for (var i in this.sourceConfig) {
    111             value = record.get(i);
    112             if (value !== undefined) {
    113                 values[i] = value;
    114             } else {
    115                 values[i] = i18n("none");
    116             }
    117         }
    118 
    119         this.setSource(values);
    120     }
    121 
    122 });