mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
fix: 修复弹窗修改可能的报错 (#9801)
This commit is contained in:
parent
e4230031ee
commit
9f027928f3
@ -40,16 +40,17 @@ export default observer(function DialogList({
|
||||
|
||||
const handleEditDialog = React.useCallback((event: React.UIEvent<any>) => {
|
||||
const index = parseInt(event.currentTarget.getAttribute('data-index')!, 10);
|
||||
const dialog = store.modals[index];
|
||||
const modal = store.modals[index];
|
||||
const modalId = modal.$$id!;
|
||||
store.openSubEditor({
|
||||
title: '编辑弹窗',
|
||||
value: {
|
||||
type: 'dialog',
|
||||
...(dialog as any),
|
||||
...(modal as any),
|
||||
definitions: modalsToDefinitions(store.modals)
|
||||
},
|
||||
onChange: ({definitions, ...modal}: any, diff: any) => {
|
||||
store.updateModal(dialog.$$id!, modal, definitions);
|
||||
store.updateModal(modalId, modal, definitions);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
@ -609,6 +609,18 @@ function DialogActionPanel({
|
||||
renderMenu={renderMenu}
|
||||
/>
|
||||
|
||||
{currentModal &&
|
||||
modals.some(
|
||||
modal =>
|
||||
modal.isCurrentActionModal &&
|
||||
!modal.isNew &&
|
||||
currentModal !== modal
|
||||
) ? (
|
||||
<div className={cx('Alert Alert--warning mt-3')}>
|
||||
切换弹窗后原来的内嵌弹窗将会被删除
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{currentModal ? (
|
||||
<div className="m-t-sm">
|
||||
<Button size="sm" level="enhance" onClick={handleDialogEdit}>
|
||||
|
@ -320,6 +320,7 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const modalId = modal.$$id;
|
||||
store.openSubEditor({
|
||||
title: '编辑弹窗',
|
||||
value: {
|
||||
@ -328,7 +329,7 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
|
||||
definitions: modalsToDefinitions(store.modals)
|
||||
},
|
||||
onChange: ({definitions, ...modal}: any, diff: any) => {
|
||||
store.updateModal(modal.$$id!, modal, definitions);
|
||||
store.updateModal(modalId, modal, definitions);
|
||||
}
|
||||
});
|
||||
}}
|
||||
@ -344,6 +345,21 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
} else if (Array.isArray(info.__actionModals)) {
|
||||
const modal = info.__actionModals.find((item: any) => item.isActive);
|
||||
if (modal) {
|
||||
// 这个时候还不能打开弹窗,schema 还没插入进去不知道 $$id,无法定位
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
打开
|
||||
<span className="variable-left">{modal.label}</span>
|
||||
|
||||
{modal.tip}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user