Fix Event source (#2258)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-08-25 10:09:33 +07:00 committed by GitHub
parent 93ebcce50d
commit 2ea4f3f93a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 7 deletions

View File

@ -36,6 +36,7 @@
"NoReminders": "No reminders",
"AllDay": "All day",
"AndMore": "And {count} more",
"CreateEvent": "Create event"
"CreateEvent": "Create event",
"EventFor": "Event for: "
}
}

View File

@ -34,6 +34,7 @@
"NoReminders": "Нет напоминаний",
"AllDay": "Весь день",
"AndMore": "И еще {count}",
"CreateEvent": "Создать событие"
"CreateEvent": "Создать событие",
"EventFor": "Событие для: "
}
}

View File

@ -14,13 +14,16 @@
-->
<script lang="ts">
import { Event } from '@anticrm/calendar'
import { getClient } from '@anticrm/presentation'
import { Doc, WithLookup } from '@anticrm/core'
import { createQuery, getClient } from '@anticrm/presentation'
import { StyledTextBox } from '@anticrm/text-editor'
import { StylishEdit } from '@anticrm/ui'
import { AnyComponent, Component, Label, StylishEdit } from '@anticrm/ui'
import ObjectPresenter from '@anticrm/view-resources/src/components/ObjectPresenter.svelte'
import { getObjectPreview } from '@anticrm/view-resources/src/utils'
import { createEventDispatcher, onMount } from 'svelte'
import calendar from '../plugin'
export let object: Event
export let object: WithLookup<Event>
const dispatch = createEventDispatcher()
const client = getClient()
@ -31,9 +34,43 @@
ignoreMixins: [calendar.mixin.Reminder]
})
})
const query = createQuery()
let doc: Doc | undefined
$: if (object.attachedTo !== undefined && object.attachedToClass !== undefined) {
query.query(object.attachedToClass, { _id: object.attachedTo }, (res) => {
doc = res.shift()
})
}
let presenter: AnyComponent | undefined
async function updatePreviewPresenter (doc?: Doc): Promise<void> {
if (doc === undefined) {
return
}
presenter = doc !== undefined ? await getObjectPreview(client, doc._class) : undefined
}
$: updatePreviewPresenter(doc)
</script>
{#if object !== undefined}
{#if object.attachedTo && object.attachedToClass}
<div class="mb-4">
<div class="flex-row-center p-1">
<Label label={calendar.string.EventFor} />
<div class="ml-2">
<ObjectPresenter _class={object.attachedToClass} objectId={object.attachedTo} value={doc} />
</div>
</div>
{#if presenter !== undefined && doc}
<div class="antiPanel p-4">
<Component is={presenter} props={{ object: doc }} />
</div>
{/if}
</div>
{/if}
<div class="mb-2">
<div class="mb-4">
<StylishEdit

View File

@ -41,6 +41,7 @@ export default mergeIds(calendarId, calendar, {
NoReminders: '' as IntlString,
AllDay: '' as IntlString,
AndMore: '' as IntlString,
CreateEvent: '' as IntlString
CreateEvent: '' as IntlString,
EventFor: '' as IntlString
}
})

View File

@ -20,7 +20,7 @@
export let objectId: Ref<Doc>
export let _class: Ref<Class<Doc>>
export let value: Doc | undefined
export let value: Doc | undefined = undefined
export let props: Record<string, any> = {}
const client = getClient()