diff --git a/packages/plugins/@nocobase/plugin-calendar/src/client/calendar/Calendar.tsx b/packages/plugins/@nocobase/plugin-calendar/src/client/calendar/Calendar.tsx index 49c953bcaf..0308569760 100644 --- a/packages/plugins/@nocobase/plugin-calendar/src/client/calendar/Calendar.tsx +++ b/packages/plugins/@nocobase/plugin-calendar/src/client/calendar/Calendar.tsx @@ -286,7 +286,15 @@ export const Calendar: any = withDynamicSchemaProps( }, [reactBigCalendar]); // 新版 UISchema(1.0 之后)中已经废弃了 useProps,这里之所以继续保留是为了兼容旧版的 UISchema - const { dataSource, fieldNames, showLunar, defaultView, getFontColor, getBackgroundColor } = useProps(props); + const { + dataSource, + fieldNames, + showLunar, + defaultView, + getFontColor, + getBackgroundColor, + enableQuickCreateEvent, + } = useProps(props); const height = useCalenderHeight(); const [date, setDate] = useState(new Date()); const [view, setView] = useState(props.defaultView || 'month'); @@ -440,7 +448,7 @@ export const Calendar: any = withDynamicSchemaProps( onView={setView} onSelectSlot={(slotInfo) => { setCurrentSelectDate(slotInfo); - if (canCreate) { + if (canCreate && enableQuickCreateEvent) { insertAddNewer(addNew); setVisibleAddNewer(true); } diff --git a/packages/plugins/@nocobase/plugin-calendar/src/client/calendar/Calender.Settings.tsx b/packages/plugins/@nocobase/plugin-calendar/src/client/calendar/Calender.Settings.tsx index 2f08b3c11a..191ad1e998 100644 --- a/packages/plugins/@nocobase/plugin-calendar/src/client/calendar/Calender.Settings.tsx +++ b/packages/plugins/@nocobase/plugin-calendar/src/client/calendar/Calender.Settings.tsx @@ -219,6 +219,30 @@ export const calendarBlockSettings = new SchemaSettings({ }; }, }, + { + name: 'quickCreateEvent', + Component: SchemaSettingsSwitchItem, + useComponentProps() { + const { t } = useTranslation(); + const fieldSchema = useFieldSchema(); + const field = useField(); + const { dn } = useDesignable(); + return { + title: t('Quick create event'), + checked: field.decoratorProps?.enableQuickCreateEvent ?? true, + onChange: (v) => { + field.decoratorProps.enableQuickCreateEvent = v; + fieldSchema['x-decorator-props']['enableQuickCreateEvent'] = v; + dn.emit('patch', { + schema: { + ['x-uid']: fieldSchema['x-uid'], + 'x-decorator-props': field.decoratorProps, + }, + }); + }, + }; + }, + }, { name: 'showLunar', Component: ShowLunarDesignerItem, diff --git a/packages/plugins/@nocobase/plugin-calendar/src/client/schema-initializer/CalendarBlockProvider.tsx b/packages/plugins/@nocobase/plugin-calendar/src/client/schema-initializer/CalendarBlockProvider.tsx index d185dc152c..b22de16d2c 100644 --- a/packages/plugins/@nocobase/plugin-calendar/src/client/schema-initializer/CalendarBlockProvider.tsx +++ b/packages/plugins/@nocobase/plugin-calendar/src/client/schema-initializer/CalendarBlockProvider.tsx @@ -17,7 +17,7 @@ export const CalendarBlockContext = createContext({}); CalendarBlockContext.displayName = 'CalendarBlockContext'; const InternalCalendarBlockProvider = (props) => { - const { fieldNames, showLunar, defaultView } = props; + const { fieldNames, showLunar, defaultView, enableQuickCreateEvent } = props; const field = useField(); const { resource, service } = useBlockRequestContext(); @@ -30,6 +30,7 @@ const InternalCalendarBlockProvider = (props) => { fieldNames, showLunar, defaultView, + enableQuickCreateEvent: enableQuickCreateEvent ?? true, fixedBlock: field?.decoratorProps?.fixedBlock, }} > @@ -104,6 +105,7 @@ export const useCalendarBlockProps = () => { fieldNames: ctx.fieldNames, showLunar: ctx.showLunar, defaultView: ctx.defaultView, + enableQuickCreateEvent: ctx.enableQuickCreateEvent, fixedBlock: ctx.fixedBlock, getFontColor, getBackgroundColor, diff --git a/packages/plugins/@nocobase/plugin-calendar/src/locale/zh-CN.json b/packages/plugins/@nocobase/plugin-calendar/src/locale/zh-CN.json index d94ebda242..bd8c056a67 100644 --- a/packages/plugins/@nocobase/plugin-calendar/src/locale/zh-CN.json +++ b/packages/plugins/@nocobase/plugin-calendar/src/locale/zh-CN.json @@ -50,5 +50,6 @@ "Color field": "颜色字段", "Not selected": "未选择", "Default view": "默认视图", - "Event open mode": "事项打开方式" + "Event open mode": "事项打开方式", + "Quick create event": "快速创建事项" }