Merge pull request #7187 from lurunze1226/editor-sharedcontext

chore(amis-editor): EditorNode中info支持设置sharedContext; fix: InputTable…
This commit is contained in:
hsm-lv 2023-06-16 13:43:25 +08:00 committed by GitHub
commit 7dc984b463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 30 deletions

View File

@ -102,7 +102,12 @@ export interface DSSourceSettingFormConfig {
grain?: DSGrain;
/** 数据源所被使用的功能场景 */
feat: DSFeatureType;
/** 是否是在CRUD场景下有的数据源在CRUD中可以统一设置 */
/** 渲染器类型 */
renderer?: string;
/**
* @deprecated 使renderer字段代替
* CRUD场景下CRUD中可以统一设置
* */
inCrud?: boolean;
/** 是否在脚手架中 */
inScaffold?: boolean;

View File

@ -33,7 +33,7 @@ import SearchPanel from './component/base/SearchPanel';
import {VRenderer} from './component/VRenderer';
import {RegionWrapper} from './component/RegionWrapper';
import {mapReactElement} from './component/factory';
import type {EditorNodeType} from './store/node';
import type {EditorNodeType, EditorNodeSnapshot} from './store/node';
import {ContainerWrapper} from './component/ContainerWrapper';
import type {EditorStoreType} from './store/editor';
import {AvailableRenderersPlugin} from './plugin/AvailableRenderers';
@ -56,6 +56,7 @@ export {
IFramePreview as IFrameEditor,
SearchPanel,
EditorNodeType,
EditorNodeSnapshot,
EditorStoreType,
ContainerWrapper,
AvailableRenderersPlugin,

View File

@ -291,6 +291,8 @@ export interface RendererInfo extends RendererScaffoldInfo {
memberIndex?: number;
tipName?: string;
/** 共享上下文 */
sharedContext?: Record<string, any>;
}
export type BasicRendererInfo = Omit<

View File

@ -77,6 +77,14 @@ export const EditorNode = types
info = value;
},
updateSharedContext(value: Record<string, any>) {
if (!value || !info?.hasOwnProperty('sharedContext')) {
return;
}
info.sharedContext = value;
},
get rendererConfig() {
return rendererConfig;
},

View File

@ -649,24 +649,31 @@ export class ComboControlPlugin extends BasePlugin {
target: EditorNodeType,
region?: EditorNodeType
) {
if (target.parent.isRegion && target.parent.region === 'items') {
const scope = scopeNode.parent.parent;
const builder = this.dsBuilderManager.resolveBuilderBySchema(
let scope;
let builder;
if (
target.type === scopeNode.type ||
(target.parent.isRegion && target.parent.region === 'items')
) {
scope = scopeNode.parent.parent;
builder = this.dsBuilderManager.resolveBuilderBySchema(
scope.schema,
'api'
);
}
if (builder && scope.schema.api) {
return builder.getAvailableContextFileds(
{
schema: scope.schema,
sourceKey: 'api',
feat: scope.schema?.feat ?? 'List',
scopeNode
},
target
);
}
if (builder && scope.schema.api) {
return builder.getAvailableContextFileds(
{
schema: scope.schema,
sourceKey: 'api',
feat: scope.schema?.feat ?? 'List',
scopeNode
},
/** ID相同为本体否则为子项 */
target?.id === scopeNode?.id ? scopeNode : target
);
}
}
}

View File

@ -1082,24 +1082,31 @@ export class TableControlPlugin extends BasePlugin {
target: EditorNodeType,
region?: EditorNodeType
) {
if (target.parent.isRegion && target.parent.region === 'columns') {
const scope = scopeNode.parent.parent;
const builder = this.dsBuilderManager.resolveBuilderBySchema(
let scope;
let builder;
if (
target.type === scopeNode.type ||
(target.parent.isRegion && target.parent.region === 'columns')
) {
scope = scopeNode.parent.parent;
builder = this.dsBuilderManager.resolveBuilderBySchema(
scope.schema,
'api'
);
}
if (builder && scope.schema.api) {
return builder.getAvailableContextFileds(
{
schema: scope.schema,
sourceKey: 'api',
feat: scope.schema?.feat ?? 'List',
scopeNode
},
target
);
}
if (builder && scope.schema.api) {
return builder.getAvailableContextFileds(
{
schema: scope.schema,
sourceKey: 'api',
feat: scope.schema?.feat ?? 'List',
scopeNode
},
/** ID相同为本体否则为子项 */
target?.id === scopeNode?.id ? scopeNode : target
);
}
}
}