partkeepr

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

MetaPartAvailabilityRenderer.js (1307B)


      1 Ext.define("PartKeepr.Components.ProjectReport.Renderers.MetaPartAvailabilityRenderer", {
      2     extend: "PartKeepr.Components.Grid.Renderers.AbstractRenderer",
      3 
      4     alias: 'columnRenderer.projectReportMetaPartAvailability',
      5 
      6     renderer: function (val, q, rec)
      7     {
      8         var part = rec.getPart();
      9         var total = 0;
     10         var partUnit = "";
     11 
     12         if (part.get("metaPart"))
     13         {
     14 
     15             for (i = 0; i <rec.subParts().getCount(); i++)
     16             {
     17                 total += rec.subParts().getAt(i).get("stockLevel");
     18             }
     19 
     20         } else
     21         {
     22             total = val;
     23 
     24             if (part.getPartUnit())
     25             {
     26                 partUnit = part.getPartUnit().get("shortName");
     27 
     28             }
     29         }
     30 
     31         if (total < rec.get("quantity")) {
     32             return '<span style="color: red;">' + total + " " + partUnit + "</span>";
     33         } else {
     34             return '<span style="color: green;">' + total + " " + partUnit + "</span>";
     35         }
     36     },
     37     statics: {
     38         rendererName: i18n("Project Report Stock Availability Renderer"),
     39         rendererDescription: i18n("Renders the available stock level which includes the sum of all meta parts"),
     40         rendererConfigs: {},
     41         restrictToEntity: ["PartKeepr.ProjectBundle.Entity.ReportPart"]
     42     }
     43 });