mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix(menuItemSettings): enhance route moving logic to support nested i… (#6413)
* fix(menuItemSettings): enhance route moving logic to support nested insertion * fix(menuItemSettings): update position method from 'prepend' to 'insertBefore' * fix: insertBefore --------- Co-authored-by: chenos <chenlinxh@gmail.com>
This commit is contained in:
parent
1e3f988c48
commit
256b526800
@ -28,7 +28,6 @@ import {
|
||||
useGlobalTheme,
|
||||
useNavigateNoUpdate,
|
||||
useNocoBaseRoutes,
|
||||
useToken,
|
||||
useURLAndHTMLSchema,
|
||||
} from '../../..';
|
||||
import { getPageMenuSchema } from '../../../';
|
||||
@ -61,7 +60,7 @@ const toItems = (routes: NocoBaseDesktopRoute[], { t, compile }) => {
|
||||
};
|
||||
|
||||
const insertPositionToMethod = {
|
||||
beforeBegin: 'prepend',
|
||||
beforeBegin: 'insertBefore',
|
||||
afterEnd: 'insertAfter',
|
||||
};
|
||||
|
||||
@ -490,7 +489,8 @@ const MoveToMenuItem = () => {
|
||||
|
||||
const { moveRoute } = useNocoBaseRoutes();
|
||||
const currentRoute = useCurrentRoute();
|
||||
const onMoveToSubmit: (values: any) => void = useCallback(async ({ target, position }) => {
|
||||
const onMoveToSubmit: (values: any) => void = useCallback(
|
||||
async ({ target, position }) => {
|
||||
const [targetId] = target?.split?.('||') || [];
|
||||
if (!targetId) {
|
||||
return;
|
||||
@ -501,17 +501,31 @@ const MoveToMenuItem = () => {
|
||||
}
|
||||
|
||||
const positionToMethod = {
|
||||
beforeBegin: 'prepend',
|
||||
beforeBegin: 'insertBefore',
|
||||
afterEnd: 'insertAfter',
|
||||
};
|
||||
|
||||
// 'beforeEnd' 表示的是插入到一个分组的里面
|
||||
const options =
|
||||
position === 'beforeEnd'
|
||||
? {
|
||||
targetScope: {
|
||||
parentId: targetId,
|
||||
},
|
||||
}
|
||||
: {
|
||||
targetId: targetId,
|
||||
};
|
||||
|
||||
await moveRoute({
|
||||
sourceId: currentRoute.id as any,
|
||||
targetId: targetId,
|
||||
sortField: 'sort',
|
||||
method: positionToMethod[position],
|
||||
...options,
|
||||
});
|
||||
}, []);
|
||||
},
|
||||
[currentRoute, moveRoute],
|
||||
);
|
||||
|
||||
return (
|
||||
<SchemaSettingsModalItem
|
||||
|
@ -34,7 +34,7 @@ import { useInsertPageSchema } from '../../../modules/menu/PageMenuItem';
|
||||
import { NocoBaseDesktopRouteType } from '../../../route-switch/antd/admin-layout/convertRoutesToSchema';
|
||||
|
||||
const insertPositionToMethod = {
|
||||
beforeBegin: 'prepend',
|
||||
beforeBegin: 'insertBefore',
|
||||
afterEnd: 'insertAfter',
|
||||
};
|
||||
|
||||
@ -453,7 +453,7 @@ export const MenuDesigner = () => {
|
||||
});
|
||||
|
||||
const positionToMethod = {
|
||||
beforeBegin: 'prepend',
|
||||
beforeBegin: 'insertBefore',
|
||||
afterEnd: 'insertAfter',
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user