mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:48:13 +08:00
fix: 修复弹窗修改无法删除属性的问题 (#10102)
This commit is contained in:
parent
6a049c5066
commit
759d4534d9
@ -553,18 +553,27 @@ export const MainStore = types
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isSubEditor = self.isSubEditor;
|
const isSubEditor = self.isSubEditor;
|
||||||
|
const isHiddenProps = getEnv(self).isHiddenProps;
|
||||||
|
|
||||||
return JSONPipeOut(
|
return JSONPipeOut(
|
||||||
JSONGetById(self.schema, self.activeId),
|
JSONGetById(self.schema, self.activeId),
|
||||||
getEnv(self).isHiddenProps ||
|
(key, props) => {
|
||||||
((key, props) =>
|
if (isSubEditor && key === 'definitions') {
|
||||||
// 如果是子弹窗,不显示 definitions,要是通过代码模式改了,就麻烦了
|
return true;
|
||||||
(isSubEditor && key === 'definitions') ||
|
}
|
||||||
|
|
||||||
|
if (typeof isHiddenProps === 'function') {
|
||||||
|
return isHiddenProps(key, props);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
(key.substring(0, 2) === '$$' &&
|
(key.substring(0, 2) === '$$' &&
|
||||||
key !== '$$comments' &&
|
key !== '$$comments' &&
|
||||||
key !== '$$commonSchema') ||
|
key !== '$$commonSchema') ||
|
||||||
typeof props === 'function' || // pipeIn 和 pipeOut
|
typeof props === 'function' || // pipeIn 和 pipeOut
|
||||||
key.substring(0, 2) === '__')
|
key.substring(0, 2) === '__'
|
||||||
|
);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1812,7 +1821,7 @@ export const MainStore = types
|
|||||||
? 'drawer'
|
? 'drawer'
|
||||||
: 'dialog';
|
: 'dialog';
|
||||||
|
|
||||||
schema = JSONUpdate(schema, id, modal);
|
schema = JSONUpdate(schema, id, modal, true);
|
||||||
|
|
||||||
// 如果编辑的是公共弹窗
|
// 如果编辑的是公共弹窗
|
||||||
if (!parent.actionType) {
|
if (!parent.actionType) {
|
||||||
@ -1829,25 +1838,35 @@ export const MainStore = types
|
|||||||
modalKey &&
|
modalKey &&
|
||||||
newHostKey !== (value === 'drawer' ? 'drawer' : 'dialog')
|
newHostKey !== (value === 'drawer' ? 'drawer' : 'dialog')
|
||||||
) {
|
) {
|
||||||
schema = JSONUpdate(schema, host.$$id, {
|
schema = JSONUpdate(
|
||||||
actionType: (modal as any).actionType || modal.type,
|
schema,
|
||||||
args: undefined,
|
host.$$id,
|
||||||
dialog: undefined,
|
{
|
||||||
drawer: undefined,
|
actionType: (modal as any).actionType || modal.type,
|
||||||
[newHostKey]: host[value === 'drawer' ? 'drawer' : 'dialog']
|
args: undefined,
|
||||||
});
|
dialog: undefined,
|
||||||
|
drawer: undefined,
|
||||||
|
[newHostKey]: host[value === 'drawer' ? 'drawer' : 'dialog']
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 内嵌弹窗只用改自己就行了
|
// 内嵌弹窗只用改自己就行了
|
||||||
schema = JSONUpdate(schema, parent.$$id, {
|
schema = JSONUpdate(
|
||||||
actionType: (modal as any).actionType || modal.type,
|
schema,
|
||||||
args: undefined,
|
parent.$$id,
|
||||||
dialog: undefined,
|
{
|
||||||
drawer: undefined,
|
actionType: (modal as any).actionType || modal.type,
|
||||||
[newHostKey]: modal
|
args: undefined,
|
||||||
});
|
dialog: undefined,
|
||||||
|
drawer: undefined,
|
||||||
|
[newHostKey]: modal
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果弹窗里面又弹窗指向自己,那么也要更新
|
// 如果弹窗里面又弹窗指向自己,那么也要更新
|
||||||
@ -1860,16 +1879,26 @@ export const MainStore = types
|
|||||||
if (refIds.length) {
|
if (refIds.length) {
|
||||||
let refKey = '';
|
let refKey = '';
|
||||||
[schema, refKey] = addModal(schema, modal);
|
[schema, refKey] = addModal(schema, modal);
|
||||||
schema = JSONUpdate(schema, parent.$$id, {
|
schema = JSONUpdate(
|
||||||
[newHostKey]: JSONPipeIn({
|
schema,
|
||||||
$ref: refKey
|
parent.$$id,
|
||||||
})
|
{
|
||||||
});
|
[newHostKey]: JSONPipeIn({
|
||||||
|
$ref: refKey
|
||||||
|
})
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
refIds.forEach(refId => {
|
refIds.forEach(refId => {
|
||||||
schema = JSONUpdate(schema, refId, {
|
schema = JSONUpdate(
|
||||||
$ref: refKey,
|
schema,
|
||||||
$$originId: undefined
|
refId,
|
||||||
});
|
{
|
||||||
|
$ref: refKey,
|
||||||
|
$$originId: undefined
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1519,7 +1519,7 @@ export function mergeDefinitions(
|
|||||||
// 当前更新弹窗里面用到了需要转成 ref
|
// 当前更新弹窗里面用到了需要转成 ref
|
||||||
if (refs.includes(key)) {
|
if (refs.includes(key)) {
|
||||||
if (schema.$$id === $$originId) {
|
if (schema.$$id === $$originId) {
|
||||||
schema = JSONUpdate(schema, $$originId, JSONPipeIn(def));
|
schema = JSONUpdate(schema, $$originId, JSONPipeIn(def), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1528,17 +1528,22 @@ export function mergeDefinitions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const modalType = def.type === 'drawer' ? 'drawer' : 'dialog';
|
const modalType = def.type === 'drawer' ? 'drawer' : 'dialog';
|
||||||
schema = JSONUpdate(schema, parent.$$id, {
|
schema = JSONUpdate(
|
||||||
...parent,
|
schema,
|
||||||
__actionModals: undefined,
|
parent.$$id,
|
||||||
args: undefined,
|
{
|
||||||
dialog: undefined,
|
...parent,
|
||||||
drawer: undefined,
|
__actionModals: undefined,
|
||||||
actionType: def.actionType ?? modalType,
|
args: undefined,
|
||||||
[modalType]: JSONPipeIn({
|
dialog: undefined,
|
||||||
$ref: key
|
drawer: undefined,
|
||||||
})
|
actionType: def.actionType ?? modalType,
|
||||||
});
|
[modalType]: JSONPipeIn({
|
||||||
|
$ref: key
|
||||||
|
})
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
schema.definitions[key] = JSONPipeIn(def);
|
schema.definitions[key] = JSONPipeIn(def);
|
||||||
} else if (parent) {
|
} else if (parent) {
|
||||||
// 没用到,可能修改了弹窗的内容为引用其他弹窗,同样需要更新,但是不会提取为 definitions
|
// 没用到,可能修改了弹窗的内容为引用其他弹窗,同样需要更新,但是不会提取为 definitions
|
||||||
@ -1550,15 +1555,20 @@ export function mergeDefinitions(
|
|||||||
if (changes) {
|
if (changes) {
|
||||||
const newModal = patchDiff(origin, changes);
|
const newModal = patchDiff(origin, changes);
|
||||||
delete newModal.$$originId;
|
delete newModal.$$originId;
|
||||||
schema = JSONUpdate(schema, parent.$$id, {
|
schema = JSONUpdate(
|
||||||
...parent,
|
schema,
|
||||||
__actionModals: undefined,
|
parent.$$id,
|
||||||
args: undefined,
|
{
|
||||||
dialog: undefined,
|
...parent,
|
||||||
drawer: undefined,
|
__actionModals: undefined,
|
||||||
actionType: def.actionType ?? modalType,
|
args: undefined,
|
||||||
[modalType]: newModal
|
dialog: undefined,
|
||||||
});
|
drawer: undefined,
|
||||||
|
actionType: def.actionType ?? modalType,
|
||||||
|
[modalType]: newModal
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (refs.includes(key)) {
|
} else if (refs.includes(key)) {
|
||||||
|
@ -132,32 +132,42 @@ function DialogActionPanel({
|
|||||||
const newModal = patchDiff(origin, changes);
|
const newModal = patchDiff(origin, changes);
|
||||||
delete newModal.$$originId;
|
delete newModal.$$originId;
|
||||||
delete newModal.$$ref;
|
delete newModal.$$ref;
|
||||||
schema = JSONUpdate(schema, parent.$$id, {
|
schema = JSONUpdate(
|
||||||
...parent,
|
schema,
|
||||||
__actionModals: undefined,
|
parent.$$id,
|
||||||
args: undefined,
|
{
|
||||||
dialog: undefined,
|
...parent,
|
||||||
drawer: undefined,
|
__actionModals: undefined,
|
||||||
actionType: def.actionType ?? modalType,
|
args: undefined,
|
||||||
[modalType]: newModal
|
dialog: undefined,
|
||||||
});
|
drawer: undefined,
|
||||||
|
actionType: def.actionType ?? modalType,
|
||||||
|
[modalType]: newModal
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 不要写下面的 defintions 了
|
// 不要写下面的 defintions 了
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
const modalType = def.type === 'drawer' ? 'drawer' : 'dialog';
|
const modalType = def.type === 'drawer' ? 'drawer' : 'dialog';
|
||||||
schema = JSONUpdate(schema, parent.$$id, {
|
schema = JSONUpdate(
|
||||||
...parent,
|
schema,
|
||||||
__actionModals: undefined,
|
parent.$$id,
|
||||||
args: undefined,
|
{
|
||||||
dialog: undefined,
|
...parent,
|
||||||
drawer: undefined,
|
__actionModals: undefined,
|
||||||
actionType: def.actionType ?? modalType,
|
args: undefined,
|
||||||
[modalType]: JSONPipeIn({
|
dialog: undefined,
|
||||||
$ref: modal.$$ref!
|
drawer: undefined,
|
||||||
})
|
actionType: def.actionType ?? modalType,
|
||||||
});
|
[modalType]: JSONPipeIn({
|
||||||
|
$ref: modal.$$ref!
|
||||||
|
})
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
schema.definitions[modal.$$ref!] = JSONPipeIn(def);
|
schema.definitions[modal.$$ref!] = JSONPipeIn(def);
|
||||||
@ -261,10 +271,15 @@ function DialogActionPanel({
|
|||||||
const definition = schema.definitions[key];
|
const definition = schema.definitions[key];
|
||||||
const exits = JSONGetById(definition, id);
|
const exits = JSONGetById(definition, id);
|
||||||
if (exits) {
|
if (exits) {
|
||||||
schema.definitions[key] = JSONUpdate(schema.definitions[key], id, {
|
schema.definitions[key] = JSONUpdate(
|
||||||
...schema,
|
schema.definitions[key],
|
||||||
definitions: undefined
|
id,
|
||||||
});
|
{
|
||||||
|
...schema,
|
||||||
|
definitions: undefined
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -280,16 +295,26 @@ function DialogActionPanel({
|
|||||||
if (refIds.length) {
|
if (refIds.length) {
|
||||||
let refKey = '';
|
let refKey = '';
|
||||||
[schema, refKey] = addModal(schema, currentModal.modal);
|
[schema, refKey] = addModal(schema, currentModal.modal);
|
||||||
schema = JSONUpdate(schema, actionSchema.$$id, {
|
schema = JSONUpdate(
|
||||||
[modalType]: JSONPipeIn({
|
schema,
|
||||||
$ref: refKey
|
actionSchema.$$id,
|
||||||
})
|
{
|
||||||
});
|
[modalType]: JSONPipeIn({
|
||||||
|
$ref: refKey
|
||||||
|
})
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
refIds.forEach(refId => {
|
refIds.forEach(refId => {
|
||||||
schema = JSONUpdate(schema, refId, {
|
schema = JSONUpdate(
|
||||||
$ref: refKey,
|
schema,
|
||||||
$$originId: undefined
|
refId,
|
||||||
});
|
{
|
||||||
|
$ref: refKey,
|
||||||
|
$$originId: undefined
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user