mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
Minor fixes (#1822)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
f6cb336d4d
commit
e02631a0a6
@ -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<Doc>
|
||||
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<Doc> = {
|
||||
...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<Doc> = {
|
||||
...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<Doc, AttachedDoc>
|
||||
const createTx = collTx.tx as unknown as TxCreateDoc<AttachedDoc>
|
||||
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<AttachedDoc> = {
|
||||
...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<AttachedDoc> = {
|
||||
...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)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
@ -17,6 +17,7 @@ export async function updateAttribute (
|
||||
): Promise<void> {
|
||||
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 })
|
||||
|
@ -22,16 +22,15 @@
|
||||
import { getAttribute, KeyedAttribute, updateAttribute } from '../attributes'
|
||||
import { getAttributePresenterClass, getClient } from '../utils'
|
||||
|
||||
// export let _class: Ref<Class<Doc>>
|
||||
export let key: KeyedAttribute | string
|
||||
export let object: Doc
|
||||
export let _class: Ref<Class<Doc>>
|
||||
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()
|
||||
|
||||
|
@ -14,24 +14,25 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import type { Doc } from '@anticrm/core'
|
||||
import type { Class, Doc, Ref } from '@anticrm/core'
|
||||
import { KeyedAttribute } from '../attributes'
|
||||
import AttributeBarEditor from './AttributeBarEditor.svelte'
|
||||
|
||||
export let object: Doc
|
||||
export let _class: Ref<Class<Doc>>
|
||||
export let keys: (string | KeyedAttribute)[]
|
||||
export let showHeader: boolean = true
|
||||
export let vertical: boolean = false
|
||||
</script>
|
||||
|
||||
<div class="attributes-bar-container {vertical ? 'vertical' : 'horizontal'}">
|
||||
{#each keys as key}
|
||||
{#each keys as key (typeof key === 'string' ? key : key.key)}
|
||||
{#if !vertical}
|
||||
<div class="flex-center column">
|
||||
<AttributeBarEditor {key} {object} {showHeader} />
|
||||
<AttributeBarEditor {key} {_class} {object} {showHeader} />
|
||||
</div>
|
||||
{:else}
|
||||
<AttributeBarEditor {key} {object} {showHeader} vertical />
|
||||
<AttributeBarEditor {key} {_class} {object} {showHeader} vertical />
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
|
@ -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)
|
||||
|
@ -68,7 +68,7 @@
|
||||
{#if dir === 'column'}
|
||||
<div class="ac-subtitle">
|
||||
<div class="ac-subtitle-content">
|
||||
<AttributesBar {object} keys={['dueTo', 'location', 'company']} vertical />
|
||||
<AttributesBar {object} _class={object._class} keys={['dueTo', 'location', 'company']} vertical />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
@ -63,7 +63,7 @@
|
||||
<svelte:fragment slot="attributes" let:direction={dir}>
|
||||
{#if dir === 'column'}
|
||||
<div class="flex-row-center subtitle">
|
||||
<AttributesBar {object} keys={[]} vertical />
|
||||
<AttributesBar {object} _class={object._class} keys={[]} vertical />
|
||||
</div>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
|
@ -71,10 +71,10 @@
|
||||
titleDeselect={task.string.TaskUnAssign}
|
||||
/>
|
||||
<div class="column">
|
||||
<AttributesBar {object} keys={filtredKeys} />
|
||||
<AttributesBar {object} _class={object._class} keys={filtredKeys} />
|
||||
</div>
|
||||
</div>
|
||||
<AttributesBar {object} keys={['doneState', 'state']} showHeader={false} />
|
||||
<AttributesBar {object} _class={object._class} keys={['doneState', 'state']} showHeader={false} />
|
||||
</div>
|
||||
{:else}
|
||||
<DocAttributeBar {object} {ignoreKeys} {mixins} on:update />
|
||||
|
@ -21,7 +21,7 @@
|
||||
import { collectionsFilter, getFiltredKeys } from '../utils'
|
||||
|
||||
export let object: Doc
|
||||
export let objectClass: Class<Doc>
|
||||
export let _class: Ref<Class<Doc>>
|
||||
export let to: Ref<Class<Doc>> | 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()
|
||||
</script>
|
||||
|
||||
@ -51,7 +53,7 @@
|
||||
>
|
||||
<div class="flex-row-center">
|
||||
<span class="overflow-label">
|
||||
<Label label={objectClass.label} />
|
||||
<Label {label} />
|
||||
</span>
|
||||
<div class="icon-arrow">
|
||||
<svg fill="var(--dark-color)" viewBox="0 0 6 6" xmlns="http://www.w3.org/2000/svg">
|
||||
@ -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}
|
||||
<div class="collapsed-container" class:collapsed>
|
||||
<AttributesBar {object} {keys} {vertical} />
|
||||
<AttributesBar {_class} {object} keys={keys.map((p) => p.key)} {vertical} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
@ -14,20 +14,14 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Doc, Mixin } from '@anticrm/core'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
import ClassAttributeBar from './ClassAttributeBar.svelte'
|
||||
|
||||
export let object: Doc
|
||||
export let mixins: Mixin<Doc>[]
|
||||
export let ignoreKeys: string[]
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
|
||||
$: objectClass = hierarchy.getClass(object._class)
|
||||
</script>
|
||||
|
||||
<ClassAttributeBar {objectClass} {object} {ignoreKeys} to={undefined} vertical on:update />
|
||||
<ClassAttributeBar _class={object._class} {object} {ignoreKeys} to={undefined} vertical on:update />
|
||||
{#each mixins as mixin}
|
||||
<!-- <div class="bottom-divider mt-4 mb-2" /> -->
|
||||
<ClassAttributeBar objectClass={mixin} {object} {ignoreKeys} to={objectClass._id} vertical on:update />
|
||||
<ClassAttributeBar _class={mixin._id} {object} {ignoreKeys} to={object._class} vertical on:update />
|
||||
{/each}
|
||||
|
@ -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 @@
|
||||
|
||||
<div class="selectPopup">
|
||||
<div class="header no-border">
|
||||
<EditBox
|
||||
bind:value
|
||||
{placeholder}
|
||||
{format}
|
||||
{kind}
|
||||
{maxWidth}
|
||||
focus
|
||||
on:change={_onchange}
|
||||
on:keypress={_onkeypress}
|
||||
/>
|
||||
<EditBox bind:value {placeholder} {format} {kind} {maxWidth} focus on:keypress={_onkeypress} />
|
||||
</div>
|
||||
</div>
|
||||
|
@ -37,10 +37,10 @@
|
||||
export let _id: Ref<Doc>
|
||||
export let _class: Ref<Class<Doc>>
|
||||
|
||||
let realObjectClass: Ref<Class<Doc>> = _class
|
||||
let lastId: Ref<Doc> = _id
|
||||
let lastClass: Ref<Class<Doc>> = _class
|
||||
let object: Doc
|
||||
let objectClass: Class<Doc>
|
||||
let parentClass: Ref<Class<Doc>>
|
||||
|
||||
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<Doc>[] = []
|
||||
|
||||
$: 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<Class<Doc>> | undefined, defaultClass: Ref<Class<Doc>>): Promise<void> {
|
||||
let editor = _class !== undefined ? await getEditor(_class) : undefined
|
||||
if (editor === undefined) {
|
||||
editor = await getEditor(defaultClass)
|
||||
}
|
||||
mainEditor = editor
|
||||
updateKeys()
|
||||
async function getEditorOrDefault (_class: Ref<Class<Doc>>): Promise<void> {
|
||||
parentClass = getParentClass(_class)
|
||||
mainEditor = await getEditor(_class)
|
||||
getMixins()
|
||||
updateKeys()
|
||||
}
|
||||
|
||||
async function getCollectionEditor (key: KeyedAttribute): Promise<AnyComponent> {
|
||||
@ -140,7 +131,8 @@
|
||||
return editorMixin.editor
|
||||
}
|
||||
|
||||
function getIcon (_class: Ref<Class<Obj>>): Asset {
|
||||
function getIcon (_class: Ref<Class<Obj>> | 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<Class<Doc>>): Ref<Class<Doc>> {
|
||||
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'}
|
||||
<DocAttributeBar {object} {mixins} {ignoreKeys} on:update={updateKeys} />
|
||||
{:else}
|
||||
<AttributesBar {object} {keys} />
|
||||
<AttributesBar {object} _class={realObjectClass} {keys} />
|
||||
{/if}
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
@ -262,8 +254,8 @@
|
||||
on:open={(ev) => {
|
||||
ignoreKeys = ev.detail.ignoreKeys
|
||||
ignoreMixins = new Set(ev.detail.ignoreMixins)
|
||||
updateKeys()
|
||||
getMixins()
|
||||
updateKeys()
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
@ -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
|
||||
})
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
@ -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
|
||||
})
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user