# HG changeset patch # User Michiel Broek # Date 1568322192 -7200 # Node ID ce814c787b794e133f9d3ef56bbff3d703f06657 # Parent fc21dcfbe51ddb6a13bd8b7ccf55d9091ab83d7c Fixed not creating new records diff -r fc21dcfbe51d -r ce814c787b79 www/js/profile_mash-min.js --- a/www/js/profile_mash-min.js Thu Sep 12 20:33:33 2019 +0200 +++ b/www/js/profile_mash-min.js Thu Sep 12 23:03:12 2019 +0200 @@ -1,1 +1,1 @@ -function createDelElements(){$("#eventWindow").jqxWindow({theme:theme,position:{x:490,y:210},width:300,height:175,resizable:false,isModal:true,modalOpacity:0.4,okButton:$("#delOk"),cancelButton:$("#delCancel"),initContent:function(){$("#delOk").jqxButton({template:"danger",width:"65px",theme:theme});$("#delCancel").jqxButton({template:"success",width:"65px",theme:theme});$("#delCancel").focus()}});$("#eventWindow").jqxWindow("hide")}$(document).ready(function(){var g=0;var d={};var c={};var b="includes/db_profile_mash.php";$("#name").jqxTooltip({content:"De naam voor dit maisch profiel."});$("#notes").jqxTooltip({content:"De uitgebreide opmerkingen over dit maisch profiel."});var f={datatype:"json",cache:false,datafields:[{name:"record",type:"number"},{name:"name",type:"string"},{name:"notes",type:"string"},{name:"steps",type:"array"}],id:"record",url:b,deleterow:function(i,k){var j="delete=true&"+$.param({record:i});$.ajax({dataType:"json",url:b,cache:false,data:j,type:"POST",success:function(m,l,n){k(true)},error:function(l,n,m){k(false)}})},addrow:function(j,m,i,l){var k="insert=true&"+$.param(m);$.ajax({dataType:"json",url:b,cache:false,data:k,type:"POST",success:function(o,n,p){l(true)},error:function(n,p,o){l(false)}})},updaterow:function(i,l,k){var j="update=true&"+$.param(l);$.ajax({dataType:"json",url:b,cache:false,data:j,type:"POST",success:function(n,m,o){k(true)},error:function(m,o,n){k(false)}})}};$("#m_step_name").jqxInput({theme:theme,width:320,height:23});$("#m_step_type").jqxDropDownList({theme:theme,source:MashStepTypeAdapter,valueMember:"id",displayMember:"nl",width:180,height:23,autoDropDownHeight:true});$("#m_step_temp").jqxNumberInput(Spin1dec);$("#m_step_temp").jqxNumberInput({Min:30,Max:80});$("#m_end_temp").jqxNumberInput(Spin1dec);$("#m_end_temp").jqxNumberInput({Min:30,Max:80});$("#m_step_time").jqxNumberInput(PosInt);$("#m_step_time").jqxNumberInput({Min:1,Max:120});$("#m_ramp_time").jqxNumberInput(PosInt);$("#m_ramp_time").jqxNumberInput({Min:1,Max:30});var h=new $.jqx.dataAdapter(f);var a=function(l){var k=function(){var m={};m.step_name="Stap 1";m.step_type=0;m.step_temp=62;m.step_time=20;m.ramp_time=1;m.end_temp=62;return m};var j={localdata:l.steps,datatype:"local",datafields:[{name:"step_name",type:"string"},{name:"step_type",type:"int"},{name:"step_temp",type:"float"},{name:"step_time",type:"float"},{name:"ramp_time",type:"float"},{name:"end_temp",type:"float"}],addrow:function(n,p,m,o){o(true)},deleterow:function(m,n){n(true)}};var i=new $.jqx.dataAdapter(j);$("#grid").jqxGrid({width:1020,height:330,source:i,theme:theme,selectionmode:"singlerow",showtoolbar:true,rendertoolbar:function(o){var n=this;var m=$("
");o.append(m);m.append('');m.append('');$("#addrowbutton").jqxButton({template:"primary",theme:theme,width:150});$("#deleterowbutton").jqxButton({template:"danger",theme:theme,width:150});$("#addrowbutton").on("click",function(){var p=k();var q=$("#grid").jqxGrid("addrow",null,p)});$("#deleterowbutton").on("click",function(){var p=$("#grid").jqxGrid("getselectedrowindex");var s=$("#grid").jqxGrid("getdatainformation").rowscount;if(p>=0&&p"+MashStepTypeData[q].nl+""}},{text:"Begin °C",datafield:"step_temp",width:100,align:"right",cellsalign:"right",cellsformat:"f1"},{text:"Eind °C",datafield:"end_temp",width:100,align:"right",cellsalign:"right",cellsformat:"f1"},{text:"Rust min.",datafield:"step_time",width:90,align:"right",cellsalign:"right"},{text:"Stap min.",datafield:"ramp_time",width:90,align:"right",cellsalign:"right"},{text:"",datafield:"Edit",columntype:"button",width:100,align:"center",cellsrenderer:function(){return"Wijzig"},buttonclick:function(m){g=m;d=$("#grid").jqxGrid("getrowdata",g);$("#m_step_name").val(d.step_name);$("#m_step_type").val(d.step_type);$("#m_step_temp").val(d.step_temp);$("#m_end_temp").val(d.end_temp);$("#m_step_time").val(d.step_time);$("#m_ramp_time").val(d.ramp_time);$("#popupStep").jqxWindow("open")}}]})};$("#name").jqxInput({theme:theme,width:480,height:23});$("#notes").jqxInput({theme:theme,width:800,height:100});var e=-1;$("#jqxgrid").jqxGrid({width:1280,height:630,source:h,theme:theme,showstatusbar:true,renderstatusbar:function(k){var i=$("
");var j=$("
Add
");i.append(j);k.append(i);j.jqxButton({theme:theme,width:90,height:20});j.click(function(l){e=-1;$("#name").val("Nieuw maisch schema");$("#notes").val("");a("");$("#popupWindow").jqxWindow("open")})},filterable:true,filtermode:"excel",columns:[{text:"Maish schema",datafield:"name",width:250},{text:"Opmerkingen",datafield:"notes"},{text:"",datafield:"Edit",width:100,align:"center",columntype:"button",cellsrenderer:function(){return"Wijzig"},buttonclick:function(j){e=j;var i=$("#jqxgrid").jqxGrid("getrowdata",e);$("#name").val(i.name);$("#notes").val(i.notes);a(i);$("#popupWindow").jqxWindow("open")}}]});$("#popupWindow").jqxWindow({width:1050,height:580,position:{x:110,y:30},resizable:false,theme:theme,isModal:true,autoOpen:false,cancelButton:$("#Cancel"),modalOpacity:0.4});$("#popupWindow").on("open",function(){$("#name").jqxInput("selectAll")});$("#popupStep").jqxWindow({width:800,height:300,position:{x:230,y:100},resizable:false,theme:theme,isModal:true,autoOpen:false,cancelButton:$("#Ready"),modalOpacity:0.4});$("#Ready").jqxButton({template:"success",width:"90px",theme:theme});$("#Ready").click(function(){$("#grid").jqxGrid("setcellvalue",g,"step_name",$("#m_step_name").val());$("#grid").jqxGrid("setcellvalue",g,"step_type",$("#m_step_type").val());$("#grid").jqxGrid("setcellvalue",g,"step_temp",$("#m_step_temp").val());$("#grid").jqxGrid("setcellvalue",g,"end_temp",$("#m_end_temp").val());$("#grid").jqxGrid("setcellvalue",g,"step_time",$("#m_step_time").val());$("#grid").jqxGrid("setcellvalue",g,"ramp_time",$("#m_ramp_time").val());$("#grid").jqxGrid("sortby","step_temp","asc")});$("#Delete").jqxButton({template:"danger",width:"90px",theme:theme});$("#Delete").click(function(){if(e>=0){$("#eventWindow").jqxWindow("open");$("#delOk").click(function(){var i=$("#jqxgrid").jqxGrid("getrowid",e);$("#jqxgrid").jqxGrid("deleterow",i)})}$("#popupWindow").jqxWindow("hide")});$("#Cancel").jqxButton({template:"primary",width:"90px",theme:theme});$("#Save").jqxButton({template:"success",width:"90px",theme:theme});$("#Save").click(function(){var i=$("#grid").jqxGrid("getrows");var j=-1;if(e>=0){j=$("#jqxgrid").jqxGrid("getrowid",e)}var k={record:j,name:$("#name").val(),notes:$("#notes").val(),steps:i};if(e>=0){$("#jqxgrid").jqxGrid("updaterow",j,k)}else{$("#jqxgrid").jqxGrid("addrow",null,k)}$("#popupWindow").jqxWindow("hide");location.reload(true)});createDelElements()}); \ No newline at end of file +function createDelElements(){$("#eventWindow").jqxWindow({theme:theme,position:{x:490,y:210},width:300,height:175,resizable:false,isModal:true,modalOpacity:0.4,okButton:$("#delOk"),cancelButton:$("#delCancel"),initContent:function(){$("#delOk").jqxButton({template:"danger",width:"65px",theme:theme});$("#delCancel").jqxButton({template:"success",width:"65px",theme:theme});$("#delCancel").focus()}});$("#eventWindow").jqxWindow("hide")}$(document).ready(function(){var g=0;var d={};var c={};var b="includes/db_profile_mash.php";$("#name").jqxTooltip({content:"De naam voor dit maisch profiel."});$("#notes").jqxTooltip({content:"De uitgebreide opmerkingen over dit maisch profiel."});var f={datatype:"json",cache:false,datafields:[{name:"record",type:"number"},{name:"name",type:"string"},{name:"notes",type:"string"},{name:"steps",type:"array"}],id:"record",url:b,deleterow:function(i,k){var j="delete=true&"+$.param({record:i});$.ajax({dataType:"json",url:b,cache:false,data:j,type:"POST",success:function(m,l,n){k(true);console.log("mash deleterow "+i+" success")},error:function(l,n,m){k(false);console.log("mash deleterow "+n)}})},addrow:function(j,m,i,l){var k="insert=true&"+$.param(m);$.ajax({dataType:"json",url:b,cache:false,data:k,type:"POST",success:function(o,n,p){l(true);console.log("mash addrow "+j+" success")},error:function(n,p,o){l(false);console.log("mash addrow "+p)}})},updaterow:function(i,l,k){var j="update=true&"+$.param(l);$.ajax({dataType:"json",url:b,cache:false,data:j,type:"POST",success:function(n,m,o){k(true);console.log("mash updaterow "+i+" success")},error:function(m,o,n){k(false);console.log("mash updaterow "+o)}})}};$("#m_step_name").jqxInput({theme:theme,width:320,height:23});$("#m_step_type").jqxDropDownList({theme:theme,source:MashStepTypeAdapter,valueMember:"id",displayMember:"nl",width:180,height:23,autoDropDownHeight:true});$("#m_step_temp").jqxNumberInput(Spin1dec);$("#m_step_temp").jqxNumberInput({Min:30,Max:80});$("#m_end_temp").jqxNumberInput(Spin1dec);$("#m_end_temp").jqxNumberInput({Min:30,Max:80});$("#m_step_time").jqxNumberInput(PosInt);$("#m_step_time").jqxNumberInput({Min:1,Max:120});$("#m_ramp_time").jqxNumberInput(PosInt);$("#m_ramp_time").jqxNumberInput({Min:1,Max:30});var h=new $.jqx.dataAdapter(f),e=-1;var a=function(l){var k=function(){var m={};m.step_name="Stap 1";m.step_type=0;m.step_temp=62;m.step_time=20;m.ramp_time=1;m.end_temp=62;return m};var j={localdata:l.steps,datatype:"local",datafields:[{name:"step_name",type:"string"},{name:"step_type",type:"int"},{name:"step_temp",type:"float"},{name:"step_time",type:"float"},{name:"ramp_time",type:"float"},{name:"end_temp",type:"float"}],addrow:function(n,p,m,o){o(true)},deleterow:function(m,n){n(true)}};var i=new $.jqx.dataAdapter(j);$("#grid").jqxGrid({width:1020,height:330,source:i,theme:theme,selectionmode:"singlerow",showtoolbar:true,rendertoolbar:function(n){var m=$("
");n.append(m);m.append('');m.append('');$("#addrowbutton").jqxButton({template:"primary",theme:theme,width:150});$("#deleterowbutton").jqxButton({template:"danger",theme:theme,width:150});$("#addrowbutton").on("click",function(){var o=k();$("#grid").jqxGrid("addrow",null,o)});$("#deleterowbutton").on("click",function(){var o=$("#grid").jqxGrid("getselectedrowindex");var q=$("#grid").jqxGrid("getdatainformation").rowscount;if(o>=0&&o"+MashStepTypeData[q].nl+""}},{text:"Begin °C",datafield:"step_temp",width:100,align:"right",cellsalign:"right",cellsformat:"f1"},{text:"Eind °C",datafield:"end_temp",width:100,align:"right",cellsalign:"right",cellsformat:"f1"},{text:"Rust min.",datafield:"step_time",width:90,align:"right",cellsalign:"right"},{text:"Stap min.",datafield:"ramp_time",width:90,align:"right",cellsalign:"right"},{text:"",datafield:"Edit",columntype:"button",width:100,align:"center",cellsrenderer:function(){return"Wijzig"},buttonclick:function(m){g=m;d=$("#grid").jqxGrid("getrowdata",g);$("#m_step_name").val(d.step_name);$("#m_step_type").val(d.step_type);$("#m_step_temp").val(d.step_temp);$("#m_end_temp").val(d.end_temp);$("#m_step_time").val(d.step_time);$("#m_ramp_time").val(d.ramp_time);$("#popupStep").jqxWindow("open")}}]})};$("#name").jqxInput({theme:theme,width:480,height:23});$("#notes").jqxInput({theme:theme,width:800,height:100});$("#jqxgrid").jqxGrid({width:1280,height:630,source:h,theme:theme,showstatusbar:true,renderstatusbar:function(k){var i=$("
");var j=$("
Add
");i.append(j);k.append(i);j.jqxButton({theme:theme,width:90,height:20});j.click(function(l){e=-1;$("#name").val("Nieuw maisch schema");$("#notes").val("");a("");$("#popupWindow").jqxWindow("open")})},filterable:true,filtermode:"excel",columns:[{text:"Maish schema",datafield:"name",width:250},{text:"Opmerkingen",datafield:"notes"},{text:"",datafield:"Edit",width:100,align:"center",columntype:"button",cellsrenderer:function(){return"Wijzig"},buttonclick:function(i){e=i;c=$("#jqxgrid").jqxGrid("getrowdata",e);$("#name").val(c.name);$("#notes").val(c.notes);a(c);$("#popupWindow").jqxWindow("open")}}]});$("#popupWindow").jqxWindow({width:1050,height:580,position:{x:110,y:30},resizable:false,theme:theme,isModal:true,autoOpen:false,cancelButton:$("#Cancel"),modalOpacity:0.4});$("#popupWindow").on("open",function(){$("#name").jqxInput("selectAll")});$("#popupStep").jqxWindow({width:800,height:300,position:{x:230,y:100},resizable:false,theme:theme,isModal:true,autoOpen:false,cancelButton:$("#Ready"),modalOpacity:0.4});$("#Ready").jqxButton({template:"success",width:"90px",theme:theme});$("#Ready").click(function(){$("#grid").jqxGrid("setcellvalue",g,"step_name",$("#m_step_name").val());$("#grid").jqxGrid("setcellvalue",g,"step_type",$("#m_step_type").val());$("#grid").jqxGrid("setcellvalue",g,"step_temp",$("#m_step_temp").val());$("#grid").jqxGrid("setcellvalue",g,"end_temp",$("#m_end_temp").val());$("#grid").jqxGrid("setcellvalue",g,"step_time",$("#m_step_time").val());$("#grid").jqxGrid("setcellvalue",g,"ramp_time",$("#m_ramp_time").val());$("#grid").jqxGrid("sortby","step_temp","asc")});$("#Delete").jqxButton({template:"danger",width:"90px",theme:theme});$("#Delete").click(function(){if(e>=0){$("#eventWindow").jqxWindow("open");$("#delOk").click(function(){var i=$("#jqxgrid").jqxGrid("getrowid",e);$("#jqxgrid").jqxGrid("deleterow",i)})}$("#popupWindow").jqxWindow("hide")});$("#Cancel").jqxButton({template:"primary",width:"90px",theme:theme});$("#Save").jqxButton({template:"success",width:"90px",theme:theme});$("#Save").click(function(){var i=$("#grid").jqxGrid("getrows");var j=-1;if(e>=0){j=$("#jqxgrid").jqxGrid("getrowid",e)}var k={record:j,name:$("#name").val(),notes:$("#notes").val(),steps:i};if(e>=0){$("#jqxgrid").jqxGrid("updaterow",j,k)}else{$("#jqxgrid").jqxGrid("addrow",null,k)}$("#popupWindow").jqxWindow("hide")});createDelElements()}); \ No newline at end of file diff -r fc21dcfbe51d -r ce814c787b79 www/js/profile_mash.js --- a/www/js/profile_mash.js Thu Sep 12 20:33:33 2019 +0200 +++ b/www/js/profile_mash.js Thu Sep 12 23:03:12 2019 +0200 @@ -47,14 +47,14 @@ var steprow = 0; var stepData = {}; var dataRecord = {}; - var url = "includes/db_profile_mash.php"; + var url = 'includes/db_profile_mash.php'; // tooltips $("#name").jqxTooltip({ content: 'De naam voor dit maisch profiel.' }); $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit maisch profiel.' }); // prepare the data var source = { - datatype: "json", + datatype: 'json', cache: false, datafields: [ { name: 'record', type: 'number' }, @@ -72,13 +72,14 @@ url: url, cache: false, data: data, - type: "POST", + type: 'POST', success: function (data, status, xhr) { - // delete command is executed. commit(true); + console.log('mash deleterow ' + rowid + ' success'); }, error: function (jqXHR, textStatus, errorThrown) { commit(false); + console.log('mash deleterow ' + textStatus); } }); }, @@ -92,9 +93,11 @@ type: "POST", success: function (data, status, xhr) { commit(true); + console.log('mash addrow ' + rowid + ' success'); }, error: function(jqXHR, textStatus, errorThrown) { commit(false); + console.log('mash addrow ' + textStatus); } }); }, @@ -107,11 +110,12 @@ data: data, type: "POST", success: function (data, status, xhr) { - // update command is executed. commit(true); + console.log('mash updaterow ' + rowid + ' success'); }, error: function(jqXHR, textStatus, errorThrown) { commit(false); + console.log('mash updaterow ' + textStatus); } }); } @@ -136,7 +140,9 @@ $("#m_ramp_time").jqxNumberInput( PosInt ); $("#m_ramp_time").jqxNumberInput({ Min: 1, Max: 30 }); - var dataAdapter = new $.jqx.dataAdapter(source); + var dataAdapter = new $.jqx.dataAdapter(source), + editrow = -1; + // Inline steps editor var editsteps = function (data) { var generaterow = function () { @@ -176,7 +182,6 @@ selectionmode: 'singlerow', showtoolbar: true, rendertoolbar: function (toolbar) { - var me = this; var container = $("
"); toolbar.append(container); container.append(''); @@ -186,7 +191,7 @@ // create new row. $("#addrowbutton").on('click', function () { var datarow = generaterow(); - var commit = $("#grid").jqxGrid('addrow', null, datarow); + $("#grid").jqxGrid('addrow', null, datarow); }); // delete row. $("#deleterowbutton").on('click', function () { @@ -194,7 +199,7 @@ var rowscount = $("#grid").jqxGrid('getdatainformation').rowscount; if (selectedrowindex >= 0 && selectedrowindex < rowscount) { var id = $("#grid").jqxGrid('getrowid', selectedrowindex); - var commit = $("#grid").jqxGrid('deleterow', id); + $("#grid").jqxGrid('deleterow', id); } }); }, @@ -231,7 +236,6 @@ // initialize the input fields. $("#name").jqxInput({ theme: theme, width: 480, height: 23 }); $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); - var editrow = -1; // initialize jqxGrid $("#jqxgrid").jqxGrid({ width: 1280, @@ -264,7 +268,7 @@ }, buttonclick: function (row) { editrow = row; // 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); $("#notes").val(dataRecord.notes); editsteps(dataRecord); @@ -328,7 +332,6 @@ }); $("#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 steprows = $('#grid').jqxGrid('getrows'); var rowID = -1; @@ -347,7 +350,6 @@ $('#jqxgrid').jqxGrid('addrow', null, row); } $("#popupWindow").jqxWindow('hide'); - location.reload( true ); // reload ourself. }); createDelElements(); });