Disallow empty inputs on required input parameters in simplified workflow form

This is another attempt at
https://github.com/galaxyproject/galaxy/issues/13220, but taking into
account
https://github.com/galaxyproject/galaxy/issues/13220#issuecomment-1068054414
by limiting this to the simplified workflow form, where we can assume
input parameter optionality to have the correct meaning.

This makes it harder to submit a mandatory text parameter that can be
empty, but that is (at this point at least) a very fringe requirement.

If really needed you can make the parameter optional (and use pick_value
to fill in an empty string if null is not OK as a value).
This commit is contained in:
mvdbeek
2023-11-17 18:32:44 +01:00
parent 26573dd7ed
commit da127b5b83
3 changed files with 17 additions and 5 deletions
+5 -1
View File
@@ -79,6 +79,10 @@ export default {
type: Boolean,
default: false,
},
allowEmptyValueOnRequiredInput: {
type: Boolean,
default: false,
},
},
data() {
return {
@@ -89,7 +93,7 @@ export default {
},
computed: {
validation() {
return validateInputs(this.formIndex, this.formData);
return validateInputs(this.formIndex, this.formData, this.allowEmptyValueOnRequiredInput);
},
},
watch: {
+5 -3
View File
@@ -104,7 +104,7 @@ export function matchInputs(index, response) {
* @param{dict} index - Index of input elements
* @param{dict} values - Dictionary of parameter values
*/
export function validateInputs(index, values) {
export function validateInputs(index, values, allowEmptyValueOnRequiredInput = false) {
let batchN = -1;
let batchSrc = null;
for (const inputId in values) {
@@ -113,8 +113,10 @@ export function validateInputs(index, values) {
if (!inputDef || inputDef.step_linked) {
continue;
}
if (inputValue == null && !inputDef.optional && inputDef.type != "hidden") {
return [inputId, "Please provide a value for this option."];
if (!inputDef.optional && inputDef.type != "hidden") {
if (inputValue == null || (allowEmptyValueOnRequiredInput && inputValue === "")) {
return [inputId, "Please provide a value for this option."];
}
}
if (inputDef.wp_linked && inputDef.text_value == inputValue) {
return [inputId, "Please provide a value for this workflow parameter."];
@@ -43,7 +43,11 @@
</b-dropdown-form>
</b-dropdown>
</div>
<FormDisplay :inputs="formInputs" @onChange="onChange" @onValidation="onValidation" />
<FormDisplay
:inputs="formInputs"
:allowEmptyValueOnRequiredInput="true"
@onChange="onChange"
@onValidation="onValidation" />
<!-- Options to default one way or the other, disable if admins want, etc.. -->
<a href="#" class="workflow-expand-form-link" @click="$emit('showAdvanced')">Expand to full workflow form.</a>
</div>
@@ -137,6 +141,8 @@ export default {
onValidation(validation) {
if (validation) {
Vue.set(this.stepValidations, validation[0], validation[1]);
} else {
this.stepValidations = {};
}
},
reuseAllowed(user) {