commit cd2514d07db4820b46754bc0d3ecb43107fed302
parent 29e78429b3aa7584a4c5df5898de419324e3e7d8
Author: Felicitus <felicitus@felicitus.org>
Date: Sun, 10 Jul 2011 06:02:20 +0200
Added grouper menu + display icon if part has an attachment
Diffstat:
3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/frontend/js/Components/Part/PartsGrid.js b/frontend/js/Components/Part/PartsGrid.js
@@ -28,7 +28,7 @@ Ext.define('PartKeepr.PartsGrid', {
initComponent: function () {
var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
- enableGroupingMenu: false,
+ //enableGroupingMenu: false,
groupHeaderTpl: '{name} ({rows.length} ' + i18n("Part(s)")+")"
});
@@ -60,6 +60,12 @@ Ext.define('PartKeepr.PartsGrid', {
defineColumns: function () {
this.columns = [
{
+ header: "",
+ dataIndex: "",
+ width: 30,
+ renderer: this.iconRenderer
+ },
+ {
header: i18n("Name"),
dataIndex: 'name',
flex: 1,
@@ -82,7 +88,12 @@ Ext.define('PartKeepr.PartsGrid', {
},{
header: i18n("Footprint"),
dataIndex: 'footprintName'
+ },{
+ header: i18n("Category"),
+ dataIndex: 'categoryPath',
+ hidden: true
}
+
];
},
/**
@@ -100,6 +111,18 @@ Ext.define('PartKeepr.PartsGrid', {
}
},
/**
+ * Used as renderer for the icon column.
+ */
+ iconRenderer: function (val,q,rec)
+ {
+ var ret = "";
+ if (rec.get("attachmentCount") > 0) {
+ ret += '<img src="resources/silkicons/attach.png" alt="'+i18n("Has attachments")+'" title="'+i18n("Has attachments")+'"/>';
+ }
+
+ return ret;
+ },
+ /**
* Sets the category. Triggers a store reload with a category filter.
*/
setCategory: function (category) {
diff --git a/frontend/js/Models/Part.js b/frontend/js/Models/Part.js
@@ -25,6 +25,7 @@ Ext.define("PartKeepr.Part", {
{ name: 'storageLocationName',type: 'string'},
{ name: 'categoryName', type: 'string'},
{ name: 'categoryPath', type: 'string'},
+ { name: 'attachmentCount', type: 'int'},
{
name: 'partUnitDefault',
type: 'boolean',
diff --git a/src/de/RaumZeitLabor/PartKeepr/Part/PartManager.php b/src/de/RaumZeitLabor/PartKeepr/Part/PartManager.php
@@ -44,6 +44,7 @@ class PartManager extends Singleton {
->leftJoin("p.footprint", "f")
->join("p.category", "c")
->leftJoin("p.partUnit", "pu");
+
$qb->where("1=1");
if ($filter != "") {
@@ -128,6 +129,14 @@ class PartManager extends Singleton {
$result = $query->getArrayResult();
+ foreach ($result as $key => $item) {
+ $dql = "SELECT COUNT(pa) FROM de\RaumZeitLabor\PartKeepr\Part\PartAttachment pa WHERE pa.part = :part";
+ $query = PartKeepr::getEM()->createQuery($dql);
+ $query->setParameter("part", $item["id"]);
+
+ $result[$key]["attachmentCount"] = $query->getSingleScalarResult();
+ }
+
return array("data" => $result, "totalCount" => $totalQuery->getSingleScalarResult());