Browse Source

Add capacity checks on no profile and submit

Neal Wilson 9 years ago
parent
commit
fc658422f4
1 changed files with 24 additions and 2 deletions
  1. 24
    2
      config/Windows/newbatch.xml

+ 24
- 2
config/Windows/newbatch.xml View File

472
             }
472
             }
473
             var noprofilebutton = findChildObject(this, 'noprofile');
473
             var noprofilebutton = findChildObject(this, 'noprofile');
474
             noprofilebutton.clicked.connect(function() {
474
             noprofilebutton.clicked.connect(function() {
475
+                var proceed = false;
476
+                if(validateCapacity()) {
477
+                    proceed = true;
478
+                } else {
479
+                    proceed = displayWarning("Suspicious Input", "Entered green coffee weight exceeds maximum batch size. Continue?");
480
+                }
481
+                if(proceed) {
482
+                    doNoProfile();
483
+                }
484
+            });
485
+            var doNoProfile = function() {
475
                 batch.windowModified = true;
486
                 batch.windowModified = true;
476
                 currentBatchInfo = batch;
487
                 currentBatchInfo = batch;
477
                 navigationwindow.loggingWindow.raise();
488
                 navigationwindow.loggingWindow.raise();
478
                 navigationwindow.loggingWindow.activateWindow();
489
                 navigationwindow.loggingWindow.activateWindow();
479
-            });
490
+            }
480
             var submitbutton = findChildObject(this, 'submit');
491
             var submitbutton = findChildObject(this, 'submit');
481
             var timefield = findChildObject(this, 'time');
492
             var timefield = findChildObject(this, 'time');
482
             var notes = findChildObject(this, 'annotation');
493
             var notes = findChildObject(this, 'annotation');
485
             approval.checked = true;
496
             approval.checked = true;
486
             var target = findChildObject(this, 'target');
497
             var target = findChildObject(this, 'target');
487
             submitbutton.clicked.connect(function() {
498
             submitbutton.clicked.connect(function() {
499
+                var proceed = false;
500
+                if(validateCapacity()) {
501
+                    proceed = true;
502
+                } else {
503
+                    proceed = displayWarning("Suspicious Input", "Entered green coffee weight exceeds maximum batch size. Continue?");
504
+                }
505
+                if(proceed) {
506
+                    doSubmit();
507
+                }
508
+            });
509
+            var doSubmit = function() {
488
                 checkQuery = new QSqlQuery();
510
                 checkQuery = new QSqlQuery();
489
                 checkQuery.exec("SELECT 1 FROM machine WHERE id = " + selectedRoasterID);
511
                 checkQuery.exec("SELECT 1 FROM machine WHERE id = " + selectedRoasterID);
490
                 if(!checkQuery.next())
512
                 if(!checkQuery.next())
544
                 query = query.invalidate();
566
                 query = query.invalidate();
545
                 batch.windowModified = false;
567
                 batch.windowModified = false;
546
                 batch.close();
568
                 batch.close();
547
-            });
569
+            }
548
         ]]>
570
         ]]>
549
     </program>
571
     </program>
550
 </window>
572
 </window>

Loading…
Cancel
Save