alibaba / alibaba/lowcode-engine
nestingRule.ancestorWhitelist 祖父节点类型白名单 无效
- Dominant language
- TypeScript
- Stars
- 15.9k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
## **Describe the bug (required)** / **详细描述 bug(必填)**
根据物料协议规范 https://lowcode-engine.cn/site/docs/specs/material-spec 中的 2.2.2.4.3 组件能力配置 component 设置了无效,详细看代码
``` typescript
/** 此插件对编辑进行控制 比如节点是否能拖到某节点下, 父节点变更处理 等*/
const EditNodeControl = (ctx: IPublicModelPluginContext) => {
return {
async init() {
// 1:所依懒的上级控件改变(如拖动改变了上级找不到上级了, 上级邦定的单据改变了等)
//注册setter
const { setters, project, canvas, material, config } = ctx;
let iniView = config.get('iniView') as t_view & { ActionType: ActionType };
//组件的拖入控制是 通过设置物料描述信息的 nestingRule 来设置的 相关文档 https://lowcode-engine.cn/site/docs/faq/faq022
/**
* 所以思路是当邦定了业务对像时. 就要自动设置支持映射字段的物料进行 nestingRule 控制
* 对于子单据 就只有一种..
*/
if (iniView.FormType == FormType.动态表单) {
return; //动态表单完全自由。 不需要进行下面的操作了
}
material.registerMetadataTransducer((e) => {
console.log('物料进入了', e);
//e.configure.component?.nestingRule
/*
要根据物料类型进行控制 如果被映射了字段 就要设置祖父节点类型白名单的白名单了
nestingRule(A) 嵌套控制:防止错误的节点嵌套,比如 a 嵌套 a, FormField 只能在 Form 容器下,Column 只能在 Table 下等 Object
nestingRule.childWhitelist 子节点类型白名单 String\|Function
nestingRule.parentWhitelist 父节点类型白名单 String\|Function
nestingRule.descendantBlacklist 后裔节点类型黑名单 String\|Function
nestingRule.ancestorWhitelist 祖父节点类型白名单 String\|Function
*/
//容器只能放业务对像下, 映射字段只能放单据里, 按扭可随便放
if (e.configure.component) {
e.configure.component.nestingRule ??= {};
console.log('已注册 ancestorWhitelist', e);
// e.configure.component.nestingRule.parentWhitelist = (testNode: IPublicModelNode, currentNode: IPublicModelNode) => {
// console.log('父节点类型白名单:testNode', testNode, 'currentNode:', currentNode);
// return false;
// };
//不起作用
e.configure.component.nestingRule.ancestorWhitelist = (testNode: IPublicModelNode, currentNode: IPublicModelNode) => {
console.log('控制祖父节点类型白名单:testNode', testNode, 'currentNode:', currentNode);
return false;
};
}
return e;
});
project.currentDocument?.onAddNode((e) => {
console.log('新增节点', e);
});
project.currentDocument?.onChangeNodeProp((e) => {
/*
如果被映射了字段 就要设置父节点的白名单了
*/
console.log('节点属性更改:', e);
});
canvas.dragon?.onDragend((e) => {
console.log('拖动结束', e);
});
},
};
};
```
e.configure.component.nestingRule.parentWhitelist 这个属性就有效. 返回false 之后, 不能拖入到任何容器下,但 e.configure.component.nestingRule.ancestorWhitelist 下就无效了.没反应了
A clear and concise description of what the bug is. / 请提供清晰且精确的 bug 描述
---
## **To Reproduce (required)** / **如何复现 bug?(必填,非常重要)**
Steps to reproduce the behavior: / 详细复现步骤:
---
## **Expected behavior (required)** / **预期行为(必填,非常重要)**
A clear and concise description of what did you expect to happen. / 请清晰和精确的描述你预期的行为
预期行为应该是 只要一个节点设置了祖白名单 .我的函数是永远false 哪就跟 parentWhitelist 一样的效果才是,不管我上面有多少层父
---
## **Screenshots (optional)** / **bug 截图(可选)**
Sceenshots for further information. (If applicable.) / 一些有用的截图将会帮助我们更好的明确以及定位问题
---
## **Environments (please complete the following information) (required):** / **请提供如下信息(必填)**
- AliLowCodeEngine version: [e.g. 1.2.2-beta.3] / 低代码引擎版本
- AliLowCodeEngineExt version: [e.g. 1.2.2-beta.3] / 低代码引擎扩展包版本
- Browser [e.g. edge] / 浏览器版本
- materials / plugins / tools / 其他物料 / 插件 / 工具链版本
> (this information can be collected via [the manual plugin](https://img.alicdn.com/imgextra/i1/O1CN0115zonY1IsgbkZ2ir7_!!6000000000949-2-tps-3066-1650.png) / 版本信息可[通过低代码用户手册插件收集](https://img.alicdn.com/imgextra/i1/O1CN0115zonY1IsgbkZ2ir7_!!6000000000949-2-tps-3066-1650.png))
## **Additional context (optional)** / **更多额外信息(可选)**
Any other context of the problem here. / 可以追加更多的额外信息,帮助定位问题
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.