www/js/inv_mash_profiles.js

Tue, 28 Aug 2018 20:54:53 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 28 Aug 2018 20:54:53 +0200
changeset 40
b825c675987d
parent 39
400aae9fb0c8
permissions
-rw-r--r--

Finished mash steps editing. Style sheets cleanup.

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 () {
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
36 $('#delOk').jqxButton({ width: '65px', 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
37 $('#delCancel').jqxButton({ width: '65px', 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
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 () {
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
46 var url = "includes/db_inventory_mash_profiles.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({
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
145 width: 640,
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" />');
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
158 container.append('<input style="margin-left: 140px;" id="deleterowbutton" type="button" value="Verwijder stap" />');
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' },
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
178 { text: 'Stap type', datafield: 'step_type', width: 100, columntype: 'dropdownlist',
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" ];
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
181 editor.jqxDropDownList({ source: dataSource, dropDownHeight: 95 });
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
182 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
183 },
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
184 { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
185 validation: function (cell, value) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
186 if (value < 35 || value > 80) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
187 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
188 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
189 return true;
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
190 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
191 },
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
192 { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
193 validation: function (cell, value) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
194 if (value < 35 || value > 80) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
195 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
196 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
197 return true;
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
198 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
199 },
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
200 { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right',
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
201 validation: function (cell, value) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
202 if (value < 1 || value > 360) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
203 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
204 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
205 return true;
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
206 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
207 },
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
208 { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right',
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
209 validation: function (cell, value) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
210 if (value < 1 || value > 60) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
211 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
212 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
213 return true;
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
214 }
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
215 }
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
216 ]
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
217 });
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
218 $("#grid").on('cellendedit', function (event) {
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
219 $('#grid').jqxGrid('sortby', 'step_temp', 'asc');
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
220 });
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
221 };
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
222
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
223 // 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
224 $("#name").jqxInput({ theme: theme, width: 250, height: 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
225 $("#notes").jqxInput({ theme: theme, width: 640, height: 100 });
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
226 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
227 // 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
228 $("#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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 statusbar.append(container);
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
240 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
241 // 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
242 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
243 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
244 $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } });
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 $("#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
246 $("#notes").val('');
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
247 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
248 $("#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
249 });
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 },
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
251 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
252 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
253 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
254 { text: 'Maish schema', datafield: 'name', width: 250 },
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
255 { text: 'Opmerkingen', datafield: 'notes' },
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
256 { 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
257 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
258 }, 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
259 // 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
260 editrow = 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
261 $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } });
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 // 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
263 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
264 $("#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
265 $("#notes").val(dataRecord.notes);
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
266 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
267 // 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
268 $("#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
269 }
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
270 }
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 ]
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 });
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 // 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
274 $("#popupWindow").jqxWindow({
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
275 width: 860,
39
400aae9fb0c8 Some small fixes
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
276 height: 550,
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
277 resizable: false,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
278 theme: theme,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
279 isModal: true,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
280 autoOpen: false,
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
281 cancelButton: $("#Cancel"),
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
282 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
283 });
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
284 $("#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
285 $("#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
286 });
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 $("#Delete").jqxButton({ 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
288 $("#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
289 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
290 // 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
291 $('#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
292 $("#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
293 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
294 $("#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
295 });
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 }
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 $("#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
298 });
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 $("#Cancel").jqxButton({ 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
300 $("#Save").jqxButton({ 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
301 // 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
302 $("#Save").click(function () {
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
303 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
304 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
305 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
306 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
307 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
308 name: $("#name").val(),
38
b7d44c98d609 Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents: 25
diff changeset
309 notes: $("#notes").val(),
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
310 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
311 };
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 $('#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
313 $("#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
314 } 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
315 // 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
316 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
317 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
318 name: $("#name").val(),
40
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
319 notes: $("#notes").val(),
b825c675987d Finished mash steps editing. Style sheets cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 39
diff changeset
320 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
321 };
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 $('#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
323 $("#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
324 }
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 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
327 });
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

mercurial