Browse Source

Add search

Neal Wilson 7 years ago
parent
commit
e1ecc2a371
1 changed files with 29 additions and 2 deletions
  1. 29
    2
      config/Windows/batchdetailsnew.xml

+ 29
- 2
config/Windows/batchdetailsnew.xml View File

@@ -3,6 +3,9 @@
3 3
         <layout type="horizontal">
4 4
             <button type="push" id="target" name="Load profile as target" />
5 5
             <button type="push" id="compare" name="Compare profile" />
6
+            <stretch />
7
+            <label>Search:</label>
8
+            <line id="search" />
6 9
         </layout>
7 10
         <tabbar id="tabs" />
8 11
         <layout type="stack" id="pages">
@@ -354,9 +357,10 @@
354 357
                         wholecolor.value = "";
355 358
                         groundcolor.value = "";
356 359
                     }
360
+                } else {
361
+                    wholecolor.value = "";
362
+                    groundcolor.value = "";
357 363
                 }
358
-                
359
-                
360 364
                 output.writeStartElement("p");
361 365
                 output.writeTextElement("strong", TTR("batchDetails", "Approved: "));
362 366
                 output.writeCharacters(query.value(6));
@@ -495,6 +499,7 @@
495 499
                 query.bind(":time", batchTime);
496 500
                 query.bind(":machine", Number(machine));
497 501
                 query.exec();
502
+                query = query.invalidate();
498 503
                 window.loadBatch(machine, batchTime);
499 504
                 displayInfo(TTR("batchDetails", "Batch Data Saved"),
500 505
                             TTR("roastspec", "New batch details saved"));
@@ -557,6 +562,28 @@
557 562
                 batchTag.setContent(buffer);
558 563
                 buffer.close();
559 564
             };
565
+            var search = findChildObject(this, 'search');
566
+            search.returnPressed.connect(function() {
567
+                if(search.text.length == 0) {
568
+                    return;
569
+                }
570
+                if(Number(search.text)) {
571
+                    var query = new QSqlQuery();
572
+                    query.prepare("SELECT machine, time FROM roasting_log WHERE files[1] = :file");
573
+                    query.bind(":file", Number(search.text));
574
+                    query.exec();
575
+                    if(query.next()) {
576
+                        window.loadBatch(query.value(0), query.value(1));
577
+                    }
578
+                    query = query.invalidate();
579
+                } else {
580
+                    var tag = JSON.parse(search.text);
581
+                    if(tag.m != undefined && tag.t != undefined) {
582
+                        window.loadBatch(tag.m, tag.t);
583
+                    }
584
+                }
585
+                search.text = "";
586
+            });
560 587
         ]]>
561 588
     </program>
562 589
 </window>

Loading…
Cancel
Save