diff -r 58c350f286e5 -r 9d2a4703bdac www/js/prod_edit.js --- a/www/js/prod_edit.js Wed May 08 22:23:52 2019 +0200 +++ b/www/js/prod_edit.js Thu May 09 14:53:10 2019 +0200 @@ -304,6 +304,22 @@ $("#need_cells").val(getNeededYeastCells()); }; + function calcMash() { + + if (!(rows = $('#mashGrid').jqxGrid('getrows'))) + return; + if (mashkg == 0) + return; + + var infused = 0; + for (var i = 0; i < rows.length; i++) { + var row = $("#mashGrid").jqxGrid('getrowdata', i); + if (row.step_type == 0) // Infusion + infused += row.step_infuse_amount; + $("#mashGrid").jqxGrid('setcellvalue', i, "step_thickness", infused / mashkg); + } + } + /* * Change OG of recipe but keep the water volumes. */ @@ -2155,6 +2171,7 @@ calcIBUs(); calcWater(); calcSparge(); + calcMash(); }); $('#boil_time').on('change', function (event) { console.log("boil_time change:"+parseFloat(event.args.value)+" old:"+dataRecord.boil_time); @@ -2186,6 +2203,7 @@ calcFermentablesFromOG(dataRecord.est_og); // Adjust fermentables amounts calcFermentables(); // Update the recipe details calcIBUs(); // and the IBU's. + calcMash(); calcYeast(); }); $('#mash_ph').on('change', function (event) { @@ -3890,6 +3908,7 @@ { name: 'step_infuse_amount', type: 'float' }, { name: 'step_temp', type: 'float' }, { name: 'step_time', type: 'float' }, + { name: 'step_thickness', type: 'float' }, { name: 'ramp_time', type: 'float' }, { name: 'end_temp', type: 'float' } ], @@ -3908,6 +3927,8 @@ var row = records[i]; if (row.step_type == 0) // Infusion mash_infuse += parseFloat(row.step_infuse_amount); + row.step_thickness = 0; // Init this field. + data.push(row); } }, }); @@ -3937,6 +3958,7 @@ } row["step_temp"] = 62.0; row['step_time'] = 20.0; + row['step_thickness'] = 0; row['ramp_time'] = 1.0; row['end_temp'] = 62.0; var commit = $("#mashGrid").jqxGrid('addrow', null, row); @@ -3954,6 +3976,7 @@ }, ready: function() { calcInit(); + calcMash(); $('#jqxLoader').jqxLoader('close'); $('#jqxTabs').jqxTabs('first'); }, @@ -3969,6 +3992,7 @@ { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, { text: 'Infuse L.', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'L/Kg.', datafield: 'step_thickness', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f2' }, { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { return "Wijzig"; }, buttonclick: function (row) { @@ -4235,6 +4259,7 @@ // Recalc percentages calcFermentables(); calcIBUs(); + calcMash(); // Waters: yes there is impact. }); $("#wf_name").jqxInput({ theme: theme, width: 320, height: 23 }); @@ -4310,6 +4335,7 @@ } calcFermentables(); calcIBUs(); + calcMash(); }; }); $("#wf_percentage").jqxNumberInput( Perc1dec ); @@ -4347,6 +4373,7 @@ } calcFermentables(); calcIBUs(); + calcMash(); } else { // Adjust all the rows. var nw = tw * diff / 100; @@ -4366,6 +4393,7 @@ } calcFermentables(); calcIBUs(); + calcMash(); } } } @@ -4409,6 +4437,7 @@ $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_added', index); calcFermentables(); calcIBUs(); + calcMash(); } }); @@ -4860,6 +4889,10 @@ row["step_infuse_amount"] = mash_infuse; else row["step_infuse_amount"] = 0; + if (mashkg > 0) + row['step_thickness'] = parseFloat(mash_infuse / mashkg); + else + row['step_thickness'] = 0; row["step_temp"] = data.step_temp; row["end_temp"] = data.end_temp; row["step_time"] = data.step_time; @@ -4882,6 +4915,7 @@ $("#MashReady").jqxButton({ template: "success", width: '90px', theme: theme }); $("#MashReady").click(function () { $("#mashGrid").jqxGrid('sortby', 'step_temp', 'asc'); + calcMash(); }); $("#wstep_name").jqxInput({ theme: theme, width: 320, height: 23 }); $("#wstep_name").on('change', function (event) {