From 4e69e4f0d15a59842d3e37948a815c4db0931633 Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Fri, 27 May 2022 22:38:22 +0600 Subject: [PATCH] EditDocFix (#1886) --- plugins/view-resources/src/components/EditDoc.svelte | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/view-resources/src/components/EditDoc.svelte b/plugins/view-resources/src/components/EditDoc.svelte index e787edf391..e75fb8f340 100644 --- a/plugins/view-resources/src/components/EditDoc.svelte +++ b/plugins/view-resources/src/components/EditDoc.svelte @@ -77,18 +77,21 @@ const dispatch = createEventDispatcher() - function getMixins (): void { + function getMixins (parentClass: Ref>, object: Doc): void { + if (object === undefined || parentClass === undefined) return const descendants = hierarchy.getDescendants(parentClass).map((p) => hierarchy.getClass(p)) mixins = descendants.filter( (m) => m.kind === ClassifierKind.MIXIN && hierarchy.hasMixin(object, m._id) && !ignoreMixins.has(m._id) ) } + $: getMixins(parentClass, object) + let ignoreKeys: string[] = [] let ignoreMixins: Set>> = new Set>>() async function updateKeys (): Promise { - const keysMap = new Map(getFiltredKeys(hierarchy, object._class, ignoreKeys).map((p) => [p.attr._id, p])) + const keysMap = new Map(getFiltredKeys(hierarchy, realObjectClass, ignoreKeys).map((p) => [p.attr._id, p])) for (const m of mixins) { const mkeys = getFiltredKeys(hierarchy, m._id, ignoreKeys) for (const key of mkeys) { @@ -120,7 +123,6 @@ async function getEditorOrDefault (_class: Ref>): Promise { parentClass = getParentClass(_class) mainEditor = await getEditor(_class) - getMixins() updateKeys() } @@ -254,7 +256,7 @@ on:open={(ev) => { ignoreKeys = ev.detail.ignoreKeys ignoreMixins = new Set(ev.detail.ignoreMixins) - getMixins() + getMixins(parentClass, object) updateKeys() }} />