commit e7cf9cf0c20a4d928a2fd5a59bd36992aa8cecf0
parent 7b5d88b590ca43a09bafb1e7b9368fde90428ee9
Author: Felicitus <felicitus@felicitus.org>
Date: Mon, 18 Jul 2011 21:38:22 +0200
Added "category sync" button
Diffstat:
3 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/frontend/js/Components/Part/PartCategoryTree.js b/frontend/js/Components/Part/PartCategoryTree.js
@@ -5,6 +5,21 @@ Ext.define("PartKeepr.PartCategoryTree", {
ddGroup: 'PartTree',
categoryModel: 'PartKeepr.PartCategory',
categoryService: 'PartCategory',
+ initComponent: function () {
+ this.addEvents("syncCategory");
+ this.callParent();
+
+ this.syncButton = Ext.create("Ext.button.Button", {
+ tooltip: i18n("Sync Category"),
+ icon: 'resources/fugue-icons/icons/arrow-split-180.png',
+ handler: Ext.bind(function () {
+ this.fireEvent("syncCategory");
+ }, this),
+ disabled: true
+ });
+ this.toolbar.add(['->', this.syncButton]);
+ },
+
onBeforeDrop: function (node, data, overModel, dropPosition, dropFunction, options) {
var draggedRecord = data.records[0];
var droppedOn = this.getView().getRecord(node);
diff --git a/frontend/js/Components/Part/PartsManager.js b/frontend/js/Components/Part/PartsManager.js
@@ -56,6 +56,7 @@ Ext.define('PartKeepr.PartManager', {
this.grid.on("itemDeselect", this.onItemSelect, this);
this.grid.on("itemAdd", this.onItemAdd, this);
this.grid.on("itemDelete", this.onItemDelete, this);
+ this.tree.on("syncCategory", this.onSyncCategory, this);
// Listen on the partChanged event, which is fired when the users edits the part
this.detail.on("partChanged", function () { this.grid.getStore().load(); }, this);
@@ -92,7 +93,24 @@ Ext.define('PartKeepr.PartManager', {
this.callParent();
},
-
+ /**
+ * Called when the sync button was clicked. Highlights the category
+ * of the selected part for a short time. We can't select the category
+ * as this would affect the parts grid.
+ */
+ onSyncCategory: function () {
+ var r = this.grid.getSelectionModel().getLastSelected();
+
+ var rootNode = this.tree.getRootNode();
+ var cat = r.get("category");
+
+ var node = rootNode.findChild("id", cat, true);
+
+ this.tree.getView().ensureVisible(node);
+ var htmlNode = new Ext.Element(this.tree.getView().getNode(node));
+
+ htmlNode.highlight("FF0000");
+ },
/**
* Called when the delete button was clicked.
*
@@ -181,13 +199,18 @@ Ext.define('PartKeepr.PartManager', {
onItemSelect: function () {
if (this.grid.getSelectionModel().getCount() > 1) {
this.detailPanel.hide();
- } else {
+ this.tree.syncButton.disable();
+ } else if (this.grid.getSelectionModel().getCount() == 1) {
var r = this.grid.getSelectionModel().getLastSelected();
this.detailPanel.setActiveTab(this.detail);
this.detailPanel.show();
this.detail.setValues(r);
- this.stockLevel.part = r.get("id");
+ this.stockLevel.part = r.get("id");
+
+ this.tree.syncButton.enable();
+ } else {
+ this.tree.syncButton.disable();
}
},
diff --git a/src/de/RaumZeitLabor/PartKeepr/Part/PartManager.php b/src/de/RaumZeitLabor/PartKeepr/Part/PartManager.php
@@ -96,7 +96,7 @@ class PartManager extends Singleton {
- $qb->select("p.averagePrice, p.status, 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->select("p.averagePrice, p.status, 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, c.name AS categoryName, pu.id AS partUnit, pu.name AS partUnitName, pu.is_default AS partUnitDefault");
if ($sort === null) {
$qb->addOrderBy("p.name", "ASC");
} else {