|
|
|
@ -28,6 +28,7 @@ import AutoHeightTextarea from '@/app/components/base/auto-height-textarea/commo
|
|
|
|
import Button from '@/app/components/base/button'
|
|
|
|
import Button from '@/app/components/base/button'
|
|
|
|
import NewSegmentModal from '@/app/components/datasets/documents/detail/new-segment-modal'
|
|
|
|
import NewSegmentModal from '@/app/components/datasets/documents/detail/new-segment-modal'
|
|
|
|
import TagInput from '@/app/components/base/tag-input'
|
|
|
|
import TagInput from '@/app/components/base/tag-input'
|
|
|
|
|
|
|
|
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
|
|
|
|
|
|
|
|
|
|
|
export const SegmentIndexTag: FC<{ positionId: string | number; className?: string }> = ({ positionId, className }) => {
|
|
|
|
export const SegmentIndexTag: FC<{ positionId: string | number; className?: string }> = ({ positionId, className }) => {
|
|
|
|
const localPositionId = useMemo(() => {
|
|
|
|
const localPositionId = useMemo(() => {
|
|
|
|
@ -66,6 +67,15 @@ export const SegmentDetail: FC<ISegmentDetailProps> = memo(({
|
|
|
|
const [question, setQuestion] = useState(segInfo?.content || '')
|
|
|
|
const [question, setQuestion] = useState(segInfo?.content || '')
|
|
|
|
const [answer, setAnswer] = useState(segInfo?.answer || '')
|
|
|
|
const [answer, setAnswer] = useState(segInfo?.answer || '')
|
|
|
|
const [keywords, setKeywords] = useState<string[]>(segInfo?.keywords || [])
|
|
|
|
const [keywords, setKeywords] = useState<string[]>(segInfo?.keywords || [])
|
|
|
|
|
|
|
|
const { eventEmitter } = useEventEmitterContextContext()
|
|
|
|
|
|
|
|
const [loading, setLoading] = useState(false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eventEmitter?.useSubscription((v) => {
|
|
|
|
|
|
|
|
if (v === 'update-segment')
|
|
|
|
|
|
|
|
setLoading(true)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
setLoading(false)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const handleCancel = () => {
|
|
|
|
const handleCancel = () => {
|
|
|
|
setIsEditing(false)
|
|
|
|
setIsEditing(false)
|
|
|
|
@ -129,7 +139,9 @@ export const SegmentDetail: FC<ISegmentDetailProps> = memo(({
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
type='primary'
|
|
|
|
type='primary'
|
|
|
|
className='!h-7 !px-3 !py-[5px] text-xs font-medium !rounded-md'
|
|
|
|
className='!h-7 !px-3 !py-[5px] text-xs font-medium !rounded-md'
|
|
|
|
onClick={handleSave}>
|
|
|
|
onClick={handleSave}
|
|
|
|
|
|
|
|
disabled={loading}
|
|
|
|
|
|
|
|
>
|
|
|
|
{t('common.operation.save')}
|
|
|
|
{t('common.operation.save')}
|
|
|
|
</Button>
|
|
|
|
</Button>
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
@ -225,6 +237,7 @@ const Completed: FC<ICompletedProps> = ({
|
|
|
|
const [allSegments, setAllSegments] = useState<Array<SegmentDetailModel[]>>([]) // all segments data
|
|
|
|
const [allSegments, setAllSegments] = useState<Array<SegmentDetailModel[]>>([]) // all segments data
|
|
|
|
const [loading, setLoading] = useState(false)
|
|
|
|
const [loading, setLoading] = useState(false)
|
|
|
|
const [total, setTotal] = useState<number | undefined>()
|
|
|
|
const [total, setTotal] = useState<number | undefined>()
|
|
|
|
|
|
|
|
const { eventEmitter } = useEventEmitterContextContext()
|
|
|
|
|
|
|
|
|
|
|
|
const onChangeStatus = ({ value }: Item) => {
|
|
|
|
const onChangeStatus = ({ value }: Item) => {
|
|
|
|
setSelectedStatus(value === 'all' ? 'all' : !!value)
|
|
|
|
setSelectedStatus(value === 'all' ? 'all' : !!value)
|
|
|
|
@ -318,6 +331,8 @@ const Completed: FC<ICompletedProps> = ({
|
|
|
|
if (keywords.length)
|
|
|
|
if (keywords.length)
|
|
|
|
params.keywords = keywords
|
|
|
|
params.keywords = keywords
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
eventEmitter?.emit('update-segment')
|
|
|
|
const res = await updateSegment({ datasetId, documentId, segmentId, body: params })
|
|
|
|
const res = await updateSegment({ datasetId, documentId, segmentId, body: params })
|
|
|
|
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
|
|
|
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
|
|
|
onCloseModal()
|
|
|
|
onCloseModal()
|
|
|
|
@ -336,6 +351,10 @@ const Completed: FC<ICompletedProps> = ({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setAllSegments([...allSegments])
|
|
|
|
setAllSegments([...allSegments])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
finally {
|
|
|
|
|
|
|
|
eventEmitter?.emit('')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
if (lastSegmentsRes !== undefined)
|
|
|
|
if (lastSegmentsRes !== undefined)
|
|
|
|
|