www/js/rec_edit.js

Sun, 16 Dec 2018 13:53:48 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 16 Dec 2018 13:53:48 +0100
changeset 145
2662720e1949
parent 144
ae15cfe5f008
child 146
2a6c00d325b2
permissions
-rw-r--r--

Protect misc Water agent ingredients against delete and changing from the miscs editor.

68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * Copyright (C) 2018
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of BMS
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * BrewCloud is distributed in the hope that it will be useful, but
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 function createDelElements() {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 $('#eventWindow').jqxWindow({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 position: { x: 490, y: 210 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 width: 300,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 height: 175,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 resizable: false,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 isModal: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 modalOpacity: 0.4,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 okButton: $('#delOk'),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 cancelButton: $('#delCancel'),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 initContent: function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 $('#delCancel').focus();
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 $('#eventWindow').jqxWindow('hide');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 $(document).ready(function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
125
f2c79ed6423a Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
47 var dataRecord = {};
127
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
48 var to_100 = false; // Fermentables adjust to 100%
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
49 var preboil_sg = 0;
97
22c277be7e7e Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
50 var sugarsm = 0; // Sugars after mash
22c277be7e7e Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
51 var sugarsf = 0; // Sugars after boil
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
52 var psugar = 0; // Percentage real sugars
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
53 var pcara = 0; // Percentage cara/crystal malts
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
54 var svg = 77; // Default attenuation
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
55 var hop_flavour = 0;
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
56 var hop_aroma = 0;
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
57
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme);
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
59 $("#jqxLoader").jqxLoader({
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
60 width: 250,
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
61 height: 150,
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
62 isModal: true,
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
63 text: "Laden recept ...",
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
64 theme: theme
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
65 });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
67 function calcFermentables() {
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
68 console.log("calcFermentables()");
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
69 sugarsf = 0;
97
22c277be7e7e Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
70 sugarsm = 0;
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
71 psugar = 0;
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
72 pcara = 0;
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
73 var colorw = 0; // Colors working
127
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
74 var my_100 = false;
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
75
125
f2c79ed6423a Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
76 var rows = $('#fermentableGrid').jqxGrid('getrows');
73
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
77 for (var i = 0; i < rows.length; i++) {
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
78 var row = rows[i];
127
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
79 if (row.f_adjust_to_total_100)
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
80 my_100 = true;
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
81 if (row.f_type == "Sugar")
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
82 psugar += row.f_percentage;
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
83 if (row.f_graintype == "Crystal")
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
84 pcara += row.f_percentage;
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
85 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100);
97
22c277be7e7e Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
86 if (row.f_added == "Mash") {
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
87 d = parseFloat($("#efficiency").jqxNumberInput('decimal')) / 100 * d;
97
22c277be7e7e Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
88 sugarsm += d;
22c277be7e7e Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
89 }
22c277be7e7e Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
90 sugarsf += d;
135
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
91 colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat($("#batch_size").jqxNumberInput('decimal')) * 8.34436;
73
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
92 }
127
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
93 if (to_100 != my_100)
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
94 console.log("change to_100 to:"+my_100);
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
95 to_100 = my_100;
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
96 var est_og = estimate_sg(sugarsf, parseFloat($("#batch_size").jqxNumberInput('decimal')));
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
97 $('#est_og').val(est_og);
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
98 $('#est_og2').val(est_og);
97
22c277be7e7e Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents: 96
diff changeset
99 preboil_sg = estimate_sg(sugarsm, parseFloat($("#boil_size").jqxNumberInput('decimal')));
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
100 var color = kw_to_ebc($("#color_method").val(), colorw);
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
101 $('#est_color').val(color);
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
102 $('#est_color2').val(color);
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
103 var scolor = ebc_to_color(color);
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
104 document.getElementById("bcolor").style.background= scolor;
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
105 document.getElementById("bcolor2").style.background= scolor;
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
106 };
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
107
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
108 function hopFlavourContribution(bt, vol, use, amount) {
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
109 var result;
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
110
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
111 if ((use == "First Wort") || (use == "First wort")) {
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
112 result = 0.15; // assume 15% flavourcontribution for fwh
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
113 } else if (bt > 50) {
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
114 result = 0.10; // assume 10% flavourcontribution as a minimum
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
115 } else {
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
116 result = 15.25 / (6 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 21) /6, 2));
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
117 if (result < 0.10)
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
118 result = 0.10; // assume 10% flavourcontribution as a minimum
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
119 }
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
120 result = (result * amount * 1000) / vol;
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
121 // console.log("hopFlavourContribution("+bt+","+vol+","+use+","+amount+"): "+result);
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
122 return result;
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
123 }
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
124
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
125 function hopAromaContribution(bt, vol, use, amount) {
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
126 var result = 0;
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
127
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
128 if (bt > 20) {
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
129 result = 0;
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
130 } else if (bt > 7.5) {
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
131 result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) /4, 2));
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
132 } else if (use == "Boil") {
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
133 result = 1;
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
134 } else if (use == "Aroma") {
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
135 result = 1.2;
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
136 } else if (use == "Whirlpool") {
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
137 result = 1.2;
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
138 } else if ((use == "Dry Hop") || (use == "Dry hop")) {
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
139 result = 1.33;
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
140 }
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
141 result = (result * amount * 1000) / vol;
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
142 // console.log("hopAromaContribution("+bt+","+vol+","+use+","+amount+"): "+result);
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
143 return result;
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
144 }
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
145
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
146 function calcIBUs() {
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
147 var total_ibus = 0;
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
148 hop_aroma = hop_flavour = 0;
125
f2c79ed6423a Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
149 var rows = $('#hopGrid').jqxGrid('getrows');
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
150 for (var i = 0; i < rows.length; i++) {
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
151 var row = rows[i];
125
f2c79ed6423a Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
152 total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')),
f2c79ed6423a Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
153 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), $("#ibu_method").val());
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
154 hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat($("#batch_size").jqxNumberInput('decimal')),
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
155 row.h_useat, parseFloat(row.h_amount));
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
156 hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat($("#batch_size").jqxNumberInput('decimal')),
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
157 row.h_useat, parseFloat(row.h_amount));
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
158 }
137
dfbf43b2797e Store calculated estimate ibu and estimate fg.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
159 total_ibus = Math.round(total_ibus);
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
160 console.log("calcIBUs(): " + total_ibus + " flavour: " + hop_flavour + " aroma: " + hop_aroma);
137
dfbf43b2797e Store calculated estimate ibu and estimate fg.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
161 dataRecord.est_ibu = total_ibus;
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
162 $('#est_ibu').val(total_ibus);
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
163 $('#est_ibu2').val(total_ibus);
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
164 $("#hop_flavour").jqxProgressBar('val', hop_flavour * 10);
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
165 $("#hop_aroma").jqxProgressBar('val', hop_aroma * 10);
73
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
166 };
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
167
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
168 function calcSVG() {
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
169 var rows = $('#yeastGrid').jqxGrid('getrows');
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
170 for (var i = 0; i < rows.length; i++) {
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
171 var row = rows[i];
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
172 if (row.y_use == "Primary")
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
173 svg = parseFloat(row.y_attenuation);
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
174 }
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
175 }
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
176
133
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
177 function calcFermentablesFromOG(OG) {
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
178
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
179 console.log("calcFermentablesFromOG("+OG+")");
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
180 var i;
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
181 var efficiency = parseFloat($("#efficiency").jqxNumberInput('decimal'));
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
182 var rows = $('#fermentableGrid').jqxGrid('getrows');
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
183 var sug = sg_to_plato(OG) * parseFloat($("#batch_size").jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
184 var tot = 0;
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
185 var d;
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
186 for (i = 0; i < rows.length; i++) {
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
187 row = rows[i];
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
188 d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100);
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
189 if (row.f_added == "Mash")
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
190 d = efficiency / 100 * d;
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
191 tot += d;
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
192 }
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
193
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
194 var totmass = 0;
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
195 if (tot)
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
196 totmass = sug / tot;
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
197
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
198 if (totmass) {
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
199 for (i = 0; i < rows.length; i++) {
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
200 row = rows[i];
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
201 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_amount", row.f_percentage / 100 * totmass);
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
202 }
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
203 }
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
204 //CalcWaterBalance;
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
205 };
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
206
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
207 function calcABV() {
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
208 $("#est_abv").val(abvol(parseFloat($("#est_og").jqxNumberInput('decimal')), parseFloat($("#est_fg").jqxNumberInput('decimal'))));
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
209 };
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
210
73
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
211 function calcInit () {
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
212 console.log("calc.init()");
135
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
213
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
214 $('#color_method').on('change', function (event) { calcFermentables(); });
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
215 $('#ibu_method').on('change', function (event) {
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
216 calcFermentables();
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
217 calcIBUs();
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
218 });
134
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
219 $('#batch_size').on('change', function (event) {
135
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
220 console.log("batch_size change:"+event.args.value+" old:"+dataRecord.batch_size);
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
221 var new_boil = parseFloat(event.args.value) + dataRecord.boil_size - dataRecord.batch_size;
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
222 dataRecord.boil_size = new_boil;
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
223 $("#boil_size").val(Math.round(new_boil * 100) / 100);
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
224 dataRecord.batch_size = parseFloat(event.args.value);
134
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
225 calcFermentablesFromOG(parseFloat($("#est_og").jqxNumberInput('decimal'))); // Keep the OG
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
226 calcFermentables();
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
227 calcSVG();
134
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
228 calcABV();
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
229 // TODO: adjust the hops, miscs, yeast, water.
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
230 calcIBUs();
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
231 });
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
232 $('#boil_time').on('change', function (event) {
135
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
233 console.log("boil_time change:"+parseFloat(event.args.value)+" old:"+dataRecord.boil_time);
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
234 var old_evap = parseFloat(dataRecord.boil_size) - parseFloat(dataRecord.batch_size);
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
235 var new_evap = old_evap * (parseFloat(event.args.value) / dataRecord.boil_time);
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
236 var new_boil = parseFloat(dataRecord.batch_size) + new_evap;
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
237 // console.log("old_evap:"+old_evap+" new_evap:"+new_evap+" new_boil:"+new_boil);
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
238 dataRecord.boil_time = parseFloat(event.args.value);
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
239 dataRecord.boil_size = new_boil;
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
240 $("#boil_size").val(Math.round(new_boil * 100) / 100);
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
241 calcFermentables();
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
242 calcSVG();
135
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
243 calcABV();
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
244 // TODO: adjust the hops, miscs, yeast, water.
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
245 calcIBUs();
134
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
246 });
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
247 $('#efficiency').on('change', function (event) {
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
248 console.log("efficiency change:"+event.args.value);
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
249 calcFermentables();
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
250 calcSVG();
134
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
251 calcABV();
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
252 calcIBUs();
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
253 });
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
254 $('#est_og').on('change', function (event) {
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
255 console.log("est_og change:"+event.args.value);
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
256 calcFermentablesFromOG(event.args.value); // Adjust fermentables amounts
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
257 calcFermentables(); // Update the recipe details
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
258 calcSVG();
134
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
259 calcABV(); // and ABV
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
260 calcIBUs(); // and the IBU's.
be59b9127978 Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents: 133
diff changeset
261 });
73
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
262 };
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
263
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
264 $("#styleSelect").jqxDropDownList({
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
265 placeHolder: "Kies bierstijl:",
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
266 theme: theme,
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
267 source: styleslist,
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
268 displayMember: "name",
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
269 width: 150,
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
270 height: 27,
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
271 dropDownVerticalAlignment: 'top',
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
272 dropDownWidth: 500,
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
273 dropDownHeight: 380,
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
274 renderer: function (index, label, value) {
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
275 var datarecord = styleslist.records[index];
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
276 return datarecord.style_guide + " " + datarecord.style_letter+ " " + datarecord.name;
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
277 }
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
278 });
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
279 $("#styleSelect").on('select', function (event) {
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
280 if (event.args) {
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
281 var index = event.args.index;
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
282 var datarecord = styleslist.records[index];
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
283 $("#st_name").val(datarecord.name);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
284 $("#st_category").val(datarecord.category);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
285 $("#st_category_number").val(datarecord.category_number);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
286 $("#st_letter").val(datarecord.style_letter);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
287 $("#st_guide").val(datarecord.style_guide);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
288 $("#st_type").val(datarecord.type);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
289 $("#st_og_min").val(datarecord.og_min);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
290 $("#st_og_max").val(datarecord.og_max);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
291 $("#st_fg_min").val(datarecord.fg_min);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
292 $("#st_fg_max").val(datarecord.fg_max);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
293 $("#st_ibu_min").val(datarecord.ibu_min);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
294 $("#st_ibu_max").val(datarecord.ibu_max);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
295 $("#st_color_min").val(datarecord.color_min);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
296 $("#st_color_max").val(datarecord.color_max);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
297 $("#st_carb_min").val(datarecord.carb_min);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
298 $("#st_carb_max").val(datarecord.carb_max);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
299 $("#st_abv_min").val(datarecord.abv_min);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
300 $("#st_abv_max").val(datarecord.abv_max);
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
301 }
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
302 });
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
303
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304 var url = "includes/db_recipes.php";
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 // tooltips
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 $("#name").jqxTooltip({ content: 'De naam voor dit recept.' });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
308 $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' });
95
8dc0a00b1db4 Boil_size volume toegevoegd.
Michiel Broek <mbroek@mbse.eu>
parents: 85
diff changeset
309 $("#batch_size").jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' });
8dc0a00b1db4 Boil_size volume toegevoegd.
Michiel Broek <mbroek@mbse.eu>
parents: 85
diff changeset
310 $("#boil_time").jqxTooltip({ content: 'De kooktijd in minuten.' });
8dc0a00b1db4 Boil_size volume toegevoegd.
Michiel Broek <mbroek@mbse.eu>
parents: 85
diff changeset
311 $("#boil_size").jqxTooltip({ content: 'Het volume van het wort voor het koken.' });
8dc0a00b1db4 Boil_size volume toegevoegd.
Michiel Broek <mbroek@mbse.eu>
parents: 85
diff changeset
312 $("#efficiency").jqxTooltip({ content: 'Het rendement van maischen en koken.' });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
313 $("#est_og").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' });
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
314 $("#est_og2").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
315 $("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
316 $("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
317 $("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
318 $("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
319 $("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
320 $("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
321 $("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
322
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'});
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
324 $("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
325 $("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
326 $("#st_category").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
327 $("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
328 $("#st_type").jqxTooltip({ content: 'Het bierstijl type.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
329 $("#st_og_min").jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
330 $("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
331 $("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
332 $("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
333 $("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
334 $("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
335 $("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
336 $("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
337 $("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
338 $("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
339 $("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
340 $("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'});
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
341
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342 // prepare the data
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343 var source = {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 datatype: "json",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
345 cache: false,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
346 datafields: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 { name: 'record', type: 'number' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348 { name: 'st_name', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349 { name: 'st_letter', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350 { name: 'st_guide', type: 'string' },
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
351 { name: 'st_type', type: 'string' },
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
352 { name: 'st_category', type: 'string' },
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
353 { name: 'st_category_number', type: 'float' },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 { name: 'st_og_min', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355 { name: 'st_og_max', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 { name: 'st_fg_min', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 { name: 'st_fg_max', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358 { name: 'st_ibu_min', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
359 { name: 'st_ibu_max', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360 { name: 'st_color_min', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
361 { name: 'st_color_max', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
362 { name: 'st_carb_min', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
363 { name: 'st_carb_max', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
364 { name: 'st_abv_min', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 { name: 'st_abv_max', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 { name: 'name', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
367 { name: 'notes', type: 'string' },
71
e1c50b21b7e3 Added new recipe screens and wizzard.
Michiel Broek <mbroek@mbse.eu>
parents: 69
diff changeset
368 { name: 'type', type: 'string' },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 { name: 'batch_size', type: 'float' },
95
8dc0a00b1db4 Boil_size volume toegevoegd.
Michiel Broek <mbroek@mbse.eu>
parents: 85
diff changeset
370 { name: 'boil_size', type: 'float' },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 { name: 'boil_time', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372 { name: 'efficiency', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373 { name: 'est_og', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
374 { name: 'est_fg', type: 'float' },
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
375 { name: 'est_abv', type: 'float' },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
376 { name: 'est_color', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
377 { name: 'color_method', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
378 { name: 'est_ibu', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
379 { name: 'ibu_method', type: 'string' },
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
380 { name: 'est_carb', type: 'float' },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
381 { name: 'mash_sparge_temp', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
382 { name: 'mash_ph', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
383 { name: 'mash_name', type: 'string' },
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
384 { name: 'fermentables', type: 'array' },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
385 { name: 'hops', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386 { name: 'miscs', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
387 { name: 'yeasts', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
388 { name: 'waters', type: 'array' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
389 { name: 'mashs', type: 'string' }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
390 ],
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391 id: 'record',
130
601920b902e5 Load a single recipe from the database instead of client side select.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
392 url: url + '?record=' + my_record
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
394 // Load data and select one record.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395 var dataAdapter = new $.jqx.dataAdapter(source, {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 loadComplete: function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 var records = dataAdapter.records;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398 dataRecord = records[0];
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 $("#name").val(dataRecord.name);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400 $("#notes").val(dataRecord.notes);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 $("#st_name").val(dataRecord.st_name);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402 $("#st_letter").val(dataRecord.st_letter);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403 $("#st_guide").val(dataRecord.st_guide);
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
404 $("#st_category").val(dataRecord.st_category);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
405 $("#st_category_number").val(dataRecord.st_category_number);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
406 $("#st_type").val(dataRecord.st_type);
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
407 $("#type").val(dataRecord.type);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
408 $("#batch_size").val(dataRecord.batch_size);
95
8dc0a00b1db4 Boil_size volume toegevoegd.
Michiel Broek <mbroek@mbse.eu>
parents: 85
diff changeset
409 $("#boil_size").val(dataRecord.boil_size);
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
410 $("#boil_time").val(dataRecord.boil_time);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
411 $("#efficiency").val(dataRecord.efficiency);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
412 $("#est_og").val(dataRecord.est_og);
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
413 $("#est_og2").val(dataRecord.est_og);
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
414 $("#st_og_min").val(dataRecord.st_og_min);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
415 $("#st_og_max").val(dataRecord.st_og_max);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
416 $("#est_fg").val(dataRecord.est_fg);
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
417 $("#st_fg_min").val(dataRecord.st_fg_min);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
418 $("#st_fg_max").val(dataRecord.st_fg_max);
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
419 $("#est_color").val(dataRecord.est_color);
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
420 $("#est_color2").val(dataRecord.est_color);
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
421 $("#est_abv").val(dataRecord.est_abv);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
422 $("#st_abv_min").val(dataRecord.st_abv_min);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
423 $("#st_abv_max").val(dataRecord.st_abv_max);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
424 $("#st_color_min").val(dataRecord.st_color_min);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
425 $("#st_color_max").val(dataRecord.st_color_max);
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
426 $("#color_method").val(dataRecord.color_method);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427 $("#est_ibu").val(dataRecord.est_ibu);
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
428 $("#est_ibu2").val(dataRecord.est_ibu);
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
429 $("#st_ibu_min").val(dataRecord.st_ibu_min);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
430 $("#st_ibu_max").val(dataRecord.st_ibu_max);
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431 $("#ibu_method").val(dataRecord.ibu_method);
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
432 $("#est_carb").val(dataRecord.est_carb);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
433 $("#st_carb_min").val(dataRecord.st_carb_min);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
434 $("#st_carb_max").val(dataRecord.st_carb_max);
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435 $("#mash_name").val(dataRecord.mash_name);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 $("#mash_ph").val(dataRecord.mash_ph);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
437 $("#mash_sparge_temp").val(dataRecord.mash_sparge_temp);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 editFermentable(dataRecord);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439 editHop(dataRecord);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440 editMisc(dataRecord);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441 editYeast(dataRecord);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
442 editWater(dataRecord);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443 editMash(dataRecord);
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
444 $('#jqxTabs').jqxTabs('next');
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 loadError: function (jqXHR, status, error) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448 beforeLoadComplete: function (records) {
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
449 $('#jqxLoader').jqxLoader('open');
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
451 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452 dataAdapter.dataBind();
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454 // Inline fermentables editor
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
455 var editFermentable = function (data) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456 var fermentableSource = {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
457 localdata: data.fermentables,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458 datatype: "local",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459 datafields: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 { name: 'f_name', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 { name: 'f_origin', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
462 { name: 'f_supplier', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
463 { name: 'f_amount', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
464 { name: 'f_cost', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
465 { name: 'f_type', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
466 { name: 'f_yield', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
467 { name: 'f_color', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
468 { name: 'f_coarse_fine_diff', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
469 { name: 'f_moisture', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
470 { name: 'f_diastatic_power', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
471 { name: 'f_protein', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
472 { name: 'f_max_in_batch', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
473 { name: 'f_graintype', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
474 { name: 'f_added', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
475 { name: 'f_dissolved_protein', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476 { name: 'f_recommend_mash', type: 'bool' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 { name: 'f_add_after_boil', type: 'bool' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478 { name: 'f_adjust_to_total_100', type: 'bool' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 { name: 'f_percentage', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480 { name: 'f_di_ph', type: 'float' }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
481 ],
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482 addrow: function (rowid, rowdata, position, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
485 deleterow: function (rowid, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
486 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
487 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
488 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
489 var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
490 $("#fermentableGrid").jqxGrid({
128
4d188d216c88 Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
491 width: 1150,
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
492 height: 400,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
493 source: fermentableAdapter,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
495 selectionmode: 'singlerow',
126
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
496 editmode: 'selectedcell',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497 editable: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 localization: getLocalization(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
499 showtoolbar: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500 rendertoolbar: function (toolbar) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 var me = this;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 toolbar.append(container);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504 container.append('<div style="float: left; margin-left: 165px;" id="faddrowbutton"></div>');
128
4d188d216c88 Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
505 container.append('<input style="float: left; margin-left: 505px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />');
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 // add fermentable from dropdownlist.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 $("#faddrowbutton").jqxDropDownList({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508 placeHolder: "Kies mout:",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510 source: fermentablelist,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 displayMember: "name",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 width: 150,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513 height: 27,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514 dropDownWidth: 500,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515 dropDownHeight: 500,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
516 renderer: function (index, label, value) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 var datarecord = fermentablelist.records[index];
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
518 return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)";
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
519 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
520 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
521 $("#faddrowbutton").on('select', function (event) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
522 if (event.args) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
523 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524 var index = event.args.index;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
525 var datarecord = fermentablelist.records[index];
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526 var row = {};
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
527 row["f_name"] = datarecord.name;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528 row["f_origin"] = datarecord.origin;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529 row["f_supplier"] = datarecord.supplier;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
530 row["f_amount"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
531 row["f_cost"] = datarecord.cost;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
532 row["f_type"] = datarecord.type;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
533 row["f_yield"] = datarecord.yield;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534 row["f_color"] = datarecord.color;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
535 row["f_coarse_fine_diff"] = datarecord.coarse_fine_diff;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536 row["f_moisture"] = datarecord.moisture;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
537 row["f_diastatic_power"] = datarecord.diastatic_power;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
538 row["f_protein"] = datarecord.protein;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
539 row["f_max_in_batch"] = datarecord.max_in_batch;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
540 row["f_graintype"] = datarecord.graintype;
73
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
541 if (datarecord.add_after_boil) {
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
542 row["f_added"] = "Primary";
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
543 } else if ((datarecord.type == "Sugar") || (datarecord.type == "Adjunct")) {
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
544 row["f_added"] = "Boil";
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
545 } else {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
546 row["f_added"] = "Mash";
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
547 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
548 row["f_dissolved_protein"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
549 row["f_recommend_mash"] = datarecord.recommend_mash;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
550 row["f_add_after_boil"] = datarecord.add_after_boil;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
551 if (rowscount == 0) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
552 // The first fermentable
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
553 row["f_adjust_to_total_100"] = 1;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554 row["f_percentage"] = 100;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555 } else {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556 row["f_adjust_to_total_100"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557 row["f_percentage"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559 row["f_di_ph"] = datarecord.di_ph;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560 var commit = $("#fermentableGrid").jqxGrid('addrow', null, row);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
564 // delete selected fermentable.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
565 $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566 $("#fdeleterowbutton").on('click', function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567 var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570 var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex);
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
571 var percent = $('#fermentableGrid').jqxGrid('getcellvalue', id, "f_percentage");
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
572 var amount = $('#fermentableGrid').jqxGrid('getcellvalue', id, "f_amount");
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 var commit = $("#fermentableGrid").jqxGrid('deleterow', id);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574 }
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
575 rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
576 if (rowscount > 1) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
577 if (to_100) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
578 for (var i = 0; i < rowscount; i++) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
579 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
580 if (rowdata.f_adjust_to_total_100) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
581 rowdata.f_percentage += percent;
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
582 rowdata.f_amount += amount;
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
583 }
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
584 }
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
585 } else {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
586 var tw = 0;
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
587 for (i = 0; i < rowscount; i++) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
588 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
589 tw += rowdata.f_amount;
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
590 };
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
591 for (i = 0; i < rowscount; i++) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
592 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
593 var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0;
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
594 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage);
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
595 };
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
596 }
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
597 } else {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
598 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100);
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
599 }
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
600 calcFermentables();
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
601 calcSVG();
133
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
602 calcABV();
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
603 calcIBUs();
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605 },
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
606 ready: function() {
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
607 calcFermentables();
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
608 $('#jqxTabs').jqxTabs('next');
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
609 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
610 columns: [
128
4d188d216c88 Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
611 { text: 'Vergistbaar ingredi&euml;nt', editable: false, datafield: 'f_name',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613 var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row);
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
614 return "<span style='margin: 3px; margin-top: 6px; float: "+
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
615 columnproperties.cellsalign+"'>" +rowData.f_supplier+" / "+rowData.f_name+" ("+rowData.f_color+" EBC)</span>";
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
616 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617 },
128
4d188d216c88 Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
618 { text: 'Type', editable: false, align: 'center', cellsalign: 'center', width: 100, datafield: 'f_type' },
127
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
619 { text: 'Moment', width: 110, align: 'center', cellsalign: 'center', datafield: 'f_added', columntype: 'dropdownlist',
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
620 createeditor: function (row, column, editor) {
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
621 var srcAdded = [ "Mash", "Boil", "Fermentation", "Lagering", "Bottle" ];
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
622 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcAdded });
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
623 }
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
624 },
128
4d188d216c88 Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
625 { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
626 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
627 columntype: 'numberinput',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
628 validation: function (cell, value) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
629 // Maximum weight is the batch_size, just a simple check.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630 var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal'));
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
631 if (value < 0 || value > maxmout) {
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
632 return { result: false, message: "Gewicht moet 0-"+maxmout+" zijn" };
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
633 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634 return true;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
635 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
636 initeditor: function (row, cellvalue, editor) {
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
637 editor.jqxNumberInput({ inputMode: 'simple', min: 0, decimalDigits: 3, spinButtons: false });
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
638 },
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
639 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
640 if (to_100) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
641 return oldvalue; // When using percentages, don't allow edited results.
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
642 }
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 },
128
4d188d216c88 Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
645 { text: 'Percentage', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646 columntype: 'numberinput',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647 validation: function (cell, value) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648 if (value < 0 || value > 100) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 return { result: false, message: "Percentage moet 0-100 zijn" };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
650 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 return true;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 initeditor: function (row, cellvalue, editor) {
126
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
654 editor.jqxNumberInput({ decimalDigits: 1, min: 0, max: 100, spinButtons: false });
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
655 },
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
656 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
657 oldvalue = Math.round(oldvalue * 10) / 10.0;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
658 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
659 if ((oldvalue != newvalue) && (rowscount > 1)) {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
660 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row);
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
661 if (rowdata.f_adjust_to_total_100) {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
662 return oldvalue;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
663 }
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
664 var diff = newvalue - oldvalue;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
665 var tw = 0; // total weight
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
666 for (i = 0; i < rowscount; i++) {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
667 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
668 tw += rowdata.f_amount;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
669 }
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
670 if (to_100) {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
671 // Adjust this row and the 100% row.
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
672 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row);
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
673 rowdata.f_amount += tw * diff / 100;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
674 for (i = 0; i < rowscount; i++) {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
675 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
676 if (rowdata.f_adjust_to_total_100) {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
677 rowdata.f_percentage -= diff;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
678 rowdata.f_amount -= tw * diff / 100;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
679 }
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
680 }
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
681 } else {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
682 // Adjust all the rows.
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
683 var nw = tw * diff / 100;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
684 for (i = 0; i < rowscount; i++) {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
685 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
686 if (i == row) {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
687 rowdata.f_amount += nw;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
688 } else {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
689 rowdata.f_amount -= nw / (rowscount - 1);
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
690 rowdata.f_percentage = Math.round((rowdata.f_amount / tw) * 1000) / 10.0;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
691 }
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
692 }
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
693 }
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
694 }
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
695 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 },
127
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
697 { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80,
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
698 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
699 if (to_100) {
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
700 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
701 for (i = 0; i < rowscount; i++) {
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
702 if (i != row) {
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
703 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
704 rowdata.f_adjust_to_total_100 = false;
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
705 }
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
706 }
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
707 }
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
708 }
6d5e215d77d2 Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
709 }
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
710 ]
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
711 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
712 $("#fermentableGrid").on('cellendedit', function (event) {
126
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
713 var args = event.args;
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
714 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
715 // Make sure the grid itself is updated.
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
716 $("#fermentableGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
717 if ((args.datafield == 'f_amount') && (! to_100)) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
718 // If one of the amounts is changed, recalculate the percentages.
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
719 console.log("adjust percentages");
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
720 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
721 if (rowscount > 1) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
722 var tw = 0;
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
723 for (i = 0; i < rowscount; i++) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
724 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
725 tw += rowdata.f_amount;
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
726 };
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
727 for (i = 0; i < rowscount; i++) {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
728 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
729 var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0;
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
730 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage);
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
731 };
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
732 } else {
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
733 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100);
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
734 }
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
735 };
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
736 $('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc'); // TODO: not reliable
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
737 calcFermentables();
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
738 calcSVG();
133
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
739 calcABV();
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
740 calcIBUs(); // Depends on gravity, so recalculate.
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
741 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
742 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
743
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744 // Inline hops editor
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
745 var editHop = function (data) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
746 var hopSource = {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
747 localdata: data.hops,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
748 datatype: "local",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
749 cache: false,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
750 datafields: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
751 { name: 'h_name', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752 { name: 'h_origin', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
753 { name: 'h_amount', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754 { name: 'h_cost', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
755 { name: 'h_type', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756 { name: 'h_form', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
757 { name: 'h_useat', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758 { name: 'h_time', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
759 { name: 'h_alpha', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760 { name: 'h_beta', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761 { name: 'h_hsi', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762 { name: 'h_humulene', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
763 { name: 'h_carophyllene', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
764 { name: 'h_cohumulone', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
765 { name: 'h_myrcene', type: 'float' },
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
766 { name: 'h_total_oil', type: 'float' },
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
767 { name: 'h_weight', type: 'float' }
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768 ],
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
769 addrow: function (rowid, rowdata, position, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
770 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
771 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
772 deleterow: function (rowid, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
773 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
774 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
775 };
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
776 var hopAdapter = new $.jqx.dataAdapter(hopSource, {
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
777 beforeLoadComplete: function (records) {
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
778 var data = new Array();
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
779 for (var i = 0; i < records.length; i++) {
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
780 var row = records[i];
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
781 row.h_weight = row.h_amount * 1000;
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
782 data.push(row);
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
783 }
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
784 return data;
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
785 },
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
786 loadError: function(jqXHR, status, error) {
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
787 $('#err').text(status + ' ' + error);
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
788 },
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
789 });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
790 $("#hopGrid").jqxGrid({
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
791 width: 1050,
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
792 height: 400,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
793 source: hopAdapter,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
794 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
795 selectionmode: 'singlerow',
125
f2c79ed6423a Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
796 editmode: 'selectedcell',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
797 editable: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
798 localization: getLocalization(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
799 showtoolbar: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
800 rendertoolbar: function (toolbar) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
801 var me = this;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
802 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
803 toolbar.append(container);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
804 container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
805 container.append('<input style="float: left; margin-left: 230px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
806 // add hop from dropdownlist.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
807 $("#haddrowbutton").jqxDropDownList({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
808 placeHolder: "Kies hop:",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
809 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
810 source: hoplist,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
811 displayMember: "name",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
812 width: 150,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
813 height: 27,
69
ca25fdce3b85 Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents: 68
diff changeset
814 dropDownWidth: 500,
ca25fdce3b85 Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents: 68
diff changeset
815 dropDownHeight: 500,
ca25fdce3b85 Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents: 68
diff changeset
816 renderer: function (index, label, value) {
ca25fdce3b85 Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents: 68
diff changeset
817 var datarecord = hoplist.records[index];
ca25fdce3b85 Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents: 68
diff changeset
818 return datarecord.origin+ " / " + datarecord.name + " (" + datarecord.alpha + "% &alpha;)";
ca25fdce3b85 Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents: 68
diff changeset
819 }
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
820 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
821 $("#haddrowbutton").on('select', function (event) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
822 if (event.args) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
823 var index = event.args.index;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
824 var datarecord = hoplist.records[index];
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
825 var row = {};
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
826 row["h_name"] = datarecord.name;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
827 row["h_origin"] = datarecord.origin;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
828 row["h_amount"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
829 row["h_cost"] = datarecord.cost;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
830 row["h_type"] = datarecord.type;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
831 row["h_form"] = datarecord.form;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
832 row["h_useat"] = datarecord.useat;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
833 row["h_time"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
834 row["h_alpha"] = datarecord.alpha;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
835 row["h_beta"] = datarecord.beta;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
836 row["h_hsi"] = datarecord.hsi;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
837 row["h_humulene"] = datarecord.humulene;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
838 row["h_carophyllene"] = datarecord.carophyllene;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
839 row["h_cohumulone"] = datarecord.cohumulone;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
840 row["h_myrcene"] = datarecord.myrcene;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
841 row["h_total_oil"] = datarecord.total_oil;
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
842 row["h_weight"] = 0;
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
843 var commit = $("#hopGrid").jqxGrid('addrow', null, row);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
844 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
845 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
846
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
847 // delete selected hop.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
848 $("#hdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
849 $("#hdeleterowbutton").on('click', function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
850 var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
851 var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
852 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
853 var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
854 var commit = $("#hopGrid").jqxGrid('deleterow', id);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
855 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
856 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
857 },
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
858 ready: function() {
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
859 $('#jqxTabs').jqxTabs('next');
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
860 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
861 columns: [
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
862 { text: 'Hop', editable: false, datafield: 'h_name',
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
863 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) {
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
864 var rowData = $("#hopGrid").jqxGrid('getrowdata', row);
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
865 return "<span style='margin: 3px; margin-top: 6px; float: "+
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
866 columnproperties.cellsalign+"'>" +rowData.h_origin+" / "+rowData.h_name+"</span>";
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
867 },
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
868 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
869 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
870 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' },
131
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
871 { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
872 { text: 'Amount', hidden: true, datafield: 'h_amount' },
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
873 { text: 'Gewicht gr', datafield: 'h_weight', width: 120, align: 'right', cellsalign: 'right',
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
874 columntype: 'numberinput',
140
93c64d7ac79c Hops grid editor amount is now in grams.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
875 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
876 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(value, "f1") + " gr</div>";
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
877 },
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
878 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
879 editor.jqxNumberInput({
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
880 inputMode: 'simple',
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
881 symbol: ' gr', symbolPosition: 'right',
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
882 decimalDigits: 1,
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
883 min: 0, max: parseFloat(dataRecord.batch_size * 200),
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
884 spinButtons: false
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
885 });
140
93c64d7ac79c Hops grid editor amount is now in grams.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
886 },
93c64d7ac79c Hops grid editor amount is now in grams.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
887 validation: function (cell, value) {
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
888 var maxhops = parseFloat(dataRecord.batch_size) * 200;
140
93c64d7ac79c Hops grid editor amount is now in grams.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
889 if (value < 0 || value > maxhops ) {
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
890 return { result: false, message: "Gewicht moet tussen 0 en "+maxhops+" gram zijn" };
140
93c64d7ac79c Hops grid editor amount is now in grams.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
891 }
93c64d7ac79c Hops grid editor amount is now in grams.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
892 return true;
93c64d7ac79c Hops grid editor amount is now in grams.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
893 }
93c64d7ac79c Hops grid editor amount is now in grams.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
894 },
126
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
895 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist',
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
896 createeditor: function (row, column, editor) {
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
897 var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ];
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
898 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse });
131
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
899 },
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
900 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
901 if ((newvalue == "Mash") || (newvalue == "First Wort")) {
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
902 $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", parseFloat(dataRecord.boil_time));
131
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
903 } else if (newvalue == "Aroma") {
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
904 $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", 0);
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
905 }
126
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
906 }
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
907 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
908 { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
909 columntype: 'numberinput',
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
910 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
911 if ((rowdata.h_useat == "Boil") || (rowdata.h_useat == "Dry Hop") || (rowdata.h_useat == "Dry hop"))
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
912 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+"</div>";
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
913 else
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
914 return "<div style='margin: 4px;' class='jqx-right-align'> </div>";
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
915 },
125
f2c79ed6423a Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
916 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
917 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) });
125
f2c79ed6423a Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
918 },
131
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
919 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
920 var use = $("#hopGrid").jqxGrid('getcellvalue', row, "h_useat");
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
921 if ((use == "Mash") || (use == "First Wort") || (use == "First wort") || (use == "Aroma"))
131
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
922 return oldvalue;
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
923 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
924 validation: function (cell, value) {
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
925 var high = parseFloat(dataRecord.boil_time);
125
f2c79ed6423a Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
926 if (value < 0 || value > high ) {
f2c79ed6423a Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
927 return { result: false, message: "De tijd moet 0-"+high+" zijn" };
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
928 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
929 return true;
132
aaefac2d08a3 Code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
930 }
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
931 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
932 { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
933 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
934 var ibu = toIBU(rowdata.h_useat,
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
935 rowdata.h_form,
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
936 preboil_sg,
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
937 parseFloat($("#batch_size").jqxNumberInput('decimal')),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
938 parseFloat(rowdata.h_amount),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
939 parseFloat(rowdata.h_time),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
940 parseFloat(rowdata.h_alpha),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
941 $("#ibu_method").val()
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
942 );
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
943 calcIBUs();
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
944 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>";
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
945 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
946 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
947 ]
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
948 });
131
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
949 $("#hopGrid").on('cellendedit', function (event) {
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
950 var args = event.args;
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
951 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
142
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
952 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
953 if (args.datafield == 'h_weight')
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
954 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, 'h_amount', args.value / 1000);
793af7691a5e During hops load an extra weight in grams field is generated for the grid. Edit the amount is done on the weight field and the amount field is updated too. During save to the database the extra field is removed.
Michiel Broek <mbroek@mbse.eu>
parents: 141
diff changeset
955 //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc');
131
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 130
diff changeset
956 });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
957 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
958
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
959 // Inline miscs editor
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
960 var editMisc = function (data) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
961 var miscSource = {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
962 localdata: data.miscs,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
963 datatype: "local",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
964 cache: false,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
965 datafields: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
966 { name: 'm_name', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
967 { name: 'm_amount', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
968 { name: 'm_cost', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
969 { name: 'm_type', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
970 { name: 'm_use_use', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
971 { name: 'm_time', type: 'float' },
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
972 { name: 'm_amount_is_weight', type: 'bool' },
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
973 { name: 'm_weight', type: 'float' }
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
974 ],
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
975 addrow: function (rowid, rowdata, position, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
976 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
977 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
978 deleterow: function (rowid, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
979 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
980 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
981 };
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
982 var miscAdapter = new $.jqx.dataAdapter(miscSource, {
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
983 beforeLoadComplete: function (records) {
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
984 var data = new Array();
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
985 for (var i = 0; i < records.length; i++) {
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
986 var row = records[i];
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
987 row.m_weight = row.m_amount * 1000;
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
988 data.push(row);
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
989 }
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
990 return data;
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
991 },
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
992 loadError: function(jqXHR, status, error) {
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
993 $('#err').text(status + ' ' + error);
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
994 },
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
995 });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
996 $("#miscGrid").jqxGrid({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
997 width: 960,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
998 height: 400,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
999 source: miscAdapter,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1000 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1001 selectionmode: 'singlerow',
126
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
1002 editmode: 'selectedcell',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1003 editable: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1004 localization: getLocalization(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1005 showtoolbar: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1006 rendertoolbar: function (toolbar) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1007 var me = this;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1008 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1009 toolbar.append(container);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1010 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1011 container.append('<input style="float: left; margin-left: 230px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1012 // add misc from dropdownlist.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1013 $("#maddrowbutton").jqxDropDownList({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1014 placeHolder: "Kies ingredient:",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1015 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1016 source: misclist,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1017 displayMember: "name",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1018 width: 150,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1019 height: 27,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1020 dropDownWidth: 300
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1021 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1022 $("#maddrowbutton").on('select', function (event) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1023 if (event.args) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1024 var index = event.args.index;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1025 var datarecord = misclist.records[index];
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1026 var row = {};
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1027 row["m_name"] = datarecord.name;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1028 row["m_amount"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1029 row["m_cost"] = datarecord.cost;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1030 row["m_type"] = datarecord.type;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1031 row["m_use_use"] = datarecord.use_use;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1032 row["m_time"] = 0;
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1033 row["m_weight"] = 0;
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1034 row["m_amount_is_weight"] = datarecord.amount_is_weight;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1035 var commit = $("#miscGrid").jqxGrid('addrow', null, row);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1036 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1037 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1038 // delete selected misc.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1039 $("#mdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1040 $("#mdeleterowbutton").on('click', function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1041 var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1042 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount;
145
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1043 var type = $("#miscGrid").jqxGrid('getcellvalue', selectedrowindex, "m_type");
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1044 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != "Water agent") {
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1045 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1046 var commit = $("#miscGrid").jqxGrid('deleterow', id);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1047 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1048 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1049 },
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1050 ready: function() {
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1051 $('#jqxTabs').jqxTabs('next');
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1052 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1053 columns: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1054 { text: 'Ingredient', editable: false, datafield: 'm_name' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1055 { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' },
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1056 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'm_use_use', columntype: 'dropdownlist',
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1057 createeditor: function (row, column, editor) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1058 var srcUseUse = [ "Mash", "Boil", "Primary", "Secondary", "Bottling" ];
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1059 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUseUse });
145
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1060 },
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1061 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1062 var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type");
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1063 if (type == "Water agent")
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1064 return oldvalue;
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1065 }
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1066 },
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1067 { datafield: 'm_amount_is_weight', hidden: true }, // We need to declare this column
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1068 { datafield: 'm_amount', hidden: true }, // We need to declare this column
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1069 { text: 'Hoeveelheid', datafield: 'm_weight', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f2',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1070 columntype: 'numberinput',
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1071 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1072 var vstr = rowdata.m_amount_is_weight ? "gr":"ml";
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1073 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value,"f2")+" "+vstr+"</div>";
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1074 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1075 validation: function (cell, value) {
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1076 var high = parseFloat(dataRecord.boil_size) * 1000;
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1077 if (value < 0 || value > high) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1078 return { result: false, message: "Hoeveelheid moet tussen 0 en "+high+" zijn" };
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1079 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1080 return true;
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1081 },
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1082 initeditor: function (row, cellvalue, editor) {
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1083 editor.jqxNumberInput({
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1084 inputMode: 'simple', min: 0, max: parseFloat(dataRecord.boil_size) * 1000,
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1085 decimalDigits: 2, spinButtons: false
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1086 });
145
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1087 },
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1088 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1089 var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type");
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1090 if (type == "Water agent")
2662720e1949 Protect misc Water agent ingredients against delete and changing from the miscs editor.
Michiel Broek <mbroek@mbse.eu>
parents: 144
diff changeset
1091 return oldvalue;
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1092 }
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1093 },
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1094 { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1095 columntype: 'numberinput',
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1096 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1097 if (rowdata.m_use_use == 'Boil') {
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1098 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" m</div>";
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1099 } else if (rowdata.m_use_use == 'Secondary') {
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1100 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" d</div>";
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1101 } else {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1102 var tijd = 0;
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1103 return "<div style='margin: 4px;' class='jqx-right-align'> </div>";
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1104 }
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1105 },
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1106 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1107 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) });
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1108 },
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1109 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1110 var use = $("#miscGrid").jqxGrid('getcellvalue', row, "m_use_use");
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1111 if ((use != "Boil") && (use != "Secondary"))
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1112 return oldvalue;
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1113 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1114 validation: function (cell, value) {
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1115 var high = parseFloat(dataRecord.boil_time);
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1116 if (value < 0 || value > high ) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1117 return { result: false, message: "De tijd moet 0-"+high+" zijn" };
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1118 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1119 return true;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1120 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1121 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1122 ]
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1123 });
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1124 $("#miscGrid").on('cellendedit', function (event) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1125 var args = event.args;
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1126 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1127 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1128 if (args.datafield == 'm_weight') {
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 142
diff changeset
1129 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_amount', parseFloat(args.value) / 1000);
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1130 }
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1131 });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1132 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1133
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1134 // Inline yeasts editor
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1135 var editYeast = function (data) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1136 var yeastSource = {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1137 localdata: data.yeasts,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1138 datatype: "local",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1139 cache: false,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1140 datafields: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1141 { name: 'y_name', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1142 { name: 'y_laboratory', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1143 { name: 'y_product_id', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1144 { name: 'y_amount', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1145 { name: 'y_cost', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1146 { name: 'y_type', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1147 { name: 'y_form', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1148 { name: 'y_time', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1149 { name: 'y_min_temperature', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1150 { name: 'y_max_temperature', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1151 { name: 'y_attenuation', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1152 { name: 'y_amount_is_weight', type: 'bool' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1153 { name: 'y_use', type: 'string' }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1154 ],
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1155 addrow: function (rowid, rowdata, position, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1156 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1157 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1158 deleterow: function (rowid, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1159 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1160 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1161 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1162 var yeastAdapter = new $.jqx.dataAdapter(yeastSource);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1163 $("#yeastGrid").jqxGrid({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1164 width: 1050,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1165 height: 300,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1166 source: yeastAdapter,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1167 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1168 selectionmode: 'singlerow',
126
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
1169 editmode: 'selectedcell',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1170 editable: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1171 localization: getLocalization(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1172 showtoolbar: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1173 rendertoolbar: function (toolbar) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1174 var me = this;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1175 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1176 toolbar.append(container);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1177 container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1178 container.append('<input style="float: left; margin-left: 230px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1179 // add yeast from dropdownlist.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1180 $("#yaddrowbutton").jqxDropDownList({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1181 placeHolder: "Kies gist:",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1182 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1183 source: yeastlist,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1184 displayMember: "name",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1185 width: 150,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1186 height: 27,
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1187 dropDownWidth: 500,
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1188 dropDownHeight: 500,
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1189 renderer: function (index, label, value) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1190 var datarecord = yeastlist.records[index];
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1191 return datarecord.laboratory+" "+datarecord.product_id+" "+datarecord.name;
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1192 }
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1193 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1194 $("#yaddrowbutton").on('select', function (event) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1195 if (event.args) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1196 var index = event.args.index;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1197 var datarecord = yeastlist.records[index];
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1198 var row = {};
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1199 row["y_name"] = datarecord.name;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1200 row["y_laboratory"] = datarecord.laboratory;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1201 row["y_product_id"] = datarecord.product_id;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1202 row["y_type"] = datarecord.type;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1203 row["y_form"] = datarecord.form;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1204 row["y_amount"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1205 row["y_cost"] = datarecord.cost;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1206 row["y_use"] = "Primary";
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1207 row["y_time"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1208 if (datarecord.form == "Dry") {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1209 row["y_amount_is_weight"] = 1;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1210 } else {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1211 row["y_amount_is_weight"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1212 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1213 row["y_min_temperature"] = datarecord.min_temperature;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1214 row["y_max_temperature"] = datarecord.max_temperature;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1215 row["y_attenuation"] = datarecord.attenuation;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1216 var commit = $("#yeastGrid").jqxGrid('addrow', null, row);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1217 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1218 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1219 // delete selected yeast.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1220 $("#ydeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1221 $("#ydeleterowbutton").on('click', function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1222 var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1223 var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1224 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1225 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1226 var commit = $("#yeastGrid").jqxGrid('deleterow', id);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1227 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1228 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1229 },
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1230 ready: function() {
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
1231 calcSVG();
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1232 $('#jqxTabs').jqxTabs('next');
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1233 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1234 columns: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1235 { text: 'Gist', editable: false, datafield: 'y_name' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1236 { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1237 { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1238 { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1239 { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1240 { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1241 { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' },
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1242 { text: 'Voor', width: 100, align: 'center', cellsalign: 'center', datafield: 'y_use', columntype: 'dropdownlist',
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1243 createeditor: function (row, column, editor) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1244 var srcYUse = [ "Primary", "Secondary", "Bottle" ];
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1245 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcYUse });
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1246 }
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1247 },
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1248 { datafield: 'y_amount', width: 90 },
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1249 { text: 'Hoeveel', datafield: 'amount', width: 110, align: 'right', cellsalign: 'right', columntype: 'numberinput',
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1250 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1251 if (rowdata.y_form == 'Liquid') {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1252 var hoeveel = rowdata.y_amount * 17;
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1253 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(hoeveel, "f0")+" pk</div>";
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1254 } else if (rowdata.y_form == 'Dry') {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1255 var hoeveel = rowdata.y_amount * 1000;
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1256 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(hoeveel, "f1")+" gr</div>";
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1257 } else {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1258 var hoeveel = rowdata.y_amount * 1000;
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1259 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(hoeveel, "f0")+" ml</div>";
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1260 }
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1261 },
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1262 initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1263 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form');
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1264 if (form == 'Liquid') {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1265 editor.jqxNumberInput({ decimalDigits: 0, min: 0 });
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1266 } else {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1267 editor.jqxNumberInput({ decimalDigits: 1, min: 0 });
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1268 }
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1269 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1270 validation: function (cell, value) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1271 if (value < 0 || value > 100000000000 ) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1272 return { result: false, message: "Volume moet 0-~ zijn" };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1273 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1274 return true;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1275 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1276 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1277 ]
141
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1278 });
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1279 $("#yeastGrid").on('cellendedit', function (event) {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1280 var args = event.args;
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1281 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1282 if (args.datafield == 'amount') {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1283 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form');
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1284 if (form == 'Liquid')
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1285 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value * 0.0588));
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1286 else
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1287 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value / 1000));
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1288 } else {
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1289 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1290 }
fe9e2a677611 The yeast droplist sorting order changed. Misc ingredients time editor uses minutes or days depending on the use of the ingredient. The yeast editor can now use grams, ml or packs.
Michiel Broek <mbroek@mbse.eu>
parents: 140
diff changeset
1291 });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1292 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1293
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1294 // Inline waters editor
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1295 var editWater = function (data) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1296 var waterSource = {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1297 localdata: data.waters,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1298 datatype: "local",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1299 datafields: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1300 { name: 'w_name', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1301 { name: 'w_amount', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1302 { name: 'w_calcium', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1303 { name: 'w_sulfate', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1304 { name: 'w_chloride', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1305 { name: 'w_sodium', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1306 { name: 'w_magnesium', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1307 { name: 'w_ph', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1308 { name: 'w_total_alkalinity', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1309 { name: 'w_cost', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1310 ],
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1311 addrow: function (rowid, rowdata, position, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1312 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1313 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1314 deleterow: function (rowid, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1315 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1316 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1317 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1318 var waterAdapter = new $.jqx.dataAdapter(waterSource);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1319 $("#waterGrid").jqxGrid({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1320 width: 960,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1321 height: 200,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1322 source: waterAdapter,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1323 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1324 selectionmode: 'singlerow',
126
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
1325 editmode: 'selectedcell',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1326 editable: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1327 localization: getLocalization(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1328 showtoolbar: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1329 rendertoolbar: function (toolbar) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1330 var me = this;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1331 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1332 toolbar.append(container);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1333 container.append('<div style="float: left; margin-left: 165px;" id="waddrowbutton"></div>');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1334 container.append('<input style="float: left; margin-left: 230px;" id="wdeleterowbutton" type="button" value="Verwijder water" />');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1335 // add water from dropdownlist.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1336 $("#waddrowbutton").jqxDropDownList({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1337 placeHolder: "Kies water:",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1338 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1339 source: waterlist,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1340 displayMember: "name",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1341 width: 150,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1342 height: 27,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1343 dropDownWidth: 300
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1344 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1345 $("#waddrowbutton").on('select', function (event) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1346 if (event.args) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1347 var index = event.args.index;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1348 var datarecord = waterlist.records[index];
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1349 var row = {};
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1350 row["w_name"] = datarecord.name;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1351 row["w_amount"] = 0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1352 row["w_calcium"] = datarecord.calcium;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1353 row["w_sulfate"] = datarecord.sulfate;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1354 row["w_chloride"] = datarecord.chloride;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1355 row["w_sodium"] = datarecord.sodium;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1356 row["w_magnesium"] = datarecord.magnesium;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1357 row["w_ph"] = datarecord.ph;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1358 row["w_total_alkalinity"] = datarecord.total_alkalinity;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1359 row["w_cost"] = datarecord.cost;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1360 var commit = $("#waterGrid").jqxGrid('addrow', null, row);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1361 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1362 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1363
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1364 // delete selected water.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1365 // Overgebleven waters in volume verhogen met het verwijderde water.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1366 $("#wdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1367 $("#wdeleterowbutton").on('click', function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1368 var selectedrowindex = $("#waterGrid").jqxGrid('getselectedrowindex');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1369 var rowscount = $("#waterGrid").jqxGrid('getdatainformation').rowscount;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1370 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1371 var id = $("#waterGrid").jqxGrid('getrowid', selectedrowindex);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1372 var commit = $("#waterGrid").jqxGrid('deleterow', id);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1373 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1374 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1375 },
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1376 ready: function() {
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1377 $('#jqxTabs').jqxTabs('next');
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1378 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1379 columns: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1380 { text: 'Water bron', editable: false, datafield: 'w_name' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1381 { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1382 columntype: 'numberinput',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1383 validation: function (cell, value) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1384 if (value < 0 || value > 100000000000 ) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1385 return { result: false, message: "Volume moet 0-~ zijn" };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1386 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1387 return true;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1388 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1389 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1390 // TODO: validator test max is hoeveelheid maischwater. Dan water verdelen voor totaal.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1391 { text: 'Ca', editable: false, datafield: 'w_calcium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1392 { text: 'Mg', editable: false, datafield: 'w_magnesium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1393 { text: 'Na', editable: false, datafield: 'w_sodium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1394 { text: 'Tot Alk', editable: false, datafield: 'w_total_alkalinity', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1395 { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1396 { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1397 { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1398 ]
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1399 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1400 }; // editWater = function (data) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1401
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1402 // inline mash editor
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1403 var editMash = function (data) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1404 var generaterow = function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1405 var row = {};
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1406 row["step_name"] = "Stap 1";
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1407 row["step_type"] = "Infusion";
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1408 row["step_infuse_amount"] = 15;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1409 row["step_temp"] = 62.0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1410 row['step_time'] = 20.0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1411 row['ramp_time'] = 1.0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1412 row['end_temp'] = 62.0;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1413 return row;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1414 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1415 var mashSource = {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1416 localdata: data.mashs,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1417 datatype: "local",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1418 cache: false,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1419 datafields: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1420 { name: 'step_name', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1421 { name: 'step_type', type: 'string' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1422 { name: 'step_infuse_amount', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1423 { name: 'step_temp', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1424 { name: 'step_time', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1425 { name: 'ramp_time', type: 'float' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1426 { name: 'end_temp', type: 'float' }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1427 ],
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1428 addrow: function (rowid, rowdata, position, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1429 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1430 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1431 deleterow: function (rowid, commit) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1432 commit(true);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1433 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1434 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1435 var mashAdapter = new $.jqx.dataAdapter(mashSource);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1436 $("#mashGrid").jqxGrid({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1437 width: 960,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1438 height: 400,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1439 source: mashAdapter,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1440 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1441 selectionmode: 'singlerow',
126
9999b3ce98cb Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents: 125
diff changeset
1442 editmode: 'selectedcell',
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1443 editable: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1444 localization: getLocalization(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1445 showtoolbar: true,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1446 rendertoolbar: function (toolbar) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1447 var me = this;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1448 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1449 toolbar.append(container);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1450 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1451 container.append('<input style="float: left; margin-left: 230px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1452 $("#saddrowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1453 $("#saddrowbutton").on('click', function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1454 var datarow = generaterow();
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1455 var commit = $("#mashGrid").jqxGrid('addrow', null, datarow);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1456 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1457 // delete selected yeast.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1458 $("#sdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1459 $("#sdeleterowbutton").on('click', function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1460 var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1461 var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1462 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1463 var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1464 var commit = $("#mashGrid").jqxGrid('deleterow', id);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1465 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1466 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1467 },
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1468 ready: function() {
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 135
diff changeset
1469 var fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, parseFloat(parseFloat($("#est_og").jqxNumberInput('decimal'))));
137
dfbf43b2797e Store calculated estimate ibu and estimate fg.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1470 dataRecord.est_fg = fg;
dfbf43b2797e Store calculated estimate ibu and estimate fg.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
1471 $('#est_fg').val(fg);
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
1472 calcInit();
129
7f41b61c3faf Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 128
diff changeset
1473 $('#jqxLoader').jqxLoader('close');
96
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1474 $('#jqxTabs').jqxTabs('first');
107c12c3e49d Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents: 95
diff changeset
1475 },
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1476 columns: [
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1477 { text: 'Stap naam', datafield: 'step_name' },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1478 { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1479 createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1480 var dataSource = [ "Infusion", "Temperature", "Decoction" ];
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1481 editor.jqxDropDownList({ source: dataSource, dropDownHeight: 105 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1482 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1483 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1484 { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1485 validation: function (cell, value) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1486 if (value < 35 || value > 80) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1487 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1488 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1489 return true;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1490 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1491 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1492 { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1493 validation: function (cell, value) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1494 if (value < 35 || value > 80) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1495 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1496 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1497 return true;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1498 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1499 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1500 { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1501 validation: function (cell, value) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1502 if (value < 1 || value > 360) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1503 return { result: false, message: "De tijd moet tussen 1 en 360 zijn." };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1504 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1505 return true;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1506 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1507 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1508 { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1509 validation: function (cell, value) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1510 if (value < 1 || value > 60) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1511 return { result: false, message: "De tijd moet tussen 1 en 60 zijn." };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1512 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1513 return true;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1514 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1515 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1516 { text: 'Infuse', datafield: 'step_infuse_amount', width: 70, align: 'right', cellsalign: 'right',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1517 validation: function (cell, value) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1518 if (value < 0 || value > 60) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1519 return { result: false, message: "De waarde moet tussen 0 en 60 zijn." };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1520 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1521 return true;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1522 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1523 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1524 ]
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1525 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1526 $("#mashGrid").on('cellendedit', function (event) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1527 $('#mashGrid').jqxGrid('sortby', 'step_temp', 'asc');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1528 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1529 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1530
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1531 // initialize the input fields.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1532 var srcType = [ "All Grain", "Partial Mash", "Extract" ];
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1533 var srcColor = [ "Morey", "Mosher", "Daniels" ];
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
1534 //var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ];
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
1535 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time.
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1536 $("#name").jqxInput({ theme: theme, width: 640, height: 23 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1537 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1538 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1539 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1540 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1541 $("#st_category").jqxInput({ theme: theme, width: 250, height: 23 });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1542 $("#st_category_number").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1543 $("#st_type").jqxInput({ theme: theme, width: 90, height: 23 });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1544 $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1545 $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: 'L', symbolPosition: 'right' });
135
cd1403633e96 Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents: 134
diff changeset
1546 $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 2, readOnly: true, symbol: 'L', symbolPosition: 'right' });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1547 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1548 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' });
133
22d28dd9c041 Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents: 132
diff changeset
1549 $("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1.000, max: 1.200, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 });
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
1550 $("#est_og2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1551 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1552 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1553
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1554 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1555 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1556 $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1557
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1558 $("#est_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1559 $("#st_abv_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1560 $("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1561
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
1562 $("#est_color").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true });
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
1563 $("#est_color2").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1564 $("#st_color_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1565 $("#st_color_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1566 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1567
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
1568 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' IBU', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true });
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1569 $("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1570 $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1571 $("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
98
92d6bc8a4cdd Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 97
diff changeset
1572 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95, dropDownVerticalAlignment: 'top' });
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1573
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1574 $("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1575 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1576 $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1577
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1578 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1579 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1580 $("#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 });
138
59874681fc13 Hop flavour and aroma sets global values. On the hop tab, show IBU and make room for the flavour and aroma presentation.
Michiel Broek <mbroek@mbse.eu>
parents: 137
diff changeset
1581 // Hop flavour and aroma gauges
139
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
1582 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
eb1ac7487710 Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
Michiel Broek <mbroek@mbse.eu>
parents: 138
diff changeset
1583 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1584
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1585 // Tabs inside the popup window.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1586 $('#jqxTabs').jqxTabs({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1587 theme: theme,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1588 width: 1280,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1589 height: 630,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1590 autoHeight: false,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1591 position: 'top'
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1592 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1593
79
f3adf543f698 Added recipe print button.
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
1594 $("#Print").jqxButton({ template: "info", width: '80px', theme: theme });
f3adf543f698 Added recipe print button.
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
1595 $("#Print").click(function () {
f3adf543f698 Added recipe print button.
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
1596 // Open print in a new tab.
f3adf543f698 Added recipe print button.
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
1597 var url="rec_print.php?record=" + my_record;
f3adf543f698 Added recipe print button.
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
1598 window.open(url);
f3adf543f698 Added recipe print button.
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
1599 });
f3adf543f698 Added recipe print button.
Michiel Broek <mbroek@mbse.eu>
parents: 73
diff changeset
1600
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1601 $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1602 $("#Delete").click(function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1603 // Open a popup to confirm this action.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1604 $('#eventWindow').jqxWindow('open');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1605 $("#delOk").click(function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1606 var data = "delete=true&" + $.param({ record: my_record });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1607 $.ajax({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1608 dataType: 'json',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1609 url: url,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1610 cache: false,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1611 data: data,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1612 type: "POST",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1613 success: function (data, status, xhr) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1614 // delete command is executed.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1615 window.location.href = my_return;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1616 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1617 error: function (jqXHR, textStatus, errorThrown) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1618 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1619 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1620 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1621 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1622
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1623 $("#Cancel").jqxButton({ template: "primary", width: '80px', theme: theme });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1624 $("#Cancel").click(function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1625 window.location.href = my_return;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1626 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1627
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1628 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1629 $("#Save").click(function () {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1630 var fermentablerow = $('#fermentableGrid').jqxGrid('getrows');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1631 var hoprow = $('#hopGrid').jqxGrid('getrows');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1632 var miscrow = $('#miscGrid').jqxGrid('getrows');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1633 var yeastrow = $('#yeastGrid').jqxGrid('getrows');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1634 var waterrow = $('#waterGrid').jqxGrid('getrows');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1635 var mashrow = $('#mashGrid').jqxGrid('getrows');
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1636 var row = {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1637 record: my_record,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1638 name: $("#name").val(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1639 notes: $("#notes").val(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1640 st_name: $('#st_name').val(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1641 st_letter: $('#st_letter').val(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1642 st_guide: $('#st_guide').val(),
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1643 st_type: $('#st_type').val(),
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1644 st_category: $('#st_category').val(),
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1645 st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')),
73
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1646 st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1647 st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1648 st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1649 st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1650 st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1651 st_ibu_max: parseFloat($("#st_ibu_max").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1652 st_color_min: parseFloat($("#st_color_min").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1653 st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1654 st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1655 st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1656 st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')),
454fc4558609 Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
1657 st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')),
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1658 type: $("#type").val(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1659 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
95
8dc0a00b1db4 Boil_size volume toegevoegd.
Michiel Broek <mbroek@mbse.eu>
parents: 85
diff changeset
1660 boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')),
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1661 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1662 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1663 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1664 est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')),
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1665 est_abv: parseFloat($("#est_abv").jqxNumberInput('decimal')),
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1666 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1667 color_method: $("#color_method").val(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1668 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1669 ibu_method: $("#ibu_method").val(),
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
1670 est_carb: parseFloat($("#est_carb").jqxNumberInput('decimal')),
68
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1671 mash_name: $("#mash_name").val(),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1672 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1673 mash_sparge_temp: parseFloat($("#mash_sparge_temp").jqxNumberInput('decimal')),
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1674 fermentables: fermentablerow,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1675 hops: hoprow,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1676 miscs: miscrow,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1677 yeasts: yeastrow,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1678 waters: waterrow,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1679 mashs: mashrow
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1680 };
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1681 var data = "update=true&" + $.param(row);
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1682 $.ajax({
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1683 dataType: 'json',
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1684 url: url,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1685 cache: false,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1686 data: data,
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1687 type: "POST",
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1688 success: function (data, status, xhr) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1689 // update command is executed.
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1690 window.location.href = my_return;
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1691 },
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1692 error: function(jqXHR, textStatus, errorThrown) {
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1693 }
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1694 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1695 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1696 createDelElements();
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1697 });
2ff83855d574 Added recipe editor screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1698

mercurial