Merge pull request #796 from lethemanh/788-mobile-adapt-for-more-options-button

#788 mobile adapt for more options button
This commit is contained in:
lethemanh
2026-04-16 14:35:46 +07:00
committed by GitHub
3 changed files with 56 additions and 29 deletions
+2 -2
View File
@@ -79,8 +79,8 @@ interface EventFormFieldsProps {
setAlarm: (alarm: string) => void setAlarm: (alarm: string) => void
busy: string busy: string
setBusy: (busy: string) => void setBusy: (busy: string) => void
eventClass: string eventClass: 'PUBLIC' | 'PRIVATE' | 'CONFIDENTIAL'
setEventClass: (eventClass: string) => void setEventClass: (eventClass: 'PUBLIC' | 'PRIVATE' | 'CONFIDENTIAL') => void
timezone: string timezone: string
setTimezone: (timezone: string) => void setTimezone: (timezone: string) => void
calendarid: string calendarid: string
+51 -24
View File
@@ -45,16 +45,9 @@ import { CalendarEvent, RepetitionObject } from './EventsTypes'
import { moveEventBetweenCalendars } from './updateEventHelpers/moveEventBetweenCalendars' import { moveEventBetweenCalendars } from './updateEventHelpers/moveEventBetweenCalendars'
import { detectRecurringEventChanges } from './utils/detectRecurringEventChanges' import { detectRecurringEventChanges } from './utils/detectRecurringEventChanges'
import { Resource } from '@/components/Attendees/ResourceSearch' import { Resource } from '@/components/Attendees/ResourceSearch'
import { useScreenSizeDetection } from '@/useScreenSizeDetection'
function EventUpdateModal({ const EventUpdateModal: React.FC<{
eventId,
calId,
open,
onClose,
onCloseAll,
eventData,
typeOfAction
}: {
eventId: string eventId: string
calId: string calId: string
open: boolean open: boolean
@@ -62,8 +55,17 @@ function EventUpdateModal({
onCloseAll?: () => void onCloseAll?: () => void
eventData?: CalendarEvent | null eventData?: CalendarEvent | null
typeOfAction?: 'solo' | 'all' typeOfAction?: 'solo' | 'all'
}) { }> = ({
eventId,
calId,
open,
onClose,
onCloseAll,
eventData,
typeOfAction
}) => {
const { t } = useI18n() const { t } = useI18n()
const { isTooSmall: isMobile } = useScreenSizeDetection()
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const calList = useAppSelector(state => state.calendars.list) const calList = useAppSelector(state => state.calendars.list)
// Get event from Redux store (cached data) as fallback // Get event from Redux store (cached data) as fallback
@@ -121,7 +123,9 @@ function EventUpdateModal({
) )
const [alarm, setAlarm] = useState('') const [alarm, setAlarm] = useState('')
const [busy, setBusy] = useState('OPAQUE') const [busy, setBusy] = useState('OPAQUE')
const [eventClass, setEventClass] = useState('PUBLIC') const [eventClass, setEventClass] = useState<
'PUBLIC' | 'PRIVATE' | 'CONFIDENTIAL'
>('PUBLIC')
const [timezone, setTimezone] = useState( const [timezone, setTimezone] = useState(
resolveTimezone(browserDefaultTimeZone) resolveTimezone(browserDefaultTimeZone)
) )
@@ -196,7 +200,7 @@ function EventUpdateModal({
} }
// Fetch the master event // Fetch the master event
const fetchMasterEvent = async () => { const fetchMasterEvent = async (): Promise<void> => {
setIsLoadingMasterEvent(true) setIsLoadingMasterEvent(true)
try { try {
const masterEventToFetch = { const masterEventToFetch = {
@@ -214,7 +218,7 @@ function EventUpdateModal({
} }
} }
fetchMasterEvent() void fetchMasterEvent()
}, [event, open, typeOfAction]) }, [event, open, typeOfAction])
// Initialize form state when event data is available // Initialize form state when event data is available
@@ -371,7 +375,7 @@ function EventUpdateModal({
]) ])
// Helper to close modal(s) - use onCloseAll if available to close preview modal too // Helper to close modal(s) - use onCloseAll if available to close preview modal too
const closeModal = () => { const closeModal = (): void => {
if (onCloseAll) { if (onCloseAll) {
onCloseAll() onCloseAll()
} else { } else {
@@ -379,7 +383,7 @@ function EventUpdateModal({
} }
} }
const handleClose = () => { const handleClose = (): void => {
// Clear temp data when user manually closes modal // Clear temp data when user manually closes modal
clearEventFormTempData('update') clearEventFormTempData('update')
closeModal() closeModal()
@@ -494,7 +498,7 @@ function EventUpdateModal({
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [open, eventId, calId, typeOfAction]) }, [open, eventId, calId, typeOfAction])
const handleSave = async () => { const handleSave = async (): Promise<void> => {
// Show validation errors when Save is clicked // Show validation errors when Save is clicked
setShowValidationErrors(true) setShowValidationErrors(true)
@@ -678,7 +682,7 @@ function EventUpdateModal({
let hasRemovedSeriesInstances = false let hasRemovedSeriesInstances = false
let createdSingleEventUid: string | null = null let createdSingleEventUid: string | null = null
const removeSeriesInstancesFromUI = () => { const removeSeriesInstancesFromUI = (): void => {
if (!seriesInstancesSnapshot) return if (!seriesInstancesSnapshot) return
Object.keys(seriesInstancesSnapshot).forEach(eventId => { Object.keys(seriesInstancesSnapshot).forEach(eventId => {
dispatch(removeEvent({ calendarUid: calId, eventUid: eventId })) dispatch(removeEvent({ calendarUid: calId, eventUid: eventId }))
@@ -686,7 +690,7 @@ function EventUpdateModal({
hasRemovedSeriesInstances = true hasRemovedSeriesInstances = true
} }
const restoreSeriesInstancesToUI = () => { const restoreSeriesInstancesToUI = (): void => {
if (!seriesInstancesSnapshot) return if (!seriesInstancesSnapshot) return
Object.values(seriesInstancesSnapshot).forEach(instance => { Object.values(seriesInstancesSnapshot).forEach(instance => {
dispatch( dispatch(
@@ -864,13 +868,13 @@ function EventUpdateModal({
const seriesInstancesSnapshot = getSeriesInstances() const seriesInstancesSnapshot = getSeriesInstances()
const removeSeriesInstancesFromUI = () => { const removeSeriesInstancesFromUI = (): void => {
Object.keys(seriesInstancesSnapshot).forEach(eventId => { Object.keys(seriesInstancesSnapshot).forEach(eventId => {
dispatch(removeEvent({ calendarUid: calId, eventUid: eventId })) dispatch(removeEvent({ calendarUid: calId, eventUid: eventId }))
}) })
} }
const restoreSeriesInstancesFromSnapshot = () => { const restoreSeriesInstancesFromSnapshot = (): void => {
Object.values(seriesInstancesSnapshot).forEach(instance => { Object.values(seriesInstancesSnapshot).forEach(instance => {
dispatch( dispatch(
updateEventLocal({ updateEventLocal({
@@ -1054,17 +1058,34 @@ function EventUpdateModal({
} }
const dialogActions = ( const dialogActions = (
<Box display="flex" justifyContent="space-between" width="100%" px={2}> <Box
display="flex"
justifyContent="space-between"
width="100%"
px={isMobile ? 0 : 2}
>
{!showMore && ( {!showMore && (
<Button startIcon={<AddIcon />} onClick={() => setShowMore(!showMore)}> <Button
size={isMobile ? 'small' : 'medium'}
startIcon={<AddIcon />}
onClick={() => setShowMore(!showMore)}
>
{t('common.moreOptions')} {t('common.moreOptions')}
</Button> </Button>
)} )}
<Box display="flex" gap={1} ml={showMore ? 'auto' : 0}> <Box display="flex" gap={1} ml={showMore ? 'auto' : 0}>
<Button variant="outlined" onClick={handleClose}> <Button
size={isMobile ? 'small' : 'medium'}
variant="outlined"
onClick={handleClose}
>
{t('common.cancel')} {t('common.cancel')}
</Button> </Button>
<Button variant="contained" onClick={handleSave}> <Button
size={isMobile ? 'small' : 'medium'}
variant="contained"
onClick={() => void handleSave()}
>
{t('actions.save')} {t('actions.save')}
</Button> </Button>
</Box> </Box>
@@ -1081,6 +1102,12 @@ function EventUpdateModal({
isExpanded={showMore} isExpanded={showMore}
onExpandToggle={() => setShowMore(!showMore)} onExpandToggle={() => setShowMore(!showMore)}
actions={dialogActions} actions={dialogActions}
sx={{
'& .MuiDialogActions-root': {
paddingLeft: isMobile ? 2 : 4,
paddingRight: isMobile ? 2 : 4
}
}}
> >
<EventFormFields <EventFormFields
title={title} title={title}
+3 -3
View File
@@ -14,7 +14,7 @@ export interface EventFormTempData {
attendees: userAttendee[] attendees: userAttendee[]
alarm: string alarm: string
busy: string busy: string
eventClass: string eventClass: 'PUBLIC' | 'PRIVATE' | 'CONFIDENTIAL'
timezone: string timezone: string
calendarid: string calendarid: string
hasVideoConference: boolean hasVideoConference: boolean
@@ -87,7 +87,7 @@ export interface EventFormState {
attendees: userAttendee[] attendees: userAttendee[]
alarm: string alarm: string
busy: string busy: string
eventClass: string eventClass: 'PUBLIC' | 'PRIVATE' | 'CONFIDENTIAL'
timezone: string timezone: string
calendarid: string calendarid: string
hasVideoConference: boolean hasVideoConference: boolean
@@ -127,7 +127,7 @@ export interface EventFormSetters {
setAttendees: (value: userAttendee[]) => void setAttendees: (value: userAttendee[]) => void
setAlarm: (value: string) => void setAlarm: (value: string) => void
setBusy: (value: string) => void setBusy: (value: string) => void
setEventClass: (value: string) => void setEventClass: (value: 'PUBLIC' | 'PRIVATE' | 'CONFIDENTIAL') => void
setTimezone: (value: string) => void setTimezone: (value: string) => void
setCalendarid: (value: string) => void setCalendarid: (value: string) => void
setHasVideoConference: (value: boolean) => void setHasVideoConference: (value: boolean) => void