diff -r 93c64d7ac79c -r fe9e2a677611 www/js/rec_edit.js
--- a/www/js/rec_edit.js Thu Dec 13 22:58:12 2018 +0100
+++ b/www/js/rec_edit.js Sat Dec 15 11:06:14 2018 +0100
@@ -946,23 +946,12 @@
validation: function (cell, value) {
var maxhops = parseFloat($("#batch_size").jqxNumberInput('decimal')) * 200;
if (value < 0 || value > maxhops ) {
- return { result: false, message: "Volume moet 0-"+maxhops+" zijn" };
+ return { result: false, message: "Gewicht moet 0-"+maxhops+" gram zijn" };
}
return true;
}
},
- /* { text: 'Gewicht Kg', datafield: 'h_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f4',
- columntype: 'numberinput',
- initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
- editor.jqxNumberInput({ decimalDigits: 4, min: 0, spinButtons: false });
- },
- validation: function (cell, value) {
- if (value < 0 || value > 100000000000 ) {
- return { result: false, message: "Volume moet 0-~ zijn" };
- }
- return true;
- }
- }, */
+ { datafield: 'h_amount', hidden: true }, // We need to declare this column
{ text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist',
createeditor: function (row, column, editor) {
var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ];
@@ -979,7 +968,7 @@
{ text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0',
columntype: 'numberinput',
initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
- editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0 });
+ editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) });
},
cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
var use = $("#hopGrid").jqxGrid('getcellvalue', row, "h_useat");
@@ -987,7 +976,7 @@
return oldvalue;
},
validation: function (cell, value) {
- var high = parseFloat($("#boil_time").jqxNumberInput('decimal'));
+ var high = parseFloat(dataRecord.boil_time);
if (value < 0 || value > high ) {
return { result: false, message: "De tijd moet 0-"+high+" zijn" };
}
@@ -1122,27 +1111,81 @@
columns: [
{ text: 'Ingredient', editable: false, datafield: 'm_name' },
{ text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' },
- { text: 'Gebruik', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'm_use_use' },
- { text: 'Gewicht', datafield: 'm_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5',
+ { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'm_use_use', columntype: 'dropdownlist',
+ createeditor: function (row, column, editor) {
+ var srcUseUse = [ "Mash", "Boil", "Primary", "Secondary", "Bottling" ];
+ editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUseUse });
+ }
+ },
+ { datafield: 'm_amount_is_weight', hidden: true }, // We need to declare this column
+ { datafield: 'm_amount', hidden: true }, // We need to declare this column
+ { text: 'Hoeveelheid', datafield: 'grammen', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f2',
columntype: 'numberinput',
+ cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
+ var gram = rowdata.m_amount * 1000;
+ var vstr = rowdata.m_amount_is_weight ? "gr":"ml";
+ return "
"+dataAdapter.formatNumber(gram,"f2")+" "+vstr+"
";
+ },
validation: function (cell, value) {
- if (value < 0 || value > 100000000000 ) {
- return { result: false, message: "Volume moet 0-~ zijn" };
+ var high = parseFloat(dataRecord.boil_size) * 1000;
+ if (value < 0 || value > high) {
+ return { result: false, message: "Hoeveelheid moet tussen 0 en "+high+" zijn" };
}
return true;
- }
+ },
+ initeditor: function (row, cellvalue, editor) {
+ editor.jqxNumberInput({ inputMode: 'simple', min: 0, decimalDigits: 2, spinButtons: false });
+ }
},
- { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0',
+ { datafield: 'm_time' },
+ { text: 'Tijd', datafield: 'time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0',
columntype: 'numberinput',
+ cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
+ if (rowdata.m_use_use == 'Boil') {
+ var tijd = rowdata.m_time;
+ return ""+dataAdapter.formatNumber(tijd, "f0")+" m
";
+ } else if (rowdata.m_use_use == 'Secondary') {
+ var tijd = Math.round(rowdata.m_time / 1440);
+ return ""+dataAdapter.formatNumber(tijd, "f0")+" d
";
+ } else {
+ var tijd = 0;
+ return "
";
+ }
+ },
+ initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
+ editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) });
+ },
+ cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
+ var use = $("#miscGrid").jqxGrid('getcellvalue', row, "m_use_use");
+ if (use != "Boil")
+ return oldvalue;
+ },
validation: function (cell, value) {
- if (value < 0 || value > 100000000000 ) {
- return { result: false, message: "De tijd moet 0-~ zijn" };
+ var high = parseFloat(dataRecord.boil_time);
+ if (value < 0 || value > high ) {
+ return { result: false, message: "De tijd moet 0-"+high+" zijn" };
}
return true;
}
}
]
- })
+ });
+ $("#miscGrid").on('cellendedit', function (event) {
+ var args = event.args;
+ console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
+ if (args.datafield == 'grammen') {
+ $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_amount', parseFloat(args.value / 1000));
+ } else if (args.datafield == 'time') {
+ var use_use = $("#miscGrid").jqxGrid('getcellvalue', args.rowindex, 'm_use_use');
+ console.log("use: "+use_use);
+ if (use_use == 'Secondary')
+ $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_time', parseFloat(args.value * 1440));
+ else
+ $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_time', parseFloat(args.value));
+ } else {
+ $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
+ }
+ });
};
// Inline yeasts editor
@@ -1219,7 +1262,12 @@
displayMember: "name",
width: 150,
height: 27,
- dropDownWidth: 300
+ dropDownWidth: 500,
+ dropDownHeight: 500,
+ renderer: function (index, label, value) {
+ var datarecord = yeastlist.records[index];
+ return datarecord.laboratory+" "+datarecord.product_id+" "+datarecord.name;
+ }
});
$("#yaddrowbutton").on('select', function (event) {
if (event.args) {
@@ -1269,9 +1317,34 @@
{ text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' },
{ text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' },
{ text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' },
- { text: 'Voor', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_use' },
- { text: 'Hoeveel', datafield: 'y_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5',
- columntype: 'numberinput',
+ { text: 'Voor', width: 100, align: 'center', cellsalign: 'center', datafield: 'y_use', columntype: 'dropdownlist',
+ createeditor: function (row, column, editor) {
+ var srcYUse = [ "Primary", "Secondary", "Bottle" ];
+ editor.jqxDropDownList({ autoDropDownHeight: true, source: srcYUse });
+ }
+ },
+ { datafield: 'y_amount', width: 90 },
+ { text: 'Hoeveel', datafield: 'amount', width: 110, align: 'right', cellsalign: 'right', columntype: 'numberinput',
+ cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
+ if (rowdata.y_form == 'Liquid') {
+ var hoeveel = rowdata.y_amount * 17;
+ return ""+dataAdapter.formatNumber(hoeveel, "f0")+" pk
";
+ } else if (rowdata.y_form == 'Dry') {
+ var hoeveel = rowdata.y_amount * 1000;
+ return ""+dataAdapter.formatNumber(hoeveel, "f1")+" gr
";
+ } else {
+ var hoeveel = rowdata.y_amount * 1000;
+ return ""+dataAdapter.formatNumber(hoeveel, "f0")+" ml
";
+ }
+ },
+ initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
+ var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form');
+ if (form == 'Liquid') {
+ editor.jqxNumberInput({ decimalDigits: 0, min: 0 });
+ } else {
+ editor.jqxNumberInput({ decimalDigits: 1, min: 0 });
+ }
+ },
validation: function (cell, value) {
if (value < 0 || value > 100000000000 ) {
return { result: false, message: "Volume moet 0-~ zijn" };
@@ -1280,7 +1353,20 @@
}
}
]
- })
+ });
+ $("#yeastGrid").on('cellendedit', function (event) {
+ var args = event.args;
+ console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
+ if (args.datafield == 'amount') {
+ var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form');
+ if (form == 'Liquid')
+ $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value * 0.0588));
+ else
+ $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value / 1000));
+ } else {
+ $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
+ }
+ });
};
// Inline waters editor