Browse Source

Fix specification recall

Neal Wilson 9 years ago
parent
commit
463d6b36d2
1 changed files with 13 additions and 1 deletions
  1. 13
    1
      config/Windows/roastspec.xml

+ 13
- 1
config/Windows/roastspec.xml View File

30
             var tolerance = findChildObject(this, 'tolerance');
30
             var tolerance = findChildObject(this, 'tolerance');
31
             var notes = findChildObject(this, 'notes');
31
             var notes = findChildObject(this, 'notes');
32
             var savebutton = findChildObject(this, 'save');
32
             var savebutton = findChildObject(this, 'save');
33
-            selector['currentIndexChanged(int)'].connect(function() {
33
+            var updateDisplay = function() {
34
                 var query = new QSqlQuery();
34
                 var query = new QSqlQuery();
35
                 query.prepare("SELECT loss, tolerance, notes FROM roasting_specification WHERE item = :id1 AND time = (SELECT max(time) FROM roasting_specification WHERE item = :id2)");
35
                 query.prepare("SELECT loss, tolerance, notes FROM roasting_specification WHERE item = :id1 AND time = (SELECT max(time) FROM roasting_specification WHERE item = :id2)");
36
                 query.bind(":id1", selector.currentData());
36
                 query.bind(":id1", selector.currentData());
39
                 if(query.next()) {
39
                 if(query.next()) {
40
                     if(query.value(0).length > 0) {
40
                     if(query.value(0).length > 0) {
41
                         expected.text = Number(query.value(0)) * 100;
41
                         expected.text = Number(query.value(0)) * 100;
42
+                    } else {
43
+                        expected.text = "";
42
                     }
44
                     }
43
                     if(query.value(1).length > 0) {
45
                     if(query.value(1).length > 0) {
44
                         tolerance.text = Number(query.value(1)) * 100;
46
                         tolerance.text = Number(query.value(1)) * 100;
47
+                    } else {
48
+                        tolerance.text = "";
45
                     }
49
                     }
46
                     notes.plainText = query.value(2);
50
                     notes.plainText = query.value(2);
51
+                } else {
52
+                    expected.text = "";
53
+                    tolerance.text = "";
54
+                    notes.plainText = "";
47
                 }
55
                 }
48
                 query = query.invalidate();
56
                 query = query.invalidate();
57
+            };
58
+            updateDisplay();
59
+            selector['currentIndexChanged(int)'].connect(function() {
60
+                updateDisplay();
49
             });
61
             });
50
             savebutton.clicked.connect(function() {
62
             savebutton.clicked.connect(function() {
51
                 var query = new QSqlQuery();
63
                 var query = new QSqlQuery();

Loading…
Cancel
Save