partkeepr

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

commit 92094d62563ecffb82de279583ed91a56bd0f230
parent 93aaaf8af9cddfb3770b302b2020a548d408cc02
Author: Felicitus <felicitus@felicitus.org>
Date:   Thu,  5 Nov 2015 17:41:50 +0100

Use better defaults for creating a blank item after save, fixes #472

Diffstat:
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/Editor/PartEditor.js | 16+++++-----------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsManager.js | 14+++++++-------
2 files changed, 12 insertions(+), 18 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 @@ -114,11 +114,10 @@ Ext.define('PartKeepr.PartEditor', { minValue: 0 }, { xtype: 'PartUnitComboBox', - fieldLabel: i18n("Part Measurement Unit"), + fieldLabel: i18n("Measurement Unit"), columnWidth: 0.5, returnObject: true, - name: 'partUnit', - value: PartKeepr.getApplication().getDefaultPartUnit() + name: 'partUnit' } ] }, { @@ -397,31 +396,26 @@ Ext.define('PartKeepr.PartEditor', { if (this.partMode == "create") { if (this.copyPartDataCheckbox.getValue() === true) { var data = this.record.getData(); - console.log(data); + delete data["@id"]; var newItem = Ext.create("PartKeepr.PartBundle.Entity.Part"); newItem.set(data); newItem.setAssociationData(this.record.getAssociationData()); this.editItem(newItem); } else { - newItem = Ext.create("PartKeepr.PartBundle.Entity.Part", this.partDefaults); + newItem = Ext.create("PartKeepr.PartBundle.Entity.Part"); + newItem.setPartUnit(PartKeepr.getApplication().getDefaultPartUnit()); this.editItem(newItem); } } else { var data = this.record.getData(); delete data["@id"]; - console.log(data); var newItem = Ext.create("PartKeepr.PartBundle.Entity.Part"); newItem.set(data); newItem.setAssociationData(this.record.getAssociationData()); - - console.log(newItem); - newItem.foobar = 123; this.editItem(newItem); } - - } }, bindChildStores: function () diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsManager.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartsManager.js @@ -335,17 +335,17 @@ Ext.define('PartKeepr.PartManager', { partMode: 'create' }); - var defaults = {}; - var defaultPartUnit = PartKeepr.getApplication().getPartUnitStore().findRecord("default", true); - defaults.partUnit = defaultPartUnit.getId(); + var record = Ext.create("PartKeepr.PartBundle.Entity.Part"); - var record = Ext.create("PartKeepr.PartBundle.Entity.Part", defaults); - record.setCategory(this.getSelectedCategory()); + if (this.getSelectedCategory() !== null) { + record.setCategory(this.getSelectedCategory()); + } else { + record.setCategory(this.tree.getRootNode().firstChild); + } - // Inject the defaults to the editor, so the editor can create a new item on its own - j.editor.partDefaults = defaults; + record.setPartUnit(defaultPartUnit); j.editor.editItem(record); j.show();