partkeepr

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

commit f38325b25d7a6eaaaed531b5242817fddc85fee8
parent 954d46cc3cf08251b2ef5fb8b266f80bedca6211
Author: Felicia Hummel <felicia@partkeepr.com>
Date:   Tue, 31 Jan 2017 17:14:44 +0100

Display part details in the combined add/remove stock dialog, fixes #727

Diffstat:
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/BarcodeScanner/Actions/AddRemoveStock.js | 6+++++-
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/AddRemoveStockWindow.js | 17+++++++++++++----
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartDisplay.js | 105++++++++++++++-----------------------------------------------------------------
Asrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartInfoGrid.js | 122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js | 10++++++++--
Msrc/PartKeepr/FrontendBundle/Resources/views/index.html.twig | 1+
6 files changed, 167 insertions(+), 94 deletions(-)

diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/BarcodeScanner/Actions/AddRemoveStock.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/BarcodeScanner/Actions/AddRemoveStock.js @@ -169,7 +169,11 @@ Ext.define("PartKeepr.BarcodeScanner.Actions.AddRemoveStock", { listeners: { show: function () { - this.down("#grid").focus(); + Ext.defer(function () + { + this.down("#grid").getView().focusRow(0); + }, 50, this); + this.down("#grid").getSelectionModel().selectRange(0, 0); } diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/AddRemoveStockWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/AddRemoveStockWindow.js @@ -7,15 +7,14 @@ Ext.define('PartKeepr.Components.Part.AddRemoveStockWindow', { // Configurations constrainHeader: true, - width: 305, - height: 180, - + width: 600, + overflowY: 'auto', resizable: false, // We set the title later title: i18n("Add/Remove Stock"), - layout: 'anchor', + layout: 'fit', bodyStyle: { padding: "5px" }, @@ -64,10 +63,20 @@ Ext.define('PartKeepr.Components.Part.AddRemoveStockWindow', { } }); + this.infoGrid = Ext.create("PartKeepr.Components.Part.PartInfoGrid", { + mode: 'short', + padding: { + bottom: "5px" + } + }); + + this.infoGrid.applyFromPart(this.record); + this.form = Ext.create("Ext.form.Panel", { border: false, bodyStyle: 'background-color: transparent', items: [ + this.infoGrid, { xtype: 'fieldcontainer', fieldLabel: i18n("Quantity"), diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartDisplay.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartDisplay.js @@ -8,57 +8,6 @@ Ext.define('PartKeepr.PartDisplay', { overflowY: 'auto', - fieldConfigs: { - "category.name": { - displayName: i18n("Category Name") - }, - stockLevel: { - displayName: i18n("Stock Level") - }, - minStockLevel: { - displayName: i18n("Minimum Stock Level") - }, - "footprint.name": { - displayName: i18n("Footprint") - }, - "storageLocation.name": { - displayName: i18n("Storage Location") - }, - comment: { - displayName: i18n("Comment") - }, - createDate: { - displayName: i18n("Create Date"), - type: 'date', - }, - status: { - displayName: i18n("Status") - }, - partCondition: { - displayName: i18n("Condition") - }, - needsReview: { - displayName: i18n("Needs Review"), - type: 'boolean' - }, - internalPartNumber: { - displayName: i18n("Internal Part Number"), - }, - projectNames: { - displayName: i18n("Used in Projects") - }, - "@id": { - displayName: i18n("Internal ID"), - renderer: function (value) - { - var values = value.split("/"); - var idstr = values[values.length - 1]; - var idint = parseInt(idstr); - return idstr + " (#"+idint.toString(36)+")"; - } - } - }, - /** * Initializes the component and adds a template as well as the add/remove stock and edit part buttons. */ @@ -131,41 +80,34 @@ Ext.define('PartKeepr.PartDisplay', { title: i18n("Images"), }); - this.infoGrid = Ext.create("Ext.grid.property.Grid", { - listeners: { - 'beforeedit': function () - { - return false; - } - }, - hideHeaders: true, - nameColumnWidth: 150, + this.infoGrid = Ext.create("PartKeepr.Components.Part.PartInfoGrid", { title: { height: 'auto', cls: 'x-title-wrappable-text' - }, - cls: 'x-wrappable-grid', - sourceConfig: this.fieldConfigs + } }); this.partParameterGrid = Ext.create("Ext.grid.Panel", { title: i18n("Part Parameters"), emptyText: i18n("No Parameters"), - columns: [{ - header: i18n("Parameter"), - dataIndex: "name", - flex: 1 - }, { - header: i18n("Value"), - renderer: function (v,m,rec) { - return PartKeepr.PartManager.formatParameter(rec); - }, - flex: 1 - }] + columns: [ + { + header: i18n("Parameter"), + dataIndex: "name", + flex: 1 + }, { + header: i18n("Value"), + renderer: function (v, m, rec) + { + return PartKeepr.PartManager.formatParameter(rec); + }, + flex: 1 + } + ] }); this.items = [ - this.infoGrid, this.partParameterGrid,{ + this.infoGrid, this.partParameterGrid, { xtype: 'panel', title: i18n("Attachments"), items: this.attachmentDisplay @@ -190,20 +132,9 @@ Ext.define('PartKeepr.PartDisplay', { { this.record = r; - var values = {}, value; - - for (var i in this.fieldConfigs) { - value = this.record.get(i); - if (value !== undefined) { - values[i] = value; - } else { - values[i] = i18n("none"); - } - } - this.attachmentDisplay.bindStore(this.record.attachments()); this.partParameterGrid.bindStore(this.record.parameters()); - this.infoGrid.setSource(values); + this.infoGrid.applyFromPart(this.record); this.infoGrid.setTitle( "<div>" + this.record.get("name") + "</div><small>" + this.record.get("description") + "</small>"); this.imageDisplay.setStore(this.record.attachments()); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartInfoGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartInfoGrid.js @@ -0,0 +1,122 @@ +Ext.define("PartKeepr.Components.Part.PartInfoGrid", { + extend: "Ext.grid.property.Grid", + + sortableColumns: false, + + fieldConfigs: { + "category.name": { + displayName: i18n("Category Name") + }, + stockLevel: { + displayName: i18n("Stock Level") + }, + minStockLevel: { + displayName: i18n("Minimum Stock Level") + }, + "footprint.name": { + displayName: i18n("Footprint") + }, + "storageLocation.name": { + displayName: i18n("Storage Location") + }, + comment: { + displayName: i18n("Comment") + }, + createDate: { + displayName: i18n("Create Date"), + type: 'date', + }, + status: { + displayName: i18n("Status") + }, + partCondition: { + displayName: i18n("Condition") + }, + needsReview: { + displayName: i18n("Needs Review"), + type: 'boolean' + }, + internalPartNumber: { + displayName: i18n("Internal Part Number"), + }, + projectNames: { + displayName: i18n("Used in Projects") + }, + "@id": { + displayName: i18n("Internal ID"), + renderer: function (value) + { + var values = value.split("/"); + var idstr = values[values.length - 1]; + var idint = parseInt(idstr); + return idstr + " (#" + idint.toString(36) + ")"; + } + } + }, + + shortFieldConfigs: { + "name": { + displayName: i18n("Name") + }, + "description": { + displayName: i18n("Description") + }, + "category.name": { + displayName: i18n("Category Name") + }, + stockLevel: { + displayName: i18n("Stock Level") + }, + "footprint.name": { + displayName: i18n("Footprint") + }, + "storageLocation.name": { + displayName: i18n("Storage Location") + }, + comment: { + displayName: i18n("Comment") + }, + internalPartNumber: { + displayName: i18n("Internal Part Number"), + }, + }, + + listeners: { + 'beforeedit': function () + { + return false; + } + }, + hideHeaders: true, + nameColumnWidth: 150, + cls: 'x-wrappable-grid', + + mode: 'full', + + initComponent: function () + { + if (this.mode === "full") { + this.sourceConfig = this.fieldConfigs; + } else { + this.sourceConfig = this.shortFieldConfigs; + } + + this.callParent(arguments); + }, + applyFromPart: function (record) + { + var values = {}, value; + + for (var i in this.sourceConfig) { + value = record.get(i); + if (value !== undefined) { + values[i] = value; + } else { + values[i] = i18n("none"); + } + } + + this.setSource(values); + } + +}); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js @@ -8,7 +8,6 @@ Ext.define('PartKeepr.PartStockWindow', { // Configurations constrainHeader: true, width: 305, - height: 180, resizable: false, @@ -31,6 +30,13 @@ Ext.define('PartKeepr.PartStockWindow', { initComponent: function () { + this.infoGrid = Ext.create("PartKeepr.Components.Part.PartInfoGrid", { + mode: 'short', + padding: { + bottom: "5px" + } + }); + this.quantityField = Ext.create("Ext.form.field.Number", { value: 0, // The initial value is 0, to indicate that this is a number field minValue: 1, // The minimum value is 1. That way we force the user to enter a value @@ -93,6 +99,7 @@ Ext.define('PartKeepr.PartStockWindow', { border: false, bodyStyle: 'background-color: transparent', items: [ + this.infoGrid, { xtype: 'fieldcontainer', fieldLabel: i18n("Quantity"), @@ -193,7 +200,6 @@ Ext.define('PartKeepr.PartStockWindow', { this.setTitle(this.removePartText); this.priceField.hide(); this.priceCheckbox.hide(); - this.setHeight(132); this.okButton.setIconCls("web-icon brick_delete"); this.show(); } diff --git a/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig b/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig @@ -167,6 +167,7 @@ '@PartKeeprFrontendBundle/Resources/public/js/Components/Statusbar.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Auth/LoginDialog.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Part/PartImageDisplay.js' + '@PartKeeprFrontendBundle/Resources/public/js/Components/Part/PartInfoGrid.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Part/PartsManager.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Part/Editor/PartEditorWindow.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Part/PartDisplay.js'