diff -r adda48f710cd -r b0d484a5525e www/js/profile_mash.js --- a/www/js/profile_mash.js Sat Jan 26 19:25:10 2019 +0100 +++ b/www/js/profile_mash.js Sat Jan 26 22:01:11 2019 +0100 @@ -46,8 +46,7 @@ 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 maich profiel.' }); - $("#grid").jqxTooltip({ content: 'De maisch stappen in dit profiel.'}); + $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit maisch profiel.' }); // prepare the data var source = { datatype: "json", @@ -68,6 +67,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { // delete command is executed. commit(true); @@ -84,6 +84,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { commit(true); }, @@ -99,6 +100,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { // update command is executed. commit(true); @@ -114,9 +116,9 @@ var editsteps = function (data) { var generaterow = function () { var row = {}; - row["step_name"] = "Stap 1"; - row["step_type"] = "Infusion"; - row["step_temp"] = 62.0; + row['step_name'] = "Stap 1"; + row['step_type'] = 0; + row['step_temp'] = 62.0; row['step_time'] = 20.0; row['ramp_time'] = 1.0; row['end_temp'] = 62.0; @@ -127,7 +129,7 @@ datatype: "local", datafields: [ { name: 'step_name', type: 'string' }, - { name: 'step_type', type: 'string' }, + { name: 'step_type', type: 'int' }, { name: 'step_temp', type: 'float' }, { name: 'step_time', type: 'float' }, { name: 'ramp_time', type: 'float' }, @@ -147,8 +149,9 @@ source: stepAdapter, theme: theme, selectionmode: 'singlerow', - editmode: 'selectedrow', + editmode: 'selectedcell', editable: true, + localization: getLocalization(), showtoolbar: true, rendertoolbar: function (toolbar) { var me = this; @@ -156,8 +159,8 @@ toolbar.append(container); container.append(''); container.append(''); - $("#addrowbutton").jqxButton({ theme: theme, width: 150 }); - $("#deleterowbutton").jqxButton({ theme: theme, width: 150 }); + $("#addrowbutton").jqxButton({ template: "primary", theme: theme, width: 150 }); + $("#deleterowbutton").jqxButton({ template: "primary", theme: theme, width: 150 }); // create new row. $("#addrowbutton").on('click', function () { var datarow = generaterow(); @@ -175,9 +178,9 @@ }, columns: [ { text: 'Stap naam', datafield: 'step_name' }, - { text: 'Stap type', datafield: 'step_type', width: 120, columntype: 'dropdownlist', + { text: 'Stap type', datafield: 'step_type', width: 150, columntype: 'dropdownlist', createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { - var dataSource = [ "Infusion", "Temperature", "Decoction" ]; + var dataSource = [ "0", "1", "2" ]; editor.jqxDropDownList({ source: dataSource, dropDownHeight: 95, @@ -225,7 +228,7 @@ }; // initialize the input fields. - $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); + $("#name").jqxInput({ theme: theme, width: 480, height: 23 }); $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); var editrow = -1; // initialize jqxGrid @@ -241,12 +244,12 @@ var addButton = $("
Add
"); 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: 160, y: 30 } }); - $("#name").val(''); + $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); + $("#name").val('Nieuw maisch schema'); $("#notes").val(''); editsteps(''); $("#popupWindow").jqxWindow('open'); @@ -257,12 +260,12 @@ columns: [ { text: 'Maish schema', datafield: 'name', width: 250 }, { text: 'Opmerkingen', datafield: 'notes' }, - { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () { + { 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: 160, 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); @@ -276,8 +279,8 @@ }); // initialize the popup window and buttons. $("#popupWindow").jqxWindow({ - width: 960, - height: 550, + width: 1050, + height: 580, resizable: false, theme: theme, isModal: true, @@ -288,7 +291,7 @@ $("#popupWindow").on('open', function () { $("#name").jqxInput('selectAll'); }); - $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme }); + $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); $("#Delete").click(function () { if (editrow >= 0) { // Open a popup to confirm this action. @@ -300,32 +303,28 @@ } $("#popupWindow").jqxWindow('hide'); }); - $("#Cancel").jqxButton({ template: "primary", width: '80px', 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 steprows = $('#grid').jqxGrid('getrows'); + var rowID = -1; if (editrow >= 0) { - var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); - var row = { - record: rowID, - name: $("#name").val(), - notes: $("#notes").val(), - steps: steprows - }; + rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); + } + var row = { + record: rowID, + name: $("#name").val(), + notes: $("#notes").val(), + steps: steprows + }; + if (editrow >= 0) { $('#jqxgrid').jqxGrid('updaterow', rowID, row); - $("#popupWindow").jqxWindow('hide'); } else { - // Insert a record - var newrow = { - record: -1, - name: $("#name").val(), - notes: $("#notes").val(), - steps: steprows - }; - $('#jqxgrid').jqxGrid('addrow', null, newrow); - $("#popupWindow").jqxWindow('hide'); + $('#jqxgrid').jqxGrid('addrow', null, row); } + $("#popupWindow").jqxWindow('hide'); + location.reload( true ); // reload ourself. }); createDelElements(); });