Merge branch 'feat/upgrade-knowledge-metabase' into deploy/dev
This commit is contained in:
commit
439124a2b8
@ -1,10 +1,10 @@
|
||||
import { useBoolean } from 'ahooks'
|
||||
import type { MetadataBatchEditToServer, MetadataItemInBatchEdit, MetadataItemWithValue } from '../types'
|
||||
import { type MetadataBatchEditToServer, type MetadataItemInBatchEdit, type MetadataItemWithEdit, type MetadataItemWithValue, UpdateType } from '../types'
|
||||
import type { SimpleDocumentDetail } from '@/models/datasets'
|
||||
import { useMemo } from 'react'
|
||||
import { isEqual } from 'lodash-es'
|
||||
import { useBatchUpdateDocMetadata } from '@/service/knowledge/use-metadata'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import { t } from 'i18next'
|
||||
|
||||
type Props = {
|
||||
datasetId: string
|
||||
@ -68,14 +68,9 @@ const useBatchEditDocumentMetadata = ({
|
||||
return res
|
||||
}, [metaDataList])
|
||||
|
||||
const formateToBackendList = (editedList: MetadataItemInBatchEdit[], addedList: MetadataItemInBatchEdit[], isApplyToAllSelectDocument: boolean) => {
|
||||
const formateToBackendList = (editedList: MetadataItemWithEdit[], addedList: MetadataItemInBatchEdit[], isApplyToAllSelectDocument: boolean) => {
|
||||
const updatedList = editedList.filter((editedItem) => {
|
||||
const originalItem = originalList.find(i => i.id === editedItem.id)
|
||||
if (!originalItem) // added item
|
||||
return true
|
||||
if (!isEqual(originalItem, editedItem)) // no change
|
||||
return true
|
||||
return false
|
||||
return editedItem.updateType === UpdateType.changeValue
|
||||
})
|
||||
const removedList = originalList.filter((originalItem) => {
|
||||
const editedItem = editedList.find(i => i.id === originalItem.id)
|
||||
@ -100,7 +95,7 @@ const useBatchEditDocumentMetadata = ({
|
||||
if (isApplyToAllSelectDocument) {
|
||||
// add missing metadata item
|
||||
updatedList.forEach((editedItem) => {
|
||||
if (!newMetadataList.find(i => i.id === editedItem.id))
|
||||
if (!newMetadataList.find(i => i.id === editedItem.id) && !editedItem.isMultipleValue)
|
||||
newMetadataList.push(editedItem)
|
||||
})
|
||||
}
|
||||
@ -132,7 +127,7 @@ const useBatchEditDocumentMetadata = ({
|
||||
hideEditModal()
|
||||
Toast.notify({
|
||||
type: 'success',
|
||||
message: 'common.api.actionSuccess',
|
||||
message: t('common.actionMsg.modifiedSuccessfully'),
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user