commit 0b5393afb0809d70b7be64c6b413f9dde0173656
parent 903389118b7f2400e7d35c9573771f1b16ab9adb
Author: Felicitus <felicitus@felicitus.org>
Date: Wed, 29 Jun 2011 18:15:00 +0200
Added grouping for the result list
Diffstat:
5 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/frontend/js/Components/Part/PartsGrid.js b/frontend/js/Components/Part/PartsGrid.js
@@ -19,11 +19,20 @@ Ext.define('PartKeepr.PartsGrid', {
enableDragDrop : true,
stripeRows : true,
multiSelect : true,
+ invalidateScrollerOnRefresh: true,
initComponent: function () {
+ var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
+ enableGroupingMenu: false,
+ groupHeaderTpl: '{name} ({rows.length} ' + i18n("Part(s)")+")"
+ });
+
// Create the columns
this.defineColumns();
+
+ this.features = [groupingFeature];
+
// Initialize the panel
this.callParent();
@@ -42,6 +51,8 @@ Ext.define('PartKeepr.PartsGrid', {
scope: this
});
+
+
// Add the filter button
this.bottomToolbar.add([ '-', this.filterButton ]);
},
diff --git a/frontend/js/Components/Part/PartsManager.js b/frontend/js/Components/Part/PartsManager.js
@@ -15,6 +15,7 @@ Ext.define('PartKeepr.PartManager', {
*/
this.createStore({
model: 'PartKeepr.Part',
+ groupField: 'categoryPath',
sorters: [{
property: 'name',
direction:'ASC'
@@ -187,7 +188,7 @@ Ext.define('PartKeepr.PartManager', {
autoSync: false, // Do not change. If true, new (empty) records would be immediately commited to the database.
remoteFilter: true,
remoteSort: true,
- pageSize: 15});
+ pageSize: 50});
this.store = Ext.create('Ext.data.Store', config);
diff --git a/frontend/js/Models/Part.js b/frontend/js/Models/Part.js
@@ -20,6 +20,7 @@ Ext.define("PartKeepr.Part", {
{ name: 'footprintName', type: 'string'},
{ name: 'storageLocationName',type: 'string'},
{ name: 'categoryName', type: 'string'},
+ { name: 'categoryPath', type: 'string'},
{
name: 'partUnitDefault',
type: 'boolean',
diff --git a/src/de/RaumZeitLabor/PartKeepr/Part/Part.php b/src/de/RaumZeitLabor/PartKeepr/Part/Part.php
@@ -2,7 +2,7 @@
namespace de\RaumZeitLabor\PartKeepr\Part;
use de\RaumZeitLabor\PartKeepr\StorageLocation\StorageLocation;
use de\RaumZeitLabor\PartKeepr\Footprint\Footprint;
-
+use de\RaumZeitLabor\PartKeepr\PartCategory\PartCategoryManager;
use de\RaumZeitLabor\PartKeepr\Util\Deserializable;
use de\RaumZeitLabor\PartKeepr\PartCategory\PartCategory;
@@ -152,6 +152,13 @@ class Part extends BaseEntity implements Serializable, Deserializable {
*/
private $createDate;
+ /**
+ * Represents the path to the category
+ * @Column(type="text",nullable=true)
+ * @var string
+ */
+ private $categoryPath;
+
public function __construct () {
$this->distributors = new \Doctrine\Common\Collections\ArrayCollection();
$this->manufacturers = new \Doctrine\Common\Collections\ArrayCollection();
@@ -255,6 +262,7 @@ class Part extends BaseEntity implements Serializable, Deserializable {
*/
public function setCategory (PartCategory $category) {
$this->category = $category;
+ $this->categoryPath = PartCategoryManager::getInstance()->getNodeManager()->wrapNode($category)->getPath(' > ', true);
}
/**
diff --git a/src/de/RaumZeitLabor/PartKeepr/Part/PartManager.php b/src/de/RaumZeitLabor/PartKeepr/Part/PartManager.php
@@ -108,7 +108,7 @@ class PartManager extends Singleton {
- $qb->select("p.averagePrice, p.name, p.needsReview, p.createDate, p.id, p.stockLevel, p.minStockLevel, p.comment, st.id AS storageLocation_id, st.name as storageLocationName, f.id AS footprint_id, f.name AS footprintName, c.id AS category_id, c.name AS categoryName, pu.id AS partUnit, pu.name AS partUnitName, pu.is_default AS partUnitDefault");
+ $qb->select("p.averagePrice, p.name, p.needsReview, p.createDate, p.id, p.stockLevel, p.minStockLevel, p.comment, st.id AS storageLocation_id, p.categoryPath, st.name as storageLocationName, f.id AS footprint_id, f.name AS footprintName, c.id AS category_id, c.name AS categoryName, pu.id AS partUnit, pu.name AS partUnitName, pu.is_default AS partUnitDefault");
$qb->orderBy($orderBy, $dir);
if ($limit > -1) {
$qb->setMaxResults($limit);