Browse Source

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

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

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

@@ -0,0 +1,47 @@
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,6 +31,7 @@
31 31
 	<include src="Windows/optime.xml" />
32 32
 	<include src="Windows/greensales.xml" />
33 33
 	<include src="Windows/profilehistory.xml" />
34
+	<include src="Windows/editbatchdetails.xml" />
34 35
 	<program>
35 36
 		var loggingWindow;
36 37
 		var currentBatchInfo;
@@ -42,4 +43,3 @@
42 43
 		navwindow.windowTitle = "Typica - Choose Your Path";
43 44
 	</program>
44 45
 </application>
45
-		

Loading…
Cancel
Save