commit 3cf676cb6862409262d2d102a560c2608cc8315c
parent 30c73d3cf38d3fe4c4ba3d9f86a77bbd59dc4e1e
Author: Timo A. Hummel <timo@netraver.de>
Date: Tue, 7 Jun 2011 11:18:55 +0200
Hide unit if it's default
Diffstat:
3 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/frontend/js/Components/Part/PartsGrid.js b/frontend/js/Components/Part/PartsGrid.js
@@ -4,8 +4,19 @@ Ext.define('PartDB2.PartsGrid', {
columns: [
{header: i18n("Name"), dataIndex: 'name', flex: 1, renderer: Ext.util.Format.htmlEncode},
{header: i18n("Storage Location"), dataIndex: 'storageLocationName'},
- {header: i18n("Stock"), dataIndex: 'stockLevel', xtype:'templatecolumn', tpl:'{stockLevel} {partUnit}'},
- {header: i18n("Min. Stock"), dataIndex: 'minStockLevel'},
+ {
+ header: i18n("Stock"),
+ dataIndex: 'stockLevel',
+ renderer: function (val,q,rec)
+ {
+ if (rec.get("partUnitDefault") !== true) {
+ return rec.get("stockLevel") + " " + rec.get("partUnit");
+ } else {
+ return val;
+ }
+ }
+ },
+ {header: i18n("Min. Stock"), dataIndex: 'minStockLevel', xtype:'templatecolumn', tpl:'{minStockLevel} {partUnit}'},
{header: i18n("Footprint"), dataIndex: 'footprintName'}
],
buttonTextMode: 'show',
diff --git a/frontend/js/Models/Part.js b/frontend/js/Models/Part.js
@@ -10,6 +10,20 @@ PartDB2.Part = Ext.define("Part", {
{ name: 'storageLocation_id',type: 'int'},
{ name: 'storageLocationName',type: 'string'},
{ name: 'partUnit',type: 'string'},
+
+ /*
+ * The partUnitDefault would belong into an association. Unless we know how to
+ * access associations in e.g. a grid, we need to pass it as this one.
+ */
+ {
+ name: 'partUnitDefault',
+ type: 'boolean',
+ convert: function (val) {
+ if (val === "true" || val === "1" || val === true)
+ { return true; }
+ else { return false; }
+ }
+ },
{ name: 'name',type: 'string'},
{ name: 'comment',type: 'string'},
{ name: 'stockLevel',type: 'int'},
diff --git a/src/de/RaumZeitLabor/PartDB2/Part/PartManager.php b/src/de/RaumZeitLabor/PartDB2/Part/PartManager.php
@@ -89,7 +89,7 @@ class PartManager extends Singleton {
- $qb->select("p.name, p.id, p.stockLevel, p.minStockLevel, p.comment, st.id AS storageLocation_id, st.name as storageLocationName, f.id AS footprint_id, f.footprint AS footprintName, c.id AS category_id, c.name AS categoryName, pu.name AS partUnit");
+ $qb->select("p.name, p.id, p.stockLevel, p.minStockLevel, p.comment, st.id AS storageLocation_id, st.name as storageLocationName, f.id AS footprint_id, f.footprint AS footprintName, c.id AS category_id, c.name AS categoryName, pu.name AS partUnit, pu.is_default AS partUnitDefault");
if ($limit > -1) {
$qb->setMaxResults($limit);