From fd866e493dd50ff1fecd6bfafc1623cd12b6e04c Mon Sep 17 00:00:00 2001 From: rtrembecky Date: Fri, 8 Dec 2023 17:06:04 +0100 Subject: [PATCH 1/5] expandable TruncatedTextField --- .../Admin/custom/TruncatedTextField.tsx | 23 ++++++++++++++++--- .../competition/CompetitionShow.tsx | 4 ++-- .../competition/series/SeriesShow.tsx | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/components/Admin/custom/TruncatedTextField.tsx b/src/components/Admin/custom/TruncatedTextField.tsx index 8ea3aede..b69f6b97 100644 --- a/src/components/Admin/custom/TruncatedTextField.tsx +++ b/src/components/Admin/custom/TruncatedTextField.tsx @@ -1,16 +1,33 @@ -import {FC} from 'react' +import {Typography} from '@mui/material' +import {FC, useState} from 'react' import {FieldProps, useRecordContext} from 'react-admin' type TruncatedTextFieldProps = FieldProps & { maxTextWidth: number + expandable?: boolean } -export const TruncatedTextField: FC = ({source, maxTextWidth}) => { +export const TruncatedTextField: FC = ({source, maxTextWidth, expandable = false}) => { + const [truncate, setTruncate] = useState(true) + const record = useRecordContext() if (!record || !source) return null const text = record[source] const isString = typeof text === 'string' + const isOverLimit = isString && text.length > maxTextWidth + + const expandableProps = + expandable && isOverLimit + ? { + onClick: () => setTruncate((prev) => !prev), + sx: {cursor: 'pointer'}, + } + : {} - return {isString && text.length > maxTextWidth ? text.slice(0, maxTextWidth - 3) + '...' : text} + return ( + + {isOverLimit && truncate ? text.slice(0, maxTextWidth - 3) + '...' : text} + + ) } diff --git a/src/components/Admin/resources/competition/competition/CompetitionShow.tsx b/src/components/Admin/resources/competition/competition/CompetitionShow.tsx index b022f33b..b5122249 100644 --- a/src/components/Admin/resources/competition/competition/CompetitionShow.tsx +++ b/src/components/Admin/resources/competition/competition/CompetitionShow.tsx @@ -25,8 +25,8 @@ export const CompetitionShow: FC = () => ( - - + + diff --git a/src/components/Admin/resources/competition/series/SeriesShow.tsx b/src/components/Admin/resources/competition/series/SeriesShow.tsx index 76a10161..48ff0081 100644 --- a/src/components/Admin/resources/competition/series/SeriesShow.tsx +++ b/src/components/Admin/resources/competition/series/SeriesShow.tsx @@ -33,7 +33,7 @@ export const SeriesShow: FC = () => ( - + From 32ef68101e227f14e7bc39e5a9d6ca6bbdc130fb Mon Sep 17 00:00:00 2001 From: rtrembecky Date: Fri, 8 Dec 2023 20:46:16 +0100 Subject: [PATCH 2/5] flatpage management --- src/components/Admin/Admin.tsx | 11 ++++++++++ .../base/flat-page/FlatpageCreate.tsx | 17 ++++++++++++++++ .../resources/base/flat-page/FlatpageEdit.tsx | 17 ++++++++++++++++ .../resources/base/flat-page/FlatpageList.tsx | 19 ++++++++++++++++++ .../resources/base/flat-page/FlatpageShow.tsx | 20 +++++++++++++++++++ 5 files changed, 84 insertions(+) create mode 100644 src/components/Admin/resources/base/flat-page/FlatpageCreate.tsx create mode 100644 src/components/Admin/resources/base/flat-page/FlatpageEdit.tsx create mode 100644 src/components/Admin/resources/base/flat-page/FlatpageList.tsx create mode 100644 src/components/Admin/resources/base/flat-page/FlatpageShow.tsx diff --git a/src/components/Admin/Admin.tsx b/src/components/Admin/Admin.tsx index 5d7f77d3..76d8b64e 100644 --- a/src/components/Admin/Admin.tsx +++ b/src/components/Admin/Admin.tsx @@ -2,6 +2,10 @@ import {FC} from 'react' import {Admin as ReactAdmin, Resource} from 'react-admin' import {dataProvider} from './dataProvider' +import {FlatpageCreate} from './resources/base/flat-page/FlatpageCreate' +import {FlatpageEdit} from './resources/base/flat-page/FlatpageEdit' +import {FlatpageList} from './resources/base/flat-page/FlatpageList' +import {FlatpageShow} from './resources/base/flat-page/FlatpageShow' import {PostCreate} from './resources/cms/post/PostCreate' import {PostEdit} from './resources/cms/post/PostEdit' import {PostList} from './resources/cms/post/PostList' @@ -34,6 +38,13 @@ export const Admin: FC = () => { show={CompetitionShow} create={CompetitionCreate} /> + ) } diff --git a/src/components/Admin/resources/base/flat-page/FlatpageCreate.tsx b/src/components/Admin/resources/base/flat-page/FlatpageCreate.tsx new file mode 100644 index 00000000..781ba469 --- /dev/null +++ b/src/components/Admin/resources/base/flat-page/FlatpageCreate.tsx @@ -0,0 +1,17 @@ +import {FC} from 'react' +import {NumberInput, required, SimpleForm, TextInput} from 'react-admin' + +import {MyCreate} from '@/components/Admin/custom/MyCreate' +import {SitesCheckboxInput} from '@/components/Admin/custom/SitesCheckboxInput' + +export const FlatpageCreate: FC = () => ( + + + + + + + + + +) diff --git a/src/components/Admin/resources/base/flat-page/FlatpageEdit.tsx b/src/components/Admin/resources/base/flat-page/FlatpageEdit.tsx new file mode 100644 index 00000000..01071f6a --- /dev/null +++ b/src/components/Admin/resources/base/flat-page/FlatpageEdit.tsx @@ -0,0 +1,17 @@ +import {FC} from 'react' +import {NumberInput, required, SimpleForm, TextInput} from 'react-admin' + +import {MyEdit} from '@/components/Admin/custom/MyEdit' +import {SitesCheckboxInput} from '@/components/Admin/custom/SitesCheckboxInput' + +export const FlatpageEdit: FC = () => ( + + + + + + + + + +) diff --git a/src/components/Admin/resources/base/flat-page/FlatpageList.tsx b/src/components/Admin/resources/base/flat-page/FlatpageList.tsx new file mode 100644 index 00000000..bc27333d --- /dev/null +++ b/src/components/Admin/resources/base/flat-page/FlatpageList.tsx @@ -0,0 +1,19 @@ +import {FC} from 'react' +import {BooleanField, Datagrid, List, NumberField, TextField} from 'react-admin' + +import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField' +import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' + +export const FlatpageList: FC = () => ( + + + + + + + + + + + +) diff --git a/src/components/Admin/resources/base/flat-page/FlatpageShow.tsx b/src/components/Admin/resources/base/flat-page/FlatpageShow.tsx new file mode 100644 index 00000000..c77e1bc9 --- /dev/null +++ b/src/components/Admin/resources/base/flat-page/FlatpageShow.tsx @@ -0,0 +1,20 @@ +import {FC} from 'react' +import {BooleanField, NumberField, Show, SimpleShowLayout, TextField} from 'react-admin' + +import {MyShowActions} from '@/components/Admin/custom/MyShowActions' +import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField' +import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' + +export const FlatpageShow: FC = () => ( + }> + + + + + + + + + + +) From 255661a122da8b08c9eca2fa96691c4061c4d397 Mon Sep 17 00:00:00 2001 From: rtrembecky Date: Sat, 9 Dec 2023 01:42:03 +0100 Subject: [PATCH 3/5] multiline inputs --- .../Admin/resources/base/flat-page/FlatpageCreate.tsx | 2 +- src/components/Admin/resources/base/flat-page/FlatpageEdit.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Admin/resources/base/flat-page/FlatpageCreate.tsx b/src/components/Admin/resources/base/flat-page/FlatpageCreate.tsx index 781ba469..94947837 100644 --- a/src/components/Admin/resources/base/flat-page/FlatpageCreate.tsx +++ b/src/components/Admin/resources/base/flat-page/FlatpageCreate.tsx @@ -10,7 +10,7 @@ export const FlatpageCreate: FC = () => ( - + diff --git a/src/components/Admin/resources/base/flat-page/FlatpageEdit.tsx b/src/components/Admin/resources/base/flat-page/FlatpageEdit.tsx index 01071f6a..fd0420b8 100644 --- a/src/components/Admin/resources/base/flat-page/FlatpageEdit.tsx +++ b/src/components/Admin/resources/base/flat-page/FlatpageEdit.tsx @@ -10,7 +10,7 @@ export const FlatpageEdit: FC = () => ( - + From 433a6b8c4852e96853df9d07fc5e54430aacf61f Mon Sep 17 00:00:00 2001 From: rtrembecky Date: Sat, 9 Dec 2023 02:29:19 +0100 Subject: [PATCH 4/5] multiline inputs for posts --- src/components/Admin/resources/cms/post/PostCreate.tsx | 2 +- src/components/Admin/resources/cms/post/PostEdit.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Admin/resources/cms/post/PostCreate.tsx b/src/components/Admin/resources/cms/post/PostCreate.tsx index 36798b4c..033a6336 100644 --- a/src/components/Admin/resources/cms/post/PostCreate.tsx +++ b/src/components/Admin/resources/cms/post/PostCreate.tsx @@ -20,7 +20,7 @@ export const PostCreate: FC = () => ( - + diff --git a/src/components/Admin/resources/cms/post/PostEdit.tsx b/src/components/Admin/resources/cms/post/PostEdit.tsx index 4d8d3215..414e938e 100644 --- a/src/components/Admin/resources/cms/post/PostEdit.tsx +++ b/src/components/Admin/resources/cms/post/PostEdit.tsx @@ -20,7 +20,7 @@ export const PostEdit: FC = () => ( - + From 4ae0315f5c9d1df331f28600d096f97a23da1d31 Mon Sep 17 00:00:00 2001 From: rtrembecky Date: Sat, 9 Dec 2023 11:19:15 +0100 Subject: [PATCH 5/5] remove unnecessary boolean pages --- .../Admin/resources/base/flat-page/FlatpageList.tsx | 4 +--- .../Admin/resources/base/flat-page/FlatpageShow.tsx | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/components/Admin/resources/base/flat-page/FlatpageList.tsx b/src/components/Admin/resources/base/flat-page/FlatpageList.tsx index bc27333d..c0245ddc 100644 --- a/src/components/Admin/resources/base/flat-page/FlatpageList.tsx +++ b/src/components/Admin/resources/base/flat-page/FlatpageList.tsx @@ -1,5 +1,5 @@ import {FC} from 'react' -import {BooleanField, Datagrid, List, NumberField, TextField} from 'react-admin' +import {Datagrid, List, NumberField, TextField} from 'react-admin' import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField' import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' @@ -11,8 +11,6 @@ export const FlatpageList: FC = () => ( - - diff --git a/src/components/Admin/resources/base/flat-page/FlatpageShow.tsx b/src/components/Admin/resources/base/flat-page/FlatpageShow.tsx index c77e1bc9..1e4a6b1f 100644 --- a/src/components/Admin/resources/base/flat-page/FlatpageShow.tsx +++ b/src/components/Admin/resources/base/flat-page/FlatpageShow.tsx @@ -1,5 +1,5 @@ import {FC} from 'react' -import {BooleanField, NumberField, Show, SimpleShowLayout, TextField} from 'react-admin' +import {NumberField, Show, SimpleShowLayout, TextField} from 'react-admin' import {MyShowActions} from '@/components/Admin/custom/MyShowActions' import {SitesArrayField} from '@/components/Admin/custom/SitesArrayField' @@ -12,8 +12,6 @@ export const FlatpageShow: FC = () => ( - -