platform/plugins/training-resources/src/components/TrainingAttemptNumberPresenter.svelte
Alexey Zinoviev 48e1ca9849
UBERF-7090: Add QMS plugins (#5716)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
2024-06-03 19:55:54 +04:00

41 lines
1.1 KiB
Svelte

<!--
Copyright @ 2024 Hardcore Engineering Inc.
-->
<script lang="ts">
import type { TrainingAttempt } from '@hcengineering/training'
import { createQuery } from '@hcengineering/presentation'
import { Label, Loading } from '@hcengineering/ui'
import training from '../plugin'
import TrainingRequestMaxAttemptsPresenter from './TrainingRequestMaxAttemptsPresenter.svelte'
export let value: TrainingAttempt
export let showLabel: boolean = false
let maxAttempts: number | null | undefined = undefined
const query = createQuery()
$: query.query(
value._class,
{ _id: value._id },
(result) => {
maxAttempts = result[0]?.$lookup?.attachedTo?.maxAttempts ?? null
},
{
lookup: {
attachedTo: training.class.TrainingRequest
}
}
)
</script>
{#if maxAttempts === undefined}
<Loading size="small" />
{:else}
<span class="no-word-wrap">
{#if showLabel}
<Label label={training.string.TrainingAttempt} />
{/if}
{value.seqNumber}/<TrainingRequestMaxAttemptsPresenter value={maxAttempts} />
</span>
{/if}