www/js/profile_mash.js

Wed, 05 Dec 2018 14:16:39 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 05 Dec 2018 14:16:39 +0100
changeset 120
b28a3d6143bc
parent 45
95251bedfab4
child 213
b0d484a5525e
permissions
-rw-r--r--

Screen layout changes.

23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * Copyright (C) 2014-2018
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of BrewCloud
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * BrewCloud is distributed in the hope that it will be useful, but
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 function createDelElements() {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 $('#eventWindow').jqxWindow({
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 theme: theme,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 position: { x: 490, y: 210 },
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 width: 300,
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
29 height: 175,
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 resizable: false,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 isModal: true,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 modalOpacity: 0.4,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 okButton: $('#delOk'),
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 cancelButton: $('#delCancel'),
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 initContent: function () {
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
36 $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme });
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
37 $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme });
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 $('#delCancel').focus();
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 }
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 $('#eventWindow').jqxWindow('hide');
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 }
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 $(document).ready(function () {
45
95251bedfab4 Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents: 40
diff changeset
46 var url = "includes/db_profile_mash.php";
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
47 // tooltips
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
48 $("#name").jqxTooltip({ content: 'De naam voor dit maisch profiel.' });
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
49 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit maich profiel.' });
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
50 $("#grid").jqxTooltip({ content: 'De maisch stappen in dit profiel.'});
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 // prepare the data
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 var source = {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 datatype: "json",
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 cache: false,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 datafields: [
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 { name: 'record', type: 'number' },
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 { name: 'name', type: 'string' },
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 { name: 'notes', type: 'string' },
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
59 { name: 'steps', type: 'array' }
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 ],
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 id: 'record',
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 url: url,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 deleterow: function (rowid, commit) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 // synchronize with the server - send delete command
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 var data = "delete=true&" + $.param({ record: rowid });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 $.ajax({
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 dataType: 'json',
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 url: url,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 cache: false,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 data: data,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 success: function (data, status, xhr) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 // delete command is executed.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 commit(true);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 },
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 error: function (jqXHR, textStatus, errorThrown) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 commit(false);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 }
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 },
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 addrow: function (rowid, rowdata, position, commit) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 var data = "insert=true&" + $.param(rowdata);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 $.ajax({
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 dataType: 'json',
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 url: url,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 cache: false,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 data: data,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 success: function (data, status, xhr) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 commit(true);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 },
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 error: function(jqXHR, textStatus, errorThrown) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 commit(false);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 }
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 },
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 updaterow: function (rowid, rowdata, commit) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 var data = "update=true&" + $.param(rowdata);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 $.ajax({
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 dataType: 'json',
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 url: url,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 cache: false,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 data: data,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 success: function (data, status, xhr) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 // update command is executed.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 commit(true);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 },
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 error: function(jqXHR, textStatus, errorThrown) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 commit(false);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 }
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 }
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 };
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
112 var dataAdapter = new $.jqx.dataAdapter(source);
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
113 // Inline steps editor
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
114 var editsteps = function (data) {
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
115 var generaterow = function () {
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
116 var row = {};
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
117 row["step_name"] = "Stap 1";
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
118 row["step_type"] = "Infusion";
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
119 row["step_temp"] = 62.0;
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
120 row['step_time'] = 20.0;
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
121 row['ramp_time'] = 1.0;
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
122 row['end_temp'] = 62.0;
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
123 return row;
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
124 }
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
125 var stepSource = {
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
126 localdata: data.steps,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
127 datatype: "local",
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
128 datafields: [
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
129 { name: 'step_name', type: 'string' },
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
130 { name: 'step_type', type: 'string' },
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
131 { name: 'step_temp', type: 'float' },
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
132 { name: 'step_time', type: 'float' },
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
133 { name: 'ramp_time', type: 'float' },
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
134 { name: 'end_temp', type: 'float' }
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
135 ],
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
136 addrow: function (rowid, rowdata, position, commit) {
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
137 commit(true);
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
138 },
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
139 deleterow: function (rowid, commit) {
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
140 commit(true);
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
141 }
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
142 };
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
143 var stepAdapter = new $.jqx.dataAdapter(stepSource);
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
144 $("#grid").jqxGrid({
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
145 width: 800,
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
146 height: 330,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
147 source: stepAdapter,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
148 theme: theme,
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
149 selectionmode: 'singlerow',
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
150 editmode: 'selectedrow',
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
151 editable: true,
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
152 showtoolbar: true,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
153 rendertoolbar: function (toolbar) {
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
154 var me = this;
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
155 var container = $("<div style='margin: 5px;'></div>");
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
156 toolbar.append(container);
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
157 container.append('<input style="margin-left: 100px;" id="addrowbutton" type="button" value="Nieuwe stap" />');
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
158 container.append('<input style="margin-left: 290px;" id="deleterowbutton" type="button" value="Verwijder stap" />');
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
159 $("#addrowbutton").jqxButton({ theme: theme, width: 150 });
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
160 $("#deleterowbutton").jqxButton({ theme: theme, width: 150 });
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
161 // create new row.
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
162 $("#addrowbutton").on('click', function () {
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
163 var datarow = generaterow();
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
164 var commit = $("#grid").jqxGrid('addrow', null, datarow);
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
165 });
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
166 // delete row.
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
167 $("#deleterowbutton").on('click', function () {
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
168 var selectedrowindex = $("#grid").jqxGrid('getselectedrowindex');
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
169 var rowscount = $("#grid").jqxGrid('getdatainformation').rowscount;
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
170 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
171 var id = $("#grid").jqxGrid('getrowid', selectedrowindex);
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
172 var commit = $("#grid").jqxGrid('deleterow', id);
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
173 }
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
174 });
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
175 },
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
176 columns: [
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
177 { text: 'Stap naam', datafield: 'step_name' },
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
178 { text: 'Stap type', datafield: 'step_type', width: 120, columntype: 'dropdownlist',
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
179 createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
180 var dataSource = [ "Infusion", "Temperature", "Decoction" ];
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
181 editor.jqxDropDownList({
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
182 source: dataSource,
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
183 dropDownHeight: 95,
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
184 dropDownWidth: 120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
185 });
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
186 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
187 },
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
188 { text: 'Temperatuur', datafield: 'step_temp', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1',
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
189 validation: function (cell, value) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
190 if (value < 35 || value > 80) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
191 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." };
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
192 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
193 return true;
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
194 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
195 },
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
196 { text: 'Eind temp', datafield: 'end_temp', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1',
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
197 validation: function (cell, value) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
198 if (value < 35 || value > 80) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
199 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." };
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
200 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
201 return true;
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
202 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
203 },
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
204 { text: 'Rusttijd', datafield: 'step_time', width: 80, align: 'right', cellsalign: 'right',
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
205 validation: function (cell, value) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
206 if (value < 1 || value > 360) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
207 return { result: false, message: "De tijd moet tussen 1 en 360 zijn." };
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
208 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
209 return true;
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
210 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
211 },
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
212 { text: 'Staptijd', datafield: 'ramp_time', width: 80, align: 'right', cellsalign: 'right',
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
213 validation: function (cell, value) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
214 if (value < 1 || value > 60) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
215 return { result: false, message: "De tijd moet tussen 1 en 60 zijn." };
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
216 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
217 return true;
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
218 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
219 }
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
220 ]
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
221 });
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
222 $("#grid").on('cellendedit', function (event) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
223 $('#grid').jqxGrid('sortby', 'step_temp', 'asc');
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
224 });
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
225 };
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
226
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 // initialize the input fields.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 $("#name").jqxInput({ theme: theme, width: 250, height: 23 });
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
229 $("#notes").jqxInput({ theme: theme, width: 800, height: 100 });
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 var editrow = -1;
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 // initialize jqxGrid
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 $("#jqxgrid").jqxGrid({
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 width: 1280,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234 height: 630,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 source: dataAdapter,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 theme: theme,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 showstatusbar: true,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 localization: getLocalization(),
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 renderstatusbar: function (statusbar) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 var addButton = $("<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>");
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 container.append(addButton);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 statusbar.append(container);
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
244 addButton.jqxButton({ theme: theme, width: 120, height: 20 });
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 // add new row.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 addButton.click(function (event) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 editrow = -1;
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
248 $("#popupWindow").jqxWindow({ position: { x: 160, y: 30 } });
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 $("#name").val('');
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 $("#notes").val('');
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
251 editsteps('');
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 $("#popupWindow").jqxWindow('open');
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 },
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 filterable: true,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256 filtermode: 'excel',
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 columns: [
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 { text: 'Maish schema', datafield: 'name', width: 250 },
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
259 { text: 'Opmerkingen', datafield: 'notes' },
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
260 { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () {
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
261 return "Wijzig";
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262 }, buttonclick: function (row) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 // open the popup window when the user clicks a button.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 editrow = row;
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
265 $("#popupWindow").jqxWindow({ position: { x: 160, y: 30 } });
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266 // get the clicked row's data and initialize the input fields.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 $("#name").val(dataRecord.name);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 $("#notes").val(dataRecord.notes);
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
270 editsteps(dataRecord);
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 // show the popup window.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 $("#popupWindow").jqxWindow('open');
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273 }
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 }
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 ]
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276 });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 // initialize the popup window and buttons.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 $("#popupWindow").jqxWindow({
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
279 width: 960,
39
400aae9fb0c8 Some small fixes
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
280 height: 550,
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
281 resizable: false,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
282 theme: theme,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
283 isModal: true,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
284 autoOpen: false,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
285 cancelButton: $("#Cancel"),
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
286 modalOpacity: 0.40
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287 });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 $("#popupWindow").on('open', function () {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 $("#name").jqxInput('selectAll');
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 });
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
291 $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme });
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 $("#Delete").click(function () {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 if (editrow >= 0) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 // Open a popup to confirm this action.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 $('#eventWindow').jqxWindow('open');
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 $("#delOk").click(function () {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 $("#jqxgrid").jqxGrid('deleterow', rowID);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 }
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 $("#popupWindow").jqxWindow('hide');
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 });
120
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
303 $("#Cancel").jqxButton({ template: "primary", width: '80px', theme: theme });
b28a3d6143bc Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
304 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 // update the edited row when the user clicks the 'Save' button.
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 $("#Save").click(function () {
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
307 var steprows = $('#grid').jqxGrid('getrows');
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 if (editrow >= 0) {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 var row = {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 record: rowID,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 name: $("#name").val(),
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
313 notes: $("#notes").val(),
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
314 steps: steprows
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 };
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 $("#popupWindow").jqxWindow('hide');
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 } else {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 // Insert a record
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 var newrow = {
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 record: -1,
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 name: $("#name").val(),
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
323 notes: $("#notes").val(),
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
324 steps: steprows
23
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 };
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326 $('#jqxgrid').jqxGrid('addrow', null, newrow);
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 $("#popupWindow").jqxWindow('hide');
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 }
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 createDelElements();
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 });
4b157d7a1cee Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332

mercurial