diff -r d202777ebae5 -r 2ac491548d8d www/js/inv_fermentables.js --- a/www/js/inv_fermentables.js Mon Jan 21 20:45:18 2019 +0100 +++ b/www/js/inv_fermentables.js Tue Jan 22 20:27:45 2019 +0100 @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (C) 2014-2018 + * Copyright (C) 2014-2019 * * Michiel Broek * @@ -51,10 +51,10 @@ datafields: [ { name: 'record', type: 'number' }, { name: 'name', type: 'string' }, - { name: 'type', type: 'string' }, + { name: 'type', type: 'int' }, { name: 'yield', type: 'float' }, { name: 'color', type: 'float' }, - { name: 'add_after_boil', type: 'bool' }, + { name: 'add_after_boil', type: 'int' }, { name: 'origin', type: 'string' }, { name: 'supplier', type: 'string' }, { name: 'notes', type: 'string' }, @@ -62,13 +62,14 @@ { name: 'moisture', type: 'float' }, { name: 'diastatic_power', type: 'float' }, { name: 'protein', type: 'float' }, + { name: 'dissolved_protein', type: 'float' }, { name: 'max_in_batch', type: 'float' }, - { name: 'recommend_mash', type: 'bool' }, - { name: 'ibu_gal_per_lb', type: 'float' }, - { name: 'always_on_stock', type: 'bool' }, + { name: 'recommend_mash', type: 'int' }, + { name: 'added', type: 'int' }, + { name: 'always_on_stock', type: 'int' }, { name: 'di_ph', type: 'float' }, { name: 'acid_to_ph_57', type: 'float' }, - { name: 'graintype', type: 'string' }, + { name: 'graintype', type: 'int' }, { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' }, { name: 'production_date', type: 'string' }, @@ -84,6 +85,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { // delete command is executed. commit(true); @@ -100,6 +102,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { commit(true); }, @@ -115,6 +118,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { // update command is executed. commit(true); @@ -125,34 +129,55 @@ }); } }; - var srcType = [ "Grain", "Sugar", "Extract", "Dry Extract", "Adjunct" ]; - var srcGraintype = [ "Base", "Crystal", "Special", "Roast", "Kilned", "No malt" ]; // initialize the input fields. - $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); - $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 100, height: 23, dropDownHeight: 156 }); - $("#yield").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#color").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); + $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); + $("#type").jqxDropDownList({ + theme: theme, + source: FermentableTypeAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); + $("#yield").jqxNumberInput( Spin1dec1 ); + $("#color").jqxNumberInput( Spin1dec5 ); $("#add_after_boil").jqxCheckBox({ theme: theme, width: 120, height: 23 }); $("#origin").jqxInput({ theme: theme, width: 250, height: 23 }); $("#supplier").jqxInput({ theme: theme, width: 250, height: 23 }); $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); - $("#coarse_fine_diff").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#moisture").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#diastatic_power").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#protein").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#max_in_batch").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); + $("#coarse_fine_diff").jqxNumberInput( Spin1dec1 ); + $("#moisture").jqxNumberInput( Spin1dec1 ); + $("#diastatic_power").jqxNumberInput( Spin1dec1 ); + $("#protein").jqxNumberInput( Spin1dec1 ); + $("#dissolved_protein").jqxNumberInput( Spin1dec1 ); + $("#max_in_batch").jqxNumberInput( Perc1dec5 ); $("#recommend_mash").jqxCheckBox({ theme: theme, width: 120, height: 23 }); - $("#ibu_gal_per_lb").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); + $("#added").jqxDropDownList({ + theme: theme, + source: AddedAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); $("#always_on_stock").jqxCheckBox({ theme: theme, width: 120, height: 23 }); - $("#di_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#acid_to_ph_57").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#graintype").jqxDropDownList({ theme: theme, source: srcGraintype, width: 100, height: 23, dropDownHeight: 185 }); - - $("#inventory").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#production_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' }); - - $("#cost").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 2, spinButtons: true }); - $("#tht_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' }); + $("#di_ph").jqxNumberInput( Spin2pH ); + $("#acid_to_ph_57").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: -1000, max: 1000, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.01 }); + $("#graintype").jqxDropDownList({ + theme: theme, + source: GrainTypeAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); + $("#inventory").jqxNumberInput( Spin1dec1 ); + $("#production_date").jqxDateTimeInput( Dateopts ); + $("#cost").jqxNumberInput( Spin2dec1 ); + $("#tht_date").jqxDateTimeInput( Dateopts ); var dataAdapter = new $.jqx.dataAdapter(source); var editrow = -1; // initialize jqxGrid @@ -168,29 +193,33 @@ 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: 230, y: 30 } }); - $("#name").val(''); - $("#type").val('Grain'); + $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); + $("#name").val('Nieuw product'); + $("#type").val(0); $("#origin").val(''); $("#supplier").val(''); $("#notes").val(''); - $("#coarse_fine_diff").val(''); - $("#moisture").val(''); - $("#diastatic_power").val(''); - $("#protein").val(''); - $("#max_in_batch").val(''); - $("#recommend_mash").val(''); - $("#ibu_gal_per_lb").val(''); - $("#always_on_stock").val(''); - $("#di_ph").val(''); - $("#acid_to_ph_57").val(''); - $("#graintype").val(''); - $("#inventory").val(''); - $("#cost").val(''); + $("#yield").val(80); + $("#color").val(3); + $("#coarse_fine_diff").val(3); + $("#moisture").val(4); + $("#diastatic_power").val(0); + $("#protein").val(0); + $("#dissolved_protein").val(0); + $("#max_in_batch").val(100); + $("#recommend_mash").val(1); + $("#always_on_stock").val(0); + $("#di_ph").val(0); + $("#acid_to_ph_57").val(0); + $("#graintype").val(0); + $("#add_after_boil").val(0); + $("#added").val(0); + $("#inventory").val(0); + $("#cost").val(0); $("#production_date").val(''); $("#tht_date").val(''); $("#popupWindow").jqxWindow('open'); @@ -199,21 +228,29 @@ filterable: true, filtermode: 'excel', columns: [ - { text: 'Producent', datafield: 'supplier', width: 200 }, + { text: 'Producent', datafield: 'supplier', width: 140 }, { text: 'Vergistbaar product', datafield: 'name' }, - { text: 'Soort', datafield: 'type', align: 'center', cellsalign: 'center', width: 90 }, - { text: 'Mout type', datafield: 'graintype', align: 'center', cellsalign: 'center', width: 90 }, + { text: 'Soort', datafield: 'type', align: 'center', cellsalign: 'center', width: 135, + cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { + return "
" + FermentableTypeData[value].nl + "
"; + } + }, + { text: 'Graan type', datafield: 'graintype', align: 'center', cellsalign: 'center', width: 125, + cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { + return "
" + GrainTypeData[value].nl + "
"; + } + }, { text: 'Herkomst', datafield: 'origin', width: 150 }, - { text: 'Kleur', datafield: 'color', width: 70, align: 'right', cellsalign: 'right' }, + { text: 'EBC', datafield: 'color', width: 60, align: 'right', cellsalign: 'right' }, { text: 'Opbrengst', datafield: 'yield', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, { text: 'Vooraad', datafield: 'inventory', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, - { text: 'Prijs', datafield: 'cost', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'c2' }, - { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () { + { text: 'Prijs/kg', datafield: 'cost', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'c2' }, + { 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: 230, 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); $("#name").val(dataRecord.name); @@ -228,9 +265,10 @@ $("#moisture").val(dataRecord.moisture); $("#diastatic_power").val(dataRecord.diastatic_power); $("#protein").val(dataRecord.protein); + $("#dissolved_protein").val(dataRecord.dissolved_protein); $("#max_in_batch").val(dataRecord.max_in_batch); $("#recommend_mash").val(dataRecord.recommend_mash); - $("#ibu_gal_per_lb").val(dataRecord.ibu_gal_per_lb); + $("#added").val(dataRecord.added); $("#always_on_stock").val(dataRecord.always_on_stock); $("#di_ph").val(dataRecord.di_ph); $("#acid_to_ph_57").val(dataRecord.acid_to_ph_57); @@ -247,12 +285,19 @@ }); // initialize the popup window and buttons. $("#popupWindow").jqxWindow({ - width: 860, resizable: false, theme: theme, isModal: true, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.40 + width: 1050, + height: 550, + resizable: false, + theme: theme, + isModal: true, + autoOpen: false, + cancelButton: $("#Cancel"), + modalOpacity: 0.40 }); $("#popupWindow").on('open', function () { $("#name").jqxInput('selectAll'); }); - $("#Delete").jqxButton({ theme: theme }); + $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); $("#Delete").click(function () { if (editrow >= 0) { // Open a popup to confirm this action. @@ -264,71 +309,48 @@ } $("#popupWindow").jqxWindow('hide'); }); - $("#Cancel").jqxButton({ theme: theme }); - $("#Save").jqxButton({ 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 () { + var rowID = -1; if (editrow >= 0) { var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); - var row = { - record: rowID, - name: $("#name").val(), - type: $("#type").val(), - yield: parseFloat($("#yield").jqxNumberInput('decimal')), - color: parseFloat($("#color").jqxNumberInput('decimal')), - add_after_boil: $("#add_after_boil").val(), - origin: $("#origin").val(), - supplier: $("#supplier").val(), - notes: $("#notes").val(), - coarse_fine_diff: parseFloat($("#coarse_fine_diff").jqxNumberInput('decimal')), - moisture: parseFloat($("#moisture").jqxNumberInput('decimal')), - diastatic_power: parseFloat($("#diastatic_power").jqxNumberInput('decimal')), - protein: parseFloat($("#protein").jqxNumberInput('decimal')), - max_in_batch: parseFloat($("#max_in_batch").jqxNumberInput('decimal')), - recommend_mash: $("#recommend_mash").val(), - ibu_gal_per_lb: parseFloat($("#ibu_gal_per_lb").jqxNumberInput('decimal')), - always_on_stock: $("#always_on_stock").val(), - di_ph: parseFloat($("#di_ph").jqxNumberInput('decimal')), - acid_to_ph_57: parseFloat($("#acid_to_ph_57").jqxNumberInput('decimal')), - graintype: $("#graintype").val(), - inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), - cost: parseFloat($("#cost").jqxNumberInput('decimal')), - production_date: $("#production_date").val(), - tht_date: $("#tht_date").val(), - }; + } + var row = { + record: rowID, + name: $("#name").val(), + type: $("#type").val(), + yield: parseFloat($("#yield").jqxNumberInput('decimal')), + color: parseFloat($("#color").jqxNumberInput('decimal')), + add_after_boil: $("#add_after_boil").val(), + origin: $("#origin").val(), + supplier: $("#supplier").val(), + notes: $("#notes").val(), + coarse_fine_diff: parseFloat($("#coarse_fine_diff").jqxNumberInput('decimal')), + moisture: parseFloat($("#moisture").jqxNumberInput('decimal')), + diastatic_power: parseFloat($("#diastatic_power").jqxNumberInput('decimal')), + protein: parseFloat($("#protein").jqxNumberInput('decimal')), + dissolved_protein: parseFloat($("#dissolved_protein").jqxNumberInput('decimal')), + max_in_batch: parseFloat($("#max_in_batch").jqxNumberInput('decimal')), + recommend_mash: $("#recommend_mash").val(), + added: $("#added").val(), + always_on_stock: $("#always_on_stock").val(), + di_ph: parseFloat($("#di_ph").jqxNumberInput('decimal')), + acid_to_ph_57: parseFloat($("#acid_to_ph_57").jqxNumberInput('decimal')), + graintype: $("#graintype").val(), + inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), + cost: parseFloat($("#cost").jqxNumberInput('decimal')), + production_date: $("#production_date").val(), + tht_date: $("#tht_date").val(), + }; + if (editrow >= 0) { $('#jqxgrid').jqxGrid('updaterow', rowID, row); - $("#popupWindow").jqxWindow('hide'); } else { - // Insert a record - var newrow = { - record: -1, - name: $("#name").val(), - type: $("#type").val(), - yield: parseFloat($("#yield").jqxNumberInput('decimal')), - color: parseFloat($("#color").jqxNumberInput('decimal')), - add_after_boil: $("#add_after_boil").val(), - origin: $("#origin").val(), - supplier: $("#supplier").val(), - notes: $("#notes").val(), - coarse_fine_diff: parseFloat($("#coarse_fine_diff").jqxNumberInput('decimal')), - moisture: parseFloat($("#moisture").jqxNumberInput('decimal')), - diastatic_power: parseFloat($("#diastatic_power").jqxNumberInput('decimal')), - protein: parseFloat($("#protein").jqxNumberInput('decimal')), - max_in_batch: parseFloat($("#max_in_batch").jqxNumberInput('decimal')), - recommend_mash: $("#recommend_mash").val(), - ibu_gal_per_lb: parseFloat($("#ibu_gal_per_lb").jqxNumberInput('decimal')), - always_on_stock: $("#always_on_stock").val(), - di_ph: parseFloat($("#di_ph").jqxNumberInput('decimal')), - acid_to_ph_57: parseFloat($("#acid_to_ph_57").jqxNumberInput('decimal')), - graintype: $("#graintype").val(), - inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), - cost: parseFloat($("#cost").jqxNumberInput('decimal')), - production_date: $("#production_date").val(), - tht_date: $("#tht_date").val(), - }; - $('#jqxgrid').jqxGrid('addrow', null, newrow); - $("#popupWindow").jqxWindow('hide'); + $('#jqxgrid').jqxGrid('addrow', null, row); } + $("#popupWindow").jqxWindow('hide'); + location.reload( true ); // reload ourself. }); createDelElements(); });