Neal Wilson 9 years ago
parent
commit
83b27e8635
2 changed files with 29 additions and 1 deletions
  1. 19
    1
      config/Windows/newbatch.xml
  2. 10
    0
      src/typica.w

+ 19
- 1
config/Windows/newbatch.xml View File

495
             var approval = findChildObject(this, 'approval');
495
             var approval = findChildObject(this, 'approval');
496
             approval.checked = true;
496
             approval.checked = true;
497
             var target = findChildObject(this, 'target');
497
             var target = findChildObject(this, 'target');
498
+            var checkSubmitEnable = function () {
499
+                if(roasted.currentIndex > 0) {
500
+                    if(timefield.text.length > 0) {
501
+                        if(duration.text.length > 0) {
502
+                            if(batch.tempData.length > 0) {
503
+                                if(green.text.length > 0) {
504
+                                    return true;
505
+                                }
506
+                            }
507
+                        }
508
+                    }
509
+                }
510
+                return false;
511
+            }
498
             submitbutton.clicked.connect(function() {
512
             submitbutton.clicked.connect(function() {
499
                 var proceed = false;
513
                 var proceed = false;
500
                 if(validateCapacity()) {
514
                 if(validateCapacity()) {
503
                     proceed = displayWarning("Suspicious Input", "Entered green coffee weight exceeds maximum batch size. Continue?");
517
                     proceed = displayWarning("Suspicious Input", "Entered green coffee weight exceeds maximum batch size. Continue?");
504
                 }
518
                 }
505
                 if(proceed) {
519
                 if(proceed) {
506
-                    doSubmit();
520
+                    if(checkSubmitEnable()) {
521
+                        doSubmit();
522
+                    } else {
523
+                        displayError("Incomplete Input", "Some required information is not available. Please check inputs and try again.");
524
+                    }
507
                 }
525
                 }
508
             });
526
             });
509
             var doSubmit = function() {
527
             var doSubmit = function() {

+ 10
- 0
src/typica.w View File

937
 
937
 
938
 @<Function prototypes for scripting@>=
938
 @<Function prototypes for scripting@>=
939
 QScriptValue displayWarning(QScriptContext *context, QScriptEngine *engine);
939
 QScriptValue displayWarning(QScriptContext *context, QScriptEngine *engine);
940
+QScriptValue displayError(QScriptContext *context, QScriptEngine *engine);
940
 
941
 
941
 @ This function is exposed to the host environment.
942
 @ This function is exposed to the host environment.
942
 
943
 
943
 @<Set up the scripting engine@>=
944
 @<Set up the scripting engine@>=
944
 constructor = engine->newFunction(displayWarning);
945
 constructor = engine->newFunction(displayWarning);
945
 engine->globalObject().setProperty("displayWarning", constructor);
946
 engine->globalObject().setProperty("displayWarning", constructor);
947
+constructor = engine->newFunction(displayError);
948
+engine->globalObject().setProperty("displayError", constructor);
946
 
949
 
947
 @ The function takes some arguments.
950
 @ The function takes some arguments.
948
 
951
 
959
     return QScriptValue(false);
962
     return QScriptValue(false);
960
 }
963
 }
961
 
964
 
965
+QScriptValue displayError(QScriptContext *context, QScriptEngine *)
966
+{
967
+    QMessageBox::critical(NULL, argument<QString>(0, context),
968
+                          argument<QString>(1, context));
969
+    return QScriptValue();
970
+}
971
+
962
 @* Scripting QMainWindow.
972
 @* Scripting QMainWindow.
963
 
973
 
964
 \noindent Rather than directly exposing |QMainWindow| to the scripting engine,
974
 \noindent Rather than directly exposing |QMainWindow| to the scripting engine,

Loading…
Cancel
Save