|
1 | 1 | <script lang="ts">
|
2 | 2 | import core, { Association, Class, Data, Doc, Ref } from '@hcengineering/core'
|
3 |
| - import { createQuery } from '@hcengineering/presentation' |
4 |
| - import { Button, Header, Breadcrumb, Separator, defineSeparators, twoPanelsSeparators } from '@hcengineering/ui' |
| 3 | + import { createQuery, getClient, MessageBox } from '@hcengineering/presentation' |
| 4 | + import { |
| 5 | + Button, |
| 6 | + Header, |
| 7 | + Breadcrumb, |
| 8 | + Separator, |
| 9 | + defineSeparators, |
| 10 | + twoPanelsSeparators, |
| 11 | + IconDelete, |
| 12 | + showPopup |
| 13 | + } from '@hcengineering/ui' |
5 | 14 | import settings from '../plugin'
|
6 |
| - import view from '@hcengineering/view' |
| 15 | + import view from '@hcengineering/view-resources/src/plugin' |
7 | 16 | import AssociationEditor from './AssociationEditor.svelte'
|
8 | 17 |
|
9 | 18 | const query = createQuery()
|
| 19 | + const client = getClient() |
10 | 20 |
|
11 | 21 | let selected: Association | Data<Association> | undefined
|
12 | 22 |
|
|
26 | 36 | }
|
27 | 37 | }
|
28 | 38 |
|
| 39 | + function isAssociation (data: Data<Association> | Association | undefined): data is Association { |
| 40 | + return (data as Association)?._id !== undefined |
| 41 | + } |
| 42 | +
|
29 | 43 | defineSeparators('workspaceSettings', twoPanelsSeparators)
|
| 44 | +
|
| 45 | + async function remove (val: Association | Data<Association> | undefined): Promise<void> { |
| 46 | + if (isAssociation(val)) { |
| 47 | + showPopup(MessageBox, { |
| 48 | + label: view.string.DeleteObject, |
| 49 | + message: view.string.DeleteObjectConfirm, |
| 50 | + params: { count: 1 }, |
| 51 | + dangerous: true, |
| 52 | + action: async () => { |
| 53 | + selected = undefined |
| 54 | + await client.remove(val) |
| 55 | + } |
| 56 | + }) |
| 57 | + } |
| 58 | + } |
30 | 59 | </script>
|
31 | 60 |
|
32 | 61 | <div class="hulyComponent">
|
33 | 62 | <Header adaptive={'disabled'}>
|
34 | 63 | <Breadcrumb icon={settings.icon.Relations} label={core.string.Relations} size={'large'} isCurrent />
|
| 64 | + |
| 65 | + <svelte:fragment slot="actions"> |
| 66 | + {#if isAssociation(selected)} |
| 67 | + <Button icon={IconDelete} label={view.string.Delete} kind={'dangerous'} on:click={() => remove(selected)} /> |
| 68 | + {/if} |
| 69 | + </svelte:fragment> |
35 | 70 | </Header>
|
36 | 71 |
|
37 | 72 | <div class="hulyComponent-content__container columns">
|
|
0 commit comments