www/js/rec_edit.js

changeset 224
d3cdcfac81cb
parent 223
0de4455bd2a1
child 225
ad2e1e3ccaca
equal deleted inserted replaced
223:0de4455bd2a1 224:d3cdcfac81cb
1738 { text: 'Gebruik', width: 110, datafield: 'h_useat', 1738 { text: 'Gebruik', width: 110, datafield: 'h_useat',
1739 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 1739 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1740 return "<div style='margin: 4px;'>" + HopUseData[value].nl + "</div>"; 1740 return "<div style='margin: 4px;'>" + HopUseData[value].nl + "</div>";
1741 } 1741 }
1742 }, 1742 },
1743 { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', 1743 { text: 'Tijdsduur', datafield: 'h_time', width: 90, align: 'right',
1744 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 1744 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1745 if ((rowdata.h_useat == 2) || (rowdata.h_useat == 5)) // Boil or Dry hop 1745 if ((rowdata.h_useat == 2) || (rowdata.h_useat == 4)) // Boil, Whirlpool
1746 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+"</div>"; 1746 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" min.</div>";
1747 if (rowdata.h_useat == 5) // Dry hop
1748 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value/1440, "f0")+" dagen</div>";
1747 else 1749 else
1748 return "<div style='margin: 4px;' class='jqx-right-align'> </div>"; 1750 return "<div style='margin: 4px;'></div>";
1749 } 1751 }
1750 }, 1752 },
1751 { text: 'IBU', datafield: 'ibu', width: 80, align: 'right', 1753 { text: 'IBU', datafield: 'ibu', width: 80, align: 'right',
1752 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 1754 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1753 var ibu = toIBU(rowdata.h_useat, 1755 var ibu = toIBU(rowdata.h_useat,
1757 parseFloat(rowdata.h_amount), 1759 parseFloat(rowdata.h_amount),
1758 parseFloat(rowdata.h_time), 1760 parseFloat(rowdata.h_time),
1759 parseFloat(rowdata.h_alpha), 1761 parseFloat(rowdata.h_alpha),
1760 $("#ibu_method").val() 1762 $("#ibu_method").val()
1761 ); 1763 );
1762 // calcIBUs();
1763 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>"; 1764 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>";
1764 } 1765 }
1765 }, 1766 },
1766 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', cellsalign: 'right', 1767 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', cellsalign: 'right',
1767 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 1768 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
1790 parseFloat($("#batch_size").jqxNumberInput('decimal')), 1791 parseFloat($("#batch_size").jqxNumberInput('decimal')),
1791 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), 1792 parseFloat(hopData.h_amount), parseFloat(hopData.h_time),
1792 parseFloat(hopData.h_alpha), $("#ibu_method").val() 1793 parseFloat(hopData.h_alpha), $("#ibu_method").val()
1793 ); 1794 );
1794 $("#wh_ibu").val(ibu); 1795 $("#wh_ibu").val(ibu);
1795 $("#wh_time").val(hopData.h_time); 1796 if (hopData.h_useat == 5) // Dry hop
1797 $("#wh_time").val(hopData.h_time / 1440);
1798 else
1799 $("#wh_time").val(hopData.h_time);
1796 $("#wh_useat").val(hopData.h_useat); 1800 $("#wh_useat").val(hopData.h_useat);
1797 // show the popup window. 1801 // show the popup window.
1798 $("#popupHop").jqxWindow('open'); 1802 $("#popupHop").jqxWindow('open');
1799 } 1803 }
1800 } 1804 }
2624 2628
2625 }); 2629 });
2626 $("#wf_adjust_to_total_100").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 2630 $("#wf_adjust_to_total_100").jqxCheckBox({ theme: theme, width: 120, height: 23 });
2627 $("#wf_adjust_to_total_100").on('checked', function (event) { 2631 $("#wf_adjust_to_total_100").on('checked', function (event) {
2628 if (fermentableData.f_adjust_to_total_100 == 0) { 2632 if (fermentableData.f_adjust_to_total_100 == 0) {
2629 // console.log("wf_adjust_to_total_100: checked row: "+fermentableRow+" old: "+fermentableData.f_adjust_to_total_100);
2630 if (to_100) { 2633 if (to_100) {
2631 // Reset other flag first. 2634 // Reset other flag first.
2632 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; 2635 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
2633 for (var i = 0; i < rowscount; i++) { 2636 for (var i = 0; i < rowscount; i++) {
2634 if (i != fermentableRow) { 2637 if (i != fermentableRow) {
2640 calcFermentables(); 2643 calcFermentables();
2641 } 2644 }
2642 }); 2645 });
2643 $("#wf_adjust_to_total_100").on('unchecked', function (event) { 2646 $("#wf_adjust_to_total_100").on('unchecked', function (event) {
2644 if (fermentableData.f_adjust_to_total_100 != 0) { 2647 if (fermentableData.f_adjust_to_total_100 != 0) {
2645 // console.log("wf_adjust_to_total_100: unchecked row: "+fermentableRow+" old: "+fermentableData.f_adjust_to_total_100);
2646 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 0); 2648 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 0);
2647 calcFermentables(); 2649 calcFermentables();
2648 } 2650 }
2649 }); 2651 });
2650 $("#wf_added").jqxDropDownList({ 2652 $("#wf_added").jqxDropDownList({
2674 cancelButton: $("#HopReady"), 2676 cancelButton: $("#HopReady"),
2675 modalOpacity: 0.40 2677 modalOpacity: 0.40
2676 }); 2678 });
2677 $("#HopReady").jqxButton({ template: "success", width: '90px', theme: theme }); 2679 $("#HopReady").jqxButton({ template: "success", width: '90px', theme: theme });
2678 $("#HopReady").click(function () { 2680 $("#HopReady").click(function () {
2679 $("#hopGrid").jqxGrid('sortby', 'f_amount', 'asc'); 2681 $("#hopGrid").jqxGrid('sortby', 'h_amount', 'asc');
2680 calcIBUs(); 2682 calcIBUs();
2681 }); 2683 });
2682 $("#wh_name").jqxInput({ theme: theme, width: 320, height: 23 }); 2684 $("#wh_name").jqxInput({ theme: theme, width: 320, height: 23 });
2683 $("#wh_instock").jqxCheckBox({ theme: theme, height: 23 }); 2685 $("#wh_instock").jqxCheckBox({ theme: theme, height: 23 });
2684 $("#wh_instock").on('change', function (event) { 2686 $("#wh_instock").on('change', function (event) {
2704 var index = event.args.index; 2706 var index = event.args.index;
2705 var datarecord = hoplist.records[index]; 2707 var datarecord = hoplist.records[index];
2706 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow); 2708 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow);
2707 $("#wh_name").val(datarecord.name); 2709 $("#wh_name").val(datarecord.name);
2708 rowdata.h_name = datarecord.name; 2710 rowdata.h_name = datarecord.name;
2709 2711 rowdata.h_origin = datarecord.origin;
2712 rowdata.h_cost = datarecord.cost;
2713 rowdata.h_type = datarecord.type;
2714 rowdata.h_form = datarecord.form;
2715 rowdata.h_alpha = datarecord.alpha;
2716 rowdata.h_beta = datarecord.beta;
2717 rowdata.h_hsi = datarecord.hsi;
2718 rowdata.h_humulene = datarecord.humulene;
2719 rowdata.h_caryophyllene = datarecord.caryophyllene;
2720 rowdata.h_cohumulone = datarecord.cohumulone;
2721 rowdata.h_myrcene = datarecord.myrcene;
2722 rowdata.h_total_oil = datarecord.total_oil;
2723 rowdata.h_inventory = datarecord.inventory;
2710 } 2724 }
2711 }); 2725 });
2712 $("#wh_amount").jqxNumberInput( Spin1dec1 ); 2726 $("#wh_amount").jqxNumberInput( Spin1dec1 );
2713 $('#wh_amount').on('change', function (event) { 2727 $('#wh_amount').on('change', function (event) {
2714 console.log("amount changed: "+event.args.value); 2728 console.log("amount changed: "+event.args.value);
2722 ); 2736 );
2723 rowdata.h_amount = amount; 2737 rowdata.h_amount = amount;
2724 // $("#hopGrid").jqxGrid('setcellvalue', hopRow, 'h_amount', amount); 2738 // $("#hopGrid").jqxGrid('setcellvalue', hopRow, 'h_amount', amount);
2725 calcIBUs(); 2739 calcIBUs();
2726 }); 2740 });
2727 $("#wh_ibu").jqxNumberInput( Spin1dec1 ); 2741 $("#wh_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
2728 $("#wh_time").jqxNumberInput( PosInt ); 2742 $("#wh_time").jqxNumberInput( PosInt );
2743 $("#wh_time").on('change', function (event) {
2744 console.log("time changed: "+event.args.value);
2745 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow);
2746 var newtime = parseFloat(event.args.value);
2747 // Check limits and correct
2748 if (rowdata.h_useat == 2) { // Boil
2749 if (newtime > parseFloat($("#boil_time").jqxNumberInput('decimal'))) {
2750 newtime = parseFloat($("#boil_time").jqxNumberInput('decimal'));
2751 $("#wh_time").val(newtime);
2752 }
2753 rowdata.h_time = newtime;
2754 } else if (rowdata.h_useat == 4) { // Whirlpool
2755 if (newtime > 120) {
2756 newtime = 120;
2757 $("#wh_time").val(newtime);
2758 }
2759 rowdata.h_time = newtime;
2760 } else if (rowdata.h_useat == 5) { // Dry hop
2761 if (newtime > 21) {
2762 newtime = 21;
2763 $("#wh_time").val(newtime);
2764 }
2765 rowdata.h_time = newtime * 1440;
2766 }
2767 var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')),
2768 parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), $("#ibu_method").val());
2769 $("#wh_ibu").val(ibu);
2770 calcIBUs();
2771 });
2729 $("#wh_useat").jqxDropDownList({ 2772 $("#wh_useat").jqxDropDownList({
2730 theme: theme, 2773 theme: theme,
2731 source: HopUseAdapter, 2774 source: HopUseAdapter,
2732 valueMember: 'id', 2775 valueMember: 'id',
2733 displayMember: 'nl', 2776 displayMember: 'nl',
2739 $("#wh_useat").on('select', function (event) { 2782 $("#wh_useat").on('select', function (event) {
2740 if (event.args) { 2783 if (event.args) {
2741 var index = event.args.index; 2784 var index = event.args.index;
2742 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow); 2785 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow);
2743 rowdata.h_useat = index; 2786 rowdata.h_useat = index;
2744 if ((index == 0) || (index == 1)) 2787 if ((index == 0) || (index == 1)) { // Mashhop or First wort hop
2745 rowdata.h_time = parseFloat(dataRecord.boil_time); 2788 rowdata.h_time = parseFloat(dataRecord.boil_time);
2746 else if (index == 3) 2789 $("#wh_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2790 $("#wh_time").val(rowdata.h_time);
2791 } else if (index == 3) { // Aroma
2747 rowdata.h_time = 0; 2792 rowdata.h_time = 0;
2793 $("#wh_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2794 $("#wh_time").val(0);
2795 } else { // Boil, Whirlpool or Dry hop
2796 $("#wh_time").jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 });
2797 }
2798 if (index == 5) // Dry hop
2799 $("#wh_pmpt_time").html("Tijd in dagen");
2800 else
2801 $("#wh_pmpt_time").html("Tijd in minuten");
2748 } 2802 }
2749 }); 2803 });
2750 2804
2751 // Tab 4, Diversen 2805 // Tab 4, Diversen
2752 2806

mercurial