# HG changeset patch # User Michiel Broek # Date 1659535290 -7200 # Node ID 488613f307897b9e2ef277014a78c0e35b330c28 # Parent ac5c3e97fcf1063c8a5d21ea187eb088095878d8 Phase 2, fermentables tab is a viewer only. diff -r ac5c3e97fcf1 -r 488613f30789 www/js/rec_edit.js --- a/www/js/rec_edit.js Wed Aug 03 15:16:07 2022 +0200 +++ b/www/js/rec_edit.js Wed Aug 03 16:01:30 2022 +0200 @@ -103,10 +103,6 @@ w100 = 90; w80 = 60; } - $('#fermentableGrid').jqxGrid({ editable: rw }); - $('#faddrowbutton').jqxDropDownList({ disabled: ro }); - $('#finstockbutton').jqxCheckBox({ disabled: ro }); - $('#fdeleterowbutton').jqxButton({ disabled: ro }); $('#hopGrid').jqxGrid({ editable: rw }); $('#haddrowbutton').jqxDropDownList({ disabled: ro }); $('#hinstockbutton').jqxCheckBox({ disabled: ro }); @@ -249,11 +245,6 @@ } $('#ferm_lintner').val(Math.round(parseFloat(lintner / mashkg))); to_100 = my_100; - if (to_100) { - $('#wf_amount').jqxNumberInput({ width: 90, readOnly: true, spinButtons: false }); - } else { - $('#wf_amount').jqxNumberInput({ width: 110, readOnly: false, spinButtons: true }); - } // Estimate total recipe OG. dataRecord.est_og = estimate_sg(sugarsf + addedS, parseFloat(dataRecord.batch_size)); @@ -933,121 +924,17 @@ height: 470, source: fermentableAdapter, theme: theme, - selectionmode: 'singlerow', - showtoolbar: true, - rendertoolbar: function(toolbar) { - //var me = this; - var container = $('
'); - toolbar.append(container); - container.append('
'); - container.append('
In voorraad:
'); - container.append('
'); - container.append(''); - // add fermentable from dropdownlist. - $('#faddrowbutton').jqxDropDownList({ - placeHolder: 'Kies mout:', - theme: theme, - template: 'primary', - source: fermentablelist, - displayMember: 'name', - width: 150, - height: 27, - dropDownWidth: 500, - dropDownHeight: 500, - renderer: function(index, label, value) { - var datarecord = fermentablelist.records[index]; - return datarecord.supplier + ' / ' + datarecord.name + ' (' + datarecord.color + ' EBC)'; - } - }); - $('#faddrowbutton').on('select', function(event) { - if (event.args) { - var index, datarecord, row = {}, rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; - index = event.args.index; - datarecord = fermentablelist.records[index]; - row['f_name'] = datarecord.name; - row['f_origin'] = datarecord.origin; - row['f_supplier'] = datarecord.supplier; - row['f_amount'] = 0; - row['f_cost'] = datarecord.cost; - row['f_type'] = datarecord.type; - row['f_yield'] = datarecord.yield; - row['f_color'] = datarecord.color; - row['f_coarse_fine_diff'] = datarecord.coarse_fine_diff; - row['f_moisture'] = datarecord.moisture; - row['f_diastatic_power'] = datarecord.diastatic_power; - row['f_protein'] = datarecord.protein; - row['f_max_in_batch'] = datarecord.max_in_batch; - row['f_graintype'] = datarecord.graintype; - if (datarecord.add_after_boil) { - row['f_added'] = 2; // Fermentation - } else if ((datarecord.type == 1) || (datarecord.type == 4)) { // Sugar or Adjunct - row['f_added'] = 1; // Boil - } else { - row['f_added'] = 0; // Mash - } - row['f_dissolved_protein'] = datarecord.dissolved_protein; - row['f_recommend_mash'] = datarecord.recommend_mash; - row['f_add_after_boil'] = datarecord.add_after_boil; - if (rowscount == 0) { - // The first fermentable - row['f_adjust_to_total_100'] = 1; - row['f_percentage'] = 100; - } else { - row['f_adjust_to_total_100'] = 0; - row['f_percentage'] = 0; - } - row['f_di_ph'] = datarecord.di_ph; - row['f_acid_to_ph_57'] = datarecord.acid_to_ph_57; - row['f_inventory'] = datarecord.inventory; - $('#fermentableGrid').jqxGrid('addrow', null, row); - } - }); - $('#finstockbutton').jqxCheckBox({ theme: theme, height: 27 }); - $('#finstockbutton').on('change', function(event) { - fermentableinstock = event.args.checked; - fermentablelist.dataBind(); - }); - - // delete selected fermentable. - $('#fdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150 }); - $('#fdeleterowbutton').on('click', function() { - var id, percent, amount, i, rowdata, rowscount, selectedrowindex = $('#fermentableGrid').jqxGrid('getselectedrowindex'); - rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; - if (selectedrowindex >= 0 && selectedrowindex < rowscount) { - id = $('#fermentableGrid').jqxGrid('getrowid', selectedrowindex); - percent = $('#fermentableGrid').jqxGrid('getcellvalue', id, 'f_percentage'); - amount = $('#fermentableGrid').jqxGrid('getcellvalue', id, 'f_amount'); - $('#fermentableGrid').jqxGrid('deleterow', id); - } - rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; - if (rowscount > 1) { - if (to_100) { - for (i = 0; i < rowscount; i++) { - rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); - if (rowdata.f_adjust_to_total_100) { - rowdata.f_percentage += percent; - rowdata.f_amount += amount; - } - } - } else { - calcPercentages(); - } - } else { - $('#fermentableGrid').jqxGrid('setcellvalue', 0, 'f_percentage', 100); - } - calcFermentables(); - calcIBUs(); - }); - }, + editable: false, ready: function() { calcFermentables(); $('#jqxTabs').jqxTabs('next'); }, columns: [ - { text: 'Vergistbaar ingrediënt', datafield: 'f_name', - cellsrenderer: function(index, datafield, value, defaulvalue, column, rowdata) { - return '' + - rowdata.f_supplier + ' / ' + rowdata.f_name + ' (' + rowdata.f_color + ' EBC)'; + { text: 'Vergistbaar ingrediënt', datafield: 'f_name' }, + { text: 'Leverancier', datafield: 'f_supplier', width: 180 }, + { text: 'Kleur', datafield: 'f_color', width: 90, align: 'right', + cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { + return '' + dataAdapter.formatNumber(value, 'f0') + ' EBC'; } }, { text: 'Type', width: 100, datafield: 'f_type', @@ -1063,15 +950,6 @@ { text: 'Maxinbatch', datafield: 'f_max_in_batch', hidden: true }, { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, - { text: 'Voorr. Kg', datafield: 'f_inventory', width: 120, align: 'right', - cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { - var color = '#ffffff'; - if (value < rowdata.f_amount) - color = '#ff4040'; - return '' + fermentableAdapter.formatNumber(value, 'f3') + ''; - } - }, { text: 'Procent', datafield: 'f_percentage', width: 90, align: 'right', cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { var color = '#ffffff'; @@ -1081,22 +959,7 @@ color + ';">' + fermentableAdapter.formatNumber(value, 'p1') + ''; } }, - { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 70 }, - { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function() { - return 'Wijzig'; - }, buttonclick: function(row) { - fermentableRow = row; - fermentableData = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); - $('#wf_name').val(fermentableData.f_name); - $('#wf_amount').val(fermentableData.f_amount); - $('#wf_percentage').val(fermentableData.f_percentage); - $('#wf_max_in_batch').val(fermentableData.f_max_in_batch); - $('#wf_adjust_to_total_100').val(fermentableData.f_adjust_to_total_100); - $('#wf_added').val(fermentableData.f_added); - // show the popup window. - $('#popupFermentable').jqxWindow('open'); - } - } + { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 70 } ] }); }; @@ -2774,219 +2637,6 @@ return (parseInt(text) * 2) + ' lintner'; } }); - $('#popupFermentable').jqxWindow({ - width: 800, - height: 300, - position: { x: 230, y: 100 }, - resizable: false, - theme: theme, - isModal: true, - autoOpen: false, - cancelButton: $('#FermentableReady'), - modalOpacity: 0.40 - }); - $('#FermentableReady').jqxButton({ template: 'success', width: '90px', theme: theme }); - $('#FermentableReady').click(function() { - var row, rowID = $('#fermentableGrid').jqxGrid('getrowid', fermentableRow); - console.log('FermentableReady row:' + fermentableRow + ' ID:' + rowID); - row = { - f_name: fermentableData.f_name, - f_origin: fermentableData.f_origin, - f_supplier: fermentableData.f_supplier, - f_amount: fermentableData.f_amount, - f_cost: fermentableData.f_cost, - f_type: fermentableData.f_type, - f_yield: fermentableData.f_yield, - f_color: fermentableData.f_color, - f_coarse_fine_diff: fermentableData.f_coarse_fine_diff, - f_moisture: fermentableData.f_moisture, - f_diastatic_power: fermentableData.f_diastatic_power, - f_protein: fermentableData.f_protein, - f_max_in_batch: fermentableData.f_max_in_batch, - f_graintype: fermentableData.f_graintype, - f_added: fermentableData.f_added, - f_dissolved_protein: fermentableData.f_dissolved_protein, - f_recommend_mash: fermentableData.f_recommend_mash, - f_add_after_boil: fermentableData.f_add_after_boil, - f_adjust_to_total_100: fermentableData.f_adjust_to_total_100, - f_percentage: fermentableData.f_percentage, - f_di_ph: fermentableData.f_di_ph, - f_acid_to_ph_57: fermentableData.f_acid_to_ph_57, - f_inventory: fermentableData.f_inventory, - f_avail: fermentableData.f_avail - }; - $('#fermentableGrid').jqxGrid('updaterow', rowID, row); - calcPercentages(); - calcFermentables(); - calcIBUs(); - calcMash(); - // Waters: yes there is impact. - }); - $('#wf_name').jqxInput({ theme: theme, width: 320, height: 23 }); - $('#wf_instock').jqxCheckBox({ theme: theme, height: 23 }); - $('#wf_instock').on('change', function(event) { - fermentableinstock = event.args.checked; - fermentablelist.dataBind(); - }); - $('#wf_select').jqxDropDownList({ - placeHolder: 'Kies mout:', - theme: theme, - source: fermentablelist, - displayMember: 'name', - width: 150, - height: 23, - dropDownWidth: 500, - dropDownHeight: 500, - renderer: function(index, label, value) { - var datarecord = fermentablelist.records[index]; - return datarecord.supplier + ' / ' + datarecord.name + ' (' + datarecord.color + ' EBC)'; - } - }); - $('#wf_select').on('select', function(event) { - if (event.args) { - var datarecord, index = event.args.index; - datarecord = fermentablelist.records[index]; - $('#wf_name').val(datarecord.name); - fermentableData.f_name = datarecord.name; - fermentableData.f_origin = datarecord.origin; - fermentableData.f_supplier = datarecord.supplier; - fermentableData.f_type = datarecord.type; - fermentableData.f_cost = datarecord.cost; - fermentableData.f_yield = datarecord.yield; - fermentableData.f_color = datarecord.color; - fermentableData.f_coarse_fine_diff = datarecord.coarse_fine_diff; - fermentableData.f_moisture = datarecord.moisture; - fermentableData.f_diastatic_power = datarecord.diastatic_power; - fermentableData.f_protein = datarecord.protein; - fermentableData.f_max_in_batch = datarecord.max_in_batch; - fermentableData.f_graintype = datarecord.graintype; - fermentableData.f_dissolved_protein = datarecord.dissolved_protein; - fermentableData.f_recommend_mash = datarecord.recommend_mash; - fermentableData.f_add_after_boil = datarecord.add_after_boil; - fermentableData.f_di_ph = datarecord.di_ph; - fermentableData.f_acid_to_ph_57 = datarecord.acid_to_ph_57; - fermentableData.f_inventory = datarecord.inventory; - } - }); - $('#wf_amount').jqxNumberInput(Spin3dec); - $('#wf_amount').on('change', function(event) { - console.log('amount changed: ' + event.args.value); - $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_amount', event.args.value); - fermentableData.f_amount = event.args.value; - if (! to_100) { - calcPercentages(); - calcFermentables(); - calcMash(); - } - }); - $('#wf_percentage').jqxNumberInput(Perc1dec); - $('#wf_percentage').on('change', function(event) { - var newperc, nw, damount, namount, rowscount, rowdata, diff, tw, i, newvalue, - oldvalue = Round(fermentableData.f_percentage, 1); - newvalue = event.args.value; - console.log('percentage changed: ' + newvalue + ' old: ' + oldvalue); - fermentableData.f_percent = newvalue; - rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; - if ((oldvalue != newvalue) && (rowscount > 1)) { - rowdata = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); - if (rowdata.f_adjust_to_total_100) { - $('#wf_percentage').val(oldvalue); - } else { - diff = newvalue - oldvalue; - tw = 0; // total weight - for (i = 0; i < rowscount; i++) { - rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); - if (rowdata.f_added < 4) - tw += Round(rowdata.f_amount, 3); - } - tw = Round(tw, 3); - if (to_100) { - // Adjust this row and the 100% row. - damount = Math.round(tw * diff * 10) / 1000; - rowdata = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); - namount = Round((rowdata.f_amount + damount), 3); - $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_amount', namount); - $('#wf_amount').val(namount); - $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_percentage', rowdata.f_percentage + diff); - for (i = 0; i < rowscount; i++) { - rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); - if (rowdata.f_adjust_to_total_100) { - namount = rowdata.f_amount - damount; - $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', rowdata.f_percentage - diff); - $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', namount); - } - } - calcFermentables(); - calcMash(); - } else { - // Adjust all the rows. - nw = tw * diff / 100; - for (i = 0; i < rowscount; i++) { - rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i); - if (rowdata.f_added < 4) { - if (i == fermentableRow) { - namount = Math.round((rowdata.f_amount + nw) * 1000) / 1000; - $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', namount); - // $('#wf_amount').val(namount); // Will crash the script. - $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', newvalue); - } else { - namount = Round((rowdata.f_amount - (nw / (rowscount - 1))), 3); - newperc = Round((namount / tw) * 100, 1); - $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_amount', namount); - $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', newperc); - } - } else { - $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', 0); - } - } - calcFermentables(); - calcMash(); - } - } - } - }); - $('#wf_max_in_batch').jqxNumberInput(Show1dec); - $('#wf_adjust_to_total_100').jqxCheckBox({ theme: theme, width: 120, height: 23 }); - $('#wf_adjust_to_total_100').on('checked', function(event) { - if (fermentableData.f_adjust_to_total_100 == 0) { - if (to_100) { - // Reset other flag first. - rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; - for (i = 0; i < rowscount; i++) { - if (i != fermentableRow) { - $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_adjust_to_total_100', 0); - } - } - } - $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 1); - calcFermentables(); - } - }); - $('#wf_adjust_to_total_100').on('unchecked', function(event) { - if (fermentableData.f_adjust_to_total_100 != 0) { - $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 0); - calcFermentables(); - } - }); - $('#wf_added').jqxDropDownList({ - theme: theme, - source: AddedAdapter, - valueMember: 'id', - displayMember: 'nl', - width: 180, - height: 23, - autoDropDownHeight: true, - dropDownVerticalAlignment: 'top' - }); - $('#wf_added').on('select', function(event) { - if (event.args) { - var index = event.args.index; - $('#fermentableGrid').jqxGrid('setcellvalue', fermentableRow, 'f_added', index); - calcFermentables(); - calcIBUs(); - calcMash(); - } - }); // Tab 3, Hoppen $('#est_ibu2').jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); diff -r ac5c3e97fcf1 -r 488613f30789 www/rec_edit.php --- a/www/rec_edit.php Wed Aug 03 15:16:07 2022 +0200 +++ b/www/rec_edit.php Wed Aug 03 16:01:30 2022 +0200 @@ -359,51 +359,6 @@ -
-
Wijzig vergistbaar ingrediënt.
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ingrediënt naam:
Ander ingrediënt:
-
-
In voorraad:
-
-
Hoeveelheid kg:
Percentage %:
-
-
Maximum %:
-
-
Aanvullen tot 100%:
Toevoegen tijdens:
- -
-
-
-
Wijzig hop detail.