Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: init value for expr selector (#16867)

ecmadao99d99daca48d
diff --git a/frontend/src/components/ExprEditor/components/MultiSelect.vue b/frontend/src/components/ExprEditor/components/MultiSelect.vue
index cdb97a8958..b2bfec1bcc 100644
--- a/frontend/src/components/ExprEditor/components/MultiSelect.vue
+++ b/frontend/src/components/ExprEditor/components/MultiSelect.vue
@@ -104,11 +104,20 @@ watch(
async () => {
await handleSearch("");
// valid initial value.
- const values = new Set(state.rawOptionList.map((opt) => opt.value));
- const filtered = (props.value as any[]).filter((v) => values.has(v));
- if (filtered.length !== props.value.length) {
- // Some values are not suitable for the select options.
- emit("update:value", filtered);
+ const search = optionConfig.value.search;
+ if (!search) {
+ return;
+ }
+ const existed = new Set(state.rawOptionList.map((opt) => opt.value));
+ const pendingInit = props.value.filter((val) => !existed.has(val));
+ for (const pending of pendingInit) {
+ const options = await search(pending as string);
+ for (const option of options) {
+ if (!existed.has(option.value)) {
+ state.rawOptionList.push(option);
+ existed.add(option.value);
+ }
+ }
}
},
{ immediate: true }
diff --git a/frontend/src/components/ExprEditor/components/SingleSelect.vue b/frontend/src/components/ExprEditor/components/SingleSelect.vue
index 75f482c4fe..f129ea78b0 100644
--- a/frontend/src/components/ExprEditor/components/SingleSelect.vue
+++ b/frontend/src/components/ExprEditor/components/SingleSelect.vue
@@ -35,7 +35,7 @@ const props = defineProps<{
expr: ConditionExpr;
}>();
-const emit = defineEmits<{
+defineEmits<{
(event: "update:value", value: string | number): void;
}>();
@@ -67,14 +67,23 @@ watch(
() => factor.value,
async () => {
await handleSearch("");
- if (state.rawOptionList.length === 0) {
+ const search = optionConfig.value.search;
+ if (!search) {
return;
}
+
if (
- !props.value ||
+ props.value &&
!state.rawOptionList.find((opt) => opt.value === props.value)
) {
- emit("update:value", state.rawOptionList[0].value!);
+ const existed = new Set(state.rawOptionList.map((opt) => opt.value));
+ const options = await search(props.value as string);
+ for (const option of options) {
+ if (!existed.has(option.value)) {
+ state.rawOptionList.push(option);
+ existed.add(option.value);
+ }
+ }
}
},
{ immediate: true }