visuddhinanda 1 год назад
Родитель
Сommit
af31b1f2fe

+ 3 - 0
dashboard/src/components/template/SentEdit.tsx

@@ -83,6 +83,7 @@ export interface IWidgetSentEditInner {
   channels?: string[];
   origin?: ISentence[];
   translation?: ISentence[];
+  answer?: ISentence;
   path?: ITocPathNode[];
   layout?: "row" | "column";
   tranNum?: number;
@@ -103,6 +104,7 @@ export const SentEditInner = ({
   channels,
   origin,
   translation,
+  answer,
   path,
   layout = "column",
   tranNum,
@@ -196,6 +198,7 @@ export const SentEditInner = ({
         wordEnd={wordEnd}
         origin={origin}
         translation={translation}
+        answer={answer}
         layout={layout}
         magicDict={magicDict}
         compact={isCompact}

+ 4 - 1
dashboard/src/components/template/SentEdit/SentContent.tsx

@@ -25,6 +25,7 @@ interface IWidgetSentContent {
   wordEnd: number;
   origin?: ISentence[];
   translation?: ISentence[];
+  answer?: ISentence;
   layout?: TDirection;
   magicDict?: string;
   compact?: boolean;
@@ -41,6 +42,7 @@ const SentContentWidget = ({
   wordEnd,
   origin,
   translation,
+  answer,
   layout = "column",
   compact = false,
   mode,
@@ -157,7 +159,8 @@ const SentContentWidget = ({
                 channelId={item.channel.id}
                 channelType={item.channel.type}
                 channelLang={item.channel.lang}
-                data={JSON.parse(item.content ? item.content : "")}
+                data={JSON.parse(item.content ?? "")}
+                answer={answer ? JSON.parse(answer.content ?? "") : undefined}
                 mode={mode}
                 wbwProgress={wbwProgress}
                 onChange={(data: IWbw[]) => {

+ 6 - 0
dashboard/src/components/template/Wbw/WbwWord.tsx

@@ -104,6 +104,7 @@ export interface IWbwFields {
 export type TWbwDisplayMode = "block" | "inline" | "list";
 interface IWidget {
   data: IWbw;
+  answer?: IWbw;
   channelId: string;
   display?: TWbwDisplayMode;
   fields?: IWbwFields;
@@ -115,6 +116,7 @@ interface IWidget {
 }
 const WbwWordWidget = ({
   data,
+  answer,
   channelId,
   display,
   mode = "edit",
@@ -288,6 +290,7 @@ const WbwWordWidget = ({
               key="meaning"
               mode={mode}
               data={wordData}
+              answer={answer}
               display={display}
               onChange={(e: string) => {
                 const newData: IWbw = JSON.parse(JSON.stringify(wordData));
@@ -303,6 +306,7 @@ const WbwWordWidget = ({
             <WbwFactors
               key="factors"
               data={wordData}
+              answer={answer}
               display={display}
               onChange={(e: string) => {
                 console.log("factor change", e);
@@ -320,6 +324,7 @@ const WbwWordWidget = ({
             <WbwFactorMeaning
               key="fm"
               data={wordData}
+              answer={answer}
               display={display}
               factors={newFactors}
               onChange={(e: string) => {
@@ -361,6 +366,7 @@ const WbwWordWidget = ({
             <WbwCase
               key="case"
               data={wordData}
+              answer={answer}
               display={display}
               onSplit={(e: boolean) => {
                 console.log("onSplit", wordData.factors?.value);

+ 16 - 2
dashboard/src/components/template/WbwSent.tsx

@@ -136,6 +136,7 @@ interface IWbwRequest {
 }
 interface IWidget {
   data: IWbw[];
+  answer?: IWbw[];
   book: number;
   para: number;
   wordStart: number;
@@ -155,6 +156,7 @@ interface IWidget {
 }
 export const WbwSentCtl = ({
   data,
+  answer,
   channelId,
   channelType,
   channelLang,
@@ -531,10 +533,16 @@ export const WbwSentCtl = ({
         }
       });
   };
-  const wbwRender = (item: IWbw, id: number, studio?: IStudio) => {
+
+  interface wbwOptions {
+    studio?: IStudio;
+    answer?: IWbw;
+  }
+  const wbwRender = (item: IWbw, id: number, options?: wbwOptions) => {
     return (
       <WbwWord
         data={item}
+        answer={options?.answer}
         channelId={channelId}
         key={id}
         mode={displayMode}
@@ -776,7 +784,13 @@ export const WbwSentCtl = ({
               return newItem;
             })
             .map((item, id) => {
-              return wbwRender(item, id, studio);
+              const currAnswer = answer?.find(
+                (value) => value.sn.join() === item.sn.join()
+              );
+              return wbwRender(item, id, {
+                studio: studio,
+                answer: currAnswer,
+              });
             })
         ) : (
           <Tree