# HG changeset patch # User Michiel Broek # Date 1659704062 -7200 # Node ID 293ec25995dbfa12ff5f0a57ffebb88e2b861e77 # Parent 16ae12aa872ecb1057cf06959a0cd8cd2298c93b Tab 4 is a viewer. diff -r 16ae12aa872e -r 293ec25995db www/js/prod_edit.js --- a/www/js/prod_edit.js Fri Aug 05 14:41:17 2022 +0200 +++ b/www/js/prod_edit.js Fri Aug 05 14:54:22 2022 +0200 @@ -843,11 +843,10 @@ { name: 'h_myrcene', type: 'float' }, { name: 'h_total_oil', type: 'float' }, { name: 'h_inventory', type: 'float' }, - { name: 'h_avail', type: 'int' } + { name: 'h_avail', type: 'int' }, + { name: 'h_utilisation', type: 'float' }, + { name: 'h_bu_factor', type: 'float' } ], - addrow: function(rowid, rowdata, position, commit) { commit(true); }, - deleterow: function(rowid, commit) { commit(true); }, - updaterow: function(rowid, rowdata, commit) { commit(true); } }, hopAdapter = new $.jqx.dataAdapter(hopSource); @@ -856,97 +855,17 @@ height: 560, source: hopAdapter, theme: theme, - selectionmode: 'singlerow', - showtoolbar: true, - rendertoolbar: function(toolbar) { - var container = $("
"); - toolbar.append(container); - container.append('
'); - container.append('
In voorraad:
'); - container.append('
'); - container.append(''); - // add hop from dropdownlist. - $('#haddrowbutton').jqxDropDownList({ - placeHolder: 'Kies hop:', - theme: theme, - template: 'primary', - source: hoplist, - disabled: (dataRecord.stage > 5), - displayMember: 'name', - width: 150, - height: 27, - dropDownWidth: 500, - dropDownHeight: 500, - renderer: function(index, label, value) { - var datarecord = hoplist.records[index]; - return datarecord.origin + ' - ' + datarecord.name + ' / ' + HopFormData[datarecord.form].nl + ' (' + datarecord.alpha + '% α) (' + - Round(datarecord.inventory * 1000.0, 1) + ' gr)'; - } - }); - $('#haddrowbutton').on('select', function(event) { - if (event.args) { - var datarecord, row = {}, index = event.args.index; - datarecord = hoplist.records[index]; - row['h_name'] = datarecord.name; - row['h_origin'] = datarecord.origin; - row['h_amount'] = 0; - row['h_cost'] = datarecord.cost; - row['h_type'] = datarecord.type; - row['h_form'] = datarecord.form; - row['h_useat'] = 2; // Boil - row['h_time'] = 0; - row['h_alpha'] = datarecord.alpha; - row['h_beta'] = datarecord.beta; - row['h_hsi'] = datarecord.hsi; - row['h_humulene'] = datarecord.humulene; - row['h_caryophyllene'] = datarecord.caryophyllene; - row['h_cohumulone'] = datarecord.cohumulone; - row['h_myrcene'] = datarecord.myrcene; - row['h_total_oil'] = datarecord.total_oil; - row['h_inventory'] = datarecord.inventory; - /* If stage > useat moment, adjust the moment */ - row['h_useat'] = minimum_hop(dataRecord.stage, row['h_useat']); - $('#hopGrid').jqxGrid('addrow', null, row); - } - $('#haddrowbutton').jqxDropDownList('clearSelection'); - }); - - $('#hinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 5) }); - $('#hinstockbutton').on('change', function(event) { - hopinstock = event.args.checked; - hoplist.dataBind(); - }); - - // delete selected hop. - $('#hdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 5) }); - $('#hdeleterowbutton').on('click', function() { - var rowscount, id, selectedrowindex = $('#hopGrid').jqxGrid('getselectedrowindex'); - rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount; - if (selectedrowindex >= 0 && selectedrowindex < rowscount) { - useat = $('#hopGrid').jqxGrid('getcellvalue', selectedrowindex, 'h_useat'); - if (block_hop(dataRecord.stage, useat)) { - alert('Ingredieënt is al verwerkt.'); - } else { - id = $('#hopGrid').jqxGrid('getrowid', selectedrowindex); - $('#hopGrid').jqxGrid('deleterow', id); - } - } - calcIBUs(); - }); - }, + editable: false, ready: function() { $('#jqxTabs').jqxTabs('next'); }, columns: [ - { text: 'Hop', datafield: 'h_name', - cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { - return '' + rowdata.h_origin + ' / ' + rowdata.h_name + ''; - }, - }, + { text: 'Hop', datafield: 'h_name' }, + { text: 'Origin', width: 180, datafield: 'h_origin' }, { text: 'Type', width: 90, datafield: 'h_type', cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { return '' + HopTypeData[value].nl + ''; } }, - { text: 'Vorm', width: 90, datafield: 'h_form', + { text: 'Vorm', width: 110, datafield: 'h_form', cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { return '' + HopFormData[value].nl + ''; } @@ -970,7 +889,7 @@ { text: 'IBU', datafield: 'ibu', width: 80, align: 'right', cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat(dataRecord.batch_size), - parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), $('#ibu_method').val(), + parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), dataRecord.ibu_method, dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6); return '' + dataAdapter.formatNumber(ibu, 'f1') + ''; } @@ -995,35 +914,6 @@ return ''; } } - }, - { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', - cellsrenderer: function() { - return 'Wijzig'; - }, buttonclick: function(row) { - hopRow = row; - hopData = $('#hopGrid').jqxGrid('getrowdata', hopRow); - if (block_hop(dataRecord.stage, hopData.h_useat)) { - alert('Ingredieënt is al verwerkt.'); - } else { - console.log('edit button row ' + row); - $('#wh_name').val(hopData.h_name); - $('#wh_amount').val(hopData.h_amount * 1000); - var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), - parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val(), - dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6); - $('#wh_ibu').val(ibu); - if (hopData.h_useat == 5) // Dry hop - $('#wh_time').val(hopData.h_time / 1440); - else - $('#wh_time').val(hopData.h_time); - $('#wh_useat').val(hopData.h_useat); - for (i = 0; i < 5; i++) { - drop_endis(dataRecord.stage > 2, '#wh_useat', i); - } - // show the popup window. - $('#popupHop').jqxWindow('open'); - } - } } ] });