commit 99b0ac9e3b08a0f6f4513482a391c29256e420bf
parent 3abe11978f2099b0b105bace6f62391950568db5
Author: Felicitus <felicitus@felicitus.org>
Date: Mon, 27 Jun 2011 17:18:16 +0200
Added status field for the parts (status could be "new", "used").
Diffstat:
3 files changed, 54 insertions(+), 20 deletions(-)
diff --git a/frontend/js/Components/Part/Editor/PartEditor.js b/frontend/js/Components/Part/Editor/PartEditor.js
@@ -44,6 +44,10 @@ Ext.define('PartKeepr.PartEditor', {
xtype: 'textarea',
fieldLabel: i18n("Comment"),
name: 'comment'
+ },{
+ xtype: 'textfield',
+ fieldLabel: i18n("Status"),
+ name: 'status'
}];
this.partDistributorGrid = Ext.create("PartKeepr.PartDistributorGrid", {
diff --git a/frontend/js/Models/Part.js b/frontend/js/Models/Part.js
@@ -1,21 +1,23 @@
Ext.define("PartKeepr.Part", {
extend: "Ext.data.Model",
fields: [
- { id: 'id', name: 'id', type: 'int' },
- { name: 'category', type: 'int'},
- { name: 'footprint', type: 'int'},
- { name: 'storageLocation',type: 'int'},
- { name: 'partUnit',type: 'int'},
- { name: 'averagePrice',type: 'float'},
- { name: 'name',type: 'string'},
- { name: 'comment',type: 'string'},
- { name: 'stockLevel',type: 'int'},
- { name: 'minStockLevel',type: 'int'},
+ { id: 'id', name: 'id', type: 'int' },
+ { name: 'category', type: 'int'},
+ { name: 'footprint', type: 'int'},
+ { name: 'storageLocation', type: 'int'},
+ { name: 'partUnit', type: 'int'},
+ { name: 'averagePrice', type: 'float'},
+ { name: 'name', type: 'string'},
+ { name: 'comment', type: 'string'},
+ { name: 'status', type: 'string'},
+ { name: 'stockLevel', type: 'int'},
+ { name: 'minStockLevel', type: 'int'},
- { name: 'partUnitName',type: 'string'},
- { name: 'footprintName', type: 'string'},
+ // Various things that don't belong to the part, but are transmitted anyways to make handling easier
+ { name: 'partUnitName', type: 'string'},
+ { name: 'footprintName', type: 'string'},
{ name: 'storageLocationName',type: 'string'},
- { name: 'categoryName', type: 'string'},
+ { name: 'categoryName', type: 'string'},
{
name: 'partUnitDefault',
type: 'boolean',
@@ -28,15 +30,15 @@ Ext.define("PartKeepr.Part", {
],
belongsTo: [
- { model: 'PartKeepr.StorageLocation', primaryKey: 'id', foreignKey: 'storageLocation'},
- { model: 'PartKeepr.Footprint', primaryKey: 'id', foreignKey: 'footprint'},
- { model: 'PartKeepr.PartCategory', primaryKey: 'id', foreignKey: 'category'}
+ { model: 'PartKeepr.StorageLocation', primaryKey: 'id', foreignKey: 'storageLocation'},
+ { model: 'PartKeepr.Footprint', primaryKey: 'id', foreignKey: 'footprint'},
+ { model: 'PartKeepr.PartCategory', primaryKey: 'id', foreignKey: 'category'}
],
hasMany: [
- { model: 'PartKeepr.PartDistributor', name: 'distributors'},
- { model: 'PartKeepr.PartManufacturer', name: 'manufacturers'},
- { model: 'PartKeepr.PartParameter', name: 'parameters'},
- { model: 'PartKeepr.PartAttachment', name: 'attachments'},
+ { model: 'PartKeepr.PartDistributor', name: 'distributors'},
+ { model: 'PartKeepr.PartManufacturer', name: 'manufacturers'},
+ { model: 'PartKeepr.PartParameter', name: 'parameters'},
+ { model: 'PartKeepr.PartAttachment', name: 'attachments'},
],
proxy: PartKeepr.getRESTProxy("Part"),
getRecordName: function () {
diff --git a/src/de/RaumZeitLabor/PartKeepr/Part/Part.php b/src/de/RaumZeitLabor/PartKeepr/Part/Part.php
@@ -131,6 +131,13 @@ class Part extends BaseEntity implements Serializable, Deserializable {
*/
private $parameters;
+ /**
+ * The part status for this part
+ * @Column(type="string",nullable=true)
+ * @var string
+ */
+ private $status;
+
public function __construct () {
$this->distributors = new \Doctrine\Common\Collections\ArrayCollection();
$this->manufacturers = new \Doctrine\Common\Collections\ArrayCollection();
@@ -303,6 +310,23 @@ class Part extends BaseEntity implements Serializable, Deserializable {
}
/**
+ * Sets the status for this part. A status is any string describing the status,
+ * e.g. "new", "used", "broken" etc.
+ * @param string $status The status
+ */
+ public function setStatus ($status) {
+ $this->status = $status;
+ }
+
+ /**
+ * Returns the status for this part.
+ * @return string The status
+ */
+ public function getStatus () {
+ return $this->status;
+ }
+
+ /**
* (non-PHPdoc)
* @see de\RaumZeitLabor\PartKeepr\Util.Serializable::serialize()
*/
@@ -314,6 +338,7 @@ class Part extends BaseEntity implements Serializable, Deserializable {
"stockLevel" => $this->getStockLevel(),
"footprint" => is_object($this->footprint) ? $this->footprint->getId() : null,
"minStockLevel" => $this->minStockLevel,
+ "status" => $this->getStatus(),
"storageLocation" => is_object($this->storageLocation) ? $this->storageLocation->getId() : null,
"category" => is_object($this->category) ? $this->category->getId() : null,
"partUnit" => is_object($this->partUnit) ? $this->getPartUnit()->getId() : null,
@@ -358,6 +383,9 @@ class Part extends BaseEntity implements Serializable, Deserializable {
$category = PartCategory::loadById($value);
$this->setCategory($category);
break;
+ case "status":
+ $this->setStatus($value);
+ break;
case "storageLocation":
$storageLocation = StorageLocation::loadById($value);
$this->setStorageLocation($storageLocation);