Skip to content

Commit

Permalink
Display part details in the combined add/remove stock dialog, fixes #727
Browse files Browse the repository at this point in the history
  • Loading branch information
Felicia Hummel committed Jan 31, 2017
1 parent 954d46c commit f38325b
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Ext.define('PartKeepr.PartStockWindow', {
// Configurations
constrainHeader: true,
width: 305,
height: 180,

resizable: false,

Expand All @@ -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
Expand Down Expand Up @@ -93,6 +99,7 @@ Ext.define('PartKeepr.PartStockWindow', {
border: false,
bodyStyle: 'background-color: transparent',
items: [
this.infoGrid,
{
xtype: 'fieldcontainer',
fieldLabel: i18n("Quantity"),
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit f38325b

Please sign in to comment.