partkeepr

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

commit faa302f5bdc9d7d17f77209e164fb55cde29b784
parent 2b69db66e7d89b439fcd6b56ea9b3cf8ed16a3f8
Author: Felicia Hummel <felicia@partkeepr.com>
Date:   Wed, 18 Oct 2017 22:46:06 +0200

Render the stock availability including meta parts

Diffstat:
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReportResultGrid.js | 8++++++--
Asrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/MetaPartAvailabilityRenderer.js | 43+++++++++++++++++++++++++++++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/MetaPartRenderer.js | 2+-
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/QuantityRenderer.js | 2+-
Msrc/PartKeepr/FrontendBundle/Resources/views/index.html.twig | 1+
5 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReportResultGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReportResultGrid.js @@ -58,7 +58,11 @@ Ext.define("PartKeepr.Components.Project.ProjectReportResultGrid", { header: i18n("Storage Location"), dataIndex: 'part.storageLocation.name', width: 100 }, { - header: i18n("Available"), dataIndex: 'part.stockLevel', + header: i18n("Available"), + dataIndex: "part.stockLevel", + renderers: [{ + rtype: "projectReportMetaPartAvailability" + }], width: 75 }, { header: i18n("Distributor"), @@ -357,7 +361,7 @@ Ext.define("PartKeepr.Components.Project.ProjectReportResultGrid", { "removals": Ext.encode(removals), "projects": Ext.encode(this.getProjectsToReport()) }, - function (options, success, response) + function (options, success) { if (success) { diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/MetaPartAvailabilityRenderer.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/MetaPartAvailabilityRenderer.js @@ -0,0 +1,43 @@ +Ext.define("PartKeepr.Components.ProjectReport.Renderers.MetaPartAvailabilityRenderer", { + extend: "PartKeepr.Components.Grid.Renderers.AbstractRenderer", + + alias: 'columnRenderer.projectReportMetaPartAvailability', + + renderer: function (val, q, rec) + { + var part = rec.getPart(); + var total = 0; + var partUnit = ""; + + if (part.get("metaPart")) + { + + for (i = 0; i <rec.subParts().getCount(); i++) + { + total += rec.subParts().getAt(i).get("stockLevel"); + } + + } else + { + total = val; + + if (part.getPartUnit()) + { + partUnit = part.getPartUnit().get("shortName"); + + } + } + + if (total < rec.get("quantity")) { + return '<span style="color: red;">' + total + " " + partUnit + "</span>"; + } else { + return '<span style="color: green;">' + total + " " + partUnit + "</span>"; + } + }, + statics: { + rendererName: i18n("Project Report Stock Availability Renderer"), + rendererDescription: i18n("Renders the available stock level which includes the sum of all meta parts"), + rendererConfigs: {}, + restrictToEntity: ["PartKeepr.ProjectBundle.Entity.ReportPart"] + } +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/MetaPartRenderer.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/MetaPartRenderer.js @@ -24,6 +24,6 @@ Ext.define("PartKeepr.Components.ProjectReport.Renderers.MetaPartRenderer", { rendererName: i18n("Project Report MetaPart Renderer"), rendererDescription: i18n("Renders a specific icon if the part is a meta part"), - restrictToEntity: ["PartKeepr.PartBundle.Entity.ProjectReport"] + restrictToEntity: ["PartKeepr.ProjectBundle.Entity.ReportPart"] } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/QuantityRenderer.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/QuantityRenderer.js @@ -54,6 +54,6 @@ Ext.define("PartKeepr.Components.ProjectReport.Renderers.QuantityRenderer", { } }, - restrictToEntity: ["PartKeepr.PartBundle.Entity.ProjectReport"] + restrictToEntity: ["PartKeepr.ProjectBundle.Entity.ProjectReport"] } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig b/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig @@ -293,6 +293,7 @@ '@PartKeeprFrontendBundle/Resources/public/js/Components/Project/ProjectReport.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Project/ProjectReportResultGrid.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Project/ProjectReportGrid.js' + '@PartKeeprFrontendBundle/Resources/public/js/Components/Project/Renderers/MetaPartAvailabilityRenderer.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Statistics/StatisticsChart.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Statistics/StatisticsChartPanel.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Statistics/SummaryStatisticsPanel.js'