balibabu commited on
Commit
6bcc79d
·
1 Parent(s): 5843365

Fix: Clicking the checkbox of the pop-up window for editing chunk is invalid #3726 (#3727)

Browse files

### What problem does this PR solve?

Fix: Clicking the checkbox of the pop-up window for editing chunk is
invalid #3726

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

web/src/locales/zh-traditional.ts CHANGED
@@ -296,7 +296,7 @@ export default {
296
  search: '搜尋',
297
  all: '所有',
298
  enabled: '啟用',
299
- disabled: '禁用的',
300
  keyword: '關鍵詞',
301
  function: '函數',
302
  chunkMessage: '請輸入值!',
 
296
  search: '搜尋',
297
  all: '所有',
298
  enabled: '啟用',
299
+ disabled: '禁用',
300
  keyword: '關鍵詞',
301
  function: '函數',
302
  chunkMessage: '請輸入值!',
web/src/locales/zh.ts CHANGED
@@ -313,7 +313,7 @@ export default {
313
  search: '搜索',
314
  all: '所有',
315
  enabled: '启用',
316
- disabled: '禁用的',
317
  keyword: '关键词',
318
  function: '函数',
319
  chunkMessage: '请输入值!',
 
313
  search: '搜索',
314
  all: '所有',
315
  enabled: '启用',
316
+ disabled: '禁用',
317
  keyword: '关键词',
318
  function: '函数',
319
  chunkMessage: '请输入值!',
web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/index.tsx CHANGED
@@ -2,7 +2,7 @@ import EditTag from '@/components/edit-tag';
2
  import { useFetchChunk } from '@/hooks/chunk-hooks';
3
  import { IModalProps } from '@/interfaces/common';
4
  import { DeleteOutlined } from '@ant-design/icons';
5
- import { Checkbox, Divider, Form, Input, Modal, Space } from 'antd';
6
  import React, { useEffect, useState } from 'react';
7
  import { useTranslation } from 'react-i18next';
8
  import { useDeleteChunkByIds } from '../../hooks';
@@ -31,9 +31,14 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
31
 
32
  useEffect(() => {
33
  if (data?.code === 0) {
34
- const { content_with_weight, important_kwd = [] } = data.data;
 
 
 
 
35
  form.setFieldsValue({ content: content_with_weight });
36
  setKeywords(important_kwd);
 
37
  }
38
 
39
  if (!chunkId) {
@@ -48,6 +53,7 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
48
  onOk?.({
49
  content: values.content,
50
  keywords, // keywords
 
51
  });
52
  } catch (errorInfo) {
53
  console.log('Failed:', errorInfo);
@@ -82,16 +88,19 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
82
  </Form.Item>
83
  </Form>
84
  <section>
85
- <p>{t('chunk.keyword')} *</p>
86
  <EditTag tags={keywords} setTags={setKeywords} />
87
  </section>
88
  {chunkId && (
89
  <section>
90
  <Divider></Divider>
91
  <Space size={'large'}>
92
- <Checkbox onChange={handleCheck} checked={checked}>
93
- {t('chunk.enabled')}
94
- </Checkbox>
 
 
 
95
 
96
  <span onClick={handleRemove}>
97
  <DeleteOutlined /> {t('common.delete')}
 
2
  import { useFetchChunk } from '@/hooks/chunk-hooks';
3
  import { IModalProps } from '@/interfaces/common';
4
  import { DeleteOutlined } from '@ant-design/icons';
5
+ import { Divider, Form, Input, Modal, Space, Switch } from 'antd';
6
  import React, { useEffect, useState } from 'react';
7
  import { useTranslation } from 'react-i18next';
8
  import { useDeleteChunkByIds } from '../../hooks';
 
31
 
32
  useEffect(() => {
33
  if (data?.code === 0) {
34
+ const {
35
+ content_with_weight,
36
+ important_kwd = [],
37
+ available_int,
38
+ } = data.data;
39
  form.setFieldsValue({ content: content_with_weight });
40
  setKeywords(important_kwd);
41
+ setChecked(available_int === 1);
42
  }
43
 
44
  if (!chunkId) {
 
53
  onOk?.({
54
  content: values.content,
55
  keywords, // keywords
56
+ available_int: checked ? 1 : 0, // available_int
57
  });
58
  } catch (errorInfo) {
59
  console.log('Failed:', errorInfo);
 
88
  </Form.Item>
89
  </Form>
90
  <section>
91
+ <p className="mb-2">{t('chunk.keyword')} *</p>
92
  <EditTag tags={keywords} setTags={setKeywords} />
93
  </section>
94
  {chunkId && (
95
  <section>
96
  <Divider></Divider>
97
  <Space size={'large'}>
98
+ <Switch
99
+ checkedChildren={t('chunk.enabled')}
100
+ unCheckedChildren={t('chunk.disabled')}
101
+ onChange={handleCheck}
102
+ checked={checked}
103
+ />
104
 
105
  <span onClick={handleRemove}>
106
  <DeleteOutlined /> {t('common.delete')}
web/src/pages/add-knowledge/components/knowledge-chunk/hooks.ts CHANGED
@@ -95,12 +95,21 @@ export const useUpdateChunk = () => {
95
  const { documentId } = useGetKnowledgeSearchParams();
96
 
97
  const onChunkUpdatingOk = useCallback(
98
- async ({ content, keywords }: { content: string; keywords: string }) => {
 
 
 
 
 
 
 
 
99
  const code = await createChunk({
100
  content_with_weight: content,
101
  doc_id: documentId,
102
  chunk_id: chunkId,
103
  important_kwd: keywords, // keywords
 
104
  });
105
 
106
  if (code === 0) {
 
95
  const { documentId } = useGetKnowledgeSearchParams();
96
 
97
  const onChunkUpdatingOk = useCallback(
98
+ async ({
99
+ content,
100
+ keywords,
101
+ available_int,
102
+ }: {
103
+ content: string;
104
+ keywords: string;
105
+ available_int: number;
106
+ }) => {
107
  const code = await createChunk({
108
  content_with_weight: content,
109
  doc_id: documentId,
110
  chunk_id: chunkId,
111
  important_kwd: keywords, // keywords
112
+ available_int,
113
  });
114
 
115
  if (code === 0) {