856 ] |
856 ] |
857 }); |
857 }); |
858 }; // editWater = function (data) { |
858 }; // editWater = function (data) { |
859 |
859 |
860 // inline mash editor |
860 // inline mash editor |
|
861 var editMash = function (data) { |
|
862 var generaterow = function () { |
|
863 var row = {}; |
|
864 row["step_name"] = "Stap 1"; |
|
865 row["step_type"] = "Infusion"; |
|
866 row["step_infuse_amount"] = 15; |
|
867 row["step_temp"] = 62.0; |
|
868 row['step_time'] = 20.0; |
|
869 row['ramp_time'] = 1.0; |
|
870 row['end_temp'] = 62.0; |
|
871 return row; |
|
872 } |
|
873 var mashSource = { |
|
874 localdata: data.mashs, |
|
875 datatype: "local", |
|
876 cache: false, |
|
877 datafields: [ |
|
878 { name: 'step_name', type: 'string' }, |
|
879 { name: 'step_type', type: 'string' }, |
|
880 { name: 'step_infuse_amount', type: 'float' }, |
|
881 { name: 'step_temp', type: 'float' }, |
|
882 { name: 'step_time', type: 'float' }, |
|
883 { name: 'ramp_time', type: 'float' }, |
|
884 { name: 'end_temp', type: 'float' } |
|
885 ], |
|
886 addrow: function (rowid, rowdata, position, commit) { |
|
887 commit(true); |
|
888 }, |
|
889 deleterow: function (rowid, commit) { |
|
890 commit(true); |
|
891 } |
|
892 }; |
|
893 var mashAdapter = new $.jqx.dataAdapter(mashSource); |
|
894 // dropdownlist datasource from profile_mash |
|
895 var mashUrl = "include/db_profile_mash.php"; |
|
896 var mashInvSource = { |
|
897 datatype: "json", |
|
898 datafields: [ |
|
899 { name: 'record', type: 'number' }, |
|
900 { name: 'name', type: 'string' }, |
|
901 { name: 'steps', type: 'array' } |
|
902 ], |
|
903 url: mashUrl, |
|
904 async: true |
|
905 }; |
|
906 var mashlist = new $.jqx.dataAdapter(mashInvSource); |
|
907 |
|
908 $("#mashGrid").jqxGrid({ |
|
909 width: 960, |
|
910 height: 400, |
|
911 source: mashAdapter, |
|
912 theme: theme, |
|
913 selectionmode: 'singlerow', |
|
914 editmode: 'selectedrow', |
|
915 editable: true, |
|
916 localization: getLocalization(), |
|
917 showtoolbar: true, |
|
918 rendertoolbar: function (toolbar) { |
|
919 var me = this; |
|
920 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
921 toolbar.append(container); |
|
922 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); |
|
923 container.append('<input style="float: left; margin-left: 230px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); |
|
924 $("#saddrowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
925 $("#saddrowbutton").on('click', function () { |
|
926 var datarow = generaterow(); |
|
927 var commit = $("#mashGrid").jqxGrid('addrow', null, datarow); |
|
928 }); |
|
929 // delete selected yeast. |
|
930 $("#sdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
931 $("#sdeleterowbutton").on('click', function () { |
|
932 var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex'); |
|
933 var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount; |
|
934 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
935 var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex); |
|
936 var commit = $("#mashGrid").jqxGrid('deleterow', id); |
|
937 } |
|
938 }); |
|
939 }, |
|
940 columns: [ |
|
941 { text: 'Stap naam', datafield: 'step_name' }, |
|
942 { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist', |
|
943 createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { |
|
944 var dataSource = [ "Infusion", "Temperature", "Decoction" ]; |
|
945 editor.jqxDropDownList({ source: dataSource, dropDownHeight: 105 }); |
|
946 } |
|
947 }, |
|
948 { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
|
949 validation: function (cell, value) { |
|
950 if (value < 35 || value > 80) { |
|
951 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; |
|
952 } |
|
953 return true; |
|
954 } |
|
955 }, |
|
956 { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
|
957 validation: function (cell, value) { |
|
958 if (value < 35 || value > 80) { |
|
959 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; |
|
960 } |
|
961 return true; |
|
962 } |
|
963 }, |
|
964 { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right', |
|
965 validation: function (cell, value) { |
|
966 if (value < 1 || value > 360) { |
|
967 return { result: false, message: "De tijd moet tussen 1 en 360 zijn." }; |
|
968 } |
|
969 return true; |
|
970 } |
|
971 }, |
|
972 { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right', |
|
973 validation: function (cell, value) { |
|
974 if (value < 1 || value > 60) { |
|
975 return { result: false, message: "De tijd moet tussen 1 en 60 zijn." }; |
|
976 } |
|
977 return true; |
|
978 } |
|
979 }, |
|
980 { text: 'Infuse', datafield: 'step_infuse_amount', width: 70, align: 'right', cellsalign: 'right', |
|
981 validation: function (cell, value) { |
|
982 if (value < 0 || value > 60) { |
|
983 return { result: false, message: "De waarde moet tussen 0 en 60 zijn." }; |
|
984 } |
|
985 return true; |
|
986 } |
|
987 } |
|
988 ] |
|
989 }); |
|
990 $("#mashGrid").on('cellendedit', function (event) { |
|
991 $('#mashGrid').jqxGrid('sortby', 'step_temp', 'asc'); |
|
992 }); |
|
993 }; |
861 |
994 |
862 // initialize the input fields. |
995 // initialize the input fields. |
863 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
996 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
864 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
997 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
865 var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; |
998 var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; |