Hops grid editor amount is now in grams.

Thu, 13 Dec 2018 22:58:12 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 13 Dec 2018 22:58:12 +0100
changeset 140
93c64d7ac79c
parent 139
eb1ac7487710
child 141
fe9e2a677611

Hops grid editor amount is now in grams.

www/js/rec_edit.js file | annotate | diff | comparison | revisions
--- a/www/js/rec_edit.js	Thu Dec 13 20:32:36 2018 +0100
+++ b/www/js/rec_edit.js	Thu Dec 13 22:58:12 2018 +0100
@@ -937,7 +937,21 @@
                                 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' },
 				{ text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' },
                                 { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
-                                { text: 'Gewicht Kg', datafield: 'h_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f4',
+				// Edit the amount in grams, shoukd be fine for batches < 10 hl.
+				{ text: 'Gewicht gr', datafield: 'grams', width: 120, align: 'right', columntype: 'numberinput', cellsformat: 'f1',
+				  cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
+					var gram = rowdata.h_amount * 1000;
+					return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(gram, "f1") + " gr</div>";
+				  },
+				  validation: function (cell, value) {
+					var maxhops = parseFloat($("#batch_size").jqxNumberInput('decimal')) * 200;
+					if (value < 0 || value > maxhops ) {
+						return { result: false, message: "Volume moet  0-"+maxhops+" zijn" };
+					}
+					return true;
+				  }
+				},
+                            /*    { text: 'Gewicht Kg', datafield: 'h_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f4',
                                   columntype: 'numberinput',
 				  initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
 					editor.jqxNumberInput({ decimalDigits: 4, min: 0, spinButtons: false });
@@ -948,7 +962,7 @@
                                         }
                                         return true;
                                   }
-                                },
+                                }, */
 				{ text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist',
 				  createeditor: function (row, column, editor) {
 					  var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ];
@@ -1000,7 +1014,11 @@
 		$("#hopGrid").on('cellendedit', function (event) {
 			var args = event.args;
 			console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
-			$("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
+			if (args.datafield == 'grams') {
+				$("#hopGrid").jqxGrid('setcellvalue', args.rowindex, 'h_amount', parseFloat(args.value / 1000));
+			} else {
+				$("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
+			}
 //			//$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc');
 		});
         };

mercurial