mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +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,
|
useGlobalTheme,
|
||||||
useNavigateNoUpdate,
|
useNavigateNoUpdate,
|
||||||
useNocoBaseRoutes,
|
useNocoBaseRoutes,
|
||||||
useToken,
|
|
||||||
useURLAndHTMLSchema,
|
useURLAndHTMLSchema,
|
||||||
} from '../../..';
|
} from '../../..';
|
||||||
import { getPageMenuSchema } from '../../../';
|
import { getPageMenuSchema } from '../../../';
|
||||||
@ -61,7 +60,7 @@ const toItems = (routes: NocoBaseDesktopRoute[], { t, compile }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const insertPositionToMethod = {
|
const insertPositionToMethod = {
|
||||||
beforeBegin: 'prepend',
|
beforeBegin: 'insertBefore',
|
||||||
afterEnd: 'insertAfter',
|
afterEnd: 'insertAfter',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -490,7 +489,8 @@ const MoveToMenuItem = () => {
|
|||||||
|
|
||||||
const { moveRoute } = useNocoBaseRoutes();
|
const { moveRoute } = useNocoBaseRoutes();
|
||||||
const currentRoute = useCurrentRoute();
|
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?.('||') || [];
|
const [targetId] = target?.split?.('||') || [];
|
||||||
if (!targetId) {
|
if (!targetId) {
|
||||||
return;
|
return;
|
||||||
@ -501,17 +501,31 @@ const MoveToMenuItem = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const positionToMethod = {
|
const positionToMethod = {
|
||||||
beforeBegin: 'prepend',
|
beforeBegin: 'insertBefore',
|
||||||
afterEnd: 'insertAfter',
|
afterEnd: 'insertAfter',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 'beforeEnd' 表示的是插入到一个分组的里面
|
||||||
|
const options =
|
||||||
|
position === 'beforeEnd'
|
||||||
|
? {
|
||||||
|
targetScope: {
|
||||||
|
parentId: targetId,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
targetId: targetId,
|
||||||
|
};
|
||||||
|
|
||||||
await moveRoute({
|
await moveRoute({
|
||||||
sourceId: currentRoute.id as any,
|
sourceId: currentRoute.id as any,
|
||||||
targetId: targetId,
|
|
||||||
sortField: 'sort',
|
sortField: 'sort',
|
||||||
method: positionToMethod[position],
|
method: positionToMethod[position],
|
||||||
|
...options,
|
||||||
});
|
});
|
||||||
}, []);
|
},
|
||||||
|
[currentRoute, moveRoute],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaSettingsModalItem
|
<SchemaSettingsModalItem
|
||||||
|
@ -34,7 +34,7 @@ import { useInsertPageSchema } from '../../../modules/menu/PageMenuItem';
|
|||||||
import { NocoBaseDesktopRouteType } from '../../../route-switch/antd/admin-layout/convertRoutesToSchema';
|
import { NocoBaseDesktopRouteType } from '../../../route-switch/antd/admin-layout/convertRoutesToSchema';
|
||||||
|
|
||||||
const insertPositionToMethod = {
|
const insertPositionToMethod = {
|
||||||
beforeBegin: 'prepend',
|
beforeBegin: 'insertBefore',
|
||||||
afterEnd: 'insertAfter',
|
afterEnd: 'insertAfter',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ export const MenuDesigner = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const positionToMethod = {
|
const positionToMethod = {
|
||||||
beforeBegin: 'prepend',
|
beforeBegin: 'insertBefore',
|
||||||
afterEnd: 'insertAfter',
|
afterEnd: 'insertAfter',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user