Skip to content

Commit

Permalink
hide "show on parent" if it has no parent
Browse files Browse the repository at this point in the history
  • Loading branch information
hero101 committed Nov 8, 2024
1 parent e24195e commit 2f13ec6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/domain/timeline/calendar/CalendarDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const CalendarDialog: FC<CalendarDialogProps> = ({
isCreatingEventInit ? <div>&nbsp;</div> : <BackButton onClick={() => setIsCreatingEvent(false)} />
}
temporaryLocation={temporaryLocation}
isSubspace={isSubspace}
/>
);

Expand Down Expand Up @@ -185,6 +186,7 @@ const CalendarDialog: FC<CalendarDialogProps> = ({
onClose={handleClose}
isSubmitting={updatingCalendarEvent}
actions={<BackButton onClick={() => setEditingEventId(undefined)} />}
isSubspace={isSubspace}
/>
)}
</CalendarEventDetailContainer>
Expand Down
3 changes: 3 additions & 0 deletions src/domain/timeline/calendar/views/CalendarEventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface CalendarEventFormProps {
isSubmitting: boolean;
actions?: ReactNode;
temporaryLocation?: boolean;
isSubspace?: boolean;
}

const typeOptions: FormikSelectValue[] = [
Expand Down Expand Up @@ -55,6 +56,7 @@ const CalendarEventForm = ({
isSubmitting,
actions,
temporaryLocation = false,
isSubspace = false,
}: CalendarEventFormProps) => {
const { t } = useTranslation();

Expand Down Expand Up @@ -164,6 +166,7 @@ const CalendarEventForm = ({
isSubmitting={isSubmitting}
actions={actions}
temporaryLocation={temporaryLocation}
isSubspace={isSubspace}
/>
</Formik>
</GridProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type EventFormProps = {
isSubmitting: boolean;
actions: React.ReactNode;
typeOptions: FormikSelectValue[];
isSubspace: boolean;

temporaryLocation?: boolean;
};
40 changes: 24 additions & 16 deletions src/domain/timeline/calendar/views/EventForm/EventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ const getMinTime = (startDate: DateType, endDate: number | DateType) => {
return isSameDay(startDate, endDate) ? undefined : dayjs(startDate);
};

const EventForm = ({ typeOptions, isSubmitting, actions, temporaryLocation = false }: EventFormProps) => {
const EventForm = ({
typeOptions,
isSubmitting,
actions,
temporaryLocation = false,
isSubspace = false,
}: EventFormProps) => {
const { t } = useTranslation();
const {
isValid,
Expand Down Expand Up @@ -110,21 +116,23 @@ const EventForm = ({ typeOptions, isSubmitting, actions, temporaryLocation = fal
<FormikInputField name="location.city" title={'Location'} placeholder={' '} fullWidth />
<TagsetField name="tags" title={t('common.tags')} />
</Gutters>
<Gutters disablePadding sx={{ flexDirection: 'row', flexGrow: 1 }}>
<FormControlLabel
control={
<Switch
checked={visibleOnParentCalendar}
name="visibleOnParentCalendar"
onChange={() => {
setFieldValue('visibleOnParentCalendar', !visibleOnParentCalendar);
}}
/>
}
label={t('calendar.event.visibleOnParentCalendar')}
sx={{ flexShrink: 0 }}
/>
</Gutters>
{isSubspace && (
<Gutters disablePadding sx={{ flexDirection: 'row', flexGrow: 1 }}>
<FormControlLabel
control={
<Switch
checked={visibleOnParentCalendar}
name="visibleOnParentCalendar"
onChange={() => {
setFieldValue('visibleOnParentCalendar', !visibleOnParentCalendar);
}}
/>
}
label={t('calendar.event.visibleOnParentCalendar')}
sx={{ flexShrink: 0 }}
/>
</Gutters>
)}
</Gutters>
</Form>
</DialogContent>
Expand Down

0 comments on commit 2f13ec6

Please sign in to comment.