partkeepr

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

commit f5b7e73d63aa071ae54bfb0fce80c456d2363b63
parent d49637160a86e634277f883deb8fa1f67d9ca7d7
Author: Felicitus <privat@timohummel.com>
Date:   Wed, 25 May 2011 21:13:51 +0200

Added storage location manager, misc fixes in te footprint manager

Diffstat:
Mfrontend/index.html | 4++++
Afrontend/js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationListGrid.js | 165+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Afrontend/js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationManagerDetails.js | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Afrontend/js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationManagerWindow.js | 37+++++++++++++++++++++++++++++++++++++
Mfrontend/js/org.jerrymouse.components/Menubar.js | 3+++
Mfrontend/js/org.jerrymouse.util.locale/locales/en_US.js | 14+++++++++++++-
Msrc/de/RaumZeitLabor/PartDB2/Footprint/FootprintManager.php | 4----
Msrc/de/RaumZeitLabor/PartDB2/Footprint/FootprintManagerService.php | 2+-
Msrc/de/RaumZeitLabor/PartDB2/StorageLocation/StorageLocationManager.php | 55+++++++++++++++++++++++++++++++++++++++++++------------
Msrc/de/RaumZeitLabor/PartDB2/StorageLocation/StorageLocationService.php | 40++++++++++++++++++++++++++++++++++++++--
10 files changed, 369 insertions(+), 20 deletions(-)

diff --git a/frontend/index.html b/frontend/index.html @@ -52,6 +52,10 @@ <script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/FootPrintManager/FootPrintManagerDetails.js"></script> <script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/FootPrintManager/FootPrintManagerWindow.js"></script> + <script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationManagerWindow.js"></script> + <script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationListGrid.js"></script> + <script type="text/javascript" src="js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationManagerDetails.js"></script> + <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> diff --git a/frontend/js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationListGrid.js b/frontend/js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationListGrid.js @@ -0,0 +1,165 @@ +Ext.ns("de.RaumZeitLabor.PartDB2"); + +de.RaumZeitLabor.PartDB2.StorageLocationListGrid = Ext.extend(Ext.grid.GridPanel, { + + store: null, + initComponent: function () { + + var pageSize = 13; + + + var call = new org.jerrymouse.service.Call( + "de.RaumZeitLabor.PartDB2.StorageLocation.StorageLocationService", + "getStorageLocations"); + + call.setLoadMessage('$[de.RaumZeitLabor.PartDB2.StorageLocationManager.loading]'); + call.setParameter("limit", pageSize); + + this.store = new Ext.data.JsonStore({ + root: 'storageLocations', + totalProperty: 'totalCount', + proxy: new ServiceCallDataProxy(call), + idProperty: 'id', + remoteSort: true, + + fields: [ + 'id', + 'name' + ] + }); + + Ext.apply(this, { + containerScroll: true, + rootVisible: false, + lines: false, + store: this.store, + autoExpandColumn: 'name', + sm: new Ext.grid.RowSelectionModel({ + singleSelect: true, + listeners: { + "rowselect": this.onStorageLocationSelected.createDelegate(this), + "selectionchange": this.onStorageLocationSelectionChange.createDelegate(this) + } + + }), + viewConfig: { + forceFit: true + }, + + colModel: new Ext.grid.ColumnModel({ + defaults: { + width: 230, + sortable: true + }, + columns: [ + {header: '$[de.RaumZeitLabor.PartDB2.StorageLocationManager.name]', dataIndex: 'name', id: 'name'} + + ], + }), + + tbar: { + items: [ + { + tooltip: '$[de.RaumZeitLabor.PartDB2.StorageLocationManager.add]', + icon: 'resources/silkicons/add.png', + handler: this.addStorageLocation.createDelegate(this) + }, + { + tooltip: '$[de.RaumZeitLabor.PartDB2.StorageLocationManager.delete]', + icon: 'resources/silkicons/delete.png', + id: 'storagelocation-delete-button', + handler: this.deleteStorageLocation.createDelegate(this), + disabled: true + },{ + xtype: 'tbfill' + },{ + xtype: 'tbtext', + text: 'Filter:' + + },{ + xtype: 'org.jerrymouse.gui.widgets.searchField', + listeners: { + 'startSearch': function (text) { + this.store.proxy.call.setParameter("filter", text); + this.store.reload(); + }.createDelegate(this), + 'resetSearch': function (text) { + this.store.proxy.call.setParameter("filter", ''); + this.store.reload(); + }.createDelegate(this) + }, + id: 'filter' + }] + + }, + bbar: new Ext.PagingToolbar( + { + "pageSize": pageSize, + store: this.store, + displayInfo: false + }) + + }); + + this.loadStorageLocations(); + + de.RaumZeitLabor.PartDB2.StorageLocationListGrid.superclass.initComponent.call(this); + + }, + + onStorageLocationSelected: function (sm, rowIdx, record) { + Ext.getCmp("storagelocation-delete-button").enable(); + + Ext.getCmp("storagelocation-details").editStorageLocation(record.get("id")); + }, + onStorageLocationSelectionChange: function (sm) { + if (sm.getCount() == 0) { + Ext.getCmp("storagelocation-delete-button").disable(); + } + }, + loadStorageLocations: function () { + this.store.load(); + }, + deleteStorageLocation: function () { + var record = this.getSelectionModel().getSelected(); + + org.jerrymouse.gui.widgets.messagebox.confirm( + '$[de.RaumZeitLabor.PartDB2.StorageLocationManager.deleteStorageLocationDialogTitle]', + sprintf('$[de.RaumZeitLabor.PartDB2.StorageLocationManager.deleteStorageLocationDialogMessage]', record.get("name")), + function(btn, text){ + if (btn == 'yes'){ + var call = new org.jerrymouse.service.Call( + "de.RaumZeitLabor.PartDB2.StorageLocation.StorageLocationService", + "deleteStorageLocation"); + call.setParameter("id", record.get("id")); + call.setLoadMessage('$[de.RaumZeitLabor.PartDB2.StorageLocationManager.deleteStorageLocation]'); + call.setHandler(this.onStorageLocationDeleted.createDelegate(this)) + call.doCall(); + } + }.createDelegate(this)); + }, + addStorageLocation: function () { + org.jerrymouse.gui.widgets.messagebox.prompt( + '$[de.RaumZeitLabor.PartDB2.StorageLocationManager.addStorageLocationDialogTitle]', + '$[de.RaumZeitLabor.PartDB2.StorageLocationManager.addStorageLocationDialogMessage]', + function(btn, text){ + if (btn == 'ok'){ + var call = new org.jerrymouse.service.Call( + "de.RaumZeitLabor.PartDB2.StorageLocation.StorageLocationService", + "addStorageLocation"); + call.setParameter("name", text); + call.setLoadMessage('$[de.RaumZeitLabor.PartDB2.StorageLocationManager.addStorageLocation]'); + call.setHandler(this.onStorageLocationAdded.createDelegate(this)) + call.doCall(); + } + }.createDelegate(this)); + }, + + onStorageLocationAdded: function (result) { + this.loadStorageLocations(); + }, + onStorageLocationDeleted: function (result) { + Ext.getCmp("storagelocation-details").hide(); + this.loadStorageLocations(); + } +}); diff --git a/frontend/js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationManagerDetails.js b/frontend/js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationManagerDetails.js @@ -0,0 +1,64 @@ +Ext.ns("de.RaumZeitLabor.PartDB2.StorageLocationManagerDetails"); + +de.RaumZeitLabor.PartDB2.StorageLocationManagerDetails = Ext.extend(Ext.form.FormPanel, { + id: "storagelocation-details", + storageLocationId: null, + labelWidth: 150, + initComponent: function () { + + Ext.apply(this, { + cls: 'x-panel-mc', + bodyStyle:'padding:0px 5px 0', + items: [ + { fieldLabel: '$[de.RaumZeitLabor.PartDB2.StorageLocationManager.name]', + name: 'name', + xtype: 'textfield' + } + ], + hidden: true, + buttons: [{ + text: '$[de.RaumZeitLabor.PartDB2.save]', + handler: this.saveStorageLocation.createDelegate(this) + },{ + text: '$[de.RaumZeitLabor.PartDB2.cancel]', + handler: function () { + this.hide(); + }.createDelegate(this) + }] + }); + de.RaumZeitLabor.PartDB2.StorageLocationManagerDetails.superclass.initComponent.call(this); + }, + + setStorageLocation: function (id) { + this.storageLocationId = id; + }, + + editStorageLocation: function (id) { + this.setStorageLocation(id); + + var call = new org.jerrymouse.service.Call( + "de.RaumZeitLabor.PartDB2.StorageLocation.StorageLocationService", + "getStorageLocation"); + call.setParameter("id", this.storageLocationId); + call.setLoadMessage('$[de.RaumZeitLabor.PartDB2.StorageLocationManager.loadStorageLocation]'); + call.setHandler(this.onStorageLocationLoaded.createDelegate(this)) + call.doCall(); + }, + saveStorageLocation: function () { + var call = new org.jerrymouse.service.Call( + "de.RaumZeitLabor.PartDB2.StorageLocation.StorageLocationService", + "saveStorageLocation"); + call.setParameter("id", this.storageLocationId); + call.setParameters(this.getForm().getValues()); + call.setLoadMessage('$[de.RaumZeitLabor.PartDB2.StorageLocationManager.saveStorageLocation]'); + call.setHandler(this.onStorageLocationSaved.createDelegate(this)) + call.doCall(); + }, + onStorageLocationSaved: function (response) { + var record = Ext.getCmp("storagelocation-list").getStore().reload(); + }, + onStorageLocationLoaded: function (response) { + this.getForm().setValues(response); + this.show(); + } +});+ \ No newline at end of file diff --git a/frontend/js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationManagerWindow.js b/frontend/js/de.RaumZeitLabor.PartDB2/StorageLocationManager/StorageLocationManagerWindow.js @@ -0,0 +1,37 @@ +Ext.ns("de.RaumZeitLabor.PartDB2.StorageLocationManagerWindow"); + +de.RaumZeitLabor.PartDB2.StorageLocationManagerWindow = Ext.extend(org.jerrymouse.gui.widgets.window, { + title: "$[de.RaumZeitLabor.PartDB2.StorageLocationManager.manage]", + width: 600, + height: 400, + layout: 'border', + defaults: { + collapsible: false, + split: false + }, + initComponent: function () { + + this.storageLocationList = new de.RaumZeitLabor.PartDB2.StorageLocationListGrid({ + region: 'west', + id: 'storagelocation-list', + width: 250 + }); + + this.storageLocationDetails = new de.RaumZeitLabor.PartDB2.StorageLocationManagerDetails({ + region: 'center' + }); + + this.items = [ + this.storageLocationList, + this.storageLocationDetails + ]; + + de.RaumZeitLabor.PartDB2.StorageLocationManagerWindow.superclass.initComponent.call(this); + } +}); + +de.RaumZeitLabor.PartDB2.StorageLocationManagerWindow.handler = function () { + var storageLocationManager = new de.RaumZeitLabor.PartDB2.StorageLocationManagerWindow(); + storageLocationManager.show(); +} + diff --git a/frontend/js/org.jerrymouse.components/Menubar.js b/frontend/js/org.jerrymouse.components/Menubar.js @@ -48,6 +48,9 @@ org.jerrymouse.components.Menubar = Ext.extend(Ext.Toolbar, { text: "$[de.RaumZeitLabor.PartDB2.FootPrintManager.manage]", handler: de.RaumZeitLabor.PartDB2.FootPrintManagerWindow.handler },{ + text: "$[de.RaumZeitLabor.PartDB2.StorageLocationManager.manage]", + handler: de.RaumZeitLabor.PartDB2.StorageLocationManagerWindow.handler + },{ text: "$[de.RaumZeitLabor.PartDB2.PartsManager.manage]", handler: de.RaumZeitLabor.PartDB2.PartsManagerWindow.handler } diff --git a/frontend/js/org.jerrymouse.util.locale/locales/en_US.js b/frontend/js/org.jerrymouse.util.locale/locales/en_US.js @@ -53,7 +53,19 @@ locales.en_US = { "de.RaumZeitLabor.PartDB2.CategoryEditor.categoryDescription": "Description", "de.RaumZeitLabor.PartDB2.CategoryEditor.parentCategory": "Parent Category", "de.RaumZeitLabor.PartDB2.CategoryEditor.loadCategor": "Loading Category...", - "de.RaumZeitLabor.PartDB2.CategoryEditor.saveCategory": "Saving Category..." + "de.RaumZeitLabor.PartDB2.CategoryEditor.saveCategory": "Saving Category...", + /* Storage Locations */ + "de.RaumZeitLabor.PartDB2.StorageLocationManager.manage": "Manage Storage Locations", + "de.RaumZeitLabor.PartDB2.StorageLocationManager.name": "Storage Location Name", + "de.RaumZeitLabor.PartDB2.StorageLocationManager.add": "Add Storage Location", + "de.RaumZeitLabor.PartDB2.StorageLocationManager.delete": "Delete Storage Location", + "de.RaumZeitLabor.PartDB2.StorageLocationManager.deleteStorageLocationDialogTitle": "Delete Storage Location", + "de.RaumZeitLabor.PartDB2.StorageLocationManager.deleteStorageLocationDialogMessage": "Do you really wish to delete the selected storage location?", + "de.RaumZeitLabor.PartDB2.StorageLocationManager.addStorageLocationDialogTitle": "Add a new storage location", + "de.RaumZeitLabor.PartDB2.StorageLocationManager.addStorageLocationDialogMessage": "Enter the name of the new storage location:", + "de.RaumZeitLabor.PartDB2.StorageLocationManager.name": "Name", + /* Parts */ + "de.RaumZeitLabor.PartDB2.PartsManager.manage": "Manage Parts" }; diff --git a/src/de/RaumZeitLabor/PartDB2/Footprint/FootprintManager.php b/src/de/RaumZeitLabor/PartDB2/Footprint/FootprintManager.php @@ -62,10 +62,6 @@ class FootprintManager extends Singleton { } } - public function saveFootprint (Footprint $footprint) { - PartDB2::getEM()->persist($footprint); - } - public function getFootprint ($id) { $footprint = PartDB2::getEM()->find("de\RaumZeitLabor\PartDB2\Footprint\Footprint", $id); diff --git a/src/de/RaumZeitLabor/PartDB2/Footprint/FootprintManagerService.php b/src/de/RaumZeitLabor/PartDB2/Footprint/FootprintManagerService.php @@ -41,7 +41,7 @@ class FootprintManagerService extends Service { $footprint->setFootprint($this->getParameter("footprint")); - FootprintManager::getInstance()->saveFootprint($footprint); + PartDB2::getEM()->flush(); return $footprint->serialize(); } diff --git a/src/de/RaumZeitLabor/PartDB2/StorageLocation/StorageLocationManager.php b/src/de/RaumZeitLabor/PartDB2/StorageLocation/StorageLocationManager.php @@ -3,28 +3,46 @@ namespace de\RaumZeitLabor\PartDB2\StorageLocation; declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartDB2\Util\Singleton, - de\RaumZeitLabor\PartDB2\Footprint\Footprint, + de\RaumZeitLabor\PartDB2\StorageLocation\StorageLocation, de\RaumZeitLabor\PartDB2\PartDB2, de\RaumZeitLabor\PartDB2\Category\CategoryManager, - de\RaumZeitLabor\PartDB2\Footprint\Exceptions\FootprintNotFoundException; + de\RaumZeitLabor\PartDB2\StorageLocation\Exceptions\StorageLocationNotFoundException; class StorageLocationManager extends Singleton { - public function getStorageLocations () { + public function getStorageLocations ($start = 0, $limit = 10, $sort = "footprint", $dir = "asc", $filter = "") { + $qb = PartDB2::getEM()->createQueryBuilder(); - $qb->select("COUNT(st)")->from("de\RaumZeitLabor\PartDB2\StorageLocation\StorageLocation","st"); + $qb->select("st.id, st.name")->from("de\RaumZeitLabor\PartDB2\StorageLocation\StorageLocation","st"); + + if ($filter != "") { + $qb = $qb->where("st.name LIKE :filter"); + $qb->setParameter("filter", "%".$filter."%"); + } + + if ($limit > -1) { + $qb->setMaxResults($limit); + $qb->setFirstResult($start); + } - $countQuery = $qb->getQuery(); - $count = $countQuery->getSingleScalarResult(); + $qb->orderBy("st.".$sort, $dir); - $qb->select("st.name, st.id"); + $query = $qb->getQuery(); + + $result = $query->getResult(); + + $totalQueryBuilder = PartDB2::getEM()->createQueryBuilder(); + $totalQueryBuilder->select("COUNT(st.id)")->from("de\RaumZeitLabor\PartDB2\StorageLocation\StorageLocation","st"); - $qb->orderBy("st.name", "asc"); - $query = $qb->getQuery(); - $result = $query->getArrayResult(); + if ($filter != "") { + $totalQueryBuilder = $totalQueryBuilder->where("st.name LIKE :filter"); + $totalQueryBuilder->setParameter("filter", "%".$filter."%"); + } + + $totalQuery = $totalQueryBuilder->getQuery(); - return array("storageLocations" => $result, "totalCount" => $count); + return array("storageLocations" => $result, "totalCount" => $totalQuery->getSingleScalarResult()); } public function getStorageLocation ($id) { @@ -33,7 +51,20 @@ class StorageLocationManager extends Singleton { if ($storageLocation) { return $storageLocation; } else { - throw new \Exception("StorageLocation not found"); + throw new StorageLocationNotFoundException(); } } + + public function addStorageLocation ($name) { + $storageLocation = new StorageLocation(); + $storageLocation->setName($name); + + PartDB2::getEM()->persist($storageLocation); + } + public function deleteStorageLocation ($id) { + $storageLocation = $this->getStorageLocation($id); + + PartDB2::getEM()->remove($storageLocation); + PartDB2::getEM()->flush(); + } } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartDB2/StorageLocation/StorageLocationService.php b/src/de/RaumZeitLabor/PartDB2/StorageLocation/StorageLocationService.php @@ -9,7 +9,43 @@ use de\RaumZeitLabor\PartDB2\Part\PartManager, de\RaumZeitLabor\PartDB2\Session\SessionManager; class StorageLocationService extends Service { - public function getStorageLocations () { - return StorageLocationManager::getInstance()->getStorageLocations(); + public function getStorageLocations() { + return StorageLocationManager::getInstance()->getStorageLocations( + $this->getParameter("start", 0), + $this->getParameter("limit", 10), + $this->getParameter("sortby", "name"), + $this->getParameter("dir", "asc"), + $this->getParameter("filter", "")); + } + + public function addStorageLocation () { + $this->requireParameter("name"); + + StorageLocationManager::getInstance()->addStorageLocation($this->getParameter("name")); + } + + public function deleteStorageLocation () { + $this->requireParameter("id"); + + StorageLocationManager::getInstance()->deleteStorageLocation($this->getParameter("id")); + } + + public function getStorageLocation () { + $this->requireParameter("id"); + + return StorageLocationManager::getInstance()->getStorageLocation($this->getParameter("id"))->serialize(); + } + + public function saveStorageLocation () { + $this->requireParameter("id"); + $this->requireParameter("name"); + + $storageLocation = StorageLocationManager::getInstance()->getStorageLocation($this->getParameter("id")); + + $storageLocation->setName($this->getParameter("name")); + + PartDB2::getEM()->flush(); + + return $storageLocation->serialize(); } } \ No newline at end of file