www/js/recipes.js

changeset 66
674948226777
parent 65
5d5c67818d11
child 67
883e897aad40
--- a/www/js/recipes.js	Sun Sep 23 22:49:45 2018 +0200
+++ b/www/js/recipes.js	Mon Sep 24 11:57:40 2018 +0200
@@ -246,6 +246,7 @@
 				});
 				$("#faddrowbutton").on('select', function (event) {
 					if (event.args) {
+						var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
 						var index = event.args.index;
 						var datarecord = fermentablelist.records[index];
 						var row = {};
@@ -271,8 +272,14 @@
 						row["f_dissolved_protein"] = 0;
 						row["f_recommend_mash"] = datarecord.recommend_mash;
 						row["f_add_after_boil"] = datarecord.add_after_boil;
-						row["f_adjust_to_total_100"] = 0;
-						row["f_percentage"] = 0;
+						if (rowscount == 0) {
+							// The first fermentable
+							row["f_adjust_to_total_100"] = 1;
+							row["f_percentage"] = 100;
+						} else {
+							row["f_adjust_to_total_100"] = 0;
+							row["f_percentage"] = 0;
+						}
 						row["f_di_ph"] = datarecord.di_ph;
 						var commit = $("#fermentableGrid").jqxGrid('addrow', null, row);
 					}

mercurial