mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:06:25 +00:00
fix: gantt collapse & expand (#3982)
This commit is contained in:
parent
de7b75fea7
commit
8eee6756d4
@ -56,9 +56,12 @@ const InternalTableBlockProvider = (props: Props) => {
|
||||
}
|
||||
}, [service?.loading, fieldSchema]);
|
||||
|
||||
const setExpandFlagValue = useCallback(() => {
|
||||
setExpandFlag(!expandFlag);
|
||||
}, [expandFlag]);
|
||||
const setExpandFlagValue = useCallback(
|
||||
(falg) => {
|
||||
setExpandFlag(falg || !expandFlag);
|
||||
},
|
||||
[expandFlag],
|
||||
);
|
||||
|
||||
return (
|
||||
<FixedBlockWrapper>
|
||||
|
@ -6,8 +6,9 @@ import {
|
||||
BlockProvider,
|
||||
useBlockRequestContext,
|
||||
TableBlockProvider,
|
||||
useTableBlockContext,
|
||||
} from '@nocobase/client';
|
||||
|
||||
import _ from 'lodash';
|
||||
export const GanttBlockContext = createContext<any>({});
|
||||
GanttBlockContext.displayName = 'GanttBlockContext';
|
||||
|
||||
@ -36,7 +37,7 @@ const formatData = (
|
||||
color: item.color,
|
||||
isDisabled: disable,
|
||||
});
|
||||
formatData(item.children, fieldNames, tasks, item.id + '', hideChildren, checkPermassion);
|
||||
formatData(item.children, fieldNames, tasks, item.id + '', hideChildren, checkPermassion, primaryKey);
|
||||
} else {
|
||||
tasks.push({
|
||||
start: item[fieldNames.start] ? new Date(item[fieldNames.start]) : undefined,
|
||||
@ -102,6 +103,8 @@ export const useGanttBlockProps = () => {
|
||||
const [tasks, setTasks] = useState<any>([]);
|
||||
const { getPrimaryKey, name, template, writableView } = useCollection_deprecated();
|
||||
const { parseAction } = useACLRoleContext();
|
||||
const ctxBlock = useTableBlockContext();
|
||||
|
||||
const primaryKey = getPrimaryKey();
|
||||
const checkPermission = (record) => {
|
||||
const actionPath = `${name}:update`;
|
||||
@ -135,8 +138,12 @@ export const useGanttBlockProps = () => {
|
||||
);
|
||||
setTasks(data);
|
||||
ctx.field.data = data;
|
||||
if (tasks.length > 0) {
|
||||
ctxBlock.setExpandFlag(true);
|
||||
}
|
||||
}
|
||||
}, [ctx?.service?.loading]);
|
||||
console.log(tasks);
|
||||
return {
|
||||
fieldNames: ctx.fieldNames,
|
||||
timeRange: ctx.timeRange,
|
||||
|
Loading…
Reference in New Issue
Block a user