commit b40125fa8a2b877707b8e9f242e6d1e42a9fadff
parent 5df586b0f19c9e22bf521938536af58ca8942b77
Author: Felicitus <felicitus@felicitus.org>
Date: Wed, 11 Jul 2012 15:44:28 +0200
Added filtering against manufacturer+distributor in the part filter panel, fixes #189
Diffstat:
2 files changed, 138 insertions(+), 10 deletions(-)
diff --git a/src/backend/PartKeepr/Part/PartService.php b/src/backend/PartKeepr/Part/PartService.php
@@ -47,10 +47,26 @@ class PartService extends Service implements RestfulService {
* Applies filtering by the storage location name
*/
if ($this->getParameter("storageLocation") !== null) {
- $queryBuilder->andWhere("st.name = :storageLocation");
+ $queryBuilder->andWhere("st.id = :storageLocation");
$queryBuilder->setParameter("storageLocation", $this->getParameter("storageLocation"));
}
+ // We need that join multiple times. Not exactly nice, as this should get pulled in only when needed.
+ // @todo Refactor so that this join only gets inside when needed
+ $queryBuilder->leftJoin("q.distributors", "di");
+
+ if ($this->getParameter("distributor") !== null) {
+ $queryBuilder->leftJoin("di.distributor", "did");
+ $queryBuilder->andWhere("did.id = :distributor");
+ $queryBuilder->setParameter("distributor", $this->getParameter("distributor"));
+ }
+
+ if ($this->getParameter("manufacturer") !== null) {
+ $queryBuilder->leftJoin("q.manufacturers", "ma");
+ $queryBuilder->leftJoin("ma.manufacturer", "mam");
+ $queryBuilder->andWhere("mam.id = :manufacturer");
+ $queryBuilder->setParameter("manufacturer", $this->getParameter("manufacturer"));
+ }
/**
* Filter by the category id and set the category mode
*
@@ -90,7 +106,6 @@ class PartService extends Service implements RestfulService {
* Query by the distributor's order number
*/
if ($this->getParameter("distributorOrderNumber")) {
- $queryBuilder->leftJoin("q.distributors", "di");
$queryBuilder->andWhere("LOWER(di.orderNumber) LIKE :orderNumber");
$queryBuilder->setParameter("orderNumber", "%".strtolower($this->getParameter("distributorOrderNumber"))."%");
}
diff --git a/src/frontend/js/Components/Part/PartFilterPanel.js b/src/frontend/js/Components/Part/PartFilterPanel.js
@@ -44,7 +44,7 @@ Ext.define('PartKeepr.PartFilterPanel', {
style: 'margin-right: 10px',
columnWidth: 0.5,
items: [
- this.storageLocationFilter,
+ this.storageLocationContainer,
this.categoryFilter,
this.partsWithoutPrice,
this.createDateFilter,
@@ -61,7 +61,9 @@ Ext.define('PartKeepr.PartFilterPanel', {
layout: 'anchor',
items: [
this.stockFilter,
- this.distributorOrderNumberFilter
+ this.distributorOrderNumberFilter,
+ this.distributorFilter,
+ this.manufacturerFilter
]
};
@@ -117,6 +119,8 @@ Ext.define('PartKeepr.PartFilterPanel', {
*/
onReset: function () {
this.storageLocationFilter.setValue("");
+ this.storageLocationFilterCheckbox.setValue(false);
+
this.categoryFilter.setValue({ category: 'all'});
this.stockFilter.setValue({ stock: 'any'});
this.distributorOrderNumberFilter.setValue("");
@@ -126,6 +130,11 @@ Ext.define('PartKeepr.PartFilterPanel', {
this.partsWithoutStockRemovals.setValue(false);
this.partsWithoutPrice.setValue(false);
+ this.distributorFilterCombo.setValue("");
+ this.distributorFilterCheckbox.setValue(false);
+ this.manufacturerFilterCombo.setValue("");
+ this.manufacturerFilterCheckbox.setValue(false);
+
this.onApply();
},
/**
@@ -135,10 +144,35 @@ Ext.define('PartKeepr.PartFilterPanel', {
// Create the storage location filter field
this.storageLocationFilter = Ext.create("PartKeepr.StorageLocationComboBox", {
- fieldLabel: i18n("Storage Location"),
- minWidth: 300,
+ flex: 1,
+ forceSelection: true,
+ listeners: {
+ select: function () {
+ this.storageLocationFilterCheckbox.setValue(true);
+ },
+ scope: this
+ }
+ });
+
+ this.storageLocationFilterCheckbox = Ext.create("Ext.form.field.Checkbox", {
+ style: 'margin-right: 5px',
+ listeners: {
+ change: function (obj, value) {
+
+ if (!value) {
+ this.storageLocationFilter.setValue("");
+ }
+ },
+ scope: this
+ }
+ });
+
+ this.storageLocationContainer = Ext.create("Ext.form.FieldContainer", {
+ layout: 'hbox',
+ items: [ this.storageLocationFilterCheckbox, this.storageLocationFilter ],
anchor: '100%',
- forceSelection: true
+ minWidth: 300,
+ fieldLabel: i18n("Storage Location")
});
// Create the category scope field
@@ -188,7 +222,8 @@ Ext.define('PartKeepr.PartFilterPanel', {
});
this.distributorOrderNumberFilter = Ext.create("Ext.form.field.Text", {
- fieldLabel: i18n("Order Number")
+ fieldLabel: i18n("Order Number"),
+ anchor: '100%'
});
this.createDateField = Ext.create("Ext.form.field.Date", {
@@ -231,6 +266,65 @@ Ext.define('PartKeepr.PartFilterPanel', {
boxLabel: i18n("Show Parts without stock removals only")
});
+ this.manufacturerFilterCheckbox = Ext.create("Ext.form.field.Checkbox", {
+ style: 'margin-right: 5px',
+ listeners: {
+ change: function (obj, value) {
+
+ if (!value) {
+ this.manufacturerFilterCombo.setValue("");
+ }
+ },
+ scope: this
+ }
+ });
+
+ this.manufacturerFilterCombo = Ext.create("PartKeepr.ManufacturerComboBox", {
+ flex: 1,
+ listeners: {
+ select: function () {
+ this.manufacturerFilterCheckbox.setValue(true);
+ },
+ scope: this
+ }
+ });
+
+ this.manufacturerFilter = Ext.create("Ext.form.FieldContainer", {
+ layout: 'hbox',
+ items: [ this.manufacturerFilterCheckbox, this.manufacturerFilterCombo ],
+ fieldLabel: i18n("Manufacturer")
+ });
+
+ this.distributorFilterCheckbox = Ext.create("Ext.form.field.Checkbox", {
+ style: 'margin-right: 5px',
+ listeners: {
+ change: function (obj, value) {
+ if (!value) {
+ this.distributorFilterCombo.setValue("");
+ }
+ },
+ scope: this
+ }
+ });
+
+ this.distributorFilterCombo = Ext.create("PartKeepr.DistributorComboBox",{
+ flex: 1,
+ listeners: {
+ select: function () {
+ this.distributorFilterCheckbox.setValue(true);
+ },
+ scope: this
+ }
+ });
+
+ this.distributorFilter = Ext.create("Ext.form.FieldContainer", {
+ layout: 'hbox',
+ items: [ this.distributorFilterCheckbox, this.distributorFilterCombo ],
+ fieldLabel: i18n("Distributor")
+ });
+
+
+
},
/**
* Applies the filter parameters to the passed extraParams object.
@@ -246,13 +340,32 @@ Ext.define('PartKeepr.PartFilterPanel', {
* distinct than entered values.
*/
if (this.storageLocationFilter.getRawValue() !== "") {
- extraParams.storageLocation = this.storageLocationFilter.getRawValue();
+ extraParams.storageLocation = this.storageLocationFilter.getValue();
} else {
delete extraParams.storageLocation;
}
+ if (this.manufacturerFilterCombo.getRawValue() !== "") {
+ extraParams.manufacturer = this.manufacturerFilterCombo.getValue();
+ } else {
+ delete extraParams.manufacturer;
+ }
+
+ if (this.distributorFilterCombo.getRawValue() !== "") {
+ extraParams.distributor = this.distributorFilterCombo.getValue();
+ } else {
+ delete extraParams.distributor;
+ }
+
extraParams.createDateRestriction = this.createDateFilterSelect.getValue();
- extraParams.createDate = Ext.util.Format.date(this.createDateField.getValue(), "Y-m-d H:i:s");
+ var createDate = Ext.util.Format.date(this.createDateField.getValue(), "Y-m-d H:i:s");
+
+ if (createDate !== "") {
+ extraParams.createDate = createDate;
+ } else {
+ delete extraParams.createDate;
+ }
+
extraParams.withoutStockRemovals = this.partsWithoutStockRemovals.getValue();
}