From 250937c17557762619b59f3a47bdcdca265dead2 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Tue, 8 Feb 2022 22:40:13 +0700 Subject: [PATCH] Fix collection editors in Safari (#973) Signed-off-by: Andrey Sobolev --- .../src/components/EditDoc.svelte | 54 ++++++++----------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/plugins/view-resources/src/components/EditDoc.svelte b/plugins/view-resources/src/components/EditDoc.svelte index df9c0fe904..cd4015c7b7 100644 --- a/plugins/view-resources/src/components/EditDoc.svelte +++ b/plugins/view-resources/src/components/EditDoc.svelte @@ -55,8 +55,7 @@ let prevSelected = selectedClass let keys: KeyedAttribute[] = [] - let collectionKeys: KeyedAttribute[] = [] - let collectionEditors: AnyComponent[] = [] + let collectionEditors: {key: KeyedAttribute, editor: AnyComponent} [] = [] let mixins: Mixin[] = [] @@ -93,14 +92,21 @@ let ignoreKeys: string[] = [] - function updateKeys (): void { + async function updateKeys (): Promise { const filtredKeys = getFiltredKeys( selectedClass ?? object._class, ignoreKeys, selectedClass !== objectClass._id ? objectClass._id : undefined ) keys = collectionsFilter(filtredKeys, false) - collectionKeys = collectionsFilter(filtredKeys, true) + + const collectionKeys = collectionsFilter(filtredKeys, true) + const editors: {key: KeyedAttribute, editor: AnyComponent}[] = [] + for (const k of collectionKeys) { + const editor = await getCollectionEditor(k) + editors.push({ key: k, editor }) + } + collectionEditors = editors } function collectionsFilter (keys: KeyedAttribute[], get: boolean): KeyedAttribute[] { @@ -215,16 +221,6 @@ headerLoading = false }) } - - async function updateCollectionEditors (keys: KeyedAttribute[]): Promise { - const editors: AnyComponent[] = [] - for (const k of keys) { - editors.push(await getCollectionEditor(k)) - } - collectionEditors = editors - } - - $: updateCollectionEditors(collectionKeys) {#if object !== undefined && title !== undefined} @@ -287,23 +283,19 @@ {/each} {/if} - {#if collectionKeys.length !== collectionEditors.length} - - {:else} - {#each collectionKeys as collection, i} -
- -
- {/each} - {/if} + {#each collectionEditors as collection, i} +
+ +
+ {/each} {/if}