mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-20 15:38:32 +00:00
refactor: 优化 setting-filed settingFieldCollector
This commit is contained in:
parent
d701eaa1bf
commit
5cfd57d16b
@ -5,6 +5,18 @@ import { SettingEntry } from './setting-entry';
|
|||||||
import { computed, obx } from '@ali/lowcode-editor-core';
|
import { computed, obx } from '@ali/lowcode-editor-core';
|
||||||
import { cloneDeep } from '@ali/lowcode-utils';
|
import { cloneDeep } from '@ali/lowcode-utils';
|
||||||
|
|
||||||
|
function getSettingFieldCollectorKey(parent: SettingEntry, config: FieldConfig) {
|
||||||
|
let top = parent;
|
||||||
|
const path = [config.name];
|
||||||
|
while (top !== parent.top) {
|
||||||
|
if (top instanceof SettingField && top.type !== 'group') {
|
||||||
|
path.unshift(top.name);
|
||||||
|
}
|
||||||
|
top = top.parent;
|
||||||
|
}
|
||||||
|
return path.join('.');
|
||||||
|
}
|
||||||
|
|
||||||
export class SettingField extends SettingPropEntry implements SettingEntry {
|
export class SettingField extends SettingPropEntry implements SettingEntry {
|
||||||
readonly isSettingField = true;
|
readonly isSettingField = true;
|
||||||
readonly isRequired: boolean;
|
readonly isRequired: boolean;
|
||||||
@ -54,12 +66,8 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
|
|||||||
if (items && items.length > 0) {
|
if (items && items.length > 0) {
|
||||||
this.initItems(items, settingFieldCollector);
|
this.initItems(items, settingFieldCollector);
|
||||||
}
|
}
|
||||||
if (settingFieldCollector && config.name) {
|
if (this.type !== 'group' && settingFieldCollector && config.name) {
|
||||||
if (parent && parent instanceof SettingField && parent.type !== 'group') {
|
settingFieldCollector(getSettingFieldCollectorKey(parent, config), this);
|
||||||
settingFieldCollector((parent as SettingField).name + '.' + config.name, this);
|
|
||||||
} else {
|
|
||||||
settingFieldCollector(config.name, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// compatiable old config
|
// compatiable old config
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user