# HG changeset patch # User Michiel Broek # Date 1544960404 -3600 # Node ID ae15cfe5f008956f5d6b9b5a0c877e5bb92ec0b9 # Parent 122f6471616137658198de4df7d8f8e74d8cf774 Moved inventory dropdown lists to global.js diff -r 122f64716161 -r ae15cfe5f008 www/js/global.js --- a/www/js/global.js Sat Dec 15 23:22:11 2018 +0100 +++ b/www/js/global.js Sun Dec 16 12:40:04 2018 +0100 @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (C) 2014 + * Copyright (C) 2014-2019 * * Michiel Broek * @@ -23,6 +23,171 @@ var sugardensity = 1.611; //kg/l in solution +// Styles dropdown list +var stylesUrl = "includes/db_profile_styles.php"; +var stylesSource = { + datatype: "json", + datafields: [ + { name: 'record', type: 'number' }, + { name: 'name', type: 'string' }, + { name: 'category', type: 'string' }, + { name: 'category_number', type: 'number' }, + { name: 'style_letter', type: 'string' }, + { name: 'style_guide', type: 'string' }, + { name: 'type', type: 'string' }, + { name: 'og_min', type: 'float' }, + { name: 'og_max', type: 'float' }, + { name: 'fg_min', type: 'float' }, + { name: 'fg_max', type: 'float' }, + { name: 'ibu_min', type: 'float' }, + { name: 'ibu_max', type: 'float' }, + { name: 'color_min', type: 'float' }, + { name: 'color_max', type: 'float' }, + { name: 'carb_min', type: 'float' }, + { name: 'carb_max', type: 'float' }, + { name: 'abv_min', type: 'float' }, + { name: 'abv_max', type: 'float' }, + { name: 'notes', type: 'string' }, + { name: 'profile', type: 'string' }, + { name: 'ingredients', type: 'string' }, + { name: 'examples', type: 'string' } + ], + url: stylesUrl, + async: true +}; +var styleslist = new $.jqx.dataAdapter(stylesSource); + +// dropdownlist datasource from inventory_fermentables +var fermentableUrl = "getfermentablesources.php"; +var fermentableInvSource = { + datatype: "json", + datafields: [ + { name: 'record', type: 'number' }, + { name: 'name', type: 'string' }, + { name: 'type', type: 'string' }, + { name: 'yield', type: 'float' }, + { name: 'color', type: 'float' }, + { name: 'add_after_boil', type: 'bool' }, + { name: 'origin', type: 'string' }, + { name: 'supplier', type: 'string' }, + { name: 'coarse_fine_diff', type: 'float' }, + { name: 'moisture', type: 'float' }, + { name: 'diastatic_power', type: 'float' }, + { name: 'protein', type: 'float' }, + { name: 'max_in_batch', type: 'float' }, + { name: 'recommend_mash', type: 'bool' }, + { name: 'graintype', type: 'string' }, + { name: 'di_ph', type: 'float' }, + { name: 'inventory', type: 'float' }, + { name: 'cost', type: 'float' } + ], + url: fermentableUrl, + async: true +}; +var fermentablelist = new $.jqx.dataAdapter(fermentableInvSource); + +// dropdownlist datasource from inventory_hops +var hopUrl = "gethopsources.php"; +var hopInvSource = { + datatype: "json", + datafields: [ + { name: 'record', type: 'number' }, + { name: 'name', type: 'string' }, + { name: 'origin', type: 'string' }, + { name: 'type', type: 'string' }, + { name: 'alpha', type: 'float' }, + { name: 'beta', type: 'float' }, + { name: 'humulene', type: 'float' }, + { name: 'caryophyllene', type: 'float' }, + { name: 'cohumulone', type: 'float' }, + { name: 'myrcene', type: 'float' }, + { name: 'hsi', type: 'float' }, + { name: 'useat', type: 'string' }, + { name: 'form', type: 'string' }, + { name: 'total_oil', type: 'float' }, + { name: 'cost', type: 'float' } + ], + url: hopUrl, + async: true +}; +var hoplist = new $.jqx.dataAdapter(hopInvSource); + +// dropdownlist datasource from inventory_miscs +var miscUrl = "getmiscsources.php"; +var miscInvSource = { + datatype: "json", + datafields: [ + { name: 'record', type: 'number' }, + { name: 'name', type: 'string' }, + { name: 'type', type: 'string' }, + { name: 'use_use', type: 'string' }, + { name: 'amount_is_weight', type: 'bool' }, + { name: 'time', type: 'float' }, + { name: 'cost', type: 'float' } + ], + url: miscUrl, + async: true +}; +var misclist = new $.jqx.dataAdapter(miscInvSource); + +// dropdownlist datasource from inventory_yeasts +var yeastUrl = "getyeastsources.php"; +var yeastInvSource = { + datatype: "json", + datafields: [ + { name: 'record', type: 'number' }, + { name: 'name', type: 'string' }, + { name: 'type', type: 'string' }, + { name: 'form', type: 'string' }, + { name: 'laboratory', type: 'string' }, + { name: 'product_id', type: 'string' }, + { name: 'min_temperature', type: 'float' }, + { name: 'max_temperature', type: 'float' }, + { name: 'attenuation', type: 'float' }, + { name: 'cost', type: 'float' } + ], + url: yeastUrl, + async: true +}; +var yeastlist = new $.jqx.dataAdapter(yeastInvSource); + +// dropdownlist datasource from inventory_waters +var waterUrl = "getwatersources.php"; +var waterInvSource = { + datatype: "json", + datafields: [ + { name: 'record', type: 'number' }, + { name: 'name', type: 'string' }, + { name: 'unlimited_stock', type: 'bool' }, + { name: 'calcium', type: 'float' }, + { name: 'sulfate', type: 'float' }, + { name: 'chloride', type: 'float' }, + { name: 'sodium', type: 'float' }, + { name: 'magnesium', type: 'float' }, + { name: 'ph', type: 'float' }, + { name: 'total_alkalinity', type: 'float' }, + { name: 'cost', type: 'float' }, + ], + url: waterUrl, + async: true +}; +var waterlist = new $.jqx.dataAdapter(waterInvSource); + +// dropdownlist datasource from profile_mash +var mashUrl = "include/db_profile_mash.php"; +var mashInvSource = { + datatype: "json", + datafields: [ + { name: 'record', type: 'number' }, + { name: 'name', type: 'string' }, + { name: 'steps', type: 'array' } + ], + url: mashUrl, + async: true +}; +var mashlist = new $.jqx.dataAdapter(mashInvSource); + + function getLocalization() { var localizationobj = {}; @@ -276,7 +441,6 @@ result = '0' + result; } result = '#' + result; - console.log("color string: " + result); return result; } diff -r 122f64716161 -r ae15cfe5f008 www/js/rec_edit.js --- a/www/js/rec_edit.js Sat Dec 15 23:22:11 2018 +0100 +++ b/www/js/rec_edit.js Sun Dec 16 12:40:04 2018 +0100 @@ -520,35 +520,6 @@ } }; var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); - // dropdownlist datasource from inventory_fermentables - var fermentableUrl = "getfermentablesources.php"; - var fermentableInvSource = { - datatype: "json", - datafields: [ - { name: 'record', type: 'number' }, - { name: 'name', type: 'string' }, - { name: 'type', type: 'string' }, - { name: 'yield', type: 'float' }, - { name: 'color', type: 'float' }, - { name: 'add_after_boil', type: 'bool' }, - { name: 'origin', type: 'string' }, - { name: 'supplier', type: 'string' }, - { name: 'coarse_fine_diff', type: 'float' }, - { name: 'moisture', type: 'float' }, - { name: 'diastatic_power', type: 'float' }, - { name: 'protein', type: 'float' }, - { name: 'max_in_batch', type: 'float' }, - { name: 'recommend_mash', type: 'bool' }, - { name: 'graintype', type: 'string' }, - { name: 'di_ph', type: 'float' }, - { name: 'inventory', type: 'float' }, - { name: 'cost', type: 'float' } - ], - url: fermentableUrl, - async: true - }; - var fermentablelist = new $.jqx.dataAdapter(fermentableInvSource); - $("#fermentableGrid").jqxGrid({ width: 1150, height: 400, @@ -702,7 +673,6 @@ if (to_100) { return oldvalue; // When using percentages, don't allow edited results. } -// console.log("row:"+row+" col:"+column+" type:"+columntype+" old:"+oldvalue+" new:"+newvalue); } }, { text: 'Percentage', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1', @@ -850,32 +820,6 @@ $('#err').text(status + ' ' + error); }, }); - // dropdownlist datasource from inventory_hops - var hopUrl = "gethopsources.php"; - var hopInvSource = { - datatype: "json", - datafields: [ - { name: 'record', type: 'number' }, - { name: 'name', type: 'string' }, - { name: 'origin', type: 'string' }, - { name: 'type', type: 'string' }, - { name: 'alpha', type: 'float' }, - { name: 'beta', type: 'float' }, - { name: 'humulene', type: 'float' }, - { name: 'caryophyllene', type: 'float' }, - { name: 'cohumulone', type: 'float' }, - { name: 'myrcene', type: 'float' }, - { name: 'hsi', type: 'float' }, - { name: 'useat', type: 'string' }, - { name: 'form', type: 'string' }, - { name: 'total_oil', type: 'float' }, - { name: 'cost', type: 'float' } - ], - url: hopUrl, - async: true - }; - var hoplist = new $.jqx.dataAdapter(hopInvSource); - $("#hopGrid").jqxGrid({ width: 1050, height: 400, @@ -1082,24 +1026,6 @@ $('#err').text(status + ' ' + error); }, }); - // dropdownlist datasource from inventory_miscs - var miscUrl = "getmiscsources.php"; - var miscInvSource = { - datatype: "json", - datafields: [ - { name: 'record', type: 'number' }, - { name: 'name', type: 'string' }, - { name: 'type', type: 'string' }, - { name: 'use_use', type: 'string' }, - { name: 'amount_is_weight', type: 'bool' }, - { name: 'time', type: 'float' }, - { name: 'cost', type: 'float' } - ], - url: miscUrl, - async: true - }; - var misclist = new $.jqx.dataAdapter(miscInvSource); - $("#miscGrid").jqxGrid({ width: 960, height: 400, @@ -1256,27 +1182,6 @@ } }; var yeastAdapter = new $.jqx.dataAdapter(yeastSource); - // dropdownlist datasource from inventory_yeasts - var yeastUrl = "getyeastsources.php"; - var yeastInvSource = { - datatype: "json", - datafields: [ - { name: 'record', type: 'number' }, - { name: 'name', type: 'string' }, - { name: 'type', type: 'string' }, - { name: 'form', type: 'string' }, - { name: 'laboratory', type: 'string' }, - { name: 'product_id', type: 'string' }, - { name: 'min_temperature', type: 'float' }, - { name: 'max_temperature', type: 'float' }, - { name: 'attenuation', type: 'float' }, - { name: 'cost', type: 'float' } - ], - url: yeastUrl, - async: true - }; - var yeastlist = new $.jqx.dataAdapter(yeastInvSource); - $("#yeastGrid").jqxGrid({ width: 1050, height: 300, @@ -1433,28 +1338,6 @@ } }; var waterAdapter = new $.jqx.dataAdapter(waterSource); - // dropdownlist datasource from inventory_waters - var waterUrl = "getwatersources.php"; - var waterInvSource = { - datatype: "json", - datafields: [ - { name: 'record', type: 'number' }, - { name: 'name', type: 'string' }, - { name: 'unlimited_stock', type: 'bool' }, - { name: 'calcium', type: 'float' }, - { name: 'sulfate', type: 'float' }, - { name: 'chloride', type: 'float' }, - { name: 'sodium', type: 'float' }, - { name: 'magnesium', type: 'float' }, - { name: 'ph', type: 'float' }, - { name: 'total_alkalinity', type: 'float' }, - { name: 'cost', type: 'float' }, - ], - url: waterUrl, - async: true - }; - var waterlist = new $.jqx.dataAdapter(waterInvSource); - $("#waterGrid").jqxGrid({ width: 960, height: 200, @@ -1572,20 +1455,6 @@ } }; var mashAdapter = new $.jqx.dataAdapter(mashSource); - // dropdownlist datasource from profile_mash - var mashUrl = "include/db_profile_mash.php"; - var mashInvSource = { - datatype: "json", - datafields: [ - { name: 'record', type: 'number' }, - { name: 'name', type: 'string' }, - { name: 'steps', type: 'array' } - ], - url: mashUrl, - async: true - }; - var mashlist = new $.jqx.dataAdapter(mashInvSource); - $("#mashGrid").jqxGrid({ width: 960, height: 400, diff -r 122f64716161 -r ae15cfe5f008 www/js/rec_new.js --- a/www/js/rec_new.js Sat Dec 15 23:22:11 2018 +0100 +++ b/www/js/rec_new.js Sun Dec 16 12:40:04 2018 +0100 @@ -66,40 +66,6 @@ $("#efficiency").val(75); $("#est_og").val(1.052); - // Styles dropdown list - var stylesUrl = "includes/db_profile_styles.php"; - var stylesSource = { - datatype: "json", - datafields: [ - { name: 'record', type: 'number' }, - { name: 'name', type: 'string' }, - { name: 'category', type: 'string' }, - { name: 'category_number', type: 'number' }, - { name: 'style_letter', type: 'string' }, - { name: 'style_guide', type: 'string' }, - { name: 'type', type: 'string' }, - { name: 'og_min', type: 'float' }, - { name: 'og_max', type: 'float' }, - { name: 'fg_min', type: 'float' }, - { name: 'fg_max', type: 'float' }, - { name: 'ibu_min', type: 'float' }, - { name: 'ibu_max', type: 'float' }, - { name: 'color_min', type: 'float' }, - { name: 'color_max', type: 'float' }, - { name: 'carb_min', type: 'float' }, - { name: 'carb_max', type: 'float' }, - { name: 'abv_min', type: 'float' }, - { name: 'abv_max', type: 'float' }, - { name: 'notes', type: 'string' }, - { name: 'profile', type: 'string' }, - { name: 'ingredients', type: 'string' }, - { name: 'examples', type: 'string' } - ], - url: stylesUrl, - async: true - }; - var styleslist = new $.jqx.dataAdapter(stylesSource); - $("#styleSelect").jqxDropDownList({ placeHolder: "Kies bierstijl:", theme: theme,