From bf1ee934d1726a14ceb78a8d37af6ac384b50651 Mon Sep 17 00:00:00 2001
From: mchateauvert <40479137+mchateauvert@users.noreply.github.com>
Date: Wed, 10 Mar 2021 21:50:08 -0500
Subject: [PATCH 1/2] Update PartStockWindow.js
Revert max value limitation. Negative stock values are allowed/expected behavior in some circumstances.
---
.../Resources/public/js/Components/Part/PartStockWindow.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js
index 27a10bfb5..977685a88 100644
--- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js
+++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js
@@ -201,7 +201,6 @@ Ext.define('PartKeepr.PartStockWindow', {
this.priceField.hide();
this.priceCheckbox.hide();
this.okButton.setIconCls("web-icon brick_delete");
- this.quantityField.maxValue = this.callbackScope.record.data.stockLevel;
this.show();
}
});
From 0cd8b384babc315525f3c997f0577fa374f63c12 Mon Sep 17 00:00:00 2001
From: mchateauvert <40479137+mchateauvert@users.noreply.github.com>
Date: Wed, 10 Mar 2021 21:52:14 -0500
Subject: [PATCH 2/2] Update PartStockWindow.js
Add confirmation dialog before allowing user to create negative stock levels. Should close issue #1113.
---
.../js/Components/Part/PartStockWindow.js | 27 ++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js
index 977685a88..6f7563ef6 100644
--- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js
+++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js
@@ -161,11 +161,32 @@ Ext.define('PartKeepr.PartStockWindow', {
price = this.priceField.getValue() / this.quantityField.getValue();
}
- Ext.callback(this.callbackFn,
+ //Warn the user if they want to remove more than the current available
+ var current_stock = this.callbackScope.record.data.stockLevel;
+ if ((this.title == this.removePartText) & (this.quantityField.getValue() > current_stock)){
+
+ Ext.Msg.confirm(i18n("Not enough stock"),
+ i18n("You are removing more parts than are in stock. \
+ If you continue a negative stock will be tracked.
\
+ Are you sure you want to remove these parts?"),
+ function(buttonid){
+ // if yes, submit data as normal
+ if (buttonid == "yes") {
+ Ext.callback(this.callbackFn,
+ this.callbackScope,
+ [this.quantityField.getValue(), price, this.commentField.getValue()]);
+ this.close();
+ }
+ return; //otherwise, return without doing anything
+ }, this);
+ }
+ else { // add or remove stock normally
+ Ext.callback(this.callbackFn,
this.callbackScope,
[this.quantityField.getValue(), price, this.commentField.getValue()]);
- this.close();
- }
+ this.close();
+ }
+ }
},
/**
* Opens the window in "add stock" mode. The target callback receives three parameters: the value of the quantity