58 { name: 'st_name', type: 'string' }, |
58 { name: 'st_name', type: 'string' }, |
59 { name: 'st_letter', type: 'string' }, |
59 { name: 'st_letter', type: 'string' }, |
60 { name: 'st_guide', type: 'string' }, |
60 { name: 'st_guide', type: 'string' }, |
61 { name: 'st_og_min', type: 'float' }, |
61 { name: 'st_og_min', type: 'float' }, |
62 { name: 'st_og_max', type: 'float' }, |
62 { name: 'st_og_max', type: 'float' }, |
|
63 { name: 'st_fg_min', type: 'float' }, |
|
64 { name: 'st_fg_max', type: 'float' }, |
|
65 { name: 'st_ibu_min', type: 'float' }, |
|
66 { name: 'st_ibu_max', type: 'float' }, |
|
67 { name: 'st_color_min', type: 'float' }, |
|
68 { name: 'st_color_max', type: 'float' }, |
|
69 { name: 'st_carb_min', type: 'float' }, |
|
70 { name: 'st_carb_max', type: 'float' }, |
|
71 { name: 'st_abv_min', type: 'float' }, |
|
72 { name: 'st_abv_max', type: 'float' }, |
63 { name: 'name', type: 'string' }, |
73 { name: 'name', type: 'string' }, |
64 { name: 'notes', type: 'string' }, |
74 { name: 'notes', type: 'string' }, |
65 { name: 'type', type: 'number' }, |
75 { name: 'type', type: 'number' }, |
66 { name: 'batch_size', type: 'float' }, |
76 { name: 'batch_size', type: 'float' }, |
67 { name: 'boil_time', type: 'float' }, |
77 { name: 'boil_time', type: 'float' }, |
135 }; |
145 }; |
136 var dataAdapter = new $.jqx.dataAdapter(source); |
146 var dataAdapter = new $.jqx.dataAdapter(source); |
137 |
147 |
138 // Inline waters editor |
148 // Inline waters editor |
139 var editWater = function (data) { |
149 var editWater = function (data) { |
140 // var generaterow = function () { |
|
141 // var row = {}; |
|
142 // row["w_name"] = "Water 1"; |
|
143 // row["step_type"] = "Infusion"; |
|
144 // row["w_amount"] = 22.0; |
|
145 // row['step_time'] = 20.0; |
|
146 // row['ramp_time'] = 1.0; |
|
147 // row['end_temp'] = 62.0; |
|
148 // return row; |
|
149 // } |
|
150 var waterSource = { |
150 var waterSource = { |
151 localdata: data.waters, |
151 localdata: data.waters, |
152 datatype: "local", |
152 datatype: "local", |
153 datafields: [ |
153 datafields: [ |
154 { name: 'w_name', type: 'string' }, |
154 { name: 'w_name', type: 'string' }, |
178 source: waterAdapter, |
178 source: waterAdapter, |
179 theme: theme, |
179 theme: theme, |
180 selectionmode: 'singlerow', |
180 selectionmode: 'singlerow', |
181 editmode: 'selectedrow', |
181 editmode: 'selectedrow', |
182 editable: true, |
182 editable: true, |
183 showstatusbar: true, |
|
184 statusbarheight: 50, |
|
185 showaggregates: true, |
|
186 showtoolbar: true, |
183 showtoolbar: true, |
187 rendertoolbar: function (toolbar) { |
184 rendertoolbar: function (toolbar) { |
188 var me = this; |
185 var me = this; |
189 var container = $("<div style='margin: 5px;'></div>"); |
186 var container = $("<div style='margin: 5px;'></div>"); |
190 toolbar.append(container); |
187 toolbar.append(container); |
210 }, |
207 }, |
211 columns: [ |
208 columns: [ |
212 { text: 'Water bron', editable: false, datafield: 'w_name' }, |
209 { text: 'Water bron', editable: false, datafield: 'w_name' }, |
213 { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
210 { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
214 columntype: 'numberinput', |
211 columntype: 'numberinput', |
215 aggregates: ['sum'], |
|
216 validation: function (cell, value) { |
212 validation: function (cell, value) { |
217 if (value < 0 || value > 100000000000 ) { |
213 if (value < 0 || value > 100000000000 ) { |
218 return { result: false, message: "Volume moet 0-~ zijn" }; |
214 return { result: false, message: "Volume moet 0-~ zijn" }; |
219 } |
215 } |
220 return true; |
216 return true; |
228 { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
224 { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
229 { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
225 { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
230 { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' } |
226 { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' } |
231 ] |
227 ] |
232 }); |
228 }); |
233 // $("#grid").on('cellendedit', function (event) { |
|
234 // $('#grid').jqxGrid('sortby', 'step_temp', 'asc'); |
|
235 // }); |
|
236 }; // editWater = function (data) { |
229 }; // editWater = function (data) { |
237 |
230 |
238 // initialize the input fields. |
231 // initialize the input fields. |
239 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
232 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
240 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
233 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
256 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); |
249 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); |
257 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 200, decimalDigits: 0, spinButtons: true }); |
250 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 200, decimalDigits: 0, spinButtons: true }); |
258 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 180 }); |
251 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 180 }); |
259 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
252 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
260 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
253 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
|
254 $("#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 }); |
261 var editrow = -1; |
255 var editrow = -1; |
262 // initialize jqxGrid |
256 // initialize jqxGrid |
263 $("#jqxgrid").jqxGrid({ |
257 $("#jqxgrid").jqxGrid({ |
264 width: 1280, |
258 width: 1280, |
265 height: 630, |
259 height: 630, |
280 $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } }); |
274 $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } }); |
281 $("#name").val(''); |
275 $("#name").val(''); |
282 $("#notes").val(''); |
276 $("#notes").val(''); |
283 $("#st_name").val(''); |
277 $("#st_name").val(''); |
284 $("#st_letter").val(''); |
278 $("#st_letter").val(''); |
285 $("#st_guide").val(''); |
279 $("#st_guide").val('BKG 2015'); |
286 $("#type").val('All Grain'); |
280 $("#type").val('All Grain'); |
287 $("#batch_size").val(20); |
281 $("#batch_size").val(20); |
288 $("#boil_time").val(90); |
282 $("#boil_time").val(90); |
289 $("#efficiency").val(75); |
283 $("#efficiency").val(75); |
290 $("#est_og").val(1.062); |
284 $("#est_og").val(1.052); |
291 $("#est_fg").val(1.000); |
285 $("#est_fg").val(1.000); |
292 $("#est_color").val(0); |
286 $("#est_color").val(20); |
293 $("#color_method").val('Morey'); |
287 $("#color_method").val('Morey'); |
294 $("#est_ibu").val(0); |
288 $("#est_ibu").val(40); |
295 $("#ibu_method").val('Tinseth'); |
289 $("#ibu_method").val('Tinseth'); |
|
290 $("#mash_sparge_temp").val(78); |
|
291 $("#mash_ph").val(5.4); |
|
292 $("#mash_name").val(''); |
296 editWater(''); |
293 editWater(''); |
297 $("#popupWindow").jqxWindow('open'); |
294 $("#popupWindow").jqxWindow('open'); |
298 }); |
295 }); |
299 }, |
296 }, |
300 filterable: true, |
297 filterable: true, |
332 $("#color_method").val(dataRecord.color_method); |
329 $("#color_method").val(dataRecord.color_method); |
333 $("#est_ibu").val(dataRecord.est_ibu); |
330 $("#est_ibu").val(dataRecord.est_ibu); |
334 $("#ibu_method").val(dataRecord.ibu_method); |
331 $("#ibu_method").val(dataRecord.ibu_method); |
335 $("#mash_name").val(dataRecord.mash_name); |
332 $("#mash_name").val(dataRecord.mash_name); |
336 $("#mash_ph").val(dataRecord.mash_ph); |
333 $("#mash_ph").val(dataRecord.mash_ph); |
|
334 $("#mash_sparge_temp").val(dataRecord.mash_sparge_temp); |
337 editWater(dataRecord); |
335 editWater(dataRecord); |
338 // editsteps(dataRecord); |
|
339 // show the popup window. |
336 // show the popup window. |
340 $("#popupWindow").jqxWindow('open'); |
337 $("#popupWindow").jqxWindow('open'); |
341 } |
338 } |
342 } |
339 } |
343 ], |
340 ], |
344 groups: ['st_guide','st_letter' ] |
341 groups: ['st_guide','st_letter' ] |
345 }); |
342 }); |
|
343 |
346 |
344 |
347 // initialize the popup window and buttons. |
345 // initialize the popup window and buttons. |
348 $("#popupWindow").jqxWindow({ |
346 $("#popupWindow").jqxWindow({ |
349 width: 1200, |
347 width: 1200, |
350 height: 620, |
348 height: 620, |
353 isModal: true, |
351 isModal: true, |
354 autoOpen: false, |
352 autoOpen: false, |
355 cancelButton: $("#Cancel"), |
353 cancelButton: $("#Cancel"), |
356 modalOpacity: 0.40 |
354 modalOpacity: 0.40 |
357 }); |
355 }); |
|
356 $("#popupWindow").on('open', function () { |
|
357 $("#name").jqxInput('selectAll'); |
|
358 }); |
358 |
359 |
359 // Tabs inside the popup window. |
360 // Tabs inside the popup window. |
360 $('#jqxTabs').jqxTabs({ |
361 $('#jqxTabs').jqxTabs({ |
361 theme: theme, |
362 theme: theme, |
362 autoHeight: false, |
363 autoHeight: false, |
363 height: 580, |
364 height: 580, |
364 position: 'top' |
365 position: 'top' |
365 }); |
366 }); |
366 |
367 |
367 $("#popupWindow").on('open', function () { |
|
368 $("#name").jqxInput('selectAll'); |
|
369 }); |
|
370 $("#Delete").jqxButton({ width: '90px', theme: theme }); |
368 $("#Delete").jqxButton({ width: '90px', theme: theme }); |
371 $("#Delete").click(function () { |
369 $("#Delete").click(function () { |
372 if (editrow >= 0) { |
370 if (editrow >= 0) { |
373 // Open a popup to confirm this action. |
371 // Open a popup to confirm this action. |
374 $('#eventWindow').jqxWindow('open'); |
372 $('#eventWindow').jqxWindow('open'); |
381 }); |
379 }); |
382 $("#Cancel").jqxButton({ width: '90px', theme: theme }); |
380 $("#Cancel").jqxButton({ width: '90px', theme: theme }); |
383 $("#Save").jqxButton({ width: '90px', theme: theme }); |
381 $("#Save").jqxButton({ width: '90px', theme: theme }); |
384 // update the edited row when the user clicks the 'Save' button. |
382 // update the edited row when the user clicks the 'Save' button. |
385 $("#Save").click(function () { |
383 $("#Save").click(function () { |
386 // var steprows = $('#grid').jqxGrid('getrows'); |
384 var waterrow = $('#waterGrid').jqxGrid('getrows'); |
387 if (editrow >= 0) { |
385 if (editrow >= 0) { |
|
386 var rowRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); |
388 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
387 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
389 var row = { |
388 var row = { |
390 record: rowID, |
389 record: rowID, |
391 name: $("#name").val(), |
390 name: $("#name").val(), |
392 notes: $("#notes").val(), |
391 notes: $("#notes").val(), |
393 st_name: $('#st_name').val(), |
392 st_name: $('#st_name').val(), |
394 st_letter: $('#st_letter').val(), |
393 st_letter: $('#st_letter').val(), |
395 st_guide: $('#st_guide').val(), |
394 st_guide: $('#st_guide').val(), |
|
395 st_og_min: rowRecord.st_og_min, |
|
396 st_og_max: rowRecord.st_og_max, |
|
397 st_fg_min: rowRecord.st_fg_min, |
|
398 st_fg_max: rowRecord.st_fg_max, |
|
399 st_ibu_min: rowRecord.st_ibu_min, |
|
400 st_ibu_max: rowRecord.st_ibu_max, |
|
401 st_color_min: rowRecord.st_color_min, |
|
402 st_color_max: rowRecord.st_color_max, |
|
403 st_carb_min: rowRecord.st_carb_min, |
|
404 st_carb_max: rowRecord.st_carb_max, |
|
405 st_abv_min: rowRecord.st_abv_min, |
|
406 st_abv_max: rowRecord.st_abv_max, |
396 type: $("#type").val(), |
407 type: $("#type").val(), |
397 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
408 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
398 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
409 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
399 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
410 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
400 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
411 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
402 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
413 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
403 color_method: $("#color_method").val(), |
414 color_method: $("#color_method").val(), |
404 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), |
415 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), |
405 ibu_method: $("#ibu_method").val(), |
416 ibu_method: $("#ibu_method").val(), |
406 mash_name: $("#mash_name").val(), |
417 mash_name: $("#mash_name").val(), |
407 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')) |
418 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')), |
408 // steps: steprows |
419 mash_sparge_temp: parseFloat($("#mash_sparge_temp").jqxNumberInput('decimal')), |
|
420 waters: waterrow |
409 }; |
421 }; |
410 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
422 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
411 $("#popupWindow").jqxWindow('hide'); |
423 $("#popupWindow").jqxWindow('hide'); |
412 } else { |
424 } else { |
413 // Insert a record |
425 // Insert a record |
416 name: $("#name").val(), |
428 name: $("#name").val(), |
417 notes: $("#notes").val(), |
429 notes: $("#notes").val(), |
418 st_name: $('#st_name').val(), |
430 st_name: $('#st_name').val(), |
419 st_letter: $('#st_letter').val(), |
431 st_letter: $('#st_letter').val(), |
420 st_guide: $('#st_guide').val(), |
432 st_guide: $('#st_guide').val(), |
|
433 st_og_min: 1.025, |
|
434 st_og_max: 1.110, |
|
435 st_fg_min: 1.000, |
|
436 st_fg_max: 1.025, |
|
437 st_ibu_min: 15, |
|
438 st_ibu_max: 150, |
|
439 st_color_min: 5, |
|
440 st_color_max: 50, |
|
441 st_carb_min: 1, |
|
442 st_carb_max: 3, |
|
443 st_abv_min: 2, |
|
444 st_abv_max: 14, |
421 type: $("#type").val(), |
445 type: $("#type").val(), |
422 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
446 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
423 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
447 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
424 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
448 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
425 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
449 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
427 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
451 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
428 color_method: $("#color_method").val(), |
452 color_method: $("#color_method").val(), |
429 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), |
453 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), |
430 ibu_method: $("#ibu_method").val(), |
454 ibu_method: $("#ibu_method").val(), |
431 mash_name: $("#mash_name").val(), |
455 mash_name: $("#mash_name").val(), |
432 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')) |
456 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')), |
433 // steps: steprows |
457 mash_sparge_temp: parseFloat($("#mash_sparge_temp").jqxNumberInput('decimal')), |
|
458 waters: waterrow |
434 }; |
459 }; |
435 $('#jqxgrid').jqxGrid('addrow', null, newrow); |
460 $('#jqxgrid').jqxGrid('addrow', null, newrow); |
436 $("#popupWindow").jqxWindow('hide'); |
461 $("#popupWindow").jqxWindow('hide'); |
437 } |
462 } |
438 }); |
463 }); |