diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartDisplay.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartDisplay.js index 9496a8564..beb2b02a5 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartDisplay.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartDisplay.js @@ -9,7 +9,7 @@ Ext.define('PartKeepr.PartDisplay', { overflowY: 'auto', fieldConfigs: { - categoryName: { + "category.name": { displayName: i18n("Category Name") }, stockLevel: { @@ -18,10 +18,10 @@ Ext.define('PartKeepr.PartDisplay', { minStockLevel: { displayName: i18n("Minimum Stock Level") }, - footprintName: { + "footprint.name": { displayName: i18n("Footprint") }, - storageLocationName: { + "storageLocation.name": { displayName: i18n("Storage Location") }, comment: { @@ -30,12 +30,6 @@ Ext.define('PartKeepr.PartDisplay', { createDate: { displayName: i18n("Create Date"), type: 'date', - renderer: function (v) - { - "use strict"; - var format = Ext.getDateFormat(); - return Ext.Date.format(v, format); - } }, status: { displayName: i18n("Status") @@ -47,11 +41,18 @@ Ext.define('PartKeepr.PartDisplay', { displayName: i18n("Needs Review"), type: 'boolean' }, - projects: { - displayName: i18n("Projects") + projectNames: { + displayName: i18n("Used in Projects") + }, + "@id": { + displayName: i18n("Internal ID"), + renderer: function (value) + { + var values = value.split("/"); + return values[values.length - 1]; + } } - } - , + }, /** * Initializes the component and adds a template as well as the add/remove stock and edit part buttons. @@ -167,17 +168,20 @@ Ext.define('PartKeepr.PartDisplay', { { this.record = r; - var values = {}; + var values = {}, value; var recordData = this.record.getData(); - for (var i in recordData) { - if (this.fieldConfigs[i]) { - if (typeof recordData[i] === "string") { - values[i] = htmlentities(recordData[i]); // phpjs + for (var i in this.fieldConfigs) { + value = this.record.get(i); + if (value !== undefined) { + if (typeof(value === "string")) { + values[i] = htmlentities(value); // phpjs } else { - values[i] = recordData[i]; + values[i] = value; } + } else { + values[i] = i18n("none"); } } diff --git a/src/PartKeepr/PartBundle/Entity/Part.php b/src/PartKeepr/PartBundle/Entity/Part.php index 5db7fd70e..0e884cee5 100644 --- a/src/PartKeepr/PartBundle/Entity/Part.php +++ b/src/PartKeepr/PartBundle/Entity/Part.php @@ -3,6 +3,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; +use PartKeepr\CoreBundle\Entity\BaseEntity; use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; use PartKeepr\FootprintBundle\Entity\Footprint; use PartKeepr\PartBundle\Exceptions\CategoryNotAssignedException; @@ -12,7 +13,6 @@ use PartKeepr\StockBundle\Entity\StockEntry; use PartKeepr\StorageLocationBundle\Entity\StorageLocation; use PartKeepr\UploadedFileBundle\Annotation\UploadedFileCollection; -use PartKeepr\CoreBundle\Entity\BaseEntity; use Symfony\Component\Serializer\Annotation\Groups; /** @@ -638,6 +638,7 @@ public function setMinStockLevel($minStockLevel) /** * Sets the average price for this part + * * @param float $price The price to set */ public function setAveragePrice($price) @@ -650,7 +651,8 @@ public function setAveragePrice($price) * * @return float */ - public function getAveragePrice () { + public function getAveragePrice() + { return $this->averagePrice; } @@ -789,6 +791,22 @@ public function getProjectParts() return $this->projectParts; } + /** + * Returns the project names this part is used in + * @Groups({"default"}) + * + * @return array + */ + public function getProjectNames() + { + $projectNames = []; + foreach ($this->projectParts as $projectPart) { + $projectNames[] = $projectPart->getProject()->getName(); + } + + return array_unique($projectNames); + } + public function recomputeStockLevels() { $sum = 0; @@ -809,7 +827,7 @@ public function recomputeStockLevels() } else { $this->setAveragePrice(0); } - + $this->setStockLevel($sum); if ($sum < $this->getMinStockLevel()) {