Ver código fonte

Merge pull request #2120 from visuddhinanda/agile

未完成作业列表只显示参课学员 ect.
visuddhinanda 1 ano atrás
pai
commit
e4c7c35b38

+ 3 - 0
dashboard/src/components/article/Article.tsx

@@ -58,6 +58,7 @@ interface IWidget {
   focus?: string | null;
   hideInteractive?: boolean;
   hideTitle?: boolean;
+  isSubWindow?: boolean;
   onArticleChange?: Function;
   onLoad?: Function;
   onAnthologySelect?: Function;
@@ -77,6 +78,7 @@ const ArticleWidget = ({
   focus,
   hideInteractive = false,
   hideTitle = false,
+  isSubWindow = false,
   onArticleChange,
   onLoad,
   onAnthologySelect,
@@ -91,6 +93,7 @@ const ArticleWidget = ({
       <DiscussionCount courseId={type === "textbook" ? courseId : undefined} />
       {type === "article" ? (
         <TypeArticle
+          isSubWindow={isSubWindow}
           type={type}
           articleId={onArticleChange ? articleId : currId}
           channelId={channelId}

+ 3 - 0
dashboard/src/components/article/TypeArticle.tsx

@@ -15,6 +15,7 @@ interface IWidget {
   active?: boolean;
   hideInteractive?: boolean;
   hideTitle?: boolean;
+  isSubWindow?: boolean;
   onArticleChange?: Function;
   onArticleEdit?: Function;
   onLoad?: Function;
@@ -29,6 +30,7 @@ const TypeArticleWidget = ({
   active = false,
   hideInteractive = false,
   hideTitle = false,
+  isSubWindow = false,
   onArticleChange,
   onLoad,
   onAnthologySelect,
@@ -61,6 +63,7 @@ const TypeArticleWidget = ({
         />
       ) : (
         <TypeArticleReader
+          isSubWindow={isSubWindow}
           type={type}
           channelId={channelId}
           articleId={articleId}

+ 3 - 0
dashboard/src/components/article/TypeArticleReader.tsx

@@ -29,6 +29,7 @@ interface IWidget {
   active?: boolean;
   hideInteractive?: boolean;
   hideTitle?: boolean;
+  isSubWindow?: boolean;
   onArticleChange?: Function;
   onLoad?: Function;
   onAnthologySelect?: Function;
@@ -43,6 +44,7 @@ const TypeArticleReaderWidget = ({
   active = false,
   hideInteractive = false,
   hideTitle = false,
+  isSubWindow = false,
   onArticleChange,
   onLoad,
   onAnthologySelect,
@@ -192,6 +194,7 @@ const TypeArticleReaderWidget = ({
             articleId={articleId}
             anthologyId={anthologyId}
             role={articleData?.role}
+            isSubWindow={isSubWindow}
             onEdit={() => {
               if (typeof onEdit !== "undefined") {
                 onEdit();

+ 18 - 12
dashboard/src/components/article/TypeArticleReaderToolbar.tsx

@@ -24,6 +24,7 @@ interface IWidget {
   anthologyId?: string | null;
   title?: string;
   role?: TRole;
+  isSubWindow?: boolean;
   onEdit?: Function;
   onAnthologySelect?: Function;
 }
@@ -32,6 +33,7 @@ const TypeArticleReaderToolbarWidget = ({
   anthologyId,
   title,
   role = "reader",
+  isSubWindow = false,
   onEdit,
   onAnthologySelect,
 }: IWidget) => {
@@ -48,18 +50,22 @@ const TypeArticleReaderToolbarWidget = ({
         style={{ padding: 4, display: "flex", justifyContent: "space-between" }}
       >
         <div>
-          <AnthologiesAtArticle
-            articleId={articleId}
-            anthologyId={anthologyId}
-            onClick={(
-              id: string,
-              e: React.MouseEvent<HTMLElement, MouseEvent>
-            ) => {
-              if (typeof onAnthologySelect !== "undefined") {
-                onAnthologySelect(id, e);
-              }
-            }}
-          />
+          {isSubWindow ? (
+            <></>
+          ) : (
+            <AnthologiesAtArticle
+              articleId={articleId}
+              anthologyId={anthologyId}
+              onClick={(
+                id: string,
+                e: React.MouseEvent<HTMLElement, MouseEvent>
+              ) => {
+                if (typeof onAnthologySelect !== "undefined") {
+                  onAnthologySelect(id, e);
+                }
+              }}
+            />
+          )}
         </div>
         <div>
           <Tooltip

+ 5 - 5
dashboard/src/components/auth/LoginAlert.tsx

@@ -3,15 +3,13 @@ import { Link } from "react-router-dom";
 import { Alert } from "antd";
 
 import { useAppSelector } from "../../hooks";
-import { currentUser as _currentUser } from "../../reducers/current-user";
+import { isGuest } from "../../reducers/current-user";
 
 const LoginAlertWidget = () => {
   const intl = useIntl();
+  const guest = useAppSelector(isGuest);
 
-  const user = useAppSelector(_currentUser);
-  return user ? (
-    <></>
-  ) : (
+  return guest === true ? (
     <Alert
       message={intl.formatMessage({
         id: "message.auth.guest.alert",
@@ -26,6 +24,8 @@ const LoginAlertWidget = () => {
         </Link>
       }
     />
+  ) : (
+    <></>
   );
 };
 

+ 1 - 0
dashboard/src/components/template/Article.tsx

@@ -64,6 +64,7 @@ export const ArticleCtl = ({
       mode="read"
       hideInteractive={true}
       hideTitle={true}
+      isSubWindow
     />
   );
   let output = <></>;

+ 36 - 24
dashboard/src/components/template/SentEdit.tsx

@@ -1,4 +1,4 @@
-import { Card } from "antd";
+import { Affix, Card } from "antd";
 import { useEffect, useRef, useState } from "react";
 import { IStudio } from "../auth/Studio";
 
@@ -127,6 +127,7 @@ export const SentEditInner = ({
   const [isFocus, setIsFocus] = useState(false);
   const focus = useAppSelector(currFocus);
   const divRef = useRef<HTMLDivElement>(null);
+  const [affix, setAffix] = useState<boolean>(false);
 
   useEffect(() => {
     if (focus) {
@@ -177,6 +178,32 @@ export const SentEditInner = ({
 
   const channelsId = translation?.map((item) => item.channel.id);
 
+  const content = (
+    <SentContent
+      sid={id}
+      book={book}
+      para={para}
+      wordStart={wordStart}
+      wordEnd={wordEnd}
+      origin={origin}
+      translation={translation}
+      answer={answer}
+      layout={layout}
+      magicDict={magicDict}
+      compact={isCompact}
+      mode={articleMode}
+      wbwProgress={wbwProgress}
+      readonly={readonly}
+      onWbwChange={(data: IWbw[]) => {
+        setWbwData(data);
+      }}
+      onMagicDictDone={() => {
+        setMagicDictLoading(false);
+        setMagicDict(undefined);
+      }}
+    />
+  );
+
   return (
     <Card
       ref={divRef}
@@ -192,29 +219,13 @@ export const SentEditInner = ({
       }}
       size="small"
     >
-      <SentContent
-        sid={id}
-        book={book}
-        para={para}
-        wordStart={wordStart}
-        wordEnd={wordEnd}
-        origin={origin}
-        translation={translation}
-        answer={answer}
-        layout={layout}
-        magicDict={magicDict}
-        compact={isCompact}
-        mode={articleMode}
-        wbwProgress={wbwProgress}
-        readonly={readonly}
-        onWbwChange={(data: IWbw[]) => {
-          setWbwData(data);
-        }}
-        onMagicDictDone={() => {
-          setMagicDictLoading(false);
-          setMagicDict(undefined);
-        }}
-      />
+      {affix ? (
+        <Affix offsetTop={44}>
+          <div style={{ backgroundColor: "white" }}>{content}</div>
+        </Affix>
+      ) : (
+        content
+      )}
       <SentTab
         id={id}
         book={book}
@@ -239,6 +250,7 @@ export const SentEditInner = ({
         }}
         onCompact={(value: boolean) => setIsCompact(value)}
         onModeChange={(value: ArticleMode | undefined) => setArticleMode(value)}
+        onAffix={() => setAffix(!affix)}
       />
     </Card>
   );

+ 4 - 0
dashboard/src/components/template/SentEdit/SentMenu.tsx

@@ -43,6 +43,10 @@ const SentMenuWidget = ({
       key: "copy-link",
       label: intl.formatMessage({ id: "buttons.copy.link" }),
     },
+    {
+      key: "affix",
+      label: "总在最顶端开/关",
+    },
     {
       type: "divider",
     },

+ 7 - 0
dashboard/src/components/template/SentEdit/SentTab.tsx

@@ -45,6 +45,7 @@ interface IWidget {
   onMagicDict?: Function;
   onCompact?: Function;
   onModeChange?: Function;
+  onAffix?: Function;
 }
 const SentTabWidget = ({
   id,
@@ -67,6 +68,7 @@ const SentTabWidget = ({
   onMagicDict,
   onCompact,
   onModeChange,
+  onAffix,
 }: IWidget) => {
   const intl = useIntl();
   const [isCompact, setIsCompact] = useState(compact);
@@ -184,6 +186,11 @@ const SentTabWidget = ({
                     message.success("链接地址已经拷贝到剪贴板");
                   });
                   break;
+                case "affix":
+                  if (typeof onAffix !== "undefined") {
+                    onAffix();
+                  }
+                  break;
                 default:
                   break;
               }

+ 7 - 1
dashboard/src/components/template/SentEdit/SentWbw.tsx

@@ -124,7 +124,13 @@ const SentWbwWidget = ({
       item.translation ? item.translation[0].studio : undefined
     );
     courseMember
-      .filter((value) => value.role === "student")
+      .filter(
+        (value) =>
+          value.role === "student" &&
+          (value.status === "joined" ||
+            value.status === "accepted" ||
+            value.status === "agreed")
+      )
       .forEach((value) => {
         const curr = hasWbwUsers.find((value1) => value1?.id === value.user_id);
         if (!curr && value.user) {

+ 4 - 1
dashboard/src/components/template/WbwSent.tsx

@@ -202,18 +202,21 @@ export const WbwSentCtl = ({
 
   useEffect(() => {
     //计算完成度
+    //祛除标点符号
     const allWord = wordData.filter(
       (value) =>
         value.real.value &&
         value.real.value?.length > 0 &&
         value.type?.value !== ".ctl."
     );
+
     const final = allWord.filter(
       (value) =>
         value.meaning?.value &&
         value.factors?.value &&
         value.factorMeaning?.value &&
-        value.case?.value
+        value.case?.value &&
+        value.parent?.value
     );
     console.debug("wbw progress", allWord, final);
     let finalLen: number = 0;

+ 2 - 0
dashboard/src/reducers/current-user.ts

@@ -56,9 +56,11 @@ export const slice = createSlice({
     signIn: (state, action: PayloadAction<[IUser, string]>) => {
       state.payload = action.payload[0];
       set(action.payload[1]);
+      state.guest = false;
     },
     signOut: (state) => {
       state.payload = undefined;
+      state.guest = undefined;
       remove();
     },
     guest: (state, action: PayloadAction<boolean>) => {