Fermentable editor checks. Fermentables dropdown list shows a frienlier list

Sun, 23 Sep 2018 22:49:45 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 23 Sep 2018 22:49:45 +0200
changeset 65
5d5c67818d11
parent 64
5d5fc6f7cbfe
child 66
674948226777

Fermentable editor checks. Fermentables dropdown list shows a frienlier list

www/getfermentablesources.php file | annotate | diff | comparison | revisions
www/js/recipes.js file | annotate | diff | comparison | revisions
--- a/www/getfermentablesources.php	Sun Sep 23 17:15:33 2018 +0200
+++ b/www/getfermentablesources.php	Sun Sep 23 22:49:45 2018 +0200
@@ -1,7 +1,7 @@
 <?php
 require_once('config.php');
 
-$query = "SELECT * FROM inventory_fermentables ORDER BY name";
+$query = "SELECT * FROM inventory_fermentables ORDER BY supplier,name";
 $connect = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
 if (! $connect) {
 	echo "[]";
--- a/www/js/recipes.js	Sun Sep 23 17:15:33 2018 +0200
+++ b/www/js/recipes.js	Sun Sep 23 22:49:45 2018 +0200
@@ -237,7 +237,12 @@
 					displayMember: "name",
 					width: 150,
 					height: 27,
-					dropDownWidth: 300
+					dropDownWidth: 500,
+					dropDownHeight: 500,
+					renderer: function (index, label, value) {
+						var datarecord = fermentablelist.records[index];
+						return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)";
+					}
 				});
 				$("#faddrowbutton").on('select', function (event) {
 					if (event.args) {
@@ -288,28 +293,39 @@
 			columns: [
 				{ text: 'Mout/suiker', editable: false, datafield: 'f_name' },
 				{ text: 'Type', editable: false, width: 100, datafield: 'f_type' },
-				{ text: 'Opbrengst', datafield: 'f_yield', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
+				{ text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
 				{ text: 'Gewicht', datafield: 'f_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3',
 				  columntype: 'numberinput',
 				  validation: function (cell, value) {
-				  	if (value < 0 || value > 100000000000 ) {
-						return { result: false, message: "Volume moet  0-~ zijn" };
+					// Maximum weight is the batch_size, just a simple check.
+					var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal'));
+				  	if (value < 0 || value > maxmout) {
+						return { result: false, message: "Gewicht moet  0-"+maxmout+" zijn" };
 				  	}
 				  	return true;
+				  },
+				  initeditor: function (row, cellvalue, editor) {
+					editor.jqxNumberInput({ decimalDigits: 3 });
 				  }
 				},
-				{ text: 'Procent', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p3',
+				{ text: 'Procent', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1',
 				  columntype: 'numberinput',
 				  validation: function (cell, value) {
 					if (value < 0 || value > 100) {
 						return { result: false, message: "Percentage moet 0-100 zijn" };
 					}
 					return true;
+				  },
+				  initeditor: function (row, cellvalue, editor) {
+					editor.jqxNumberInput({ decimalDigits: 1 });
 				  }
 				},
 				{ text: '100%', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80 }
 			]
-		})
+		});
+		$("#fermentableGrid").on('cellendedit', function (event) {
+			$('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc');
+		});
 	};
 
 	// Inline hops editor
@@ -1115,7 +1131,6 @@
 		groups: ['st_guide','st_letter' ]
 	});
 
-
 	// initialize the popup window and buttons.
 	$("#popupWindow").jqxWindow({
 		width: 1202,
@@ -1127,10 +1142,6 @@
 		cancelButton: $("#Cancel"),
 		modalOpacity: 0.40
 	});
-	$("#popupWindow").on('open', function () {
-		$("#name").jqxInput('selectAll');
-	});
-
 	// Tabs inside the popup window.
 	$('#jqxTabs').jqxTabs({
 		theme: theme,
@@ -1138,6 +1149,9 @@
 		height: 580,
 		position: 'top'
 	});
+	$("#popupWindow").on('open', function () {
+		$("#name").jqxInput('selectAll');
+	});
 
 	$("#Delete").jqxButton({ width: '90px', theme: theme });
 	$("#Delete").click(function () {
@@ -1151,6 +1165,7 @@
 		}
 		$("#popupWindow").jqxWindow('hide');
 	});
+
 	$("#Cancel").jqxButton({ width: '90px', theme: theme });
 	$("#Save").jqxButton({ width: '90px', theme: theme });
 	// update the edited row when the user clicks the 'Save' button.

mercurial