Browse Source

add isPublish in onSave

visuddhinanda 2 years ago
parent
commit
381a8c1b50

+ 15 - 6
dashboard/src/components/template/Wbw/WbwDetail.tsx

@@ -1,7 +1,6 @@
 import { useEffect, useState } from "react";
 import { useIntl } from "react-intl";
 import { Dropdown, Tabs, Divider, Button, Switch, Rate } from "antd";
-import type { MenuProps } from "antd";
 import { SaveOutlined, CommentOutlined } from "@ant-design/icons";
 
 import { IWbw, IWbwField, TFieldName } from "./WbwWord";
@@ -89,9 +88,6 @@ const WbwDetailWidget = ({
     }
     setCurrWbwData(mData);
   }
-  const onMenuClick: MenuProps["onClick"] = (e) => {
-    console.log("click", e);
-  };
 
   const items = [
     {
@@ -245,10 +241,23 @@ const WbwDetailWidget = ({
         <Dropdown.Button
           style={{ width: "unset" }}
           type="primary"
-          menu={{ items, onClick: onMenuClick }}
+          menu={{
+            items: [
+              {
+                key: "user-dict",
+                label: intl.formatMessage({ id: "buttons.save.publish" }),
+              },
+            ],
+            onClick: (e) => {
+              if (typeof onSave !== "undefined") {
+                //保存并发布
+                onSave(currWbwData, true);
+              }
+            },
+          }}
           onClick={() => {
             if (typeof onSave !== "undefined") {
-              onSave(currWbwData);
+              onSave(currWbwData, false);
             }
           }}
         >

+ 2 - 2
dashboard/src/components/template/Wbw/WbwPali.tsx

@@ -77,9 +77,9 @@ const WbwPaliWidget = ({ data, display, onSave }: IWidget) => {
         setPaliColor("unset");
         setPopOpen(false);
       }}
-      onSave={(e: IWbw) => {
+      onSave={(e: IWbw, isPublish: boolean) => {
         if (typeof onSave !== "undefined") {
-          onSave(e);
+          onSave(e, isPublish);
           setPopOpen(false);
           setPaliColor("unset");
         }

+ 2 - 3
dashboard/src/components/template/Wbw/WbwWord.tsx

@@ -205,12 +205,11 @@ const WbwWordWidget = ({
           key="pali"
           data={wordData}
           display={display}
-          onSave={(e: IWbw) => {
-            console.log("save", e);
+          onSave={(e: IWbw, isPublish: boolean) => {
             const newData: IWbw = JSON.parse(JSON.stringify(e));
             setWordData(newData);
             if (typeof onChange !== "undefined") {
-              onChange(e);
+              onChange(e, isPublish);
             }
           }}
         />