mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +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]);
|
||||
|
||||
// 新版 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<Date>(new Date());
|
||||
const [view, setView] = useState<View>(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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -17,7 +17,7 @@ export const CalendarBlockContext = createContext<any>({});
|
||||
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,
|
||||
|
@ -50,5 +50,6 @@
|
||||
"Color field": "颜色字段",
|
||||
"Not selected": "未选择",
|
||||
"Default view": "默认视图",
|
||||
"Event open mode": "事项打开方式"
|
||||
"Event open mode": "事项打开方式",
|
||||
"Quick create event": "快速创建事项"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user