# HG changeset patch # User Michiel Broek # Date 1544738292 -3600 # Node ID 93c64d7ac79c1a68948e146ef8959be3c6ea2fa3 # Parent eb1ac74877104501f6337174e5f807e7bc376273 Hops grid editor amount is now in grams. diff -r eb1ac7487710 -r 93c64d7ac79c www/js/rec_edit.js --- a/www/js/rec_edit.js Thu Dec 13 20:32:36 2018 +0100 +++ b/www/js/rec_edit.js Thu Dec 13 22:58:12 2018 +0100 @@ -937,7 +937,21 @@ { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, - { text: 'Gewicht Kg', datafield: 'h_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f4', + // Edit the amount in grams, shoukd be fine for batches < 10 hl. + { text: 'Gewicht gr', datafield: 'grams', width: 120, align: 'right', columntype: 'numberinput', cellsformat: 'f1', + cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { + var gram = rowdata.h_amount * 1000; + return "
" + dataAdapter.formatNumber(gram, "f1") + " gr
"; + }, + 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 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 }); @@ -948,7 +962,7 @@ } return true; } - }, + }, */ { 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" ]; @@ -1000,7 +1014,11 @@ $("#hopGrid").on('cellendedit', function (event) { var args = event.args; console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); - $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); + if (args.datafield == 'grams') { + $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, 'h_amount', parseFloat(args.value / 1000)); + } else { + $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); + } // //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc'); }); };