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; grain?: DSGrain;
/** 数据源所被使用的功能场景 */ /** 数据源所被使用的功能场景 */
feat: DSFeatureType; feat: DSFeatureType;
/** 是否是在CRUD场景下有的数据源在CRUD中可以统一设置 */ /** 渲染器类型 */
renderer?: string;
/**
* @deprecated 使renderer字段代替
* CRUD场景下CRUD中可以统一设置
* */
inCrud?: boolean; inCrud?: boolean;
/** 是否在脚手架中 */ /** 是否在脚手架中 */
inScaffold?: boolean; inScaffold?: boolean;

View File

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

View File

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

View File

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

View File

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

View File

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