www/js/profile_mash-min.js

Fri, 13 Sep 2019 11:04:00 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 13 Sep 2019 11:04:00 +0200
changeset 483
ac69a63dc23e
parent 482
ce814c787b79
child 494
af28ebe4a779
permissions
-rw-r--r--

Added the reload function in the data save callback code.

483
ac69a63dc23e Added the reload function in the data save callback code.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
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);console.log("mash deleterow "+i+" success");location.reload(true)},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");location.reload(true)},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");location.reload(true)},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=$("<div style='margin: 5px;'></div>");n.append(m);m.append('<input style="margin-left: 100px;" id="addrowbutton" type="button" value="Nieuwe stap" />');m.append('<input style="margin-left: 450px;" id="deleterowbutton" type="button" value="Verwijder stap" />');$("#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<q){var p=$("#grid").jqxGrid("getrowid",o);$("#grid").jqxGrid("deleterow",p)}})},columns:[{text:"Stap naam",datafield:"step_name"},{text:"Stap type",datafield:"step_type",width:150,cellsrenderer:function(n,m,q,p,o,r){return"<div style='margin: 4px;'>"+MashStepTypeData[q].nl+"</div>"}},{text:"Begin &deg;C",datafield:"step_temp",width:100,align:"right",cellsalign:"right",cellsformat:"f1"},{text:"Eind &deg;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=$("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");var j=$("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Add</span></div>");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()});

mercurial