refactor: replace timezone Select with Autocomplete
- Replace timezone Select field with Autocomplete in EventModal and EventFormFields - Add search functionality for timezones with text input - Add timezone icon to match PeopleSearch component style - Remove 'Mark as important' checkbox from EventModal (re showup when rebase) - Remove gap space in description when desc field show up
This commit is contained in:
committed by
Benoit TELLIER
parent
adbb77fe8a
commit
2ab7c448bf
@@ -14,6 +14,7 @@ import {
|
|||||||
Typography,
|
Typography,
|
||||||
ToggleButtonGroup,
|
ToggleButtonGroup,
|
||||||
ToggleButton,
|
ToggleButton,
|
||||||
|
Autocomplete,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import {
|
import {
|
||||||
Description as DescriptionIcon,
|
Description as DescriptionIcon,
|
||||||
@@ -22,6 +23,7 @@ import {
|
|||||||
CameraAlt as VideocamIcon,
|
CameraAlt as VideocamIcon,
|
||||||
ContentCopy as CopyIcon,
|
ContentCopy as CopyIcon,
|
||||||
Close as DeleteIcon,
|
Close as DeleteIcon,
|
||||||
|
PublicOutlined as TimezoneIcon,
|
||||||
} from "@mui/icons-material";
|
} from "@mui/icons-material";
|
||||||
import AttendeeSelector from "../Attendees/AttendeeSearch";
|
import AttendeeSelector from "../Attendees/AttendeeSearch";
|
||||||
import RepeatEvent from "./EventRepeat";
|
import RepeatEvent from "./EventRepeat";
|
||||||
@@ -261,22 +263,23 @@ export default function EventFormFields({
|
|||||||
/>
|
/>
|
||||||
</FieldWithLabel>
|
</FieldWithLabel>
|
||||||
|
|
||||||
<FieldWithLabel label=" " isExpanded={showMore}>
|
{!showDescription && (
|
||||||
<Box display="flex" gap={1} mb={1}>
|
<FieldWithLabel label=" " isExpanded={showMore}>
|
||||||
<Button
|
<Box display="flex" gap={1} mb={1}>
|
||||||
startIcon={<DescriptionIcon />}
|
<Button
|
||||||
onClick={() => setShowDescription(true)}
|
startIcon={<DescriptionIcon />}
|
||||||
size="small"
|
onClick={() => setShowDescription(true)}
|
||||||
sx={{
|
size="small"
|
||||||
textTransform: "none",
|
sx={{
|
||||||
color: "text.secondary",
|
textTransform: "none",
|
||||||
display: showDescription ? "none" : "flex",
|
color: "text.secondary",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Add description
|
Add description
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</FieldWithLabel>
|
</FieldWithLabel>
|
||||||
|
)}
|
||||||
|
|
||||||
{showDescription && (
|
{showDescription && (
|
||||||
<FieldWithLabel label="Description" isExpanded={showMore}>
|
<FieldWithLabel label="Description" isExpanded={showMore}>
|
||||||
@@ -404,19 +407,47 @@ export default function EventFormFields({
|
|||||||
}
|
}
|
||||||
label="Repeat"
|
label="Repeat"
|
||||||
/>
|
/>
|
||||||
<FormControl size="small" sx={{ width: 160 }}>
|
<Autocomplete
|
||||||
<Select
|
value={timezone}
|
||||||
value={timezone}
|
options={timezoneList.zones}
|
||||||
onChange={(e: SelectChangeEvent) => setTimezone(e.target.value)}
|
size="small"
|
||||||
displayEmpty
|
sx={{ width: 240 }}
|
||||||
>
|
getOptionLabel={(option) =>
|
||||||
{timezoneList.zones.map((tz) => (
|
`(${timezoneList.getTimezoneOffset(option)}) ${option.replace(/_/g, " ")}`
|
||||||
<MenuItem key={tz} value={tz}>
|
}
|
||||||
({timezoneList.getTimezoneOffset(tz)}) {tz.replace(/_/g, " ")}
|
onChange={(event, newValue) => {
|
||||||
</MenuItem>
|
if (newValue) {
|
||||||
))}
|
setTimezone(newValue);
|
||||||
</Select>
|
}
|
||||||
</FormControl>
|
}}
|
||||||
|
renderInput={(params) => (
|
||||||
|
<TextField
|
||||||
|
{...params}
|
||||||
|
placeholder="Select timezone"
|
||||||
|
autoComplete="off"
|
||||||
|
slotProps={{
|
||||||
|
input: {
|
||||||
|
...params.InputProps,
|
||||||
|
startAdornment: (
|
||||||
|
<>
|
||||||
|
<TimezoneIcon
|
||||||
|
style={{
|
||||||
|
marginRight: 8,
|
||||||
|
color: "rgba(0, 0, 0, 0.54)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{params.InputProps.startAdornment}
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
inputProps={{
|
||||||
|
...params.inputProps,
|
||||||
|
autoComplete: "new-password",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</FieldWithLabel>
|
</FieldWithLabel>
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
Typography,
|
Typography,
|
||||||
ToggleButtonGroup,
|
ToggleButtonGroup,
|
||||||
ToggleButton,
|
ToggleButton,
|
||||||
|
Autocomplete,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import {
|
import {
|
||||||
Description as DescriptionIcon,
|
Description as DescriptionIcon,
|
||||||
@@ -20,6 +21,7 @@ import {
|
|||||||
CameraAlt as VideocamIcon,
|
CameraAlt as VideocamIcon,
|
||||||
ContentCopy as CopyIcon,
|
ContentCopy as CopyIcon,
|
||||||
Close as DeleteIcon,
|
Close as DeleteIcon,
|
||||||
|
PublicOutlined as TimezoneIcon,
|
||||||
} from "@mui/icons-material";
|
} from "@mui/icons-material";
|
||||||
import { Box, Button } from "@mui/material";
|
import { Box, Button } from "@mui/material";
|
||||||
import AddIcon from "@mui/icons-material/Add";
|
import AddIcon from "@mui/icons-material/Add";
|
||||||
@@ -184,7 +186,6 @@ function EventPopover({
|
|||||||
const [alarm, setAlarm] = useState(event?.alarm?.trigger ?? "");
|
const [alarm, setAlarm] = useState(event?.alarm?.trigger ?? "");
|
||||||
const [eventClass, setEventClass] = useState(event?.class ?? "PUBLIC");
|
const [eventClass, setEventClass] = useState(event?.class ?? "PUBLIC");
|
||||||
const [busy, setBusy] = useState(event?.transp ?? "OPAQUE");
|
const [busy, setBusy] = useState(event?.transp ?? "OPAQUE");
|
||||||
const [important, setImportant] = useState(false);
|
|
||||||
const [timezone, setTimezone] = useState(
|
const [timezone, setTimezone] = useState(
|
||||||
event?.timezone ? resolveTimezone(event.timezone) : calendarTimezone
|
event?.timezone ? resolveTimezone(event.timezone) : calendarTimezone
|
||||||
);
|
);
|
||||||
@@ -220,7 +221,6 @@ function EventPopover({
|
|||||||
setAlarm("");
|
setAlarm("");
|
||||||
setEventClass("PUBLIC");
|
setEventClass("PUBLIC");
|
||||||
setBusy("OPAQUE");
|
setBusy("OPAQUE");
|
||||||
setImportant(false);
|
|
||||||
setTimezone(calendarTimezone);
|
setTimezone(calendarTimezone);
|
||||||
setHasVideoConference(false);
|
setHasVideoConference(false);
|
||||||
setMeetingLink(null);
|
setMeetingLink(null);
|
||||||
@@ -308,7 +308,6 @@ function EventPopover({
|
|||||||
setAlarm("");
|
setAlarm("");
|
||||||
setEventClass("PUBLIC");
|
setEventClass("PUBLIC");
|
||||||
setBusy("OPAQUE");
|
setBusy("OPAQUE");
|
||||||
setImportant(false);
|
|
||||||
setTimezone(timezoneList.browserTz);
|
setTimezone(timezoneList.browserTz);
|
||||||
setHasVideoConference(false);
|
setHasVideoConference(false);
|
||||||
setMeetingLink(null);
|
setMeetingLink(null);
|
||||||
@@ -454,22 +453,23 @@ function EventPopover({
|
|||||||
/>
|
/>
|
||||||
</FieldWithLabel>
|
</FieldWithLabel>
|
||||||
|
|
||||||
<FieldWithLabel label=" " isExpanded={showMore}>
|
{!showDescription && (
|
||||||
<Box display="flex" gap={1} mb={1}>
|
<FieldWithLabel label=" " isExpanded={showMore}>
|
||||||
<Button
|
<Box display="flex" gap={1} mb={1}>
|
||||||
startIcon={<DescriptionIcon />}
|
<Button
|
||||||
onClick={() => setShowDescription(true)}
|
startIcon={<DescriptionIcon />}
|
||||||
size="small"
|
onClick={() => setShowDescription(true)}
|
||||||
sx={{
|
size="small"
|
||||||
textTransform: "none",
|
sx={{
|
||||||
color: "text.secondary",
|
textTransform: "none",
|
||||||
display: showDescription ? "none" : "flex",
|
color: "text.secondary",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Add description
|
Add description
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</FieldWithLabel>
|
</FieldWithLabel>
|
||||||
|
)}
|
||||||
|
|
||||||
{showDescription && (
|
{showDescription && (
|
||||||
<FieldWithLabel label="Description" isExpanded={showMore}>
|
<FieldWithLabel label="Description" isExpanded={showMore}>
|
||||||
@@ -558,15 +558,6 @@ function EventPopover({
|
|||||||
</FieldWithLabel>
|
</FieldWithLabel>
|
||||||
<FieldWithLabel label=" " isExpanded={showMore}>
|
<FieldWithLabel label=" " isExpanded={showMore}>
|
||||||
<Box display="flex" gap={2} alignItems="center">
|
<Box display="flex" gap={2} alignItems="center">
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={important}
|
|
||||||
onChange={() => setImportant(!important)}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Mark as important"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
@@ -629,19 +620,47 @@ function EventPopover({
|
|||||||
}
|
}
|
||||||
label="Repeat"
|
label="Repeat"
|
||||||
/>
|
/>
|
||||||
<FormControl size="small" sx={{ width: 160 }}>
|
<Autocomplete
|
||||||
<Select
|
value={timezone}
|
||||||
value={timezone}
|
options={timezoneList.zones}
|
||||||
onChange={(e: SelectChangeEvent) => setTimezone(e.target.value)}
|
size="small"
|
||||||
displayEmpty
|
sx={{ width: 240 }}
|
||||||
>
|
getOptionLabel={(option) =>
|
||||||
{timezoneList.zones.map((tz) => (
|
`(${getTimezoneOffset(option)}) ${option.replace(/_/g, " ")}`
|
||||||
<MenuItem key={tz} value={tz}>
|
}
|
||||||
({getTimezoneOffset(tz)}) {tz.replace(/_/g, " ")}
|
onChange={(event, newValue) => {
|
||||||
</MenuItem>
|
if (newValue) {
|
||||||
))}
|
setTimezone(newValue);
|
||||||
</Select>
|
}
|
||||||
</FormControl>
|
}}
|
||||||
|
renderInput={(params) => (
|
||||||
|
<TextField
|
||||||
|
{...params}
|
||||||
|
placeholder="Select timezone"
|
||||||
|
autoComplete="off"
|
||||||
|
slotProps={{
|
||||||
|
input: {
|
||||||
|
...params.InputProps,
|
||||||
|
startAdornment: (
|
||||||
|
<>
|
||||||
|
<TimezoneIcon
|
||||||
|
style={{
|
||||||
|
marginRight: 8,
|
||||||
|
color: "rgba(0, 0, 0, 0.54)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{params.InputProps.startAdornment}
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
inputProps={{
|
||||||
|
...params.inputProps,
|
||||||
|
autoComplete: "new-password",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</FieldWithLabel>
|
</FieldWithLabel>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user