mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 03:46:08 +00:00
Merge branch 'main' into next
This commit is contained in:
commit
ba46b69ff3
@ -13,6 +13,6 @@ export * from './FixedBlockDesignerItem';
|
||||
export * from './Page';
|
||||
export * from './Page.Settings';
|
||||
export { PagePopups } from './PagePopups';
|
||||
export { storePopupContext, withSearchParams, getPopupPathFromParams } from './pagePopupUtils';
|
||||
export { storePopupContext, getStoredPopupContext, withSearchParams, getPopupPathFromParams } from './pagePopupUtils';
|
||||
export * from './PageTab.Settings';
|
||||
export { PopupSettingsProvider } from './PopupSettingsProvider';
|
||||
|
@ -30,6 +30,7 @@ const interfaces = {
|
||||
multipleSelect: MultipleSelectInterface,
|
||||
checkboxes: MultipleSelectInterface,
|
||||
checkboxGroup: MultipleSelectInterface,
|
||||
checkbox: BooleanInterface,
|
||||
select: SelectInterface,
|
||||
radio: SelectInterface,
|
||||
radioGroup: SelectInterface,
|
||||
|
@ -41,6 +41,7 @@ const localizer = dayjsLocalizer(dayjs);
|
||||
|
||||
export const DeleteEventContext = React.createContext({
|
||||
close: () => {},
|
||||
allowDeleteEvent: false,
|
||||
});
|
||||
|
||||
function Toolbar(props: ToolbarProps) {
|
||||
@ -107,7 +108,6 @@ const useEvents = (dataSource: any, fieldNames: any, date: Date, view: (typeof W
|
||||
return eventStart.isSame(d);
|
||||
}
|
||||
});
|
||||
console.log(99);
|
||||
if (res) return out;
|
||||
const title = getLabelFormatValue(labelUiSchema, get(item, fieldNames.title), true);
|
||||
const event = {
|
||||
@ -216,7 +216,6 @@ export const Calendar: any = withDynamicSchemaProps(
|
||||
noEventsInRange: i18nt('None'),
|
||||
showMore: (count) => i18nt('{{count}} more items', { count }),
|
||||
};
|
||||
console.log(events, dataSource, fieldNames, date, view);
|
||||
return wrapSSR(
|
||||
<div className={`${hashId} ${containerClassName}`} style={{ height: height || 700 }}>
|
||||
<PopupContextProvider visible={visible} setVisible={setVisible}>
|
||||
|
@ -10,23 +10,38 @@
|
||||
import { observer } from '@formily/react';
|
||||
import { Modal, Radio, Space, Typography } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import React, { useContext, useState } from 'react';
|
||||
import React, { useContext, useState, useMemo } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { DeleteEventContext } from './Calendar';
|
||||
import { formatDate } from './utils';
|
||||
import { useActionContext, useRecord, useFilterByTk, useBlockRequestContext } from '@nocobase/client';
|
||||
import {
|
||||
useActionContext,
|
||||
useRecord,
|
||||
useFilterByTk,
|
||||
useBlockRequestContext,
|
||||
getStoredPopupContext,
|
||||
usePopupUtils,
|
||||
} from '@nocobase/client';
|
||||
import { useTranslation } from '../../locale';
|
||||
const { Text } = Typography;
|
||||
|
||||
export const DeleteEvent = observer(
|
||||
() => {
|
||||
const { visible, setVisible } = useActionContext();
|
||||
const { visible, setVisible, setSubmitted } = useActionContext();
|
||||
const { exclude = [], cron, ...record } = useRecord();
|
||||
const { close } = useContext(DeleteEventContext);
|
||||
const startDate = formatDate(dayjs(record.__parent?.__event.start));
|
||||
const { context: popUpCtx, closePopup } = usePopupUtils();
|
||||
const parentXUid = popUpCtx?.params?.popupuid || '';
|
||||
const eventData = getStoredPopupContext(parentXUid) || { record: null, service: null };
|
||||
const startDate = useMemo(
|
||||
() => formatDate(dayjs(eventData.record?.data?.__event.start)),
|
||||
[eventData.record?.data?.__event.start],
|
||||
);
|
||||
// directly access popup can only del all, for we have no event detail
|
||||
const disableDelPart = eventData.record ? false : true;
|
||||
const filterByTk = useFilterByTk();
|
||||
const { resource, service, __parent } = useBlockRequestContext();
|
||||
const [value, onChange] = useState(startDate);
|
||||
const [value, onChange] = useState(disableDelPart ? 'all' : startDate);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const onOk = async () => {
|
||||
setLoading(true);
|
||||
@ -47,6 +62,7 @@ export const DeleteEvent = observer(
|
||||
service?.refresh?.();
|
||||
setVisible?.(false, true);
|
||||
close();
|
||||
setSubmitted?.(true);
|
||||
};
|
||||
|
||||
const { t } = useTranslation();
|
||||
@ -61,8 +77,12 @@ export const DeleteEvent = observer(
|
||||
{cron ? (
|
||||
<Radio.Group value={value} onChange={(event) => onChange(event.target.value)}>
|
||||
<Space direction="vertical">
|
||||
<Radio value={startDate}>{t('This event')}</Radio>
|
||||
<Radio value={`${startDate}_after`}>{t('This and following events')}</Radio>
|
||||
<Radio value={startDate} disabled={disableDelPart}>
|
||||
{t('This event')}
|
||||
</Radio>
|
||||
<Radio value={`${startDate}_after`} disabled={disableDelPart}>
|
||||
{t('This and following events')}
|
||||
</Radio>
|
||||
<Radio value="all">{t('All events')}</Radio>
|
||||
</Space>
|
||||
</Radio.Group>
|
||||
|
@ -27,10 +27,9 @@ export const Event = observer(
|
||||
const close = useCallback(() => {
|
||||
setVisible(false);
|
||||
}, [setVisible]);
|
||||
|
||||
return (
|
||||
<PopupContextProvider visible={visible} setVisible={setVisible}>
|
||||
<DeleteEventContext.Provider value={{ close }}>
|
||||
<DeleteEventContext.Provider value={{ close, allowDeleteEvent: true }}>
|
||||
<VariablePopupRecordProvider recordData={recordData} collection={collection}>
|
||||
{props.children}
|
||||
</VariablePopupRecordProvider>
|
||||
|
@ -7,14 +7,17 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
import {
|
||||
SchemaInitializer,
|
||||
SchemaInitializerItemType,
|
||||
useCollection_deprecated,
|
||||
useActionAvailable,
|
||||
} from '@nocobase/client';
|
||||
import { useContext } from 'react';
|
||||
import { generateNTemplate } from '../../../locale';
|
||||
import { DeleteEventActionInitializer } from '../items/DeleteEventActionInitializer';
|
||||
import { DeleteEventContext } from '../../calendar/Calendar';
|
||||
export const deleteEventActionInitializer: SchemaInitializerItemType<any> = {
|
||||
name: 'deleteEvent',
|
||||
title: generateNTemplate('Delete Event'),
|
||||
@ -24,8 +27,9 @@ export const deleteEventActionInitializer: SchemaInitializerItemType<any> = {
|
||||
'x-decorator': 'ACLActionProvider',
|
||||
},
|
||||
useVisible() {
|
||||
const { allowDeleteEvent } = useContext(DeleteEventContext);
|
||||
const collection = useCollection_deprecated();
|
||||
return collection.template === 'calendar';
|
||||
return collection.template === 'calendar' && allowDeleteEvent;
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
"name": "@nocobase/plugin-data-source-main",
|
||||
"displayName": "Data source: Main",
|
||||
"displayName.zh-CN": "数据源:主数据库",
|
||||
"description": "NocoBase main database, supports relational databases such as MySQL, PostgreSQL, SQLite and so on.",
|
||||
"description.zh-CN": "NocoBase 主数据库,支持 MySQL、PostgreSQL、SQLite 等关系型数据库。",
|
||||
"description": "NocoBase main database, supports relational databases such as PostgreSQL, MySQL, MariaDB and so on.",
|
||||
"description.zh-CN": "NocoBase 主数据库,支持 PostgreSQL、MySQL、MariaDB 等关系型数据库。",
|
||||
"version": "1.4.0-alpha",
|
||||
"main": "./dist/server/index.js",
|
||||
"homepage": "https://docs.nocobase.com/handbook/data-source-main",
|
||||
|
Loading…
Reference in New Issue
Block a user