mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-08 23:19:26 +08:00
feat: support expend and collapse
This commit is contained in:
parent
eddaac0c94
commit
dbf53a762e
@ -2,7 +2,7 @@ import { ArrayField, createForm } from '@formily/core';
|
||||
import { FormContext, Schema, useField, useFieldSchema } from '@formily/react';
|
||||
import uniq from 'lodash/uniq';
|
||||
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { useCollectionManager } from '../collection-manager';
|
||||
import { useCollectionManager, useCollection } from '../collection-manager';
|
||||
import { BlockProvider, RenderChildrenWithAssociationFilter, useBlockRequestContext } from './BlockProvider';
|
||||
import { useFixedSchema } from '../schema-component';
|
||||
|
||||
@ -88,11 +88,12 @@ export const TableBlockProvider = (props) => {
|
||||
const appends = useAssociationNames(props.collection);
|
||||
const form = useMemo(() => createForm(), []);
|
||||
const fieldSchema = useFieldSchema();
|
||||
const collection = useCollection();
|
||||
const { treeTable } = fieldSchema['x-decorator-props'];
|
||||
if (props.dragSort) {
|
||||
params['sort'] = ['sort'];
|
||||
}
|
||||
if (treeTable !== false) {
|
||||
if ((collection as any).template === 'tree' && treeTable !== false) {
|
||||
params['tree'] = true;
|
||||
}
|
||||
if (!Object.keys(params).includes('appends')) {
|
||||
|
@ -20,11 +20,13 @@ export function extractIndex(str) {
|
||||
|
||||
export function getIdsWithChildren(nodes) {
|
||||
const ids = [];
|
||||
for (let node of nodes) {
|
||||
if (node.children && node.children.length > 0) {
|
||||
ids.push(node.id);
|
||||
ids.push(...getIdsWithChildren(node.children));
|
||||
if (nodes) {
|
||||
for (let node of nodes) {
|
||||
if (node.children && node.children.length > 0) {
|
||||
ids.push(node.id);
|
||||
ids.push(...getIdsWithChildren(node.children));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user