Skip to content

Commit a400abf

Browse files
fix(entities-plugins): fields set to null (#1939)
1 parent 4771aad commit a400abf

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/entities/entities-plugins/src/components/PluginForm.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,7 @@ const saveFormData = async (): Promise<void> => {
12011201
originalModel: formFieldsOriginal,
12021202
model: form.fields,
12031203
payload,
1204+
schema: schema.value,
12041205
})
12051206
}
12061207

packages/entities/entities-plugins/src/definitions/schemas/AIProxyAdvanced.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ export const aiProxyAdvancedSchema: CommonSchemaFields = {
44
// For the ai-proxy-advanced plugin, 'config-embeddings' and 'config-vectordb' fields are non-required
55
// but they have nested fields that are required. If the nested fields are not provided, 'config-embeddings'
66
// and 'config-vectordb' should be set to null in the payload.
7-
shamefullyTransformPayload: ({ originalModel, model, payload }) => {
7+
shamefullyTransformPayload: ({ originalModel, model, payload, schema }) => {
88
const isDirty = (key: string) => {
9+
// if the field is required and the model value is not empty
10+
// the field is dirty
11+
if (schema[key]?.required && model[key]) {
12+
return true
13+
}
14+
915
// if the model value is the same as the original value
1016
// the field is not dirty
1117
if (originalModel[key] === model[key]) {

0 commit comments

Comments
 (0)