diff --git a/dev/tool/src/elastic.ts b/dev/tool/src/elastic.ts index fc50d04474..7d28e713fd 100644 --- a/dev/tool/src/elastic.ts +++ b/dev/tool/src/elastic.ts @@ -219,26 +219,30 @@ async function restoreElastic (mongoUrl: string, dbName: string, minio: Client, await Promise.all( createTxes.map(async (tx) => { const createTx = tx as TxCreateDoc - const docSnapshot = ( - await tool.storage.findAll(metricsCtx, createTx.objectClass, { _id: createTx.objectId }, { limit: 1 }) - ).shift() - if (docSnapshot !== undefined) { - // If there is no doc, then it is removed, not need to do something with elastic. - const { _class, _id, modifiedBy, modifiedOn, space, ...docData } = docSnapshot - try { - const newTx: TxCreateDoc = { - ...createTx, - attributes: docData, - modifiedBy, - modifiedOn, - objectSpace: space // <- it could be moved, let's take actual one. + try { + const docSnapshot = ( + await tool.storage.findAll(metricsCtx, createTx.objectClass, { _id: createTx.objectId }, { limit: 1 }) + ).shift() + if (docSnapshot !== undefined) { + // If there is no doc, then it is removed, not need to do something with elastic. + const { _class, _id, modifiedBy, modifiedOn, space, ...docData } = docSnapshot + try { + const newTx: TxCreateDoc = { + ...createTx, + attributes: docData, + modifiedBy, + modifiedOn, + objectSpace: space // <- it could be moved, let's take actual one. + } + await tool.fulltext.tx(metricsCtx, newTx) + } catch (err: any) { + console.error('failed to replay tx', tx, err.message) } - await tool.fulltext.tx(metricsCtx, newTx) - } catch (err: any) { - console.error('failed to replay tx', tx, err.message) + } else { + removedDocument.add(createTx.objectId) } - } else { - removedDocument.add(createTx.objectId) + } catch (e) { + console.error('failed to find object', tx, e) } }) ) @@ -250,28 +254,32 @@ async function restoreElastic (mongoUrl: string, dbName: string, minio: Client, collectionTxes.map(async (tx) => { const collTx = tx as TxCollectionCUD const createTx = collTx.tx as unknown as TxCreateDoc - const docSnapshot = ( - await tool.storage.findAll(metricsCtx, createTx.objectClass, { _id: createTx.objectId }, { limit: 1 }) - ).shift() as AttachedDoc - if (docSnapshot !== undefined) { - // If there is no doc, then it is removed, not need to do something with elastic. - const { _class, _id, modifiedBy, modifiedOn, space, ...data } = docSnapshot - try { - const newTx: TxCreateDoc = { - ...createTx, - attributes: data, - modifiedBy, - modifiedOn, - objectSpace: space // <- it could be moved, let's take actual one. + try { + const docSnapshot = ( + await tool.storage.findAll(metricsCtx, createTx.objectClass, { _id: createTx.objectId }, { limit: 1 }) + ).shift() as AttachedDoc + if (docSnapshot !== undefined) { + // If there is no doc, then it is removed, not need to do something with elastic. + const { _class, _id, modifiedBy, modifiedOn, space, ...data } = docSnapshot + try { + const newTx: TxCreateDoc = { + ...createTx, + attributes: data, + modifiedBy, + modifiedOn, + objectSpace: space // <- it could be moved, let's take actual one. + } + collTx.tx = newTx + collTx.modifiedBy = modifiedBy + collTx.modifiedOn = modifiedOn + collTx.objectSpace = space + await tool.fulltext.tx(metricsCtx, collTx) + } catch (err: any) { + console.error('failed to replay tx', tx, err.message) } - collTx.tx = newTx - collTx.modifiedBy = modifiedBy - collTx.modifiedOn = modifiedOn - collTx.objectSpace = space - await tool.fulltext.tx(metricsCtx, collTx) - } catch (err: any) { - console.error('failed to replay tx', tx, err.message) } + } catch (e) { + console.error('failed to find object', tx, e) } }) ) diff --git a/packages/presentation/src/attributes.ts b/packages/presentation/src/attributes.ts index 3e4bcad448..e2bec5c272 100644 --- a/packages/presentation/src/attributes.ts +++ b/packages/presentation/src/attributes.ts @@ -17,6 +17,7 @@ export async function updateAttribute ( ): Promise { const doc = object const attributeKey = attribute.key + if ((doc as any)[attributeKey] === value) return const attr = attribute.attr if (client.getHierarchy().isMixin(attr.attributeOf)) { await client.updateMixin(doc._id, _class, doc.space, attr.attributeOf, { [attributeKey]: value }) diff --git a/packages/presentation/src/components/AttributeBarEditor.svelte b/packages/presentation/src/components/AttributeBarEditor.svelte index 272778a7bb..5be8e5c2ff 100644 --- a/packages/presentation/src/components/AttributeBarEditor.svelte +++ b/packages/presentation/src/components/AttributeBarEditor.svelte @@ -22,16 +22,15 @@ import { getAttribute, KeyedAttribute, updateAttribute } from '../attributes' import { getAttributePresenterClass, getClient } from '../utils' - // export let _class: Ref> export let key: KeyedAttribute | string export let object: Doc + export let _class: Ref> export let maxWidth: string | undefined = undefined export let focus: boolean = false export let minimize: boolean = false export let showHeader: boolean = true export let vertical: boolean = false - const _class = object._class const client = getClient() const hierarchy = client.getHierarchy() diff --git a/packages/presentation/src/components/AttributesBar.svelte b/packages/presentation/src/components/AttributesBar.svelte index 13cff74eee..81819a7aa0 100644 --- a/packages/presentation/src/components/AttributesBar.svelte +++ b/packages/presentation/src/components/AttributesBar.svelte @@ -14,24 +14,25 @@ // limitations under the License. -->
- {#each keys as key} + {#each keys as key (typeof key === 'string' ? key : key.key)} {#if !vertical}
- +
{:else} - + {/if} {/each}
diff --git a/plugins/contact-resources/src/components/EditPerson.svelte b/plugins/contact-resources/src/components/EditPerson.svelte index ff23b9ed6f..7e1658b1e2 100644 --- a/plugins/contact-resources/src/components/EditPerson.svelte +++ b/plugins/contact-resources/src/components/EditPerson.svelte @@ -21,7 +21,7 @@ import { AttributeEditor, Avatar, createQuery, EditableAvatar, getClient } from '@anticrm/presentation' import setting, { IntegrationType } from '@anticrm/setting' import { EditBox, createFocusManager, FocusHandler } from '@anticrm/ui' - import { afterUpdate, createEventDispatcher, onMount } from 'svelte' + import { createEventDispatcher, onMount } from 'svelte' import contact from '../plugin' import ChannelsEditor from './ChannelsEditor.svelte' @@ -68,7 +68,6 @@ const sendOpen = () => dispatch('open', { ignoreKeys: ['comments', 'name', 'channels', 'city'] }) onMount(sendOpen) - afterUpdate(sendOpen) async function onAvatarDone (e: any) { const uploadFile = await getResource(attachment.helper.UploadFile) diff --git a/plugins/recruit-resources/src/components/EditVacancy.svelte b/plugins/recruit-resources/src/components/EditVacancy.svelte index f3e0840685..b2b308ca00 100644 --- a/plugins/recruit-resources/src/components/EditVacancy.svelte +++ b/plugins/recruit-resources/src/components/EditVacancy.svelte @@ -68,7 +68,7 @@ {#if dir === 'column'}
- +
{/if} diff --git a/plugins/recruit-resources/src/components/review/EditReviewCategory.svelte b/plugins/recruit-resources/src/components/review/EditReviewCategory.svelte index 2ba8eed69b..4de7ab727a 100644 --- a/plugins/recruit-resources/src/components/review/EditReviewCategory.svelte +++ b/plugins/recruit-resources/src/components/review/EditReviewCategory.svelte @@ -63,7 +63,7 @@ {#if dir === 'column'}
- +
{/if}
diff --git a/plugins/task-resources/src/components/TaskHeader.svelte b/plugins/task-resources/src/components/TaskHeader.svelte index 879e2097ed..4ea6b1daa6 100644 --- a/plugins/task-resources/src/components/TaskHeader.svelte +++ b/plugins/task-resources/src/components/TaskHeader.svelte @@ -71,10 +71,10 @@ titleDeselect={task.string.TaskUnAssign} />
- +
- + {:else} diff --git a/plugins/view-resources/src/components/ClassAttributeBar.svelte b/plugins/view-resources/src/components/ClassAttributeBar.svelte index deecd902df..be30becbbb 100644 --- a/plugins/view-resources/src/components/ClassAttributeBar.svelte +++ b/plugins/view-resources/src/components/ClassAttributeBar.svelte @@ -21,7 +21,7 @@ import { collectionsFilter, getFiltredKeys } from '../utils' export let object: Doc - export let objectClass: Class + export let _class: Ref> export let to: Ref> | undefined export let ignoreKeys: string[] = [] export let vertical: boolean @@ -32,12 +32,14 @@ let collapsed: boolean = false function updateKeys (ignoreKeys: string[]): void { - const filtredKeys = getFiltredKeys(hierarchy, objectClass._id, ignoreKeys, to) + const filtredKeys = getFiltredKeys(hierarchy, _class, ignoreKeys, to) keys = collectionsFilter(hierarchy, filtredKeys, false) } $: updateKeys(ignoreKeys) + $: label = hierarchy.getClass(_class).label + const dispatch = createEventDispatcher() @@ -51,7 +53,7 @@ >
-
@@ -66,7 +68,7 @@ kind={'transparent'} on:click={(ev) => { ev.stopPropagation() - showPopup(view.component.CreateAttribute, { _class: objectClass._id }, 'top', () => { + showPopup(view.component.CreateAttribute, { _class }, 'top', () => { updateKeys(ignoreKeys) dispatch('update') }) @@ -78,7 +80,7 @@ {/if} {#if keys.length || !vertical}
- + p.key)} {vertical} />
{/if} diff --git a/plugins/view-resources/src/components/DocAttributeBar.svelte b/plugins/view-resources/src/components/DocAttributeBar.svelte index d9c9cdc23c..8de831800b 100644 --- a/plugins/view-resources/src/components/DocAttributeBar.svelte +++ b/plugins/view-resources/src/components/DocAttributeBar.svelte @@ -14,20 +14,14 @@ --> - + {#each mixins as mixin} - - + {/each} diff --git a/plugins/view-resources/src/components/EditBoxPopup.svelte b/plugins/view-resources/src/components/EditBoxPopup.svelte index 1fcee40da6..d0b95ad457 100644 --- a/plugins/view-resources/src/components/EditBoxPopup.svelte +++ b/plugins/view-resources/src/components/EditBoxPopup.svelte @@ -27,9 +27,6 @@ const dispatch = createEventDispatcher() - function _onchange () { - dispatch('update', value) - } function _onkeypress (ev: KeyboardEvent) { if (ev.key === 'Enter') dispatch('close', value) } @@ -37,15 +34,6 @@
- +
diff --git a/plugins/view-resources/src/components/EditDoc.svelte b/plugins/view-resources/src/components/EditDoc.svelte index 896a561bae..e787edf391 100644 --- a/plugins/view-resources/src/components/EditDoc.svelte +++ b/plugins/view-resources/src/components/EditDoc.svelte @@ -37,10 +37,10 @@ export let _id: Ref export let _class: Ref> + let realObjectClass: Ref> = _class let lastId: Ref = _id let lastClass: Ref> = _class let object: Doc - let objectClass: Class let parentClass: Ref> const client = getClient() @@ -67,20 +67,14 @@ _class && query.query(_class, { _id }, (result) => { object = result[0] + realObjectClass = object._class }) - $: if (object !== undefined) objectClass = hierarchy.getClass(object._class) - let keys: KeyedAttribute[] = [] let collectionEditors: { key: KeyedAttribute; editor: AnyComponent }[] = [] let mixins: Mixin[] = [] - $: if (object) { - parentClass = getParentClass(object._class) - getMixins() - } - const dispatch = createEventDispatcher() function getMixins (): void { @@ -120,17 +114,14 @@ return editorMixin.editor } - let mainEditor: AnyComponent - $: if (object) getEditorOrDefault(object._class, object._class) + let mainEditor: AnyComponent | undefined + $: getEditorOrDefault(realObjectClass) - async function getEditorOrDefault (_class: Ref> | undefined, defaultClass: Ref>): Promise { - let editor = _class !== undefined ? await getEditor(_class) : undefined - if (editor === undefined) { - editor = await getEditor(defaultClass) - } - mainEditor = editor - updateKeys() + async function getEditorOrDefault (_class: Ref>): Promise { + parentClass = getParentClass(_class) + mainEditor = await getEditor(_class) getMixins() + updateKeys() } async function getCollectionEditor (key: KeyedAttribute): Promise { @@ -140,7 +131,8 @@ return editorMixin.editor } - function getIcon (_class: Ref>): Asset { + function getIcon (_class: Ref> | undefined): Asset | undefined { + if (_class === undefined) return undefined let clazz = hierarchy.getClass(_class) if (clazz.icon !== undefined) return clazz.icon while (clazz.extends !== undefined) { @@ -152,7 +144,7 @@ throw new Error(`Icon not found for ${_class}`) } - $: icon = object && getIcon(object._class) + $: icon = getIcon(realObjectClass) function getParentClass (_class: Ref>): Ref> { const baseDomain = hierarchy.getDomain(_class) @@ -198,9 +190,9 @@ let headerEditor: AnyComponent | undefined = undefined let headerLoading = false - $: if (object !== undefined) { + $: { headerLoading = true - getHeaderEditor(object._class).then((r) => { + getHeaderEditor(realObjectClass).then((r) => { headerEditor = r headerLoading = false }) @@ -250,7 +242,7 @@ {:else if dir === 'column'} {:else} - + {/if} {/if} @@ -262,8 +254,8 @@ on:open={(ev) => { ignoreKeys = ev.detail.ignoreKeys ignoreMixins = new Set(ev.detail.ignoreMixins) - updateKeys() getMixins() + updateKeys() }} /> {/if} diff --git a/plugins/view-resources/src/components/NumberEditor.svelte b/plugins/view-resources/src/components/NumberEditor.svelte index c7e2aa2b8b..7f1d629b34 100644 --- a/plugins/view-resources/src/components/NumberEditor.svelte +++ b/plugins/view-resources/src/components/NumberEditor.svelte @@ -38,21 +38,13 @@ class="link-container" on:click={(ev) => { if (!shown) { - showPopup( - EditBoxPopup, - { value, format: 'number' }, - eventToHTMLElement(ev), - (res) => { - if (res !== undefined) { - value = res - onChange(value) - } - shown = false - }, - (res) => { - if (res !== undefined) value = res + showPopup(EditBoxPopup, { value, format: 'number' }, eventToHTMLElement(ev), (res) => { + if (res !== undefined) { + value = res + onChange(value) } - ) + shown = false + }) } }} > diff --git a/plugins/view-resources/src/components/StringEditor.svelte b/plugins/view-resources/src/components/StringEditor.svelte index 15c0a5df48..d610b5061c 100644 --- a/plugins/view-resources/src/components/StringEditor.svelte +++ b/plugins/view-resources/src/components/StringEditor.svelte @@ -38,21 +38,13 @@ class="link-container" on:click={(ev) => { if (!shown) { - showPopup( - EditBoxPopup, - { value }, - eventToHTMLElement(ev), - (res) => { - if (res !== undefined) { - value = res - onChange(value) - } - shown = false - }, - (res) => { - if (res !== undefined) value = res + showPopup(EditBoxPopup, { value }, eventToHTMLElement(ev), (res) => { + if (res !== undefined) { + value = res + onChange(value) } - ) + shown = false + }) } }} >