diff -r 578c78abf058 -r dc30801e6961 www/js/inv_equipments.js --- a/www/js/inv_equipments.js Sat Jan 26 11:59:15 2019 +0100 +++ b/www/js/inv_equipments.js Sat Jan 26 15:03:09 2019 +0100 @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (C) 2014-2018 + * Copyright (C) 2014-2019 * * Michiel Broek * @@ -44,6 +44,8 @@ $(document).ready(function () { + var dataRecord = {}; + function calcBatchVolume() { var calc = $("#calc_boil_volume").val(); var boil_size = parseFloat($("#boil_size").jqxNumberInput('decimal')); @@ -93,13 +95,13 @@ { name: 'tun_volume', type: 'float' }, { name: 'tun_weight', type: 'float' }, { name: 'tun_specific_heat', type: 'float' }, - { name: 'tun_material', type: 'string' }, + { name: 'tun_material', type: 'int' }, { name: 'tun_height', type: 'float' }, { name: 'top_up_water', type: 'float' }, { name: 'trub_chiller_loss', type: 'float' }, { name: 'evap_rate', type: 'float' }, { name: 'boil_time', type: 'float' }, - { name: 'calc_boil_volume', type: 'bool' }, + { name: 'calc_boil_volume', type: 'int' }, { name: 'top_up_kettle', type: 'float' }, { name: 'hop_utilization', type: 'float' }, { name: 'notes', type: 'string' }, @@ -122,6 +124,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { // delete command is executed. commit(true); @@ -138,6 +141,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { commit(true); }, @@ -153,6 +157,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { // update command is executed. commit(true); @@ -165,20 +170,30 @@ }; // initialize the input fields. - var srcMaterial= [ "RVS", "Aluminium", "Kunststof", "Koper" ]; - $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); - $("#boil_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); - $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.5 }); - $("#tun_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); - $("#tun_weight").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 2, spinButtons: true }); + $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); + $("#boil_size").jqxNumberInput( Spin1dec5 ); + $("#batch_size").jqxNumberInput( Spin2dec1 ); + $("#batch_size").jqxNumberInput({ spinButtonsStep: 0.5 }); + $("#tun_volume").jqxNumberInput( Spin1dec5 ); + $("#tun_weight").jqxNumberInput( Spin2dec1 ); $("#tun_specific_heat").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); - $("#tun_material").jqxDropDownList({ theme: theme, source: srcMaterial, selectedIndex: 0, width: 110, height: 23, dropDownHeight: 130 }); - $("#tun_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#top_up_water").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 20000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - $("#trub_chiller_loss").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - $("#evap_rate").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 40000, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05 }); - $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 1440, decimalDigits: 0, spinButtons: true }); + $("#tun_material").jqxDropDownList({ + theme: theme, + source: MaterialAdapter, + valueMember: 'id', + displayMember: 'nl', +// selectedIndex: 0, + width: 180, + height: 23, + autoDropDownHeight: true + }); + $("#tun_height").jqxNumberInput( Spin1dec1 ); + $("#top_up_water").jqxNumberInput( Spin1dec1 ); + $("#trub_chiller_loss").jqxNumberInput( Spin1dec1 ); + $("#evap_rate").jqxNumberInput( Spin2dec1 ); + $("#boil_time").jqxNumberInput( PosInt ); + $("#boil_time").jqxNumberInput({ max: 1440 }); $("#calc_boil_volume").jqxCheckBox({ theme: theme, width: 120, height: 23 }); $("#calc_boil_volume").on('checked', function (event) { $("#batch_size").jqxNumberInput({ readOnly: true, width: 90, spinButtons: false }); @@ -186,17 +201,18 @@ $("#calc_boil_volume").on('unchecked', function (event) { $("#batch_size").jqxNumberInput({ readOnly: false, width: 110, spinButtons: true }); }); - $("#top_up_kettle").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - $("#hop_utilization").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 0, spinButtons: true }); - $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); - $("#lauter_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); - $("#lauter_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#lauter_deadspace").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - $("#kettle_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); - $("#kettle_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#mash_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); - $("#mash_max").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); - $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); + $("#top_up_kettle").jqxNumberInput( Spin1dec1 ); + $("#hop_utilization").jqxNumberInput( Perc0 ); + $("#hop_utilization").jqxNumberInput({ Max: 200 }); + $("#lauter_volume").jqxNumberInput( Spin1dec5 ); + $("#lauter_height").jqxNumberInput( Spin1dec1 ); + $("#lauter_deadspace").jqxNumberInput( Spin1dec1 ); + $("#kettle_volume").jqxNumberInput( Spin1dec5 ); + $("#kettle_height").jqxNumberInput( Spin1dec1 ); + $("#mash_volume").jqxNumberInput( Spin1dec5 ); + $("#mash_max").jqxNumberInput( Spin1dec5 ); + $("#efficiency").jqxNumberInput( Perc1dec5 ); + var dataAdapter = new $.jqx.dataAdapter(source); var editrow = -1; // initialize jqxGrid @@ -212,40 +228,39 @@ var addButton = $("
Nieuw
"); container.append(addButton); statusbar.append(container); - addButton.jqxButton({ theme: theme, width: 120, height: 20 }); + addButton.jqxButton({ theme: theme, width: 90, height: 20 }); // add new row. addButton.click(function (event) { editrow = -1; - $("#popupWindow").jqxWindow({ position: { x: 180, y: 30 } }); - $("#name").val(''); - $("#boil_size").val('18'); - $("#batch_size").val('15.3'); - $("#tun_volume").val('20'); - $("#tun_weight").val('2'); - $("#tun_specific_heat").val('0.11'); - $("#tun_material").val('RVS'); - $("#tun_height").val('20'); - $("#top_up_water").val('0'); - $("#trub_chiller_loss").val('0.5'); - $("#evap_rate").val('1.8'); - $("#boil_time").val('90'); - $("#calc_boil_volume").val(true); - $("#top_up_kettle").val('0'); - $("#hop_utilization").val('100'); + $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); + $("#name").val('Nieuwe brouwset'); + $("#boil_size").val(18); + $("#batch_size").val(15.3); + $("#tun_volume").val(20); + $("#tun_weight").val(2); + $("#tun_specific_heat").val(0.11); + $("#tun_material").val(0); + $("#tun_height").val(20); + $("#top_up_water").val(0); + $("#trub_chiller_loss").val(0.5); + $("#evap_rate").val(1.8); + $("#boil_time").val(90); + $("#calc_boil_volume").val(1); + $("#top_up_kettle").val(0); + $("#hop_utilization").val(100); $("#notes").val(''); - $("#lauter_volume").val('20'); - $("#lauter_height").val('20'); - $("#lauter_deadspace").val('0.5'); - $("#kettle_volume").val('20'); - $("#kettle_height").val('20'); - $("#mash_volume").val('18'); - $("#mash_max").val('6'); - $("#efficiency").val('75'); + $("#lauter_volume").val(20); + $("#lauter_height").val(20); + $("#lauter_deadspace").val(0.5); + $("#kettle_volume").val(20); + $("#kettle_height").val(20); + $("#mash_volume").val(18); + $("#mash_max").val(6); + $("#efficiency").val(75); $("#popupWindow").jqxWindow('open'); }); }, - filterable: true, - filtermode: 'excel', + filterable: false, ready: function() { $('#boil_size').on('change', function (event) { calcBatchVolume(); }); $('#evap_rate').on('change', function (event) { calcBatchVolume(); }); @@ -253,31 +268,23 @@ $('#top_up_kettle').on('change', function (event) { calcBatchVolume(); }); $("#calc_boil_volume").on('change', function (event) { calcBatchVolume(); }); $('#tun_material').on('change', function (event) { - switch ($('#tun_material').val()) { - case 'RVS': $("#tun_specific_heat").val('0.11'); - break; - case 'Aluminium': $("#tun_specific_heat").val('0.22'); - break; - case 'Kunststof': $("#tun_specific_heat").val('0.46'); - break; - case 'Koper': $("#tun_specific_heat").val('0.092'); - break; - } + dataRecord.tun_specific_heat = MaterialData[event.args.index].sh; + $("#tun_specific_heat").val(dataRecord.tun_specific_heat); }); }, columns: [ { text: 'Installatie naam', datafield: 'name', width: 200 }, - { text: 'Kook volume', datafield: 'boil_size', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, - { text: 'Batch volume', datafield: 'batch_size', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Kook volume', datafield: 'boil_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Batch volume', datafield: 'batch_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, { text: 'Opmerkingen', datafield: 'notes' }, - { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () { + { text: 'Wijzig', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { return "Wijzig"; }, buttonclick: function (row) { // open the popup window when the user clicks a button. editrow = row; - $("#popupWindow").jqxWindow({ position: { x: 180, y: 30 } }); + $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); // get the clicked row's data and initialize the input fields. - var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); + dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); $("#name").val(dataRecord.name); $("#boil_size").val(dataRecord.boil_size); $("#batch_size").val(dataRecord.batch_size); @@ -310,12 +317,19 @@ }); // initialize the popup window and buttons. $("#popupWindow").jqxWindow({ - width: 900, resizable: false, theme: theme, isModal: true, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.40 + width: 1050, + height: 600, + resizable: false, + theme: theme, + isModal: true, + autoOpen: false, + cancelButton: $("#Cancel"), + modalOpacity: 0.40 }); $("#popupWindow").on('open', function () { $("#name").jqxInput('selectAll'); }); - $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme }); + $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); $("#Delete").click(function () { if (editrow >= 0) { // Open a popup to confirm this action. @@ -327,7 +341,7 @@ } $("#popupWindow").jqxWindow('hide'); }); - $("#Cancel").jqxButton({ template: "primary", width: '80px', theme: theme }); + $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); // update the edited row when the user clicks the 'Save' button. $("#Save").click(function () { @@ -368,6 +382,7 @@ $('#jqxgrid').jqxGrid('addrow', null, row); } $("#popupWindow").jqxWindow('hide'); + location.reload( true ); // reload ourself. }); createDelElements(); });