Răsfoiți Sursa

name add TermModal

visuddhinanda 2 ani în urmă
părinte
comite
d8fd436bb7
1 a modificat fișierele cu 33 adăugiri și 53 ștergeri
  1. 33 53
      dashboard/src/pages/admin/relation/list.tsx

+ 33 - 53
dashboard/src/pages/admin/relation/list.tsx

@@ -1,5 +1,5 @@
 import { useIntl } from "react-intl";
 import { useIntl } from "react-intl";
-import { Button, Dropdown, Modal, message, Tag, Space, Typography } from "antd";
+import { Button, Dropdown, Modal, message, Tag, Space } from "antd";
 import { ActionType, ProTable } from "@ant-design/pro-components";
 import { ActionType, ProTable } from "@ant-design/pro-components";
 import {
 import {
   PlusOutlined,
   PlusOutlined,
@@ -7,6 +7,7 @@ import {
   ExclamationCircleOutlined,
   ExclamationCircleOutlined,
   ImportOutlined,
   ImportOutlined,
   ExportOutlined,
   ExportOutlined,
+  TranslationOutlined,
 } from "@ant-design/icons";
 } from "@ant-design/icons";
 
 
 import { API_HOST, delete_, get } from "../../../request";
 import { API_HOST, delete_, get } from "../../../request";
@@ -25,8 +26,6 @@ import TimeShow from "../../../components/general/TimeShow";
 import { ITerm } from "../../../components/term/TermEdit";
 import { ITerm } from "../../../components/term/TermEdit";
 import TermModal from "../../../components/term/TermModal";
 import TermModal from "../../../components/term/TermModal";
 
 
-const { Text } = Typography;
-
 export const getSorterUrl = (sorter?: Record<string, SortOrder>): string => {
 export const getSorterUrl = (sorter?: Record<string, SortOrder>): string => {
   let url: string = "";
   let url: string = "";
   for (const key in sorter) {
   for (const key in sorter) {
@@ -43,53 +42,11 @@ export const getSorterUrl = (sorter?: Record<string, SortOrder>): string => {
   return url;
   return url;
 };
 };
 
 
-export const CaseValueEnum = () => {
-  const intl = useIntl();
-  return {
-    all: {
-      text: "all",
-    },
-    nom: {
-      text: intl.formatMessage({
-        id: "dict.fields.type.nom.label",
-      }),
-    },
-    acc: {
-      text: intl.formatMessage({
-        id: "dict.fields.type.acc.label",
-      }),
-    },
-    gen: {
-      text: intl.formatMessage({
-        id: "dict.fields.type.gen.label",
-      }),
-    },
-    dat: {
-      text: intl.formatMessage({
-        id: "dict.fields.type.dat.label",
-      }),
-    },
-    inst: {
-      text: intl.formatMessage({
-        id: "dict.fields.type.inst.label",
-      }),
-    },
-    abl: {
-      text: intl.formatMessage({
-        id: "dict.fields.type.abl.label",
-      }),
-    },
-    loc: {
-      text: intl.formatMessage({
-        id: "dict.fields.type.loc.label",
-      }),
-    },
-  };
-};
-
 export interface IRelationRequest {
 export interface IRelationRequest {
   id?: string;
   id?: string;
   name: string;
   name: string;
+  name_channel?: string;
+  name_term?: ITerm;
   case?: string | null;
   case?: string | null;
   from?: IFrom | null;
   from?: IFrom | null;
   to?: string[];
   to?: string[];
@@ -121,6 +78,8 @@ export interface IRelation {
   sn?: number;
   sn?: number;
   id?: string;
   id?: string;
   name: string;
   name: string;
+  name_channel?: string;
+  name_term?: ITerm;
   case?: string | null;
   case?: string | null;
   from?: IFrom | null;
   from?: IFrom | null;
   fromCase?: string[];
   fromCase?: string[];
@@ -217,10 +176,29 @@ const Widget = () => {
             dataIndex: "name1",
             dataIndex: "name1",
             key: "name1",
             key: "name1",
             render: (text, row, index, action) => {
             render: (text, row, index, action) => {
-              const localName = terms?.find(
-                (item) => item.word === row.name
-              )?.meaning;
-              return localName;
+              return row.name_term ? (
+                <TermModal
+                  trigger={
+                    <Button type="link" icon={<TranslationOutlined />}>
+                      {row.name_term?.meaning}
+                    </Button>
+                  }
+                  id={row.name_term.id}
+                  channelId={row.category_channel}
+                  onUpdate={() => ref.current?.reload()}
+                />
+              ) : row.name_channel && row.name ? (
+                <TermModal
+                  trigger={
+                    <Button type="link" key="button" icon={<PlusOutlined />}>
+                      {intl.formatMessage({ id: "buttons.create" })}
+                    </Button>
+                  }
+                  word={row.name}
+                  channelId={row.name_channel}
+                  onUpdate={() => ref.current?.reload()}
+                />
+              ) : undefined;
             },
             },
           },
           },
           {
           {
@@ -270,12 +248,12 @@ const Widget = () => {
             key: "category",
             key: "category",
             render: (text, row, index, action) => {
             render: (text, row, index, action) => {
               return (
               return (
-                <Space direction="vertical">
+                <Space>
                   {row.category}
                   {row.category}
                   {row.category_term ? (
                   {row.category_term ? (
                     <TermModal
                     <TermModal
                       trigger={
                       trigger={
-                        <Button type="link">
+                        <Button type="link" icon={<TranslationOutlined />}>
                           {row.category_term?.meaning}
                           {row.category_term?.meaning}
                         </Button>
                         </Button>
                       }
                       }
@@ -394,6 +372,8 @@ const Widget = () => {
               sn: offset + id + 1,
               sn: offset + id + 1,
               id: item.id,
               id: item.id,
               name: item.name,
               name: item.name,
+              name_channel: item.name_channel,
+              name_term: item.name_term,
               case: item.case,
               case: item.case,
               from: item.from,
               from: item.from,
               to: item.to,
               to: item.to,