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 { FormContext, Schema, useField, useFieldSchema } from '@formily/react';
|
||||||
import uniq from 'lodash/uniq';
|
import uniq from 'lodash/uniq';
|
||||||
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
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 { BlockProvider, RenderChildrenWithAssociationFilter, useBlockRequestContext } from './BlockProvider';
|
||||||
import { useFixedSchema } from '../schema-component';
|
import { useFixedSchema } from '../schema-component';
|
||||||
|
|
||||||
@ -88,11 +88,12 @@ export const TableBlockProvider = (props) => {
|
|||||||
const appends = useAssociationNames(props.collection);
|
const appends = useAssociationNames(props.collection);
|
||||||
const form = useMemo(() => createForm(), []);
|
const form = useMemo(() => createForm(), []);
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
|
const collection = useCollection();
|
||||||
const { treeTable } = fieldSchema['x-decorator-props'];
|
const { treeTable } = fieldSchema['x-decorator-props'];
|
||||||
if (props.dragSort) {
|
if (props.dragSort) {
|
||||||
params['sort'] = ['sort'];
|
params['sort'] = ['sort'];
|
||||||
}
|
}
|
||||||
if (treeTable !== false) {
|
if ((collection as any).template === 'tree' && treeTable !== false) {
|
||||||
params['tree'] = true;
|
params['tree'] = true;
|
||||||
}
|
}
|
||||||
if (!Object.keys(params).includes('appends')) {
|
if (!Object.keys(params).includes('appends')) {
|
||||||
|
@ -20,11 +20,13 @@ export function extractIndex(str) {
|
|||||||
|
|
||||||
export function getIdsWithChildren(nodes) {
|
export function getIdsWithChildren(nodes) {
|
||||||
const ids = [];
|
const ids = [];
|
||||||
for (let node of nodes) {
|
if (nodes) {
|
||||||
if (node.children && node.children.length > 0) {
|
for (let node of nodes) {
|
||||||
ids.push(node.id);
|
if (node.children && node.children.length > 0) {
|
||||||
ids.push(...getIdsWithChildren(node.children));
|
ids.push(node.id);
|
||||||
|
ids.push(...getIdsWithChildren(node.children));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user