Tue, 04 Sep 2018 13:44:02 +0200
More recipe editor changes
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /***************************************************************************** |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Copyright (C) 2018 |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * Michiel Broek <mbroek at mbse dot eu> |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * This file is part of BMS |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * This is free software; you can redistribute it and/or modify it |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * under the terms of the GNU General Public License as published by the |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * Free Software Foundation; either version 2, or (at your option) any |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * later version. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * BrewCloud is distributed in the hope that it will be useful, but |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * General Public License for more details. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | *****************************************************************************/ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | function createDelElements() { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | $('#eventWindow').jqxWindow({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | theme: theme, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | position: { x: 490, y: 210 }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | width: 300, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | height: 175, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | resizable: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | isModal: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | modalOpacity: 0.4, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | okButton: $('#delOk'), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | cancelButton: $('#delCancel'), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | initContent: function () { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | $('#delOk').jqxButton({ width: '65px', theme: theme }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | $('#delCancel').jqxButton({ width: '65px', theme: theme }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | $('#delCancel').focus(); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | $('#eventWindow').jqxWindow('hide'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | $(document).ready(function () { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | var url = "includes/db_recipes.php"; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | // tooltips |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' }); |
51 | 50 | $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | // prepare the data |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | var source = { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | datatype: "json", |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | cache: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | datafields: [ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | { name: 'record', type: 'number' }, |
51 | 58 | { name: 'st_name', type: 'string' }, |
59 | { name: 'st_letter', type: 'string' }, | |
60 | { name: 'st_guide', type: 'string' }, | |
61 | { name: 'st_og_min', type: 'float' }, | |
62 | { name: 'st_og_max', type: 'float' }, | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | { name: 'name', type: 'string' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | { name: 'notes', type: 'string' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | { name: 'type', type: 'number' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | { name: 'batch_size', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | { name: 'boil_time', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | { name: 'efficiency', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | { name: 'est_og', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | { name: 'est_fg', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | { name: 'est_color', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | { name: 'color_method', type: 'string' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | { name: 'est_ibu', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | { name: 'ibu_method', type: 'string' }, |
51 | 75 | { name: 'mash_sparge_temp', type: 'float' }, |
76 | { name: 'mash_ph', type: 'float' }, | |
77 | { name: 'mash_name', type: 'string' }, | |
78 | { name: 'fermentables', type: 'string' }, | |
79 | { name: 'hops', type: 'string' }, | |
80 | { name: 'miscs', type: 'string' }, | |
81 | { name: 'yeasts', type: 'string' }, | |
82 | { name: 'waters', type: 'array' }, | |
83 | { name: 'mashs', type: 'string' } | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | ], |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | id: 'record', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | url: url, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | deleterow: function (rowid, commit) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | // synchronize with the server - send delete command |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | var data = "delete=true&" + $.param({ record: rowid }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | $.ajax({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | dataType: 'json', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | url: url, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | cache: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | data: data, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | success: function (data, status, xhr) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | // delete command is executed. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | commit(true); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | error: function (jqXHR, textStatus, errorThrown) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | commit(false); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | addrow: function (rowid, rowdata, position, commit) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | var data = "insert=true&" + $.param(rowdata); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | $.ajax({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | dataType: 'json', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | url: url, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | cache: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | data: data, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | success: function (data, status, xhr) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | commit(true); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | error: function(jqXHR, textStatus, errorThrown) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | commit(false); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | updaterow: function (rowid, rowdata, commit) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | var data = "update=true&" + $.param(rowdata); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | $.ajax({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | dataType: 'json', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | url: url, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | cache: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | data: data, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | success: function (data, status, xhr) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | // update command is executed. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | commit(true); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | error: function(jqXHR, textStatus, errorThrown) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | commit(false); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | }; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | var dataAdapter = new $.jqx.dataAdapter(source); |
51 | 137 | |
138 | // Inline waters editor | |
139 | var editWater = function (data) { | |
140 | // var generaterow = function () { | |
141 | // var row = {}; | |
142 | // row["w_name"] = "Water 1"; | |
143 | // row["step_type"] = "Infusion"; | |
144 | // row["w_amount"] = 22.0; | |
145 | // row['step_time'] = 20.0; | |
146 | // row['ramp_time'] = 1.0; | |
147 | // row['end_temp'] = 62.0; | |
148 | // return row; | |
149 | // } | |
150 | var waterSource = { | |
151 | localdata: data.waters, | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | datatype: "local", |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | datafields: [ |
51 | 154 | { name: 'w_name', type: 'string' }, |
155 | { name: 'w_amount', type: 'float' }, | |
156 | { name: 'w_calcium', type: 'float' }, | |
157 | { name: 'w_bicarbonate', type: 'float' }, | |
158 | { name: 'w_sulfate', type: 'float' }, | |
159 | { name: 'w_chloride', type: 'float' }, | |
160 | { name: 'w_sodium', type: 'float' }, | |
161 | { name: 'w_magnesium', type: 'float' }, | |
162 | { name: 'w_ph', type: 'float' }, | |
163 | { name: 'w_total_alkalinity', type: 'float' }, | |
164 | { name: 'w_cost', type: 'float' }, | |
165 | { name: 'w_default_water', type: 'bool' } | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | ], |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | addrow: function (rowid, rowdata, position, commit) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | commit(true); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | deleterow: function (rowid, commit) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | commit(true); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 | }; |
51 | 174 | var waterAdapter = new $.jqx.dataAdapter(waterSource); |
175 | $("#waterGrid").jqxGrid({ | |
176 | width: 960, | |
177 | height: 200, | |
178 | source: waterAdapter, | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
179 | theme: theme, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
180 | selectionmode: 'singlerow', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
181 | editmode: 'selectedrow', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
182 | editable: true, |
51 | 183 | showstatusbar: true, |
184 | statusbarheight: 50, | |
185 | showaggregates: true, | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
186 | showtoolbar: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
187 | rendertoolbar: function (toolbar) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
188 | var me = this; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
189 | var container = $("<div style='margin: 5px;'></div>"); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
190 | toolbar.append(container); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
191 | container.append('<input style="margin-left: 100px;" id="addrowbutton" type="button" value="Nieuwe stap" />'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
192 | container.append('<input style="margin-left: 140px;" id="deleterowbutton" type="button" value="Verwijder stap" />'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
193 | $("#addrowbutton").jqxButton({ theme: theme, width: 150 }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
194 | $("#deleterowbutton").jqxButton({ theme: theme, width: 150 }); |
51 | 195 | // create new row. Dropdown uit water inventory. |
196 | // $("#addrowbutton").on('click', function () { | |
197 | // var datarow = generaterow(); | |
198 | // var commit = $("#waterGrid").jqxGrid('addrow', null, datarow); | |
199 | // }); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
200 | // delete row. |
51 | 201 | // Overgebleven waters in volume verhogen met het verwijderde water. |
202 | // $("#deleterowbutton").on('click', function () { | |
203 | // var selectedrowindex = $("#grid").jqxGrid('getselectedrowindex'); | |
204 | // var rowscount = $("#grid").jqxGrid('getdatainformation').rowscount; | |
205 | // if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
206 | // var id = $("#grid").jqxGrid('getrowid', selectedrowindex); | |
207 | // var commit = $("#grid").jqxGrid('deleterow', id); | |
208 | // } | |
209 | // }); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | columns: [ |
51 | 212 | { text: 'Water bron', editable: false, datafield: 'w_name' }, |
213 | { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', | |
214 | columntype: 'numberinput', | |
215 | aggregates: ['sum'], | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | validation: function (cell, value) { |
51 | 217 | if (value < 0 || value > 100000000000 ) { |
218 | return { result: false, message: "Volume moet 0-~ zijn" }; | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | return true; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | }, |
51 | 223 | // TODO: validator test max is hoeveelheid maischwater. Dan water verdelen voor totaal. |
224 | { text: 'Ca', editable: false, datafield: 'w_calcium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
225 | { text: 'Mg', editable: false, datafield: 'w_magnesium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
226 | { text: 'Na', editable: false, datafield: 'w_sodium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
227 | { text: 'Tot Alk', editable: false, datafield: 'w_total_alkalinity', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
228 | { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
229 | { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
230 | { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' } | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
231 | ] |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | }); |
51 | 233 | // $("#grid").on('cellendedit', function (event) { |
234 | // $('#grid').jqxGrid('sortby', 'step_temp', 'asc'); | |
235 | // }); | |
236 | }; // editWater = function (data) { | |
237 | ||
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
238 | // initialize the input fields. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
239 | var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
240 | var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
241 | var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
242 | $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
243 | $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); |
51 | 244 | $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); |
245 | $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); | |
246 | $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 }); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
247 | $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
248 | $("#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' }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
249 | $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', template: "success", theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
250 | $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
251 | $("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 1.9, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); |
51 | 252 | $("#st_og_min").jqxNumberInput({ disabled: true, inputMode: 'simple', width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
253 | $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
254 | $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, min: 0.980, max: 1.040, decimalDigits: 3, readOnly: true }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
255 | $("#est_color").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 200, decimalDigits: 0, spinButtons: true }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
256 | $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
257 | $("#est_ibu").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 200, decimalDigits: 0, spinButtons: true }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
258 | $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 180 }); |
51 | 259 | $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
260 | $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
261 | var editrow = -1; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
262 | // initialize jqxGrid |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
263 | $("#jqxgrid").jqxGrid({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
264 | width: 1280, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
265 | height: 630, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
266 | source: dataAdapter, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
267 | groupable: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
268 | theme: theme, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
269 | showstatusbar: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
270 | localization: getLocalization(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
271 | renderstatusbar: function (statusbar) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
272 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
273 | var addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Add</span></div>"); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
274 | container.append(addButton); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
275 | statusbar.append(container); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
276 | addButton.jqxButton({ theme: theme, width: 120, height: 20 }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
277 | // add new row. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
278 | addButton.click(function (event) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
279 | editrow = -1; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
280 | $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
281 | $("#name").val(''); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
282 | $("#notes").val(''); |
51 | 283 | $("#st_name").val(''); |
284 | $("#st_letter").val(''); | |
285 | $("#st_guide").val(''); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
286 | $("#type").val('All Grain'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
287 | $("#batch_size").val(20); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
288 | $("#boil_time").val(90); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
289 | $("#efficiency").val(75); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
290 | $("#est_og").val(1.062); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
291 | $("#est_fg").val(1.000); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
292 | $("#est_color").val(0); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
293 | $("#color_method").val('Morey'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
294 | $("#est_ibu").val(0); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
295 | $("#ibu_method").val('Tinseth'); |
51 | 296 | editWater(''); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
297 | $("#popupWindow").jqxWindow('open'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
298 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
299 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
300 | filterable: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
301 | filtermode: 'excel', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
302 | columns: [ |
51 | 303 | { text: 'Stijlgids', datafield: 'st_guide', width: 120 }, |
304 | { text: 'Letter', datafield: 'st_letter', width: 60 }, | |
305 | { text: 'Stijl', datafield: 'st_name', width: 150 }, | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
306 | { text: 'Naam', datafield: 'name' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
307 | { text: 'OG', datafield: 'est_og', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
308 | { text: 'EBC', datafield: 'est_color', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
309 | { text: 'IBU', datafield: 'est_ibu', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
310 | { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
311 | return "Wijzig"; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
312 | }, buttonclick: function (row) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
313 | // open the popup window when the user clicks a button. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
314 | editrow = row; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
315 | $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
316 | // get the clicked row's data and initialize the input fields. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
317 | var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
318 | $("#name").val(dataRecord.name); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
319 | $("#notes").val(dataRecord.notes); |
51 | 320 | $("#st_name").val(dataRecord.st_name); |
321 | $("#st_letter").val(dataRecord.st_letter); | |
322 | $("#st_guide").val(dataRecord.st_guide); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
323 | $("#type").val(dataRecord.type); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
324 | $("#batch_size").val(dataRecord.batch_size); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
325 | $("#boil_time").val(dataRecord.boil_time); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
326 | $("#efficiency").val(dataRecord.efficiency); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
327 | $("#est_og").val(dataRecord.est_og); |
51 | 328 | $("#st_og_min").val(dataRecord.st_og_min); |
329 | $("#st_og_max").val(dataRecord.st_og_max); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
330 | $("#est_fg").val(dataRecord.est_fg); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
331 | $("#est_color").val(dataRecord.est_color); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
332 | $("#color_method").val(dataRecord.color_method); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
333 | $("#est_ibu").val(dataRecord.est_ibu); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
334 | $("#ibu_method").val(dataRecord.ibu_method); |
51 | 335 | $("#mash_name").val(dataRecord.mash_name); |
336 | $("#mash_ph").val(dataRecord.mash_ph); | |
337 | editWater(dataRecord); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
338 | // editsteps(dataRecord); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
339 | // show the popup window. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
340 | $("#popupWindow").jqxWindow('open'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
341 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
342 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
343 | ], |
51 | 344 | groups: ['st_guide','st_letter' ] |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
345 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
346 | |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
347 | // initialize the popup window and buttons. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
348 | $("#popupWindow").jqxWindow({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
349 | width: 1200, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
350 | height: 620, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
351 | resizable: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
352 | theme: theme, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
353 | isModal: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
354 | autoOpen: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
355 | cancelButton: $("#Cancel"), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
356 | modalOpacity: 0.40 |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
357 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
358 | |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
359 | // Tabs inside the popup window. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
360 | $('#jqxTabs').jqxTabs({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
361 | theme: theme, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
362 | autoHeight: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
363 | height: 580, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
364 | position: 'top' |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
365 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
366 | |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
367 | $("#popupWindow").on('open', function () { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
368 | $("#name").jqxInput('selectAll'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
369 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
370 | $("#Delete").jqxButton({ width: '90px', theme: theme }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
371 | $("#Delete").click(function () { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
372 | if (editrow >= 0) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
373 | // Open a popup to confirm this action. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
374 | $('#eventWindow').jqxWindow('open'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
375 | $("#delOk").click(function () { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
376 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
377 | $("#jqxgrid").jqxGrid('deleterow', rowID); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
378 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
379 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
380 | $("#popupWindow").jqxWindow('hide'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
381 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
382 | $("#Cancel").jqxButton({ width: '90px', theme: theme }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
383 | $("#Save").jqxButton({ width: '90px', theme: theme }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
384 | // update the edited row when the user clicks the 'Save' button. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
385 | $("#Save").click(function () { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
386 | // var steprows = $('#grid').jqxGrid('getrows'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
387 | if (editrow >= 0) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
388 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
389 | var row = { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
390 | record: rowID, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
391 | name: $("#name").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
392 | notes: $("#notes").val(), |
51 | 393 | st_name: $('#st_name').val(), |
394 | st_letter: $('#st_letter').val(), | |
395 | st_guide: $('#st_guide').val(), | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
396 | type: $("#type").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
397 | batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
398 | boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
399 | efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
400 | est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
401 | est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
402 | est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
403 | color_method: $("#color_method").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
404 | est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), |
51 | 405 | ibu_method: $("#ibu_method").val(), |
406 | mash_name: $("#mash_name").val(), | |
407 | mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')) | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
408 | // steps: steprows |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
409 | }; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
410 | $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
411 | $("#popupWindow").jqxWindow('hide'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
412 | } else { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
413 | // Insert a record |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
414 | var newrow = { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
415 | record: -1, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
416 | name: $("#name").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
417 | notes: $("#notes").val(), |
51 | 418 | st_name: $('#st_name').val(), |
419 | st_letter: $('#st_letter').val(), | |
420 | st_guide: $('#st_guide').val(), | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
421 | type: $("#type").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
422 | batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
423 | boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
424 | efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
425 | est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
426 | est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
427 | est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
428 | color_method: $("#color_method").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
429 | est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), |
51 | 430 | ibu_method: $("#ibu_method").val(), |
431 | mash_name: $("#mash_name").val(), | |
432 | mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')) | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
433 | // steps: steprows |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
434 | }; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
435 | $('#jqxgrid').jqxGrid('addrow', null, newrow); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
436 | $("#popupWindow").jqxWindow('hide'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
437 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
438 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
439 | createDelElements(); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
440 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
441 |