Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: #11128 dialog动作的data支持dataMergeData配置 #11129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/amis-core/src/actions/DialogAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class DialogAction implements RendererAction {
actionType: 'dialog',
dialog: action.dialog,
reload: 'none',
dataMergeMode: action.dataMergeMode,
data: action.rawData
},
action.data
Expand All @@ -100,6 +101,7 @@ export class DialogAction implements RendererAction {
actionType: 'dialog',
dialog: action.dialog,
reload: 'none',
dataMergeMode: action.dataMergeMode,
data: action.rawData
},
action.data
Expand Down Expand Up @@ -230,6 +232,7 @@ export class ConfirmAction implements RendererAction {
actionType: 'dialog',
dialog: modal,
data: action.rawData,
dataMergeMode: action.dataMergeMode,
reload: 'none',
callback: (result: boolean) => resolve(result)
},
Expand All @@ -241,6 +244,7 @@ export class ConfirmAction implements RendererAction {
actionType: 'dialog',
dialog: modal,
data: action.rawData,
dataMergeMode: action.dataMergeMode,
reload: 'none',
callback: (result: boolean) => resolve(result)
},
Expand Down
7 changes: 6 additions & 1 deletion packages/amis-core/src/store/iRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ export const iRendererStore = StoreNode.named('iRendererStore')
}

const data = createObjectFromChain(chain);
const mappingData = self.action.data ?? self.action.dialog?.data;
const dataMergeMode = self.action.dataMergeMode || 'merge';
// 当配置了 data 的时候,可以控制数据追加方式,支持合并(merge)和覆盖(override)两种模式
const mappingData =
dataMergeMode === 'override'
? self.action.data ?? self.action.dialog?.data
: {...self.action.dialog?.data, ...self.action.data};
if (mappingData) {
self.dialogData = createObjectFromChain([
top?.context,
Expand Down
Loading