Fri, 28 Sep 2018 17:29:23 +0200
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.
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' }, | |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
63 | { name: 'st_fg_min', type: 'float' }, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
64 | { name: 'st_fg_max', type: 'float' }, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
65 | { name: 'st_ibu_min', type: 'float' }, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
66 | { name: 'st_ibu_max', type: 'float' }, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
67 | { name: 'st_color_min', type: 'float' }, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
68 | { name: 'st_color_max', type: 'float' }, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
69 | { name: 'st_carb_min', type: 'float' }, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
70 | { name: 'st_carb_max', type: 'float' }, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
71 | { name: 'st_abv_min', type: 'float' }, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
72 | { name: 'st_abv_max', type: 'float' }, |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | { name: 'name', type: 'string' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | { name: 'notes', type: 'string' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | { name: 'type', type: 'number' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | { name: 'batch_size', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | { name: 'boil_time', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | { name: 'efficiency', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | { name: 'est_og', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | { name: 'est_fg', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | { name: 'est_color', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | { name: 'color_method', type: 'string' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | { name: 'est_ibu', type: 'float' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | { name: 'ibu_method', type: 'string' }, |
51 | 85 | { name: 'mash_sparge_temp', type: 'float' }, |
86 | { name: 'mash_ph', type: 'float' }, | |
87 | { name: 'mash_name', type: 'string' }, | |
88 | { name: 'fermentables', type: 'string' }, | |
89 | { name: 'hops', type: 'string' }, | |
90 | { name: 'miscs', type: 'string' }, | |
91 | { name: 'yeasts', type: 'string' }, | |
92 | { name: 'waters', type: 'array' }, | |
93 | { name: 'mashs', type: 'string' } | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | ], |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | id: 'record', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | url: url, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | deleterow: function (rowid, commit) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | // synchronize with the server - send delete command |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | var data = "delete=true&" + $.param({ record: rowid }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | $.ajax({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | dataType: 'json', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | url: url, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | cache: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | data: data, |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
105 | type: "POST", |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | success: function (data, status, xhr) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | // delete command is executed. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | commit(true); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | error: function (jqXHR, textStatus, errorThrown) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | commit(false); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | } |
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 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | addrow: function (rowid, rowdata, position, commit) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | var data = "insert=true&" + $.param(rowdata); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | $.ajax({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | dataType: 'json', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | url: url, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | cache: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | data: data, |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
122 | type: "POST", |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | success: function (data, status, xhr) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | commit(true); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | error: function(jqXHR, textStatus, errorThrown) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | commit(false); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | } |
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 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | updaterow: function (rowid, rowdata, commit) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | var data = "update=true&" + $.param(rowdata); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | $.ajax({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | dataType: 'json', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | url: url, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | cache: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | data: data, |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
138 | type: "POST", |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | success: function (data, status, xhr) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | // update command is executed. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | commit(true); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | error: function(jqXHR, textStatus, errorThrown) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | commit(false); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | }; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | var dataAdapter = new $.jqx.dataAdapter(source); |
51 | 150 | |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
151 | // Inline fermentables editor |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
152 | var editFermentable = function (data) { |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
153 | var fermentableSource = { |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
154 | localdata: data.fermentables, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
155 | datatype: "local", |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
156 | datafields: [ |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
157 | { name: 'f_name', type: 'string' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
158 | { name: 'f_origin', type: 'string' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
159 | { name: 'f_supplier', type: 'string' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
160 | { name: 'f_amount', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
161 | { name: 'f_cost', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
162 | { name: 'f_type', type: 'string' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
163 | { name: 'f_yield', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
164 | { name: 'f_color', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
165 | { name: 'f_coarse_fine_diff', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
166 | { name: 'f_moisture', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
167 | { name: 'f_diastatic_power', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
168 | { name: 'f_protein', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
169 | { name: 'f_max_in_batch', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
170 | { name: 'f_graintype', type: 'string' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
171 | { name: 'f_added', type: 'string' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
172 | { name: 'f_dissolved_protein', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
173 | { name: 'f_recommend_mash', type: 'bool' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
174 | { name: 'f_add_after_boil', type: 'bool' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
175 | { name: 'f_adjust_to_total_100', type: 'bool' }, |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
176 | { name: 'f_percentage', type: 'float' }, |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
177 | { name: 'f_di_ph', type: 'float' } |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
178 | ], |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
179 | addrow: function (rowid, rowdata, position, commit) { |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
180 | commit(true); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
181 | }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
182 | deleterow: function (rowid, commit) { |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
183 | commit(true); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
184 | } |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
185 | }; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
186 | var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
187 | // dropdownlist datasource from inventory_fermentables |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
188 | var fermentableUrl = "getfermentablesources.php"; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
189 | var fermentableInvSource = { |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
190 | datatype: "json", |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
191 | datafields: [ |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
192 | { name: 'record', type: 'number' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
193 | { name: 'name', type: 'string' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
194 | { name: 'type', type: 'string' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
195 | { name: 'yield', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
196 | { name: 'color', type: 'float' }, |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
197 | { name: 'add_after_boil', type: 'bool' }, |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
198 | { name: 'origin', type: 'string' }, |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
199 | { name: 'supplier', type: 'string' }, |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
200 | { name: 'coarse_fine_diff', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
201 | { name: 'moisture', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
202 | { name: 'diastatic_power', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
203 | { name: 'protein', type: 'float' }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
204 | { name: 'max_in_batch', type: 'float' }, |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
205 | { name: 'recommend_mash', type: 'bool' }, |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
206 | { name: 'graintype', type: 'string' }, |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
207 | { name: 'di_ph', type: 'float' }, |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
208 | { name: 'inventory', type: 'float' }, |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
209 | { name: 'cost', type: 'float' } |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
210 | ], |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
211 | url: fermentableUrl, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
212 | async: true |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
213 | }; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
214 | var fermentablelist = new $.jqx.dataAdapter(fermentableInvSource); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
215 | |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
216 | $("#fermentableGrid").jqxGrid({ |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
217 | width: 960, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
218 | height: 400, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
219 | source: fermentableAdapter, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
220 | theme: theme, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
221 | selectionmode: 'singlerow', |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
222 | editmode: 'selectedrow', |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
223 | editable: true, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
224 | localization: getLocalization(), |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
225 | showtoolbar: true, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
226 | rendertoolbar: function (toolbar) { |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
227 | var me = this; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
228 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
229 | toolbar.append(container); |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
230 | container.append('<div style="float: left; margin-left: 165px;" id="faddrowbutton"></div>'); |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
231 | container.append('<input style="float: left; margin-left: 230px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />'); |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
232 | // add fermentable from dropdownlist. |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
233 | $("#faddrowbutton").jqxDropDownList({ |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
234 | placeHolder: "Kies mout:", |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
235 | theme: theme, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
236 | source: fermentablelist, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
237 | displayMember: "name", |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
238 | width: 150, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
239 | height: 27, |
65
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
240 | dropDownWidth: 500, |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
241 | dropDownHeight: 500, |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
242 | renderer: function (index, label, value) { |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
243 | var datarecord = fermentablelist.records[index]; |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
244 | return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)"; |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
245 | } |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
246 | }); |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
247 | $("#faddrowbutton").on('select', function (event) { |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
248 | if (event.args) { |
66
674948226777
Changed profile styles editor a bit. Fermentable inline editor sets precentage and adjust_to_total_100 when a row is added.
Michiel Broek <mbroek@mbse.eu>
parents:
65
diff
changeset
|
249 | var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
250 | var index = event.args.index; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
251 | var datarecord = fermentablelist.records[index]; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
252 | var row = {}; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
253 | row["f_name"] = datarecord.name; |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
254 | row["f_origin"] = datarecord.origin; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
255 | row["f_supplier"] = datarecord.supplier; |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
256 | row["f_amount"] = 0; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
257 | row["f_cost"] = datarecord.cost; |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
258 | row["f_type"] = datarecord.type; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
259 | row["f_yield"] = datarecord.yield; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
260 | row["f_color"] = datarecord.color; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
261 | row["f_coarse_fine_diff"] = datarecord.coarse_fine_diff; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
262 | row["f_moisture"] = datarecord.moisture; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
263 | row["f_diastatic_power"] = datarecord.diastatic_power; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
264 | row["f_protein"] = datarecord.protein; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
265 | row["f_max_in_batch"] = datarecord.max_in_batch; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
266 | row["f_graintype"] = datarecord.graintype; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
267 | if (datarecord.type == "Sugar") { |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
268 | row["f_added"] = "Boil"; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
269 | } else { |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
270 | row["f_added"] = "Mash"; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
271 | } |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
272 | row["f_dissolved_protein"] = 0; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
273 | row["f_recommend_mash"] = datarecord.recommend_mash; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
274 | row["f_add_after_boil"] = datarecord.add_after_boil; |
66
674948226777
Changed profile styles editor a bit. Fermentable inline editor sets precentage and adjust_to_total_100 when a row is added.
Michiel Broek <mbroek@mbse.eu>
parents:
65
diff
changeset
|
275 | if (rowscount == 0) { |
674948226777
Changed profile styles editor a bit. Fermentable inline editor sets precentage and adjust_to_total_100 when a row is added.
Michiel Broek <mbroek@mbse.eu>
parents:
65
diff
changeset
|
276 | // The first fermentable |
674948226777
Changed profile styles editor a bit. Fermentable inline editor sets precentage and adjust_to_total_100 when a row is added.
Michiel Broek <mbroek@mbse.eu>
parents:
65
diff
changeset
|
277 | row["f_adjust_to_total_100"] = 1; |
674948226777
Changed profile styles editor a bit. Fermentable inline editor sets precentage and adjust_to_total_100 when a row is added.
Michiel Broek <mbroek@mbse.eu>
parents:
65
diff
changeset
|
278 | row["f_percentage"] = 100; |
674948226777
Changed profile styles editor a bit. Fermentable inline editor sets precentage and adjust_to_total_100 when a row is added.
Michiel Broek <mbroek@mbse.eu>
parents:
65
diff
changeset
|
279 | } else { |
674948226777
Changed profile styles editor a bit. Fermentable inline editor sets precentage and adjust_to_total_100 when a row is added.
Michiel Broek <mbroek@mbse.eu>
parents:
65
diff
changeset
|
280 | row["f_adjust_to_total_100"] = 0; |
674948226777
Changed profile styles editor a bit. Fermentable inline editor sets precentage and adjust_to_total_100 when a row is added.
Michiel Broek <mbroek@mbse.eu>
parents:
65
diff
changeset
|
281 | row["f_percentage"] = 0; |
674948226777
Changed profile styles editor a bit. Fermentable inline editor sets precentage and adjust_to_total_100 when a row is added.
Michiel Broek <mbroek@mbse.eu>
parents:
65
diff
changeset
|
282 | } |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
283 | row["f_di_ph"] = datarecord.di_ph; |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
284 | var commit = $("#fermentableGrid").jqxGrid('addrow', null, row); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
285 | } |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
286 | }); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
287 | |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
288 | // delete selected fermentable. |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
289 | // Precentage aanpassen basis mout. |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
290 | $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
291 | $("#fdeleterowbutton").on('click', function () { |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
292 | var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex'); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
293 | var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
294 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
295 | var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
296 | var commit = $("#fermentableGrid").jqxGrid('deleterow', id); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
297 | } |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
298 | }); |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
299 | }, |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
300 | columns: [ |
67
883e897aad40
Start building the workflow in the scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
301 | { text: 'Mout/suiker', editable: false, datafield: 'f_name', |
883e897aad40
Start building the workflow in the scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
302 | cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { |
883e897aad40
Start building the workflow in the scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
303 | var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row); |
883e897aad40
Start building the workflow in the scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
304 | return rowData.f_name + " (" + rowData.f_color + " EBC)"; |
883e897aad40
Start building the workflow in the scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
305 | } |
883e897aad40
Start building the workflow in the scripts.
Michiel Broek <mbroek@mbse.eu>
parents:
66
diff
changeset
|
306 | }, |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
307 | { text: 'Type', editable: false, width: 100, datafield: 'f_type' }, |
65
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
308 | { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
309 | { text: 'Gewicht', datafield: 'f_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
310 | columntype: 'numberinput', |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
311 | validation: function (cell, value) { |
65
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
312 | // Maximum weight is the batch_size, just a simple check. |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
313 | var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal')); |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
314 | if (value < 0 || value > maxmout) { |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
315 | return { result: false, message: "Gewicht moet 0-"+maxmout+" zijn" }; |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
316 | } |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
317 | return true; |
65
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
318 | }, |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
319 | initeditor: function (row, cellvalue, editor) { |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
320 | editor.jqxNumberInput({ decimalDigits: 3 }); |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
321 | } |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
322 | }, |
65
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
323 | { text: 'Procent', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1', |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
324 | columntype: 'numberinput', |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
325 | validation: function (cell, value) { |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
326 | if (value < 0 || value > 100) { |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
327 | return { result: false, message: "Percentage moet 0-100 zijn" }; |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
328 | } |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
329 | return true; |
65
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
330 | }, |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
331 | initeditor: function (row, cellvalue, editor) { |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
332 | editor.jqxNumberInput({ decimalDigits: 1 }); |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
333 | } |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
334 | }, |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
335 | { text: '100%', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80 } |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
336 | ] |
65
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
337 | }); |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
338 | $("#fermentableGrid").on('cellendedit', function (event) { |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
339 | $('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc'); |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
340 | }); |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
341 | }; |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
342 | |
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
343 | // Inline hops editor |
58
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
344 | var editHop = function (data) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
345 | var hopSource = { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
346 | localdata: data.hops, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
347 | datatype: "local", |
59
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
348 | cache: false, |
58
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
349 | datafields: [ |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
350 | { name: 'h_name', type: 'string' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
351 | { name: 'h_origin', type: 'string' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
352 | { name: 'h_amount', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
353 | { name: 'h_cost', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
354 | { name: 'h_type', type: 'string' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
355 | { name: 'h_form', type: 'string' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
356 | { name: 'h_useat', type: 'string' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
357 | { name: 'h_time', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
358 | { name: 'h_alpha', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
359 | { name: 'h_beta', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
360 | { name: 'h_hsi', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
361 | { name: 'h_humulene', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
362 | { name: 'h_carophyllene', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
363 | { name: 'h_cohumulone', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
364 | { name: 'h_myrcene', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
365 | { name: 'h_total_oil', type: 'float' } |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
366 | ], |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
367 | addrow: function (rowid, rowdata, position, commit) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
368 | commit(true); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
369 | }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
370 | deleterow: function (rowid, commit) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
371 | commit(true); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
372 | } |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
373 | }; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
374 | var hopAdapter = new $.jqx.dataAdapter(hopSource); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
375 | // dropdownlist datasource from inventory_hops |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
376 | var hopUrl = "gethopsources.php"; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
377 | var hopInvSource = { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
378 | datatype: "json", |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
379 | datafields: [ |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
380 | { name: 'record', type: 'number' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
381 | { name: 'name', type: 'string' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
382 | { name: 'origin', type: 'string' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
383 | { name: 'type', type: 'string' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
384 | { name: 'alpha', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
385 | { name: 'beta', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
386 | { name: 'humulene', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
387 | { name: 'caryophyllene', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
388 | { name: 'cohumulone', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
389 | { name: 'myrcene', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
390 | { name: 'hsi', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
391 | { name: 'useat', type: 'string' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
392 | { name: 'form', type: 'string' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
393 | { name: 'total_oil', type: 'float' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
394 | { name: 'cost', type: 'float' } |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
395 | ], |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
396 | url: hopUrl, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
397 | async: true |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
398 | }; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
399 | var hoplist = new $.jqx.dataAdapter(hopInvSource); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
400 | |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
401 | $("#hopGrid").jqxGrid({ |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
402 | width: 960, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
403 | height: 400, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
404 | source: hopAdapter, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
405 | theme: theme, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
406 | selectionmode: 'singlerow', |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
407 | editmode: 'selectedrow', |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
408 | editable: true, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
409 | localization: getLocalization(), |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
410 | showtoolbar: true, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
411 | rendertoolbar: function (toolbar) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
412 | var me = this; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
413 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
414 | toolbar.append(container); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
415 | container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>'); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
416 | container.append('<input style="float: left; margin-left: 230px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />'); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
417 | // add hop from dropdownlist. |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
418 | $("#haddrowbutton").jqxDropDownList({ |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
419 | placeHolder: "Kies hop:", |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
420 | theme: theme, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
421 | source: hoplist, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
422 | displayMember: "name", |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
423 | width: 150, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
424 | height: 27, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
425 | dropDownWidth: 300 |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
426 | }); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
427 | $("#haddrowbutton").on('select', function (event) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
428 | if (event.args) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
429 | var index = event.args.index; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
430 | var datarecord = hoplist.records[index]; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
431 | var row = {}; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
432 | row["h_name"] = datarecord.name; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
433 | row["h_origin"] = datarecord.origin; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
434 | row["h_amount"] = 0; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
435 | row["h_cost"] = datarecord.cost; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
436 | row["h_type"] = datarecord.type; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
437 | row["h_form"] = datarecord.form; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
438 | row["h_useat"] = datarecord.useat; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
439 | row["h_time"] = 0; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
440 | row["h_alpha"] = datarecord.alpha; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
441 | row["h_beta"] = datarecord.beta; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
442 | row["h_hsi"] = datarecord.hsi; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
443 | row["h_humulene"] = datarecord.humulene; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
444 | row["h_carophyllene"] = datarecord.carophyllene; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
445 | row["h_cohumulone"] = datarecord.cohumulone; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
446 | row["h_myrcene"] = datarecord.myrcene; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
447 | row["h_total_oil"] = datarecord.total_oil; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
448 | var commit = $("#hopGrid").jqxGrid('addrow', null, row); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
449 | } |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
450 | }); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
451 | |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
452 | // delete selected hop. |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
453 | $("#hdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
454 | $("#hdeleterowbutton").on('click', function () { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
455 | var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex'); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
456 | var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
457 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
458 | var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
459 | var commit = $("#hopGrid").jqxGrid('deleterow', id); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
460 | } |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
461 | }); |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
462 | }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
463 | columns: [ |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
464 | { text: 'Hop', editable: false, datafield: 'h_name' }, |
59
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
465 | { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
466 | { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, |
58
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
467 | { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
468 | { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
469 | columntype: 'numberinput', |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
470 | validation: function (cell, value) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
471 | if (value < 0 || value > 100000000000 ) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
472 | return { result: false, message: "Volume moet 0-~ zijn" }; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
473 | } |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
474 | return true; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
475 | } |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
476 | }, |
59
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
477 | { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat' }, |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
478 | { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
58
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
479 | columntype: 'numberinput', |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
480 | validation: function (cell, value) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
481 | if (value < 0 || value > 100000000000 ) { |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
482 | return { result: false, message: "De tijd moet 0-~ zijn" }; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
483 | } |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
484 | return true; |
59
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
485 | } // TODO: Only enable editing if Boil, else use fixed values. |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
486 | }, |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
487 | { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right', |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
488 | cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
489 | var ibu = toIBU(rowdata.h_useat, |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
490 | rowdata.h_form, |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
491 | parseFloat($("#est_og").jqxNumberInput('decimal')), |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
492 | parseFloat($("#batch_size").jqxNumberInput('decimal')), |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
493 | parseFloat(rowdata.h_amount), |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
494 | parseFloat(rowdata.h_time), |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
495 | parseFloat(rowdata.h_alpha), |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
496 | $("#ibu_method").val() |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
497 | ); |
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
498 | return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>"; |
58
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
499 | } |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
500 | } |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
501 | ] |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
502 | }) |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
503 | }; |
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
504 | |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
505 | // Inline miscs editor |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
506 | var editMisc = function (data) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
507 | var miscSource = { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
508 | localdata: data.miscs, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
509 | datatype: "local", |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
510 | cache: false, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
511 | datafields: [ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
512 | { name: 'm_name', type: 'string' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
513 | { name: 'm_amount', type: 'float' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
514 | { name: 'm_cost', type: 'float' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
515 | { name: 'm_type', type: 'string' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
516 | { name: 'm_use_use', type: 'string' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
517 | { name: 'm_time', type: 'float' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
518 | { name: 'm_amount_is_weight', type: 'bool' } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
519 | ], |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
520 | addrow: function (rowid, rowdata, position, commit) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
521 | commit(true); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
522 | }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
523 | deleterow: function (rowid, commit) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
524 | commit(true); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
525 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
526 | }; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
527 | var miscAdapter = new $.jqx.dataAdapter(miscSource); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
528 | // dropdownlist datasource from inventory_miscs |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
529 | var miscUrl = "getmiscsources.php"; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
530 | var miscInvSource = { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
531 | datatype: "json", |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
532 | datafields: [ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
533 | { name: 'record', type: 'number' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
534 | { name: 'name', type: 'string' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
535 | { name: 'type', type: 'string' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
536 | { name: 'use_use', type: 'string' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
537 | { name: 'amount_is_weight', type: 'bool' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
538 | { name: 'time', type: 'float' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
539 | { name: 'cost', type: 'float' } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
540 | ], |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
541 | url: miscUrl, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
542 | async: true |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
543 | }; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
544 | var misclist = new $.jqx.dataAdapter(miscInvSource); |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
545 | |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
546 | $("#miscGrid").jqxGrid({ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
547 | width: 960, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
548 | height: 400, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
549 | source: miscAdapter, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
550 | theme: theme, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
551 | selectionmode: 'singlerow', |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
552 | editmode: 'selectedrow', |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
553 | editable: true, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
554 | localization: getLocalization(), |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
555 | showtoolbar: true, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
556 | rendertoolbar: function (toolbar) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
557 | var me = this; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
558 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
559 | toolbar.append(container); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
560 | container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>'); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
561 | container.append('<input style="float: left; margin-left: 230px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />'); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
562 | // add misc from dropdownlist. |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
563 | $("#maddrowbutton").jqxDropDownList({ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
564 | placeHolder: "Kies ingredient:", |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
565 | theme: theme, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
566 | source: misclist, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
567 | displayMember: "name", |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
568 | width: 150, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
569 | height: 27, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
570 | dropDownWidth: 300 |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
571 | }); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
572 | $("#maddrowbutton").on('select', function (event) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
573 | if (event.args) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
574 | var index = event.args.index; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
575 | var datarecord = misclist.records[index]; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
576 | var row = {}; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
577 | row["m_name"] = datarecord.name; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
578 | row["m_amount"] = 0; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
579 | row["m_cost"] = datarecord.cost; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
580 | row["m_type"] = datarecord.type; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
581 | row["m_use_use"] = datarecord.use_use; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
582 | row["m_time"] = 0; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
583 | row["m_amount_is_weight"] = datarecord.amount_is_weight; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
584 | var commit = $("#miscGrid").jqxGrid('addrow', null, row); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
585 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
586 | }); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
587 | // delete selected misc. |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
588 | $("#mdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
589 | $("#mdeleterowbutton").on('click', function () { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
590 | var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex'); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
591 | var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
592 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
593 | var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
594 | var commit = $("#miscGrid").jqxGrid('deleterow', id); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
595 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
596 | }); |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
597 | }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
598 | columns: [ |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
599 | { text: 'Ingredient', editable: false, datafield: 'm_name' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
600 | { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
601 | { text: 'Gebruik', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'm_use_use' }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
602 | { text: 'Gewicht', datafield: 'm_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5', |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
603 | columntype: 'numberinput', |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
604 | validation: function (cell, value) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
605 | if (value < 0 || value > 100000000000 ) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
606 | return { result: false, message: "Volume moet 0-~ zijn" }; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
607 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
608 | return true; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
609 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
610 | }, |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
611 | { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
612 | columntype: 'numberinput', |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
613 | validation: function (cell, value) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
614 | if (value < 0 || value > 100000000000 ) { |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
615 | return { result: false, message: "De tijd moet 0-~ zijn" }; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
616 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
617 | return true; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
618 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
619 | } |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
620 | ] |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
621 | }) |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
622 | }; |
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
623 | |
61 | 624 | // Inline yeasts editor |
625 | var editYeast = function (data) { | |
626 | var yeastSource = { | |
627 | localdata: data.yeasts, | |
628 | datatype: "local", | |
629 | cache: false, | |
630 | datafields: [ | |
631 | { name: 'y_name', type: 'string' }, | |
632 | { name: 'y_laboratory', type: 'string' }, | |
633 | { name: 'y_product_id', type: 'string' }, | |
634 | { name: 'y_amount', type: 'float' }, | |
635 | { name: 'y_cost', type: 'float' }, | |
636 | { name: 'y_type', type: 'string' }, | |
637 | { name: 'y_form', type: 'string' }, | |
638 | { name: 'y_time', type: 'float' }, | |
639 | { name: 'y_min_temperature', type: 'float' }, | |
640 | { name: 'y_max_temperature', type: 'float' }, | |
641 | { name: 'y_attenuation', type: 'float' }, | |
642 | { name: 'y_amount_is_weight', type: 'bool' }, | |
643 | { name: 'y_use', type: 'string' } | |
644 | ], | |
645 | addrow: function (rowid, rowdata, position, commit) { | |
646 | commit(true); | |
647 | }, | |
648 | deleterow: function (rowid, commit) { | |
649 | commit(true); | |
650 | } | |
651 | }; | |
652 | var yeastAdapter = new $.jqx.dataAdapter(yeastSource); | |
653 | // dropdownlist datasource from inventory_yeasts | |
654 | var yeastUrl = "getyeastsources.php"; | |
655 | var yeastInvSource = { | |
656 | datatype: "json", | |
657 | datafields: [ | |
658 | { name: 'record', type: 'number' }, | |
659 | { name: 'name', type: 'string' }, | |
660 | { name: 'type', type: 'string' }, | |
661 | { name: 'form', type: 'string' }, | |
662 | { name: 'laboratory', type: 'string' }, | |
663 | { name: 'product_id', type: 'string' }, | |
664 | { name: 'min_temperature', type: 'float' }, | |
665 | { name: 'max_temperature', type: 'float' }, | |
666 | { name: 'attenuation', type: 'float' }, | |
667 | { name: 'cost', type: 'float' } | |
668 | ], | |
669 | url: yeastUrl, | |
670 | async: true | |
671 | }; | |
672 | var yeastlist = new $.jqx.dataAdapter(yeastInvSource); | |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
673 | |
61 | 674 | $("#yeastGrid").jqxGrid({ |
675 | width: 1050, | |
676 | height: 300, | |
677 | source: yeastAdapter, | |
678 | theme: theme, | |
679 | selectionmode: 'singlerow', | |
680 | editmode: 'selectedrow', | |
681 | editable: true, | |
682 | localization: getLocalization(), | |
683 | showtoolbar: true, | |
684 | rendertoolbar: function (toolbar) { | |
685 | var me = this; | |
686 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
687 | toolbar.append(container); | |
688 | container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>'); | |
689 | container.append('<input style="float: left; margin-left: 230px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />'); | |
690 | // add yeast from dropdownlist. | |
691 | $("#yaddrowbutton").jqxDropDownList({ | |
692 | placeHolder: "Kies gist:", | |
693 | theme: theme, | |
694 | source: yeastlist, | |
695 | displayMember: "name", | |
696 | width: 150, | |
697 | height: 27, | |
698 | dropDownWidth: 300 | |
699 | }); | |
700 | $("#yaddrowbutton").on('select', function (event) { | |
701 | if (event.args) { | |
702 | var index = event.args.index; | |
703 | var datarecord = yeastlist.records[index]; | |
704 | var row = {}; | |
705 | row["y_name"] = datarecord.name; | |
706 | row["y_laboratory"] = datarecord.laboratory; | |
707 | row["y_product_id"] = datarecord.product_id; | |
708 | row["y_type"] = datarecord.type; | |
709 | row["y_form"] = datarecord.form; | |
710 | row["y_amount"] = 0; | |
711 | row["y_cost"] = datarecord.cost; | |
712 | row["y_use"] = "Primary"; | |
713 | row["y_time"] = 0; | |
714 | if (datarecord.form == "Dry") { | |
715 | row["y_amount_is_weight"] = 1; | |
716 | } else { | |
717 | row["y_amount_is_weight"] = 0; | |
718 | } | |
719 | row["y_min_temperature"] = datarecord.min_temperature; | |
720 | row["y_max_temperature"] = datarecord.max_temperature; | |
721 | row["y_attenuation"] = datarecord.attenuation; | |
722 | var commit = $("#yeastGrid").jqxGrid('addrow', null, row); | |
723 | } | |
724 | }); | |
725 | // delete selected yeast. | |
726 | $("#ydeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); | |
727 | $("#ydeleterowbutton").on('click', function () { | |
728 | var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex'); | |
729 | var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount; | |
730 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
731 | var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex); | |
732 | var commit = $("#yeastGrid").jqxGrid('deleterow', id); | |
733 | } | |
734 | }); | |
735 | }, | |
736 | columns: [ | |
737 | { text: 'Gist', editable: false, datafield: 'y_name' }, | |
738 | { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' }, | |
739 | { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, | |
740 | { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, | |
741 | { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, | |
742 | { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, | |
743 | { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, | |
744 | { text: 'Voor', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_use' }, | |
745 | { text: 'Hoeveel', datafield: 'y_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5', | |
746 | columntype: 'numberinput', | |
747 | validation: function (cell, value) { | |
748 | if (value < 0 || value > 100000000000 ) { | |
749 | return { result: false, message: "Volume moet 0-~ zijn" }; | |
750 | } | |
751 | return true; | |
752 | } | |
753 | } | |
754 | ] | |
755 | }) | |
756 | }; | |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
757 | |
51 | 758 | // Inline waters editor |
759 | var editWater = function (data) { | |
760 | var waterSource = { | |
761 | localdata: data.waters, | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
762 | datatype: "local", |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
763 | datafields: [ |
51 | 764 | { name: 'w_name', type: 'string' }, |
765 | { name: 'w_amount', type: 'float' }, | |
766 | { name: 'w_calcium', type: 'float' }, | |
767 | { name: 'w_sulfate', type: 'float' }, | |
768 | { name: 'w_chloride', type: 'float' }, | |
769 | { name: 'w_sodium', type: 'float' }, | |
770 | { name: 'w_magnesium', type: 'float' }, | |
771 | { name: 'w_ph', type: 'float' }, | |
772 | { name: 'w_total_alkalinity', type: 'float' }, | |
773 | { name: 'w_cost', type: 'float' }, | |
774 | { name: 'w_default_water', type: 'bool' } | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
775 | ], |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
776 | addrow: function (rowid, rowdata, position, commit) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
777 | commit(true); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
778 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
779 | deleterow: function (rowid, commit) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
780 | commit(true); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
781 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
782 | }; |
51 | 783 | var waterAdapter = new $.jqx.dataAdapter(waterSource); |
55
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
784 | // dropdownlist datasource from inventory_waters |
54
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
785 | var waterUrl = "getwatersources.php"; |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
786 | var waterInvSource = { |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
787 | datatype: "json", |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
788 | datafields: [ |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
789 | { name: 'record', type: 'number' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
790 | { name: 'name', type: 'string' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
791 | { name: 'unlimited_stock', type: 'bool' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
792 | { name: 'calcium', type: 'float' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
793 | { name: 'sulfate', type: 'float' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
794 | { name: 'chloride', type: 'float' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
795 | { name: 'sodium', type: 'float' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
796 | { name: 'magnesium', type: 'float' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
797 | { name: 'ph', type: 'float' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
798 | { name: 'total_alkalinity', type: 'float' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
799 | { name: 'cost', type: 'float' }, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
800 | { name: 'default_water', type: 'bool' } |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
801 | ], |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
802 | url: waterUrl, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
803 | async: true |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
804 | }; |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
805 | var waterlist = new $.jqx.dataAdapter(waterInvSource); |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
806 | |
51 | 807 | $("#waterGrid").jqxGrid({ |
808 | width: 960, | |
809 | height: 200, | |
810 | source: waterAdapter, | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
811 | theme: theme, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
812 | selectionmode: 'singlerow', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
813 | editmode: 'selectedrow', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
814 | editable: true, |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
815 | localization: getLocalization(), |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
816 | showtoolbar: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
817 | rendertoolbar: function (toolbar) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
818 | var me = this; |
55
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
819 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
820 | toolbar.append(container); |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
821 | container.append('<div style="float: left; margin-left: 165px;" id="waddrowbutton"></div>'); |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
822 | container.append('<input style="float: left; margin-left: 230px;" id="wdeleterowbutton" type="button" value="Verwijder water" />'); |
55
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
823 | // add water from dropdownlist. |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
824 | $("#waddrowbutton").jqxDropDownList({ |
54
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
825 | placeHolder: "Kies water:", |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
826 | theme: theme, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
827 | source: waterlist, |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
828 | displayMember: "name", |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
829 | width: 150, |
55
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
830 | height: 27, |
54
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
831 | dropDownWidth: 300 |
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
832 | }); |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
833 | $("#waddrowbutton").on('select', function (event) { |
55
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
834 | if (event.args) { |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
835 | var index = event.args.index; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
836 | var datarecord = waterlist.records[index]; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
837 | var row = {}; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
838 | row["w_name"] = datarecord.name; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
839 | row["w_amount"] = 0; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
840 | row["w_calcium"] = datarecord.calcium; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
841 | row["w_sulfate"] = datarecord.sulfate; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
842 | row["w_chloride"] = datarecord.chloride; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
843 | row["w_sodium"] = datarecord.sodium; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
844 | row["w_magnesium"] = datarecord.magnesium; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
845 | row["w_ph"] = datarecord.ph; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
846 | row["w_total_alkalinity"] = datarecord.total_alkalinity; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
847 | row["w_default_water"] = datarecord.default_water; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
848 | row["w_cost"] = datarecord.cost; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
849 | var commit = $("#waterGrid").jqxGrid('addrow', null, row); |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
850 | } |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
851 | }); |
54
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
852 | |
55
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
853 | // delete selected water. |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
854 | // Overgebleven waters in volume verhogen met het verwijderde water. |
57
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
855 | $("#wdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
bb9a06aa9acd
Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
56
diff
changeset
|
856 | $("#wdeleterowbutton").on('click', function () { |
55
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
857 | var selectedrowindex = $("#waterGrid").jqxGrid('getselectedrowindex'); |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
858 | var rowscount = $("#waterGrid").jqxGrid('getdatainformation').rowscount; |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
859 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
860 | var id = $("#waterGrid").jqxGrid('getrowid', selectedrowindex); |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
861 | var commit = $("#waterGrid").jqxGrid('deleterow', id); |
3e29755638b6
Add and delete water completed.
Michiel Broek <mbroek@mbse.eu>
parents:
54
diff
changeset
|
862 | } |
54
294dda7f1779
Beginning of water totals and selecting
Michiel Broek <mbroek@mbse.eu>
parents:
53
diff
changeset
|
863 | }); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
864 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
865 | columns: [ |
51 | 866 | { text: 'Water bron', editable: false, datafield: 'w_name' }, |
867 | { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', | |
868 | columntype: 'numberinput', | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
869 | validation: function (cell, value) { |
51 | 870 | if (value < 0 || value > 100000000000 ) { |
871 | 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
|
872 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
873 | return true; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
874 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
875 | }, |
51 | 876 | // TODO: validator test max is hoeveelheid maischwater. Dan water verdelen voor totaal. |
877 | { text: 'Ca', editable: false, datafield: 'w_calcium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
878 | { text: 'Mg', editable: false, datafield: 'w_magnesium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
879 | { text: 'Na', editable: false, datafield: 'w_sodium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
880 | { text: 'Tot Alk', editable: false, datafield: 'w_total_alkalinity', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
881 | { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
882 | { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
883 | { 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
|
884 | ] |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
885 | }); |
51 | 886 | }; // editWater = function (data) { |
887 | ||
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
888 | // inline mash editor |
62
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
889 | var editMash = function (data) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
890 | var generaterow = function () { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
891 | var row = {}; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
892 | row["step_name"] = "Stap 1"; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
893 | row["step_type"] = "Infusion"; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
894 | row["step_infuse_amount"] = 15; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
895 | row["step_temp"] = 62.0; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
896 | row['step_time'] = 20.0; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
897 | row['ramp_time'] = 1.0; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
898 | row['end_temp'] = 62.0; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
899 | return row; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
900 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
901 | var mashSource = { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
902 | localdata: data.mashs, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
903 | datatype: "local", |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
904 | cache: false, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
905 | datafields: [ |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
906 | { name: 'step_name', type: 'string' }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
907 | { name: 'step_type', type: 'string' }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
908 | { name: 'step_infuse_amount', type: 'float' }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
909 | { name: 'step_temp', type: 'float' }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
910 | { name: 'step_time', type: 'float' }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
911 | { name: 'ramp_time', type: 'float' }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
912 | { name: 'end_temp', type: 'float' } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
913 | ], |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
914 | addrow: function (rowid, rowdata, position, commit) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
915 | commit(true); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
916 | }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
917 | deleterow: function (rowid, commit) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
918 | commit(true); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
919 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
920 | }; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
921 | var mashAdapter = new $.jqx.dataAdapter(mashSource); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
922 | // dropdownlist datasource from profile_mash |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
923 | var mashUrl = "include/db_profile_mash.php"; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
924 | var mashInvSource = { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
925 | datatype: "json", |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
926 | datafields: [ |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
927 | { name: 'record', type: 'number' }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
928 | { name: 'name', type: 'string' }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
929 | { name: 'steps', type: 'array' } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
930 | ], |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
931 | url: mashUrl, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
932 | async: true |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
933 | }; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
934 | var mashlist = new $.jqx.dataAdapter(mashInvSource); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
935 | |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
936 | $("#mashGrid").jqxGrid({ |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
937 | width: 960, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
938 | height: 400, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
939 | source: mashAdapter, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
940 | theme: theme, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
941 | selectionmode: 'singlerow', |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
942 | editmode: 'selectedrow', |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
943 | editable: true, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
944 | localization: getLocalization(), |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
945 | showtoolbar: true, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
946 | rendertoolbar: function (toolbar) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
947 | var me = this; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
948 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
949 | toolbar.append(container); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
950 | container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
951 | container.append('<input style="float: left; margin-left: 230px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
952 | $("#saddrowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
953 | $("#saddrowbutton").on('click', function () { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
954 | var datarow = generaterow(); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
955 | var commit = $("#mashGrid").jqxGrid('addrow', null, datarow); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
956 | }); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
957 | // delete selected yeast. |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
958 | $("#sdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
959 | $("#sdeleterowbutton").on('click', function () { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
960 | var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex'); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
961 | var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
962 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
963 | var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
964 | var commit = $("#mashGrid").jqxGrid('deleterow', id); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
965 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
966 | }); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
967 | }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
968 | columns: [ |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
969 | { text: 'Stap naam', datafield: 'step_name' }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
970 | { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist', |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
971 | createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
972 | var dataSource = [ "Infusion", "Temperature", "Decoction" ]; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
973 | editor.jqxDropDownList({ source: dataSource, dropDownHeight: 105 }); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
974 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
975 | }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
976 | { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
977 | validation: function (cell, value) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
978 | if (value < 35 || value > 80) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
979 | return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
980 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
981 | return true; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
982 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
983 | }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
984 | { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
985 | validation: function (cell, value) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
986 | if (value < 35 || value > 80) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
987 | return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
988 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
989 | return true; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
990 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
991 | }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
992 | { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right', |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
993 | validation: function (cell, value) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
994 | if (value < 1 || value > 360) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
995 | return { result: false, message: "De tijd moet tussen 1 en 360 zijn." }; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
996 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
997 | return true; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
998 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
999 | }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1000 | { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right', |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1001 | validation: function (cell, value) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1002 | if (value < 1 || value > 60) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1003 | return { result: false, message: "De tijd moet tussen 1 en 60 zijn." }; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1004 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1005 | return true; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1006 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1007 | }, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1008 | { text: 'Infuse', datafield: 'step_infuse_amount', width: 70, align: 'right', cellsalign: 'right', |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1009 | validation: function (cell, value) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1010 | if (value < 0 || value > 60) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1011 | return { result: false, message: "De waarde moet tussen 0 en 60 zijn." }; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1012 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1013 | return true; |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1014 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1015 | } |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1016 | ] |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1017 | }); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1018 | $("#mashGrid").on('cellendedit', function (event) { |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1019 | $('#mashGrid').jqxGrid('sortby', 'step_temp', 'asc'); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1020 | }); |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1021 | }; |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
1022 | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1023 | // initialize the input fields. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1024 | var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1025 | var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1026 | var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1027 | $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1028 | $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); |
51 | 1029 | $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); |
1030 | $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); | |
1031 | $("#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
|
1032 | $("#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
|
1033 | $("#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
|
1034 | $("#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
|
1035 | $("#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
|
1036 | $("#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 | 1037 | $("#st_og_min").jqxNumberInput({ disabled: true, inputMode: 'simple', width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
1038 | $("#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
|
1039 | $("#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
|
1040 | $("#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
|
1041 | $("#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
|
1042 | $("#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
|
1043 | $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 180 }); |
51 | 1044 | $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
1045 | $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); | |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1046 | $("#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 }); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1047 | var editrow = -1; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1048 | // initialize jqxGrid |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1049 | $("#jqxgrid").jqxGrid({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1050 | width: 1280, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1051 | height: 630, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1052 | source: dataAdapter, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1053 | groupable: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1054 | theme: theme, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1055 | showstatusbar: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1056 | localization: getLocalization(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1057 | renderstatusbar: function (statusbar) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1058 | 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
|
1059 | 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
|
1060 | container.append(addButton); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1061 | statusbar.append(container); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1062 | addButton.jqxButton({ theme: theme, width: 120, height: 20 }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1063 | // add new row. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1064 | addButton.click(function (event) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1065 | editrow = -1; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1066 | $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1067 | $("#name").val(''); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1068 | $("#notes").val(''); |
51 | 1069 | $("#st_name").val(''); |
1070 | $("#st_letter").val(''); | |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1071 | $("#st_guide").val('BKG 2015'); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1072 | $("#type").val('All Grain'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1073 | $("#batch_size").val(20); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1074 | $("#boil_time").val(90); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1075 | $("#efficiency").val(75); |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1076 | $("#est_og").val(1.052); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1077 | $("#est_fg").val(1.000); |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1078 | $("#est_color").val(20); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1079 | $("#color_method").val('Morey'); |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1080 | $("#est_ibu").val(40); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1081 | $("#ibu_method").val('Tinseth'); |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1082 | $("#mash_sparge_temp").val(78); |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1083 | $("#mash_ph").val(5.4); |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1084 | $("#mash_name").val(''); |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
1085 | editFermentable(''); |
58
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
1086 | editHop(''); |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
1087 | editMisc(''); |
61 | 1088 | editYeast(''); |
51 | 1089 | editWater(''); |
62
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1090 | editMash(''); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1091 | $("#popupWindow").jqxWindow('open'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1092 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1093 | }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1094 | filterable: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1095 | filtermode: 'excel', |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1096 | columns: [ |
51 | 1097 | { text: 'Stijlgids', datafield: 'st_guide', width: 120 }, |
1098 | { text: 'Letter', datafield: 'st_letter', width: 60 }, | |
1099 | { text: 'Stijl', datafield: 'st_name', width: 150 }, | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1100 | { text: 'Naam', datafield: 'name' }, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1101 | { 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
|
1102 | { 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
|
1103 | { 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
|
1104 | { 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
|
1105 | return "Wijzig"; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1106 | }, buttonclick: function (row) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1107 | // 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
|
1108 | editrow = row; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1109 | $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1110 | // 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
|
1111 | var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1112 | $("#name").val(dataRecord.name); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1113 | $("#notes").val(dataRecord.notes); |
51 | 1114 | $("#st_name").val(dataRecord.st_name); |
1115 | $("#st_letter").val(dataRecord.st_letter); | |
1116 | $("#st_guide").val(dataRecord.st_guide); | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1117 | $("#type").val(dataRecord.type); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1118 | $("#batch_size").val(dataRecord.batch_size); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1119 | $("#boil_time").val(dataRecord.boil_time); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1120 | $("#efficiency").val(dataRecord.efficiency); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1121 | $("#est_og").val(dataRecord.est_og); |
51 | 1122 | $("#st_og_min").val(dataRecord.st_og_min); |
1123 | $("#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
|
1124 | $("#est_fg").val(dataRecord.est_fg); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1125 | $("#est_color").val(dataRecord.est_color); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1126 | $("#color_method").val(dataRecord.color_method); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1127 | $("#est_ibu").val(dataRecord.est_ibu); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1128 | $("#ibu_method").val(dataRecord.ibu_method); |
51 | 1129 | $("#mash_name").val(dataRecord.mash_name); |
1130 | $("#mash_ph").val(dataRecord.mash_ph); | |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1131 | $("#mash_sparge_temp").val(dataRecord.mash_sparge_temp); |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
1132 | editFermentable(dataRecord); |
58
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
1133 | editHop(dataRecord); |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
1134 | editMisc(dataRecord); |
61 | 1135 | editYeast(dataRecord); |
51 | 1136 | editWater(dataRecord); |
62
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1137 | editMash(dataRecord); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1138 | // show the popup window. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1139 | $("#popupWindow").jqxWindow('open'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1140 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1141 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1142 | ], |
51 | 1143 | groups: ['st_guide','st_letter' ] |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1144 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1145 | |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1146 | // initialize the popup window and buttons. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1147 | $("#popupWindow").jqxWindow({ |
53 | 1148 | width: 1202, |
1149 | height: 622, | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1150 | resizable: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1151 | theme: theme, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1152 | isModal: true, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1153 | autoOpen: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1154 | cancelButton: $("#Cancel"), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1155 | modalOpacity: 0.40 |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1156 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1157 | // Tabs inside the popup window. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1158 | $('#jqxTabs').jqxTabs({ |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1159 | theme: theme, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1160 | autoHeight: false, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1161 | height: 580, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1162 | position: 'top' |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1163 | }); |
65
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
1164 | $("#popupWindow").on('open', function () { |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
1165 | $("#name").jqxInput('selectAll'); |
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
1166 | }); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1167 | |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1168 | $("#Delete").jqxButton({ width: '90px', theme: theme }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1169 | $("#Delete").click(function () { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1170 | if (editrow >= 0) { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1171 | // Open a popup to confirm this action. |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1172 | $('#eventWindow').jqxWindow('open'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1173 | $("#delOk").click(function () { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1174 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1175 | $("#jqxgrid").jqxGrid('deleterow', rowID); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1176 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1177 | } |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1178 | $("#popupWindow").jqxWindow('hide'); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1179 | }); |
65
5d5c67818d11
Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents:
62
diff
changeset
|
1180 | |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1181 | $("#Cancel").jqxButton({ width: '90px', theme: theme }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1182 | $("#Save").jqxButton({ width: '90px', theme: theme }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1183 | // 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
|
1184 | $("#Save").click(function () { |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
1185 | var fermentablerow = $('#fermentableGrid').jqxGrid('getrows'); |
58
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
1186 | var hoprow = $('#hopGrid').jqxGrid('getrows'); |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
1187 | var miscrow = $('#miscGrid').jqxGrid('getrows'); |
61 | 1188 | var yeastrow = $('#yeastGrid').jqxGrid('getrows'); |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1189 | var waterrow = $('#waterGrid').jqxGrid('getrows'); |
62
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1190 | var mashrow = $('#mashGrid').jqxGrid('getrows'); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1191 | if (editrow >= 0) { |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1192 | var rowRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1193 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1194 | var row = { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1195 | record: rowID, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1196 | name: $("#name").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1197 | notes: $("#notes").val(), |
51 | 1198 | st_name: $('#st_name').val(), |
1199 | st_letter: $('#st_letter').val(), | |
1200 | st_guide: $('#st_guide').val(), | |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1201 | st_og_min: rowRecord.st_og_min, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1202 | st_og_max: rowRecord.st_og_max, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1203 | st_fg_min: rowRecord.st_fg_min, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1204 | st_fg_max: rowRecord.st_fg_max, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1205 | st_ibu_min: rowRecord.st_ibu_min, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1206 | st_ibu_max: rowRecord.st_ibu_max, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1207 | st_color_min: rowRecord.st_color_min, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1208 | st_color_max: rowRecord.st_color_max, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1209 | st_carb_min: rowRecord.st_carb_min, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1210 | st_carb_max: rowRecord.st_carb_max, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1211 | st_abv_min: rowRecord.st_abv_min, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1212 | st_abv_max: rowRecord.st_abv_max, |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1213 | type: $("#type").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1214 | batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1215 | boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1216 | efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1217 | est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1218 | est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1219 | est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1220 | color_method: $("#color_method").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1221 | est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), |
51 | 1222 | ibu_method: $("#ibu_method").val(), |
1223 | mash_name: $("#mash_name").val(), | |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1224 | mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')), |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1225 | mash_sparge_temp: parseFloat($("#mash_sparge_temp").jqxNumberInput('decimal')), |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
1226 | fermentables: fermentablerow, |
59
ad28e09e3abd
Added Tinseth IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
1227 | hops: hoprow, |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
1228 | miscs: miscrow, |
61 | 1229 | yeasts: yeastrow, |
62
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1230 | waters: waterrow, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1231 | mashs: mashrow |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1232 | }; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1233 | $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1234 | } else { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1235 | // Insert a record |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1236 | var newrow = { |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1237 | record: -1, |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1238 | name: $("#name").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1239 | notes: $("#notes").val(), |
51 | 1240 | st_name: $('#st_name').val(), |
1241 | st_letter: $('#st_letter').val(), | |
1242 | st_guide: $('#st_guide').val(), | |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1243 | st_og_min: 1.025, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1244 | st_og_max: 1.110, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1245 | st_fg_min: 1.000, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1246 | st_fg_max: 1.025, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1247 | st_ibu_min: 15, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1248 | st_ibu_max: 150, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1249 | st_color_min: 5, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1250 | st_color_max: 50, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1251 | st_carb_min: 1, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1252 | st_carb_max: 3, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1253 | st_abv_min: 2, |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1254 | st_abv_max: 14, |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1255 | type: $("#type").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1256 | batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1257 | boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1258 | efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1259 | est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1260 | est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1261 | est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1262 | color_method: $("#color_method").val(), |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1263 | est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), |
51 | 1264 | ibu_method: $("#ibu_method").val(), |
1265 | mash_name: $("#mash_name").val(), | |
52
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1266 | mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')), |
b1f2a893572f
More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents:
51
diff
changeset
|
1267 | mash_sparge_temp: parseFloat($("#mash_sparge_temp").jqxNumberInput('decimal')), |
56
d4f4762e59b3
Start inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
1268 | fermentables: fermentablerow, |
58
83ccc36df675
Added hops inline editor framework
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
1269 | hops: hoprow, |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
1270 | miscs: miscrow, |
61 | 1271 | yeasts: yeastrow, |
62
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1272 | waters: waterrow, |
12c5eae75d1e
Added inline mash steps editor framework, the rough parts are ready.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1273 | mashs: mashrow |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1274 | }; |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1275 | $('#jqxgrid').jqxGrid('addrow', null, newrow); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1276 | } |
60
dbbe408108ea
Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents:
59
diff
changeset
|
1277 | $("#popupWindow").jqxWindow('hide'); |
50
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1278 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1279 | createDelElements(); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1280 | }); |
6d94167c2697
Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1281 |