www/js/recipes.js

changeset 52
b1f2a893572f
parent 51
7224109adfe1
child 53
a17c644a0510
--- a/www/js/recipes.js	Tue Sep 04 13:44:02 2018 +0200
+++ b/www/js/recipes.js	Tue Sep 04 23:12:13 2018 +0200
@@ -60,6 +60,16 @@
 			{ name: 'st_guide', type: 'string' },
 			{ name: 'st_og_min', type: 'float' },
 			{ name: 'st_og_max', type: 'float' },
+			{ name: 'st_fg_min', type: 'float' },
+			{ name: 'st_fg_max', type: 'float' },
+			{ name: 'st_ibu_min', type: 'float' },
+			{ name: 'st_ibu_max', type: 'float' },
+			{ name: 'st_color_min', type: 'float' },
+			{ name: 'st_color_max', type: 'float' },
+			{ name: 'st_carb_min', type: 'float' },
+			{ name: 'st_carb_max', type: 'float' },
+			{ name: 'st_abv_min', type: 'float' },
+			{ name: 'st_abv_max', type: 'float' },
 			{ name: 'name', type: 'string' },
 			{ name: 'notes', type: 'string' },
 			{ name: 'type', type: 'number' },
@@ -137,16 +147,6 @@
 
 	// Inline waters editor
 	var editWater = function (data) {
-//		var generaterow = function () {
-//			var row = {};
-//			row["w_name"] = "Water 1";
-//			row["step_type"] = "Infusion";
-//			row["w_amount"] = 22.0;
-//			row['step_time'] = 20.0;
-//			row['ramp_time'] = 1.0;
-//			row['end_temp'] = 62.0;
-//			return row;
-//		}
 		var waterSource = {
 			localdata: data.waters,
 			datatype: "local",
@@ -180,9 +180,6 @@
 			selectionmode: 'singlerow',
 			editmode: 'selectedrow',
 			editable: true,
-			showstatusbar: true,
-			statusbarheight: 50,
-			showaggregates: true,
 			showtoolbar: true,
 			rendertoolbar: function (toolbar) {
 				var me = this;
@@ -212,7 +209,6 @@
 				{ text: 'Water bron', editable: false, datafield: 'w_name' },
 				{ text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', 
 				  columntype: 'numberinput',
-				  aggregates: ['sum'],
 				  validation: function (cell, value) {
 					if (value < 0 || value > 100000000000 ) {
 						return { result: false, message: "Volume moet  0-~ zijn" };
@@ -230,9 +226,6 @@
 				{ text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }
 			]
 		});
-//		$("#grid").on('cellendedit', function (event) {
-//			$('#grid').jqxGrid('sortby', 'step_temp', 'asc');
-//		});
 	}; // editWater = function (data) {
 
 	// initialize the input fields.
@@ -258,6 +251,7 @@
 	$("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 180 });
 	$("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
 	$("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
+	$("#mash_sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
 	var editrow = -1;
 	// initialize jqxGrid
 	$("#jqxgrid").jqxGrid({
@@ -282,17 +276,20 @@
 				$("#notes").val('');
 				$("#st_name").val('');
 				$("#st_letter").val('');
-				$("#st_guide").val('');
+				$("#st_guide").val('BKG 2015');
 				$("#type").val('All Grain');
 				$("#batch_size").val(20);
 				$("#boil_time").val(90);
 				$("#efficiency").val(75);
-				$("#est_og").val(1.062);
+				$("#est_og").val(1.052);
 				$("#est_fg").val(1.000);
-				$("#est_color").val(0);
+				$("#est_color").val(20);
 				$("#color_method").val('Morey');
-				$("#est_ibu").val(0);
+				$("#est_ibu").val(40);
 				$("#ibu_method").val('Tinseth');
+				$("#mash_sparge_temp").val(78);
+				$("#mash_ph").val(5.4);
+				$("#mash_name").val('');
 				editWater('');
 				$("#popupWindow").jqxWindow('open');
 			});
@@ -334,8 +331,8 @@
 					$("#ibu_method").val(dataRecord.ibu_method);
 					$("#mash_name").val(dataRecord.mash_name);
 					$("#mash_ph").val(dataRecord.mash_ph);
+					$("#mash_sparge_temp").val(dataRecord.mash_sparge_temp);
 					editWater(dataRecord);
-		//			editsteps(dataRecord);
 					// show the popup window.
 					$("#popupWindow").jqxWindow('open');
 				}
@@ -344,6 +341,7 @@
 		groups: ['st_guide','st_letter' ]
 	});
 
+
 	// initialize the popup window and buttons.
 	$("#popupWindow").jqxWindow({
 		width: 1200,
@@ -355,6 +353,9 @@
 		cancelButton: $("#Cancel"),
 		modalOpacity: 0.40
 	});
+	$("#popupWindow").on('open', function () {
+		$("#name").jqxInput('selectAll');
+	});
 
 	// Tabs inside the popup window.
 	$('#jqxTabs').jqxTabs({
@@ -364,9 +365,6 @@
 		position: 'top'
 	});
 
-	$("#popupWindow").on('open', function () {
-		$("#name").jqxInput('selectAll');
-	});
 	$("#Delete").jqxButton({ width: '90px', theme: theme });
 	$("#Delete").click(function () {
 		if (editrow >= 0) {
@@ -383,8 +381,9 @@
 	$("#Save").jqxButton({ width: '90px', theme: theme });
 	// update the edited row when the user clicks the 'Save' button.
 	$("#Save").click(function () {
-//		var steprows = $('#grid').jqxGrid('getrows');
+		var waterrow = $('#waterGrid').jqxGrid('getrows');
 		if (editrow >= 0) {
+			var rowRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
 			var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
 			var row = {
 				record: rowID,
@@ -393,6 +392,18 @@
 				st_name: $('#st_name').val(),
 				st_letter: $('#st_letter').val(),
 				st_guide: $('#st_guide').val(),
+				st_og_min: rowRecord.st_og_min,
+				st_og_max: rowRecord.st_og_max,
+				st_fg_min: rowRecord.st_fg_min,
+				st_fg_max: rowRecord.st_fg_max,
+				st_ibu_min: rowRecord.st_ibu_min,
+				st_ibu_max: rowRecord.st_ibu_max,
+				st_color_min: rowRecord.st_color_min,
+				st_color_max: rowRecord.st_color_max,
+				st_carb_min: rowRecord.st_carb_min,
+				st_carb_max: rowRecord.st_carb_max,
+				st_abv_min: rowRecord.st_abv_min,
+				st_abv_max: rowRecord.st_abv_max,
 				type: $("#type").val(),
 				batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
 				boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
@@ -404,8 +415,9 @@
 				est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
 				ibu_method: $("#ibu_method").val(),
 				mash_name: $("#mash_name").val(),
-				mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal'))
-//				steps: steprows
+				mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')),
+				mash_sparge_temp: parseFloat($("#mash_sparge_temp").jqxNumberInput('decimal')),
+				waters: waterrow
 			};
 			$('#jqxgrid').jqxGrid('updaterow', rowID, row);
 			$("#popupWindow").jqxWindow('hide');
@@ -418,6 +430,18 @@
 				st_name: $('#st_name').val(),
 				st_letter: $('#st_letter').val(),
 				st_guide: $('#st_guide').val(),
+				st_og_min: 1.025,
+				st_og_max: 1.110,
+				st_fg_min: 1.000,
+				st_fg_max: 1.025,
+				st_ibu_min: 15,
+				st_ibu_max: 150,
+				st_color_min: 5,
+				st_color_max: 50,
+				st_carb_min: 1,
+				st_carb_max: 3,
+				st_abv_min: 2,
+				st_abv_max: 14,
 				type: $("#type").val(),
 				batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
 				boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
@@ -429,8 +453,9 @@
 				est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
 				ibu_method: $("#ibu_method").val(),
 				mash_name: $("#mash_name").val(),
-				mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal'))
-//				steps: steprows
+				mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')),
+				mash_sparge_temp: parseFloat($("#mash_sparge_temp").jqxNumberInput('decimal')),
+				waters: waterrow
 			};
 			$('#jqxgrid').jqxGrid('addrow', null, newrow);
 			$("#popupWindow").jqxWindow('hide');

mercurial