From 97817f97c10a88a42b6c1f8617c3cd1deca774de Mon Sep 17 00:00:00 2001 From: AlasDiablo <25723276+AlasDiablo@users.noreply.github.com> Date: Thu, 18 Jul 2024 13:16:59 +0200 Subject: [PATCH] feat: make selectionnable the size of the markdown modal --- src/app/custom/translations.tsv | 2 + .../text/markdown/modal/MarkdownModalAdmin.js | 49 ++++++++++++++++- .../text/markdown/modal/MarkdownModalView.js | 53 +++++++++++++++++-- 3 files changed, 98 insertions(+), 6 deletions(-) diff --git a/src/app/custom/translations.tsv b/src/app/custom/translations.tsv index 84d63585c..098c92a73 100644 --- a/src/app/custom/translations.tsv +++ b/src/app/custom/translations.tsv @@ -1102,3 +1102,5 @@ "routine_arg" "Field N°" "Champ N°" "routine_arg_add" "Add a new field" "Ajouter un nouveau champ" "routine_arg_delete" "Delete this field" "Supprimer ce champ" +"label_format_fullscreen" "Full screen" "plein écran" +"label_format_size" "Size" "Taille" diff --git a/src/app/js/formats/text/markdown/modal/MarkdownModalAdmin.js b/src/app/js/formats/text/markdown/modal/MarkdownModalAdmin.js index 760653c72..b13f263a3 100644 --- a/src/app/js/formats/text/markdown/modal/MarkdownModalAdmin.js +++ b/src/app/js/formats/text/markdown/modal/MarkdownModalAdmin.js @@ -3,17 +3,22 @@ import translate from 'redux-polyglot/translate'; import PropTypes from 'prop-types'; import { polyglot as polyglotPropTypes } from '../../../../propTypes'; import { FormatDefaultParamsFieldSet } from '../../../utils/components/field-set/FormatFieldSets'; -import { MenuItem, TextField } from '@mui/material'; +import TextField from '@mui/material/TextField'; import FormatGroupedFieldSet from '../../../utils/components/field-set/FormatGroupedFieldSet'; +import MenuItem from '@mui/material/MenuItem'; +import FormControlLabel from '@mui/material/FormControlLabel'; +import Switch from '@mui/material/Switch'; export const defaultArgs = { type: 'text', label: '', + fullScreen: false, + maxWidth: 'sm', }; const MarkdownModalAdmin = (props) => { const { args, p, onChange } = props; - const { type, label } = args; + const { type, label, fullScreen, maxWidth } = args; const handleType = (event) => { onChange({ @@ -29,6 +34,20 @@ const MarkdownModalAdmin = (props) => { }); }; + const handleFullScreen = (_, newFullScreen) => { + onChange({ + ...args, + fullScreen: newFullScreen, + }); + }; + + const handleSize = (event) => { + onChange({ + ...args, + maxWidth: event.target.value, + }); + }; + return ( @@ -56,6 +75,30 @@ const MarkdownModalAdmin = (props) => { onChange={handleLabel} value={label} /> + + } + label={p.t('label_format_fullscreen')} + /> + {!fullScreen ? ( + + xs + sm + md + lg + xl + + ) : null} ); @@ -65,6 +108,8 @@ MarkdownModalAdmin.propTypes = { args: PropTypes.shape({ type: PropTypes.oneOf(['text', 'column']), label: PropTypes.string, + fullScreen: PropTypes.bool, + maxWidth: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), }), onChange: PropTypes.func.isRequired, p: polyglotPropTypes.isRequired, diff --git a/src/app/js/formats/text/markdown/modal/MarkdownModalView.js b/src/app/js/formats/text/markdown/modal/MarkdownModalView.js index b1a51bcf3..62654e762 100644 --- a/src/app/js/formats/text/markdown/modal/MarkdownModalView.js +++ b/src/app/js/formats/text/markdown/modal/MarkdownModalView.js @@ -5,6 +5,7 @@ import Dialog from '@mui/material/Dialog'; import DialogTitle from '@mui/material/DialogTitle'; import DialogContent from '@mui/material/DialogContent'; import IconButton from '@mui/material/IconButton'; +import Container from '@mui/material/Container'; import CloseIcon from '@mui/icons-material/Close'; import PropTypes from 'prop-types'; @@ -21,6 +22,8 @@ const MarkdownModalView = ({ fields, type, label, + fullScreen, + maxWidth, }) => { const [open, setOpen] = useState(false); @@ -49,10 +52,41 @@ const MarkdownModalView = ({ return ; } - return ( -
- - + const CustomDialog = () => { + if (fullScreen) { + return ( + + {buttonLabel} + + + + + +
+
+
+
+ ); + } + + return ( + {buttonLabel}
+ ); + }; + + return ( +
+ +
); }; @@ -81,6 +124,8 @@ MarkdownModalView.propTypes = { resource: PropTypes.object.isRequired, type: PropTypes.oneOf(['text', 'column']), label: PropTypes.string.isRequired, + fullScreen: PropTypes.bool, + maxWidth: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), }; MarkdownModalView.defaultProps = {