diff -r fd6d87d1c9ed -r 98536f6539ee www/js/rec_edit.js
--- a/www/js/rec_edit.js Fri Feb 01 11:58:38 2019 +0100
+++ b/www/js/rec_edit.js Fri Feb 01 15:30:33 2019 +0100
@@ -82,6 +82,8 @@
var miscData = {};
var yeastRow = 0;
var yeastData = {};
+ var mashRow = 0;
+ var mashData = {};
console.log("record:" + my_record + " return:" + my_return + " theme:" + theme);
$("#jqxLoader").jqxLoader({
@@ -2253,13 +2255,11 @@
},
});
$("#mashGrid").jqxGrid({
- width: 960,
+ width: 1240,
height: 400,
source: mashAdapter,
theme: theme,
selectionmode: 'singlerow',
- editmode: 'selectedcell',
- editable: true,
localization: getLocalization(),
showtoolbar: true,
rendertoolbar: function (toolbar) {
@@ -2267,14 +2267,14 @@
var container = $("
");
toolbar.append(container);
container.append('');
- container.append('');
- $("#saddrowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
+ container.append('');
+ $("#saddrowbutton").jqxButton({ template: "primary", theme: theme, height: 27, width: 150 });
$("#saddrowbutton").on('click', function () {
var datarow = generaterow();
var commit = $("#mashGrid").jqxGrid('addrow', null, datarow);
});
// delete selected yeast.
- $("#sdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 });
+ $("#sdeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 });
$("#sdeleterowbutton").on('click', function () {
var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex');
var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount;
@@ -2293,51 +2293,38 @@
},
columns: [
{ text: 'Stap naam', datafield: 'step_name' },
- { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist',
- createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) {
- var dataSource = [ "Infusion", "Temperature", "Decoction" ];
- editor.jqxDropDownList({ source: dataSource, dropDownHeight: 105 });
- }
- },
- { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
- validation: function (cell, value) {
- if (value < 35 || value > 80) {
- return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." };
- }
- return true;
- }
- },
- { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
- validation: function (cell, value) {
- if (value < 35 || value > 80) {
- return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." };
- }
- return true;
+ { text: 'Stap type', datafield: 'step_type', width: 175,
+ cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
+ return "" + MashStepTypeData[value].nl + "
";
}
},
- { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right',
- validation: function (cell, value) {
- if (value < 1 || value > 360) {
- return { result: false, message: "De tijd moet tussen 1 en 360 zijn." };
+ { text: 'Start °C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
+ { text: 'Eind °C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
+ { text: 'Tijd', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' },
+ { text: 'Stap', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' },
+ { text: 'Infuse', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right' },
+ { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
+ return "Wijzig";
+ }, buttonclick: function (row) {
+ mashRow = row;
+ mashData = $("#mashGrid").jqxGrid('getrowdata', mashRow);
+ $("#wstep_name").val(mashData.step_name);
+ $("#wstep_type").val(mashData.step_type);
+ $("#wstep_infuse_amount").val(mashData.step_infuse_amount);
+ $("#wstep_temp").val(mashData.step_temp);
+ $("#wend_temp").val(mashData.end_temp);
+ $("#wstep_time").val(mashData.step_time);
+ $("#wramp_time").val(mashData.ramp_time);
+ if (mashData.step_type == 0) {
+ $("#wstep_infuse_amount").show();
+ $("#wstep_pmpt").show();
+ } else {
+ $("#wstep_infuse_amount").hide();
+ $("#wstep_pmpt").hide();
+ }
+ // show the popup window.
+ $("#popupMash").jqxWindow('open');
}
- return true;
- }
- },
- { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right',
- validation: function (cell, value) {
- if (value < 1 || value > 60) {
- return { result: false, message: "De tijd moet tussen 1 en 60 zijn." };
- }
- return true;
- }
- },
- { text: 'Infuse', datafield: 'step_infuse_amount', width: 70, align: 'right', cellsalign: 'right',
- validation: function (cell, value) {
- if (value < 0 || value > 60) {
- return { result: false, message: "De waarde moet tussen 0 en 60 zijn." };
- }
- return true;
- }
}
]
});
@@ -2998,6 +2985,127 @@
// Tab 6, Maischen
$("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
+ $("#mash_select").jqxDropDownList({
+ placeHolder: "Kies schema:",
+ theme: theme,
+ source: mashlist,
+ displayMember: "name",
+ width: 250,
+ height: 23,
+ dropDownWidth: 500,
+ dropDownHeight: 500,
+ dropDownHorizontalAlignment: 'right'
+ });
+ $("#mash_select").on('select', function (event) {
+ if (event.args) {
+ var index = event.args.index;
+ // First delete all current steps
+ var rowIDs = new Array();
+ var rows = $("#mashGrid").jqxGrid('getdisplayrows');
+ for (var i = 0; i < rows.length; i++) {
+ var row = rows[i];
+ rowIDs.push(row.uid);
+ }
+ $("#mashGrid").jqxGrid('deleterow', rowIDs);
+ // Then add the new steps
+ var datarecord = mashlist.records[index];
+ $("#mash_name").val(datarecord.name);
+ for (var i = 0; i < datarecord.steps.length; i++) {
+ var data = datarecord.steps[i];
+ var row = {};
+ row["step_name"] = data.step_name;
+ row["step_type"] = data.step_type;
+ // For now, but this must be smarter.
+ if (i == 0)
+ row["step_infuse_amount"] = mash_infuse;
+ else
+ row["step_infuse_amount"] = 0;
+ row["step_temp"] = data.step_temp;
+ row["end_temp"] = data.end_temp;
+ row["step_time"] = data.step_time;
+ row["ramp_time"] = data.ramp_time;
+ var commit = $("#mashGrid").jqxGrid('addrow', null, row);
+ }
+ }
+ });
+ $("#popupMash").jqxWindow({
+ width: 800,
+ height: 350,
+ position: { x: 230, y: 100 },
+ resizable: false,
+ theme: theme,
+ isModal: true,
+ autoOpen: false,
+ cancelButton: $("#MashReady"),
+ modalOpacity: 0.40
+ });
+ $("#MashReady").jqxButton({ template: "success", width: '90px', theme: theme });
+ $("#MashReady").click(function () {
+ $("#mashGrid").jqxGrid('sortby', 'step_temp', 'asc');
+ });
+ $("#wstep_name").jqxInput({ theme: theme, width: 320, height: 23 });
+ $("#wstep_type").jqxDropDownList({
+ theme: theme,
+ source: MashStepTypeAdapter,
+ valueMember: 'id',
+ displayMember: 'nl',
+ width: 180,
+ height: 23,
+ autoDropDownHeight: true
+ });
+ $("#wstep_type").on('select', function (event) {
+ if (event.args) {
+ var index = event.args.index;
+ var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
+ rowdata.step_type = index;
+ if (index == 0) {
+ $("#wstep_infuse_amount").show();
+ $("#wstep_pmpt").show();
+ } else {
+ $("#wstep_infuse_amount").hide();
+ $("#wstep_pmpt").hide();
+ }
+ mash_infuse = 0;
+ var rows = $('#mashGrid').jqxGrid('getrows');
+ for (var i = 0; i < rows.length; i++) {
+ var row = rows[i];
+ if (row.step_type == 0) // Infusion
+ mash_infuse += parseFloat(row.step_infuse_amount);
+ }
+ }
+ });
+ $("#wstep_temp").jqxNumberInput( Spin1dec5 );
+ $('#wstep_temp').on('change', function (event) {
+ var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
+ rowdata.step_temp = parseFloat(event.args.value);
+ });
+ $("#wend_temp").jqxNumberInput( Spin1dec5 );
+ $('#wend_temp').on('change', function (event) {
+ var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
+ rowdata.end_temp = parseFloat(event.args.value);
+ });
+ $("#wstep_time").jqxNumberInput( PosInt );
+ $('#wstep_time').on('change', function (event) {
+ var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
+ rowdata.step_time = parseFloat(event.args.value);
+ });
+ $("#wramp_time").jqxNumberInput( PosInt );
+ $('#wramp_time').on('change', function (event) {
+ var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
+ rowdata.ramp_time = parseFloat(event.args.value);
+ });
+ $("#wstep_infuse_amount").jqxNumberInput( Spin1dec5 );
+ $('#wstep_infuse_amount').on('change', function (event) {
+ var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);
+ rowdata.step_infuse_amount = parseFloat(event.args.value);
+ mash_infuse = 0;
+ var rows = $('#mashGrid').jqxGrid('getrows');
+ for (var i = 0; i < rows.length; i++) {
+ var row = rows[i];
+ if (row.step_type == 0) // Infusion
+ mash_infuse += parseFloat(row.step_infuse_amount);
+ }
+ });
// Tab 7, Water
$("#tgt_bu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 2, readOnly: true });