From 4b693fc27f3869278c800e6af83cbb235641a384 Mon Sep 17 00:00:00 2001
From: Juan Fuentes <juanf@bs-mbpr28.d.ethz.ch>
Date: Wed, 4 Dec 2019 14:20:03 +0100
Subject: [PATCH] SSDM-9104 : Better validation on the add-hoc product creation
 on the request form

---
 .../widgets/ordering/NewProductsController.js       | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/ordering/NewProductsController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/ordering/NewProductsController.js
index 054ab4439ef..d646ecb4bc7 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/ordering/NewProductsController.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/ordering/NewProductsController.js
@@ -53,6 +53,19 @@ function NewProductsController() {
 							"ANNOTATION.REQUEST.QUANTITY_OF_ITEMS" : $($($productProperties[5]).children()[0]).val()
 						}
 				}
+				if(!newProduct.properties["$NAME"] && !newProduct.properties["$PRODUCT.CATALOG_NUM"]) {
+                    Util.showError("Indicating a name or catalog number is mandatory for new products.");
+                    return;
+                }
+				if(!newProduct.annotations["ANNOTATION.REQUEST.QUANTITY_OF_ITEMS"] ||
+				    parseInt(newProduct.annotations["ANNOTATION.REQUEST.QUANTITY_OF_ITEMS"]) <= 0) {
+                    Util.showError("Indicating the quantity of items is mandatory for new requests.");
+                    return;
+				}
+				if(!newProduct.parentsIdentifiers[0]) {
+                    Util.showError("Indicating the provider is mandatory for new products.");
+                    return;
+                }
 				if(!newProduct.properties["$PRODUCT.CURRENCY"]) {
 					delete newProduct.properties["$PRODUCT.CURRENCY"];
 				}
-- 
GitLab