Browse Source

Merge pull request #1826 from visuddhinanda/agile

句子编号从顶层传递下来
visuddhinanda 2 năm trước cách đây
mục cha
commit
5cc74327b7

+ 3 - 1
dashboard/src/components/anthology/EditableTocTree.tsx

@@ -42,11 +42,13 @@ const EditableTocTreeWidget = ({
   const [viewArticleId, setViewArticleId] = useState<string>();
 
   const save = (data?: ListNodeData[]) => {
-    console.log("onSave", data);
+    console.debug("onSave", data);
     if (typeof data === "undefined") {
+      console.warn("data === undefined");
       return;
     }
     const url = `/v2/article-map/${anthologyId}`;
+    console.info("url", url);
     const newData: IArticleMapRequest[] = data.map((item) => {
       let title = "";
       if (typeof item.title === "string") {

+ 11 - 5
dashboard/src/components/channel/ChannelMy.tsx

@@ -70,9 +70,13 @@ const ChannelMy = ({
   const [infoOpen, setInfoOpen] = useState<boolean>(false);
   const [statistic, setStatistic] = useState<IItem>();
   const [sentenceCount, setSentenceCount] = useState<number>(0);
+  const [sentencesId, setSentencesId] = useState<string[]>();
+
+  console.debug("ChannelMy render", type, articleId);
+
   useEffect(() => {
     load();
-  }, []);
+  }, [type, articleId]);
 
   useEffect(() => {
     if (selectedRowKeys.join() !== selectedKeys.join()) {
@@ -130,15 +134,15 @@ const ChannelMy = ({
       const id = articleId?.split("-");
       if (id?.length === 2) {
         const url = `/v2/sentences-in-chapter?book=${id[0]}&para=${id[1]}`;
-        console.info("url", url);
+        console.info("ChannelMy url", url);
         get<ISentInChapterListResponse>(url)
           .then((res) => {
-            console.debug("ISentInChapterListResponse", res);
+            console.debug("ChannelMy ISentInChapterListResponse", res);
             if (res && res.ok) {
               sentList = res.data.rows.map((item) => {
                 return `${item.book}-${item.paragraph}-${item.word_begin}-${item.word_end}`;
               });
-
+              setSentencesId(sentList);
               loadChannel(sentList);
             } else {
               console.error("res", res);
@@ -155,6 +159,7 @@ const ChannelMy = ({
         const id = element.id.split("_")[1];
         sentList.push(id);
       }
+      setSentencesId(sentList);
       loadChannel(sentList);
     }
   };
@@ -171,7 +176,7 @@ const ChannelMy = ({
       owner: currOwner,
     })
       .then((res) => {
-        console.log("progress data", res.data.rows);
+        console.debug("progress data", res.data.rows);
         const items: IItem[] = res.data.rows
           .filter((value) => value.name.substring(0, 4) !== "_Sys")
           .map((item, id) => {
@@ -437,6 +442,7 @@ const ChannelMy = ({
         )}
       </Card>
       <CopyToModal
+        sentencesId={sentencesId}
         channel={copyChannel}
         open={copyOpen}
         onClose={() => setCopyOpen(false)}

+ 1 - 1
dashboard/src/components/channel/ChannelPickerTable.tsx

@@ -205,7 +205,7 @@ const ChannelPickerTableWidget = ({
               owner: currOwner,
             }
           );
-          console.log("progress data", res.data.rows);
+          console.debug("progress data", res.data.rows);
           const items: IItem[] = res.data.rows
             .filter((value) => value.name.substring(0, 4) !== "_Sys")
             .map((item, id) => {

+ 11 - 0
dashboard/src/components/channel/ChannelSentDiff.tsx

@@ -236,6 +236,17 @@ const ChannelSentDiffWidget = ({
               title: "pali",
               width: "33%",
               dataIndex: "pali",
+              render: (value, record, index) => {
+                return (
+                  <Text>
+                    <div
+                      dangerouslySetInnerHTML={{
+                        __html: record.pali ? record.pali : "",
+                      }}
+                    />
+                  </Text>
+                );
+              },
             },
             {
               title: (

+ 9 - 1
dashboard/src/components/channel/CopyToModal.tsx

@@ -7,10 +7,17 @@ import { IChannel } from "./Channel";
 interface IWidget {
   trigger?: JSX.Element | string;
   channel?: IChannel;
+  sentencesId?: string[];
   open?: boolean;
   onClose?: Function;
 }
-const CopyToModalWidget = ({ trigger, channel, open, onClose }: IWidget) => {
+const CopyToModalWidget = ({
+  trigger,
+  channel,
+  sentencesId,
+  open,
+  onClose,
+}: IWidget) => {
   const [isModalOpen, setIsModalOpen] = useState(open);
   const [initStep, setInitStep] = useState(0);
 
@@ -51,6 +58,7 @@ const CopyToModalWidget = ({ trigger, channel, open, onClose }: IWidget) => {
         <CopyToStep
           initStep={initStep}
           channel={channel}
+          sentencesId={sentencesId}
           onClose={() => {
             setIsModalOpen(false);
             Modal.destroyAll();

+ 3 - 10
dashboard/src/components/channel/CopyToStep.tsx

@@ -12,7 +12,7 @@ interface IWidget {
   channel?: IChannel;
   type?: ArticleType;
   articleId?: string;
-  sentence?: string[];
+  sentencesId?: string[];
   stepChange?: Function;
   onClose?: Function;
 }
@@ -21,7 +21,7 @@ const CopyToStepWidget = ({
   channel,
   type,
   articleId,
-  sentence,
+  sentencesId,
   stepChange,
   onClose,
 }: IWidget) => {
@@ -29,13 +29,6 @@ const CopyToStepWidget = ({
   const [destChannel, setDestChannel] = useState<IChannel>();
   const [copyPercent, setCopyPercent] = useState<number>();
 
-  let sentList: string[] = [];
-  const sentElement = document.querySelectorAll(".pcd_sent");
-  for (let index = 0; index < sentElement.length; index++) {
-    const element = sentElement[index];
-    const id = element.id.split("_")[1];
-    sentList.push(id);
-  }
   useEffect(() => {
     setCurrent(initStep);
   }, [initStep]);
@@ -83,7 +76,7 @@ const CopyToStepWidget = ({
         <ChannelSentDiff
           srcChannel={channel}
           destChannel={destChannel}
-          sentences={sentList}
+          sentences={sentencesId}
           goPrev={() => {
             prev();
           }}

+ 1 - 1
dashboard/src/components/corpus/TocPath.tsx

@@ -38,7 +38,7 @@ const TocPathWidget = ({
   const [currData, setCurrData] = useState(data);
   const navigate = useNavigate();
   const [searchParams] = useSearchParams();
-  console.log("TocPathWidget render");
+  console.debug("TocPathWidget render");
   useEffect(() => setCurrData(data), [data]);
   const fullPath = (
     <Breadcrumb