commit b2ed56354adf7a99318771345d8d40c2ef4f611d
parent 99014e0c1a36112c66a8b1c347bcd1ec97259863
Author: Felicitus <privat@timohummel.com>
Date: Sun, 22 May 2011 19:26:40 +0200
Added parts display
Diffstat:
7 files changed, 192 insertions(+), 4 deletions(-)
diff --git a/frontend/index.html b/frontend/index.html
@@ -55,6 +55,7 @@
<script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/PartsManager/PartsManagerTree.js"></script>
<!-- <script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/PartsManager/FootPrintManagerDetails.js"></script> -->
<script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/PartsManager/PartsManagerWindow.js"></script>
+ <script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/PartsManager/PartsManagerListGrid.js"></script>
<script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/CategoryEditor/CategoryEditor.js"></script>
<script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/CategoryEditor/CategoryWidget.js"></script>
diff --git a/frontend/js/de.RaumZeitLabor.PartDB2/PartsManager/PartsManagerListGrid.js b/frontend/js/de.RaumZeitLabor.PartDB2/PartsManager/PartsManagerListGrid.js
@@ -0,0 +1,56 @@
+Ext.ns("de.RaumZeitLabor.PartDB2.PartsManagerListGrid");
+
+de.RaumZeitLabor.PartDB2.PartsManagerListGrid = Ext.extend(Ext.grid.GridPanel, {
+ height: '100%',
+ initComponent: function () {
+
+ this.colModel = new Ext.grid.ColumnModel({
+ defaults: {
+ width: 120,
+ sortable: true
+ },
+ columns: [
+ {header: 'Name', dataIndex: 'name', width: 300},
+ ],
+ });
+
+ var pageSize = 13;
+
+ this.call = new org.jerrymouse.service.Call(
+ "de.RaumZeitLabor.PartDB2.Part.PartManagerService",
+ "getParts");
+
+ this.call.setLoadMessage('$[de.RaumZeitLabor.PartDB2.FootPrintManager.loading]');
+ this.call.setParameter("limit", pageSize);
+
+ this.store = new Ext.data.JsonStore({
+ root: 'parts',
+ totalProperty: 'totalCount',
+ proxy: new ServiceCallDataProxy(this.call),
+ idProperty: 'id',
+ remoteSort: true,
+ listeners: {
+ beforeLoad: this.onBeforeLoad.createDelegate(this)
+ },
+ fields: [
+ 'id',
+ 'name'
+ ]
+ });
+
+
+ this.bbar = new Ext.PagingToolbar(
+ {
+ "pageSize": pageSize,
+ store: this.store,
+ displayInfo: false
+ });
+ de.RaumZeitLabor.PartDB2.PartsManagerListGrid.superclass.initComponent.call(this);
+ },
+ onBeforeLoad: function (store, options) {
+ this.call.setParameter("category", this.limitCategory);
+ },
+ setLimitCategory: function (category) {
+ this.limitCategory = category;
+ }
+});+
\ No newline at end of file
diff --git a/frontend/js/de.RaumZeitLabor.PartDB2/PartsManager/PartsManagerTree.js b/frontend/js/de.RaumZeitLabor.PartDB2/PartsManager/PartsManagerTree.js
@@ -56,6 +56,12 @@ de.RaumZeitLabor.PartDB2.PartsManagerTree = Ext.extend(Ext.tree.TreePanel, {
} else {
Ext.getCmp("category-edit-button").disable();
}
+
+ Ext.getCmp("parts-manager-window").showPartsList();
+
+ Ext.getCmp("parts-list").setLimitCategory(node.attributes.id);
+ Ext.getCmp("parts-list").store.load();
+ Ext.getCmp("parts-list").show();
},
editCategory: function () {
var category = this.getSelectionModel().getSelectedNode().id;
diff --git a/frontend/js/de.RaumZeitLabor.PartDB2/PartsManager/PartsManagerWindow.js b/frontend/js/de.RaumZeitLabor.PartDB2/PartsManager/PartsManagerWindow.js
@@ -14,8 +14,8 @@ de.RaumZeitLabor.PartDB2.PartsManagerWindow = Ext.extend(org.jerrymouse.gui.widg
width: 250
});
- this.partsManagerDetails = new de.RaumZeitLabor.PartDB2.CategoryEditor();
-
+ this.categoryEditor = new de.RaumZeitLabor.PartDB2.CategoryEditor({ id: 'card-category-editor' });
+ this.partsList = new de.RaumZeitLabor.PartDB2.PartsManagerListGrid({ layout: 'fit', id: 'parts-list'});
Ext.apply(this.partsManagerDetails, {
region:'center',
@@ -34,14 +34,26 @@ de.RaumZeitLabor.PartDB2.PartsManagerWindow = Ext.extend(org.jerrymouse.gui.widg
},
items: [
this.partsManagerTree,
- this.partsManagerDetails]
+ {
+ layout: 'card',
+ region: 'center',
+ id: 'parts-mananger-window-card',
+ items: [
+ this.categoryEditor,
+ this.partsList
+ ]
+ }]
});
de.RaumZeitLabor.PartDB2.PartsManagerWindow.superclass.initComponent.call(this);
+ },
+ showPartsList: function () {
+ Ext.getCmp("parts-mananger-window-card").getLayout().setActiveItem("parts-list");
+ this.partsList.show();
}
});
de.RaumZeitLabor.PartDB2.PartsManagerWindow.handler = function () {
- var partsManager = new de.RaumZeitLabor.PartDB2.PartsManagerWindow();
+ var partsManager = new de.RaumZeitLabor.PartDB2.PartsManagerWindow({id: 'parts-manager-window'});
partsManager.show();
}
diff --git a/src/de/RaumZeitLabor/PartDB2/Category/CategoryManager.php b/src/de/RaumZeitLabor/PartDB2/Category/CategoryManager.php
@@ -23,6 +23,17 @@ class CategoryManager extends Singleton {
return $this->nodeManager;
}
+ public function getChildNodes ($id) {
+ $category = $this->getCategory($id);
+
+ $aData = array();
+
+ foreach ($category->getDescendants() as $cat) {
+ $aData[] = $cat->getNode()->getId();
+ }
+ return $aData;
+ }
+
public function getAllCategories () {
return $this->getNodeManager()->fetchTree(1);
}
diff --git a/src/de/RaumZeitLabor/PartDB2/Part/PartManager.php b/src/de/RaumZeitLabor/PartDB2/Part/PartManager.php
@@ -0,0 +1,80 @@
+<?php
+namespace de\raumzeitlabor\PartDB2\Part;
+declare(encoding = 'UTF-8');
+
+use de\RaumZeitLabor\PartDB2\Util\Singleton,
+ de\RaumZeitLabor\PartDB2\Footprint\Footprint,
+ de\RaumZeitLabor\PartDB2\PartDB2,
+ de\RaumZeitLabor\PartDB2\Category\CategoryManager,
+ de\RaumZeitLabor\PartDB2\Footprint\Exceptions\FootprintNotFoundException;
+
+class PartManager extends Singleton {
+ public function getParts ($aParameters = array()) {
+ $qb = PartDB2::getEM()->createQueryBuilder();
+ $qb->select("COUNT(p)")->from("de\RaumZeitLabor\PartDB2\Part\Part","p");
+
+ if (array_key_exists("limit", $aParameters)) {
+ $limit = intval($aParameters["limit"]);
+ } else {
+ $limit = 20;
+ }
+
+ if (array_key_exists("start", $aParameters)) {
+ $start = intval($aParameters["start"]);
+ } else {
+ $start = 0;
+ }
+
+ if (array_key_exists("dir", $aParameters)) {
+ $dir = $aParameters["dir"];
+
+ if (strtolower($dir) != "asc" && strtolower($dir) != "desc") {
+ $dir = "asc";
+ }
+ } else {
+ $dir = "asc";
+ }
+
+ if (array_key_exists("sortby", $aParameters)) {
+ $sortby = $aParameters["sortby"];
+
+ switch (strtolower($sortby)) {
+ case "name":
+ break;
+ default:
+ $sortby = "name";
+ }
+ } else {
+ $sortby = "name";
+ }
+
+ if (array_key_exists("category", $aParameters)) {
+ $category = intval($aParameters["category"]);
+ } else {
+ $category = 0;
+ }
+
+ $qb->where("1=1");
+
+ if ($category !== 0) {
+ /* Fetch all children */
+ $childs = CategoryManager::getInstance()->getChildNodes($category);
+ $childs[] = $category;
+ $qb->andWhere("p.category IN (".implode(",", $childs).")");
+ }
+
+ $countQuery = $qb->getQuery();
+ $count = $countQuery->getSingleScalarResult();
+
+ $qb->setMaxResults($limit);
+ $qb->setFirstResult($start);
+ $qb->select("p.name");
+ $qb->orderBy("p.".$sortby, $dir);
+
+ $query = $qb->getQuery();
+
+ $result = $query->getArrayResult();
+
+ return array("parts" => $result, "totalCount" => $count);
+ }
+}+
\ No newline at end of file
diff --git a/src/de/RaumZeitLabor/PartDB2/Part/PartManagerService.php b/src/de/RaumZeitLabor/PartDB2/Part/PartManagerService.php
@@ -0,0 +1,19 @@
+<?php
+namespace de\raumzeitlabor\PartDB2\Part;
+declare(encoding = 'UTF-8');
+
+use de\RaumZeitLabor\PartDB2\Service\Service;
+use de\RaumZeitLabor\PartDB2\Part\PartManager;
+
+class PartManagerService extends Service {
+ public function getParts () {
+ $aParameters = array(
+ "start" => $this->getParameter("start", 0),
+ "sortby" => $this->getParameter("sortby", "name"),
+ "dir" => $this->getParameter("dir", "asc"),
+ "filter" => $this->getParameter("filter", ""),
+ "category" => $this->getParameter("category", 0)
+ );
+ return PartManager::getInstance()->getParts($aParameters);
+ }
+}+
\ No newline at end of file