partkeepr

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

commit bceda5c2ce719702186da8f6c4f1d6f9b3b36a37
parent 28c5bcf15ed5f860154dea271ba9f8447e45d1b1
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed, 23 Dec 2015 15:28:36 +0100

Don't access the initialStockLevel getValue() method if it wasn't defined

Diffstat:
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/Editor/PartEditor.js | 30++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/Editor/PartEditor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/Editor/PartEditor.js @@ -175,9 +175,10 @@ Ext.define('PartKeepr.PartEditor', { xtype: 'displayfield', fieldLabel: i18n("Internal ID"), name: '@id', - renderer: function (value) { + renderer: function (value) + { var values = value.split("/"); - return values[values.length-1]; + return values[values.length - 1]; } } ] @@ -358,22 +359,23 @@ Ext.define('PartKeepr.PartEditor', { this.record.setFootprint(null); } - var initialStockLevel = this.initialStockLevel.getValue(); + if (this.initialStockLevel) { + var initialStockLevel = this.initialStockLevel.getValue(); - if (this.record.phantom && initialStockLevel > 0) { - var stockLevel = Ext.create("PartKeepr.StockBundle.Entity.StockEntry"); - stockLevel.set("stockLevel", initialStockLevel); - stockLevel.setUser(this.initialStockLevelUser.getValue()); + if (this.record.phantom && initialStockLevel > 0) { + var stockLevel = Ext.create("PartKeepr.StockBundle.Entity.StockEntry"); + stockLevel.set("stockLevel", initialStockLevel); + stockLevel.setUser(this.initialStockLevelUser.getValue()); - if (this.initialStockLevelPricePerItem.getValue() === true) { - stockLevel.set("price", this.initialStockLevelPrice.getValue() / initialStockLevel); - } else { - stockLevel.set("price", this.initialStockLevelPrice.getValue()); - } + if (this.initialStockLevelPricePerItem.getValue() === true) { + stockLevel.set("price", this.initialStockLevelPrice.getValue() / initialStockLevel); + } else { + stockLevel.set("price", this.initialStockLevelPrice.getValue()); + } - this.record.stockLevels().add(stockLevel); + this.record.stockLevels().add(stockLevel); + } } - }, onEditStart: function () {