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