feat: Add service_name for article list
All checks were successful
release-tag / release-image (push) Successful in 2m23s

This commit is contained in:
Илья Куприец 2025-05-26 17:24:04 +03:00
parent db5e9d9fc4
commit 9bf294e124
5 changed files with 138 additions and 78 deletions

View File

@ -21,6 +21,7 @@ export function MediaView({ media }: Readonly<{ media?: MediaData }>) {
display: "flex",
flexGrow: 1,
justifyContent: "center",
margin: "0 auto",
}}
>
{media?.media_type === 1 && (

View File

@ -18,7 +18,7 @@ export const ArticleList = observer(() => {
const { dataGridProps } = useDataGrid({
resource: "article",
...META_LANGUAGE(language)
...META_LANGUAGE(language),
});
const columns = React.useMemo<GridColDef[]>(
@ -33,7 +33,7 @@ export const ArticleList = observer(() => {
headerAlign: "left",
},
{
field: "heading",
field: "service_name",
headerName: "Заголовок",
type: "string",
minWidth: 300,
@ -43,6 +43,16 @@ export const ArticleList = observer(() => {
flex: 1,
},
// {
// field: "service_name",
// headerName: "Сервисное название (тест)",
// type: "string",
// minWidth: 300,
// display: "flex",
// align: "left",
// headerAlign: "left",
// flex: 1,
// },
// {
// field: 'body',
// headerName: 'Контент',
// type: 'string',
@ -66,10 +76,7 @@ export const ArticleList = observer(() => {
<>
<EditButton hideText recordItemId={row.id} />
<ShowButton hideText recordItemId={row.id} />
<DeleteButton
hideText
recordItemId={row.id}
/>
<DeleteButton hideText recordItemId={row.id} />
</>
);
},

View File

@ -1,88 +1,107 @@
import {type GridColDef} from '@mui/x-data-grid'
import {CustomDataGrid} from '../../components/CustomDataGrid'
import {DeleteButton, EditButton, List, ShowButton, useDataGrid} from '@refinedev/mui'
import React from 'react'
import {MEDIA_TYPES} from '../../lib/constants'
import { observer } from "mobx-react-lite"
import { type GridColDef } from "@mui/x-data-grid";
import { CustomDataGrid } from "../../components/CustomDataGrid";
import {
DeleteButton,
EditButton,
List,
ShowButton,
useDataGrid,
} from "@refinedev/mui";
import React from "react";
import { MEDIA_TYPES } from "../../lib/constants";
import { observer } from "mobx-react-lite";
import {localeText} from '../../locales/ru/localeText'
import { languageStore, META_LANGUAGE } from '@stores'
import { localeText } from "../../locales/ru/localeText";
import { languageStore, META_LANGUAGE } from "@stores";
export const MediaList = observer(() => {
const { language } = languageStore;
const {dataGridProps} = useDataGrid({
...META_LANGUAGE(language)
})
const { dataGridProps } = useDataGrid({
...META_LANGUAGE(language),
});
const columns = React.useMemo<GridColDef[]>(
() => [
{
field: 'id',
headerName: 'ID',
type: 'number',
field: "id",
headerName: "ID",
type: "number",
minWidth: 350,
display: 'flex',
align: 'left',
headerAlign: 'left',
display: "flex",
align: "left",
headerAlign: "left",
},
{
field: 'filename',
headerName: 'Название файла',
type: 'string',
field: "filename",
headerName: "Название файла",
type: "string",
minWidth: 250,
display: 'flex',
align: 'left',
headerAlign: 'left',
display: "flex",
align: "left",
headerAlign: "left",
},
{
field: 'media_name',
headerName: 'Название',
type: 'string',
field: "media_name",
headerName: "Название",
type: "string",
minWidth: 150,
display: 'flex',
align: 'left',
headerAlign: 'left',
flex: 1,
display: "flex",
align: "left",
headerAlign: "left",
},
{
field: 'media_type',
headerName: 'Тип',
type: 'string',
display: 'flex',
align: 'left',
headerAlign: 'left',
field: "media_type",
headerName: "Тип",
type: "string",
display: "flex",
align: "left",
headerAlign: "left",
flex: 1,
renderCell: (params) => {
const value = params.row.media_type
return MEDIA_TYPES.find((type) => type.value === value)?.label || value
const value = params.row.media_type;
return (
MEDIA_TYPES.find((type) => type.value === value)?.label || value
);
},
},
{
field: 'actions',
headerName: 'Действия',
field: "actions",
headerName: "Действия",
minWidth: 120,
display: 'flex',
align: 'right',
headerAlign: 'center',
display: "flex",
align: "right",
headerAlign: "center",
sortable: false,
filterable: false,
disableColumnMenu: true,
renderCell: function render({row}) {
renderCell: function render({ row }) {
return (
<>
<EditButton hideText recordItemId={row.id} />
<ShowButton hideText recordItemId={row.id} />
<DeleteButton hideText confirmTitle="Вы уверены?" recordItemId={row.id} />
<DeleteButton
hideText
confirmTitle="Вы уверены?"
recordItemId={row.id}
/>
</>
)
);
},
},
],
[],
)
[]
);
return (
<List>
<CustomDataGrid {...dataGridProps} columns={columns} localeText={localeText} getRowId={(row: any) => row.id} languageEnabled/>
<CustomDataGrid
{...dataGridProps}
columns={columns}
localeText={localeText}
getRowId={(row: any) => row.id}
languageEnabled
/>
</List>
)
);
});

View File

@ -60,6 +60,7 @@ export const RouteList = observer(() => {
minWidth: 150,
display: "flex",
align: "left",
flex: 1,
headerAlign: "left",
},
{
@ -68,6 +69,7 @@ export const RouteList = observer(() => {
type: "string",
minWidth: 120,
display: "flex",
align: "left",
headerAlign: "left",
},

View File

@ -782,21 +782,9 @@ export const SightEdit = observer(() => {
bgcolor: "#806c59",
}}
>
<Box
sx={{
mb: 2,
margin: "0 auto 40px auto",
display: "flex",
flexDirection: "column",
maxHeight: "300px",
gap: 2,
}}
>
{leftArticleData?.media && (
<MediaView media={leftArticleData.media} />
)}
</Box>
{leftArticleData?.media && (
<MediaView media={leftArticleData.media} />
)}
{/* Заголовок статьи */}
<Typography
@ -1093,7 +1081,8 @@ export const SightEdit = observer(() => {
width: "30%",
top: "178px",
minHeight: "600px",
maxHeight: "600px",
overflowY: "auto",
right: 50,
zIndex: 1000,
borderRadius: 2,
@ -1246,14 +1235,56 @@ export const SightEdit = observer(() => {
{creatingArticleHeading}
</Typography>
<Typography
variant="body1"
gutterBottom
px={2}
sx={{ color: "text.primary" }}
<Box
sx={{
mt: -6,
p: 2,
"& img": {
maxWidth: "100%",
height: "auto",
borderRadius: 1,
},
"& h1, & h2, & h3, & h4, & h5, & h6": {
color: "primary.main",
mt: 2,
mb: 1,
},
"& p": {
mb: 2,
color: (theme) =>
theme.palette.mode === "dark"
? "grey.300"
: "grey.800",
},
"& a": {
color: "primary.main",
textDecoration: "none",
"&:hover": {
textDecoration: "underline",
},
},
"& blockquote": {
borderLeft: "4px solid",
borderColor: "primary.main",
pl: 2,
my: 2,
color: "text.secondary",
},
"& code": {
bgcolor: (theme) =>
theme.palette.mode === "dark"
? "grey.900"
: "grey.100",
p: 0.5,
borderRadius: 0.5,
color: "primary.main",
},
}}
>
{creatingArticleBody}
</Typography>
<ReactMarkdown rehypePlugins={[rehypeRaw]}>
{creatingArticleBody}
</ReactMarkdown>
</Box>
</Box>
)}
<Box sx={{ mt: "auto" }}>