mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
feat: calendar plugin with optional settings to enable or disable quick event creation (#6391)
* feat: calendar plugin with optional settings to enable or disable quick event creation * feat: remove useless code * Update zh-CN.json * feat: modify configuration name * feat: use nullish coalescing operator
This commit is contained in:
parent
18ab00bce1
commit
ee728bd9bf
@ -286,7 +286,15 @@ export const Calendar: any = withDynamicSchemaProps(
|
|||||||
}, [reactBigCalendar]);
|
}, [reactBigCalendar]);
|
||||||
|
|
||||||
// 新版 UISchema(1.0 之后)中已经废弃了 useProps,这里之所以继续保留是为了兼容旧版的 UISchema
|
// 新版 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 height = useCalenderHeight();
|
||||||
const [date, setDate] = useState<Date>(new Date());
|
const [date, setDate] = useState<Date>(new Date());
|
||||||
const [view, setView] = useState<View>(props.defaultView || 'month');
|
const [view, setView] = useState<View>(props.defaultView || 'month');
|
||||||
@ -440,7 +448,7 @@ export const Calendar: any = withDynamicSchemaProps(
|
|||||||
onView={setView}
|
onView={setView}
|
||||||
onSelectSlot={(slotInfo) => {
|
onSelectSlot={(slotInfo) => {
|
||||||
setCurrentSelectDate(slotInfo);
|
setCurrentSelectDate(slotInfo);
|
||||||
if (canCreate) {
|
if (canCreate && enableQuickCreateEvent) {
|
||||||
insertAddNewer(addNew);
|
insertAddNewer(addNew);
|
||||||
setVisibleAddNewer(true);
|
setVisibleAddNewer(true);
|
||||||
}
|
}
|
||||||
|
@ -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',
|
name: 'showLunar',
|
||||||
Component: ShowLunarDesignerItem,
|
Component: ShowLunarDesignerItem,
|
||||||
|
@ -17,7 +17,7 @@ export const CalendarBlockContext = createContext<any>({});
|
|||||||
CalendarBlockContext.displayName = 'CalendarBlockContext';
|
CalendarBlockContext.displayName = 'CalendarBlockContext';
|
||||||
|
|
||||||
const InternalCalendarBlockProvider = (props) => {
|
const InternalCalendarBlockProvider = (props) => {
|
||||||
const { fieldNames, showLunar, defaultView } = props;
|
const { fieldNames, showLunar, defaultView, enableQuickCreateEvent } = props;
|
||||||
const field = useField();
|
const field = useField();
|
||||||
const { resource, service } = useBlockRequestContext();
|
const { resource, service } = useBlockRequestContext();
|
||||||
|
|
||||||
@ -30,6 +30,7 @@ const InternalCalendarBlockProvider = (props) => {
|
|||||||
fieldNames,
|
fieldNames,
|
||||||
showLunar,
|
showLunar,
|
||||||
defaultView,
|
defaultView,
|
||||||
|
enableQuickCreateEvent: enableQuickCreateEvent ?? true,
|
||||||
fixedBlock: field?.decoratorProps?.fixedBlock,
|
fixedBlock: field?.decoratorProps?.fixedBlock,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -104,6 +105,7 @@ export const useCalendarBlockProps = () => {
|
|||||||
fieldNames: ctx.fieldNames,
|
fieldNames: ctx.fieldNames,
|
||||||
showLunar: ctx.showLunar,
|
showLunar: ctx.showLunar,
|
||||||
defaultView: ctx.defaultView,
|
defaultView: ctx.defaultView,
|
||||||
|
enableQuickCreateEvent: ctx.enableQuickCreateEvent,
|
||||||
fixedBlock: ctx.fixedBlock,
|
fixedBlock: ctx.fixedBlock,
|
||||||
getFontColor,
|
getFontColor,
|
||||||
getBackgroundColor,
|
getBackgroundColor,
|
||||||
|
@ -50,5 +50,6 @@
|
|||||||
"Color field": "颜色字段",
|
"Color field": "颜色字段",
|
||||||
"Not selected": "未选择",
|
"Not selected": "未选择",
|
||||||
"Default view": "默认视图",
|
"Default view": "默认视图",
|
||||||
"Event open mode": "事项打开方式"
|
"Event open mode": "事项打开方式",
|
||||||
|
"Quick create event": "快速创建事项"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user