Skip to content

Commit a4cd1e9

Browse files
reset formConfig.errors if there is no refreshRequest
Also consider `this.validationInternal` as errors. The clearing of `formConfig.errors` on no refresh request seems to work because in `FormDisplay`, we seem to be returning that boolean as a param when there is a change in value that would possibly return errors from the backend. And of course, `this.validationInternal` contains errors found by the client for individual inputs and is therefore, an essential check to disable run.
1 parent d4f633e commit a4cd1e9

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

client/src/components/Tool/ToolForm.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export default {
205205
],
206206
immutableHistoryMessage:
207207
"This history is immutable and you cannot run tools in it. Please switch to a different history.",
208+
formConfigInitialized: false,
208209
};
209210
},
210211
computed: {
@@ -227,7 +228,7 @@ export default {
227228
switch (true) {
228229
case !this.canMutateHistory:
229230
return this.immutableHistoryMessage;
230-
case this.formConfig.errors && Object.values(this.formConfig.errors).length > 0:
231+
case this.hasConfigOrValErrors:
231232
return "Please correct errors before running the tool.";
232233
case this.showExecuting:
233234
return "Tool is being executed...";
@@ -259,8 +260,13 @@ export default {
259260
return this.currentHistory && canMutateHistory(this.currentHistory);
260261
},
261262
runButtonDisabled() {
263+
return this.disabled || !this.canMutateHistory || this.hasConfigOrValErrors;
264+
},
265+
/** If there are any backend returned `formConfig.errors` or internal/client checked validation errors. */
266+
hasConfigOrValErrors() {
262267
return (
263-
this.disabled || !this.canMutateHistory || (this.formConfig.errors && Object.values(this.formConfig.errors).length > 0)
268+
(this.formConfig.errors && Object.values(this.formConfig.errors).length > 0) ||
269+
this.validationInternal?.length
264270
);
265271
},
266272
},
@@ -294,7 +300,12 @@ export default {
294300
this.formData = newData;
295301
if (refreshRequest) {
296302
this.onUpdate();
303+
} else if (this.formConfigInitialized && this.hasConfigOrValErrors) {
304+
// After the first manual change to a form input, for every change, if there isn't a request to refresh,
305+
// we reset the errors since we haven't received a tool form update via the backend.
306+
this.formConfig.errors = null;
297307
}
308+
this.formConfigInitialized = true;
298309
},
299310
onUpdate() {
300311
this.disabled = true;

0 commit comments

Comments
 (0)