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