Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -31,7 +31,7 @@ export function ImportTab({
|
||||
name: string;
|
||||
setName: Function;
|
||||
description: string;
|
||||
setDescription: Function;
|
||||
setDescription: (d: string) => void;
|
||||
color: Record<string, string>;
|
||||
setColor: Function;
|
||||
visibility: "public" | "private";
|
||||
|
||||
@@ -13,6 +13,7 @@ import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useAppSelector } from "../../app/hooks";
|
||||
import { Calendars } from "../../features/Calendars/CalendarTypes";
|
||||
import { AddDescButton } from "../Event/AddDescButton";
|
||||
import { ColorPicker } from "./CalendarColorPicker";
|
||||
|
||||
export function SettingsTab({
|
||||
@@ -29,7 +30,7 @@ export function SettingsTab({
|
||||
name: string;
|
||||
setName: Function;
|
||||
description: string;
|
||||
setDescription: Function;
|
||||
setDescription: (d: string) => void;
|
||||
color: Record<string, string>;
|
||||
setColor: Function;
|
||||
visibility: "public" | "private";
|
||||
@@ -57,29 +58,13 @@ export function SettingsTab({
|
||||
margin="dense"
|
||||
/>
|
||||
|
||||
{!toggleDesc && (
|
||||
<Button
|
||||
variant="outlined"
|
||||
size="small"
|
||||
onClick={() => setToggleDesc(!toggleDesc)}
|
||||
startIcon={<FormatListBulletedIcon />}
|
||||
>
|
||||
{t("calendar.addDescription")}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{toggleDesc && (
|
||||
<TextField
|
||||
fullWidth
|
||||
label={t("common.description")}
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
size="small"
|
||||
margin="dense"
|
||||
multiline
|
||||
rows={2}
|
||||
/>
|
||||
)}
|
||||
<AddDescButton
|
||||
showDescription={toggleDesc}
|
||||
setShowDescription={setToggleDesc}
|
||||
showMore={false}
|
||||
description={description}
|
||||
setDescription={setDescription}
|
||||
/>
|
||||
|
||||
<Box mt={2}>
|
||||
<Typography variant="body2" gutterBottom>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Box, Button, TextField } from "@mui/material";
|
||||
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
||||
import { FieldWithLabel } from "./components/FieldWithLabel";
|
||||
import { Description as DescriptionIcon } from "@mui/icons-material";
|
||||
|
||||
export function AddDescButton({
|
||||
showDescription,
|
||||
setShowDescription,
|
||||
showMore,
|
||||
description,
|
||||
setDescription,
|
||||
}: {
|
||||
showDescription: boolean;
|
||||
setShowDescription: (b: boolean) => void;
|
||||
showMore: boolean;
|
||||
description: string;
|
||||
setDescription: (d: string) => void;
|
||||
}) {
|
||||
const { t } = useI18n();
|
||||
return (
|
||||
<>
|
||||
{!showDescription && (
|
||||
<FieldWithLabel label=" " isExpanded={showMore}>
|
||||
<Box display="flex" gap={1} mb={1}>
|
||||
<Button
|
||||
startIcon={<DescriptionIcon />}
|
||||
onClick={() => setShowDescription(true)}
|
||||
size="small"
|
||||
sx={{
|
||||
textTransform: "none",
|
||||
color: "text.secondary",
|
||||
}}
|
||||
>
|
||||
{t("event.form.addDescription")}
|
||||
</Button>
|
||||
</Box>
|
||||
</FieldWithLabel>
|
||||
)}
|
||||
{showDescription && (
|
||||
<FieldWithLabel
|
||||
label={t("event.form.description")}
|
||||
isExpanded={showMore}
|
||||
>
|
||||
<TextField
|
||||
fullWidth
|
||||
label={!showMore ? t("event.form.description") : ""}
|
||||
placeholder={t("event.form.descriptionPlaceholder")}
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
size="small"
|
||||
margin="dense"
|
||||
multiline
|
||||
minRows={2}
|
||||
maxRows={10}
|
||||
sx={{
|
||||
"& .MuiInputBase-root": {
|
||||
maxHeight: "33%",
|
||||
overflowY: "auto",
|
||||
},
|
||||
"& textarea": {
|
||||
resize: "vertical",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</FieldWithLabel>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -42,6 +42,7 @@ import {} from "./utils/dateRules";
|
||||
import {} from "./utils/dateTimeFormatters";
|
||||
import { validateEventForm } from "./utils/formValidation";
|
||||
import { SnackbarAlert } from "../Loading/SnackBarAlert";
|
||||
import { AddDescButton } from "./AddDescButton";
|
||||
|
||||
interface EventFormFieldsProps {
|
||||
// Form state
|
||||
@@ -424,52 +425,13 @@ export default function EventFormFields({
|
||||
/>
|
||||
</FieldWithLabel>
|
||||
|
||||
{!showDescription && (
|
||||
<FieldWithLabel label=" " isExpanded={showMore}>
|
||||
<Box display="flex" gap={1} mb={1}>
|
||||
<Button
|
||||
startIcon={<DescriptionIcon />}
|
||||
onClick={() => setShowDescription(true)}
|
||||
size="small"
|
||||
sx={{
|
||||
textTransform: "none",
|
||||
color: "text.secondary",
|
||||
}}
|
||||
>
|
||||
{t("event.form.addDescription")}
|
||||
</Button>
|
||||
</Box>
|
||||
</FieldWithLabel>
|
||||
)}
|
||||
|
||||
{showDescription && (
|
||||
<FieldWithLabel
|
||||
label={t("event.form.description")}
|
||||
isExpanded={showMore}
|
||||
>
|
||||
<TextField
|
||||
fullWidth
|
||||
label={!showMore ? t("event.form.description") : ""}
|
||||
placeholder={t("event.form.descriptionPlaceholder")}
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
size="small"
|
||||
margin="dense"
|
||||
multiline
|
||||
minRows={2}
|
||||
maxRows={10}
|
||||
sx={{
|
||||
"& .MuiInputBase-root": {
|
||||
maxHeight: "33%",
|
||||
overflowY: "auto",
|
||||
},
|
||||
"& textarea": {
|
||||
resize: "vertical",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</FieldWithLabel>
|
||||
)}
|
||||
<AddDescButton
|
||||
showDescription={showDescription}
|
||||
setShowDescription={setShowDescription}
|
||||
showMore={showMore}
|
||||
description={description}
|
||||
setDescription={setDescription}
|
||||
/>
|
||||
|
||||
<FieldWithLabel label={t("event.form.dateTime")} isExpanded={showMore}>
|
||||
<DateTimeFields
|
||||
|
||||
Reference in New Issue
Block a user