Skip to content

Commit

Permalink
fix: required Boolean & Multiselect rules (#6445)
Browse files Browse the repository at this point in the history
* fix: required Boolean & Multiselect rules

* fix single line in light mode dark editor
  • Loading branch information
elevatebart authored Dec 12, 2024
1 parent 93db727 commit e8a98d9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
4 changes: 4 additions & 0 deletions ui/src/components/inputs/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@
box-shadow: 0 0 0 1px var(--bs-border-color) inset;
padding-top: 7px;
&.custom-dark-vs-theme {
background-color: $input-bg;
}
html.dark & {
background-color: var(--bs-gray-100);
}
Expand Down
41 changes: 32 additions & 9 deletions ui/src/components/inputs/InputsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:key="input.id"
:label="input.displayName ? input.displayName : input.id"
:required="input.required !== false"
:rules="input.type === 'BOOLEAN' ? [requiredBooleanRule(input)] : undefined"
:rules="requiredRules(input)"
:prop="input.id"
:error="inputError(input.id)"
:inline-message="true"
Expand Down Expand Up @@ -397,15 +397,38 @@
});
}
},
requiredBooleanRule(input) {
return input.required !== false ? {
validator: (_, val, callback) => {
if(val === "undefined"){
return callback(new Error(this.$t("is required", {field: input.displayName || input.id})));
requiredRules(input) {
if(input.required === false)
return undefined
if(input.type === "BOOLEAN"){
return [{
validator: (_, val, callback) => {
if(val === "undefined"){
return callback(new Error(this.$t("is required", {field: input.displayName || input.id})));
}
callback()
},
}]
}
if(["ENUM", "SELECT", "MULTISELECT"].includes(input.type)){
return [
{
required: true,
validator: (_, __, callback) => {
const val = input.type === "MULTISELECT" ? this.multiSelectInputs[input.id] : this.inputsValues[input.id]
if(!val?.length){
return callback(new Error(this.$t("is required", {field: input.displayName || input.id})));
}
callback()
},
trigger: "change",
}
callback()
},
} : undefined
]
}
return undefined
}
},
watch: {
Expand Down

0 comments on commit e8a98d9

Please sign in to comment.