Browse Source

Post batch editing of approval and annotation data. Fixes #59

Neal Wilson 12 years ago
parent
commit
01104056eb
3 changed files with 75 additions and 7 deletions
  1. 27
    6
      config/Windows/batchdetailsnew.xml
  2. 47
    0
      config/Windows/editbatchdetails.xml
  3. 1
    1
      config/config.xml

+ 27
- 6
config/Windows/batchdetailsnew.xml View File

4
             <button type="push" id="target" name="Load profile as target" />
4
             <button type="push" id="target" name="Load profile as target" />
5
 			<button type="push" id="viewprofile" name="View profile" />
5
 			<button type="push" id="viewprofile" name="View profile" />
6
 			<button type="push" id="compare" name="Compare profile" />
6
 			<button type="push" id="compare" name="Compare profile" />
7
+			<button type="push" id="edit" name="Edit" />
7
         </layout>
8
         </layout>
8
         <webview id="view" />
9
         <webview id="view" />
9
     </layout>
10
     </layout>
14
 			var fileID;
15
 			var fileID;
15
 			var target = findChildObject(this, 'target');
16
 			var target = findChildObject(this, 'target');
16
 			var compare = findChildObject(this, 'compare');
17
 			var compare = findChildObject(this, 'compare');
18
+			var edit = findChildObject(this, 'edit');
19
+			edit.enabled = false;
17
 			if(typeof(navigationwindow.loggingWindow) == "undefined") {
20
 			if(typeof(navigationwindow.loggingWindow) == "undefined") {
18
 				compare.enabled = false;
21
 				compare.enabled = false;
19
 				target.enabled = false;
22
 				target.enabled = false;
20
 			}
23
 			}
24
+			var tableReference;
25
+			var rowReference;
26
+			var batchTime;
27
+			var machine;
28
+			var approval;
29
+			var annotation;
30
+			edit.clicked.connect(function() {
31
+				var editWindow = createWindow("editBatchDetails");
32
+				editWindow.loadData(window, tableReference, rowReference, batchTime, machine, approval, annotation);
33
+			});
21
 			compare.clicked.connect(function() {
34
 			compare.clicked.connect(function() {
22
 				var query = new QSqlQuery;
35
 				var query = new QSqlQuery;
23
 				query.prepare("SELECT file, name FROM files WHERE id = :id");
36
 				query.prepare("SELECT file, name FROM files WHERE id = :id");
135
 				query = query.invalidate();
148
 				query = query.invalidate();
136
 			});
149
 			});
137
 			window.loadData = function(table, row) {
150
 			window.loadData = function(table, row) {
151
+				tableReference = table;
152
+				rowReference = row;
138
 				var buffer = new QBuffer;
153
 				var buffer = new QBuffer;
139
 				buffer.open(3);
154
 				buffer.open(3);
140
 				var output = new XmlWriter(buffer);
155
 				var output = new XmlWriter(buffer);
157
 				output.writeAttribute("style", "float: left");
172
 				output.writeAttribute("style", "float: left");
158
 				output.writeStartElement("p");
173
 				output.writeStartElement("p");
159
 				output.writeTextElement("strong", "Roasted On: ");
174
 				output.writeTextElement("strong", "Roasted On: ");
160
-				output.writeTextElement("span", table.data(row, 0));
175
+				batchTime = table.data(row, 0);
176
+				output.writeTextElement("span", batchTime);
161
 				output.writeEndElement();
177
 				output.writeEndElement();
162
 				output.writeStartElement("p");
178
 				output.writeStartElement("p");
163
 				output.writeTextElement("strong", "Batch Duration: ");
179
 				output.writeTextElement("strong", "Batch Duration: ");
177
 				output.writeStartElement("tbody");
193
 				output.writeStartElement("tbody");
178
 				var query = new QSqlQuery();
194
 				var query = new QSqlQuery();
179
 				query.prepare("SELECT unroasted_id, unroasted_quantity, approval, files, annotation FROM roasting_log WHERE time = :time AND machine = :machine");
195
 				query.prepare("SELECT unroasted_id, unroasted_quantity, approval, files, annotation FROM roasting_log WHERE time = :time AND machine = :machine");
180
-				query.bind(":time", table.data(row, 0));
181
-				query.bind(":machine", table.data(row, 1));
196
+				query.bind(":time", batchTime);
197
+				machine = table.data(row, 1);
198
+				query.bind(":machine", machine);
182
 				query.exec();
199
 				query.exec();
183
 				query.next();
200
 				query.next();
201
+				approval = query.value(2);
202
+				annotation = query.value(4);
184
 				var items = sqlToArray(query.value(0));
203
 				var items = sqlToArray(query.value(0));
185
 				var quantities = sqlToArray(query.value(1));
204
 				var quantities = sqlToArray(query.value(1));
186
 				var nameQuery = new QSqlQuery();
205
 				var nameQuery = new QSqlQuery();
235
 				output.writeEndElement();
254
 				output.writeEndElement();
236
 				output.writeStartElement("p");
255
 				output.writeStartElement("p");
237
 				output.writeTextElement("strong", "Approved: ");
256
 				output.writeTextElement("strong", "Approved: ");
238
-				output.writeCharacters(query.value(2));
257
+				output.writeCharacters(approval);
239
 				output.writeEndElement();
258
 				output.writeEndElement();
240
 				output.writeStartElement("p");
259
 				output.writeStartElement("p");
241
 				output.writeTextElement("strong", "Files: ");
260
 				output.writeTextElement("strong", "Files: ");
242
-				output.writeCharacters(query.value(3));				output.writeEndElement();
261
+				output.writeCharacters(query.value(3));
262
+				output.writeEndElement();
243
 				output.writeStartElement("p");
263
 				output.writeStartElement("p");
244
 				output.writeTextElement("strong", "Annotations:");
264
 				output.writeTextElement("strong", "Annotations:");
245
 				var files = sqlToArray(query.value(3));
265
 				var files = sqlToArray(query.value(3));
299
 				}
319
 				}
300
 				output.writeEndElement();
320
 				output.writeEndElement();
301
 				output.writeEndElement();
321
 				output.writeEndElement();
302
-				output.writeCharacters(query.value(4));
322
+				output.writeCharacters(annotation);
303
 				output.writeEndElement();
323
 				output.writeEndElement();
304
 				output.writeEndElement();
324
 				output.writeEndElement();
305
 				output.writeEndElement();
325
 				output.writeEndElement();
307
 				dataView.setContent(buffer);
327
 				dataView.setContent(buffer);
308
 				buffer.close();
328
 				buffer.close();
309
 				query = query.invalidate();
329
 				query = query.invalidate();
330
+				edit.enabled = true;
310
 			};
331
 			};
311
         ]]>
332
         ]]>
312
     </program>
333
     </program>

+ 47
- 0
config/Windows/editbatchdetails.xml View File

1
+<window id="editBatchDetails">
2
+    <layout type="vertical">
3
+		<button type="check" name="Approved" id="approval" />
4
+		<layout type="horizontal">
5
+			<label>Annotation</label>
6
+			<textarea id="annotation" />
7
+		</layout>
8
+		<button type="push" id="submit" name="Submit" />
9
+	</layout>
10
+    <program>
11
+        <![CDATA[
12
+			var window = this;
13
+			var approvalButton = findChildObject(this, 'approval');
14
+			var annotationField = findChildObject(this, 'annotation');
15
+			var parentWindow;
16
+			var tableReference;
17
+			var rowReference;
18
+			var timeKey;
19
+			var machineKey;
20
+			var submit = findChildObject(this, 'submit');
21
+			submit.enabled = false;
22
+			this.loadData = function(parent, table, row, time, machine, approval, annotation) {
23
+				parentWindow = parent;
24
+				tableReference = table;
25
+				rowReference = row;
26
+				if(approval == "true") {
27
+					approvalButton.checked = true;
28
+				}
29
+				annotationField.plainText = annotation;
30
+				timeKey = time;
31
+				machineKey = machine;
32
+				submit.enabled = true;
33
+			};
34
+			submit.clicked.connect(function() {
35
+				var query = new QSqlQuery;
36
+				query.prepare("UPDATE roasting_log SET approval = :approval, annotation = :annotation WHERE time = :time AND machine = :machine");
37
+				query.bind("approval", approvalButton.checked);
38
+				query.bind("annotation", annotationField.plainText);
39
+				query.bind("time", timeKey);
40
+				query.bind("machine", machineKey);
41
+				query.exec();
42
+				parentWindow.loadData(tableReference, rowReference);
43
+				window.close();
44
+			});
45
+        ]]>
46
+    </program>
47
+</window>

+ 1
- 1
config/config.xml View File

31
 	<include src="Windows/optime.xml" />
31
 	<include src="Windows/optime.xml" />
32
 	<include src="Windows/greensales.xml" />
32
 	<include src="Windows/greensales.xml" />
33
 	<include src="Windows/profilehistory.xml" />
33
 	<include src="Windows/profilehistory.xml" />
34
+	<include src="Windows/editbatchdetails.xml" />
34
 	<program>
35
 	<program>
35
 		var loggingWindow;
36
 		var loggingWindow;
36
 		var currentBatchInfo;
37
 		var currentBatchInfo;
42
 		navwindow.windowTitle = "Typica - Choose Your Path";
43
 		navwindow.windowTitle = "Typica - Choose Your Path";
43
 	</program>
44
 	</program>
44
 </application>
45
 </application>
45
-		

Loading…
Cancel
Save