partkeepr

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

commit 6807371f10c0591a9c6777dc98715195dccafc77
parent 7f5edad011a2c95415eaf930184580707cea1f09
Author: Timo A. Hummel <timo@netraver.de>
Date:   Mon,  6 Jun 2011 15:57:56 +0200

* Added "edit part" validation
* Added validation for numberfields

Diffstat:
Mfrontend/js/Components/Part/PartDistributorGrid.js | 3++-
Mfrontend/js/Components/Part/PartEditor.js | 19++++++++++++++++---
Mfrontend/js/Components/Part/PartEditorWindow.js | 14+++++++++++++-
Mfrontend/js/Components/Widgets/CategoryComboBox.js | 7+++++++
Mfrontend/js/PartDB2.js | 1-
Msrc/de/RaumZeitLabor/PartDB2/Part/PartManager.php | 1+
6 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/frontend/js/Components/Part/PartDistributorGrid.js b/frontend/js/Components/Part/PartDistributorGrid.js @@ -63,7 +63,8 @@ Ext.define('PartDB2.PartDistributorGrid', { editor: { xtype:'numberfield', allowDecimals: false, - allowBlank:false + allowBlank:false, + minValue: 1 } } ]; diff --git a/frontend/js/Components/Part/PartEditor.js b/frontend/js/Components/Part/PartEditor.js @@ -10,13 +10,16 @@ Ext.define('PartDB2.PartEditor', { var basicEditorFields = [{ xtype: 'textfield', name: 'name', - fieldLabel: i18n("Name") + fieldLabel: i18n("Name"), + allowBlank: false },{ xtype: 'numberfield', fieldLabel: i18n('Minimum Stock'), allowDecimals: false, allowBlank: false, - name: 'minStockLevel' + name: 'minStockLevel', + value: 0, + minValue: 0 },{ xtype: 'CategoryComboBox', fieldLabel: i18n("Category"), @@ -24,7 +27,8 @@ Ext.define('PartDB2.PartEditor', { },{ xtype: 'StorageLocationComboBox', fieldLabel: i18n("Storage Location"), - name: 'storageLocation_id' + name: 'storageLocation_id', + allowBlank: false },{ xtype: 'FootprintComboBox', fieldLabel: i18n("Footprint"), @@ -51,6 +55,11 @@ Ext.define('PartDB2.PartEditor', { items: [{ xtype: 'panel', border: false, + layout: 'anchor', + defaults: { + anchor: '100%', + labelWidth: 150 + }, bodyStyle: 'background:#DFE8F6;padding: 10px;', title: i18n("Basic Data"), items: basicEditorFields @@ -67,6 +76,10 @@ Ext.define('PartDB2.PartEditor', { this.callParent(); }, onItemSave: function () { + if (!this.getForm().isValid()) { + return; + } + var call = new PartDB2.ServiceCall( "Part", "addOrUpdatePart"); diff --git a/frontend/js/Components/Part/PartEditorWindow.js b/frontend/js/Components/Part/PartEditorWindow.js @@ -6,7 +6,7 @@ Ext.define('PartDB2.PartEditorWindow', { minHeight: 300, height: 320, layout: 'fit', - title: i18n("Edit Part"), + title: i18n("Add Part"), initComponent: function () { this.editor = Ext.create("PartDB2.PartEditor", { border: false @@ -18,9 +18,21 @@ Ext.define('PartDB2.PartEditorWindow', { this.callParent(); }, applyRecord: function (r) { + if (r.id) { + this.setTitle(i18n("Edit Part")); + } + this.editor.getForm().setValues(r); this.editor.rawValues = r; + if (!r.distributors) { + r.distributors = []; + } + + if (!r.manufacturers) { + r.manufacturers = []; + } + this.editor.partDistributorGrid.getStore().loadData(r.distributors); this.editor.partManufacturerGrid.getStore().loadData(r.manufacturers); } diff --git a/frontend/js/Components/Widgets/CategoryComboBox.js b/frontend/js/Components/Widgets/CategoryComboBox.js @@ -109,5 +109,12 @@ Ext.define("PartDB2.CategoryComboBox",{ picker.el[isAbove ? 'addCls' : 'removeCls'](picker.baseCls + aboveSfx); } } + }, + getErrors: function(value) { + if (this.getValue() === null) { + return [ i18n("You need to select a category")]; + } + + return []; } }); \ No newline at end of file diff --git a/frontend/js/PartDB2.js b/frontend/js/PartDB2.js @@ -248,7 +248,6 @@ PartDB2.getBasePath = function () { }; PartDB2.serializeRecords = function (records) { - console.log(records); var finalData = []; for (var i=0;i<records.length;i++) { diff --git a/src/de/RaumZeitLabor/PartDB2/Part/PartManager.php b/src/de/RaumZeitLabor/PartDB2/Part/PartManager.php @@ -1,6 +1,7 @@ <?php namespace de\raumzeitlabor\PartDB2\Part; use de\RaumZeitLabor\PartDB2\Part\PartDistributor; +use de\RaumZeitLabor\PartDB2\Part\PartManufacturer; use de\RaumZeitLabor\PartDB2\StorageLocation\StorageLocation;