mirror of
https://github.com/hcengineering/platform.git
synced 2026-10-01 05:55:09 +02:00
@@ -14,34 +14,39 @@
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import type { IntlString, Asset } from '@anticrm/platform'
|
||||
import type { AnySvelteComponent } from '@anticrm/ui'
|
||||
import type { IntlString, Asset, Resource } from '@anticrm/platform'
|
||||
import { getResource } from '@anticrm/platform'
|
||||
import { getClient, createQuery } from '@anticrm/presentation'
|
||||
import type { Ref, Class, Doc } from '@anticrm/core'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { Icon, Label, IconMoreH, IconFile } from '@anticrm/ui'
|
||||
import type { Action, ActionTarget } from '@anticrm/view'
|
||||
import { getActions } from '../utils'
|
||||
import view from '@anticrm/view'
|
||||
|
||||
export let title: IntlString
|
||||
export let caption: IntlString
|
||||
export let object: Doc
|
||||
|
||||
let actions: Action[] = []
|
||||
|
||||
interface PopupItem {
|
||||
icon: Asset | AnySvelteComponent
|
||||
label: IntlString
|
||||
action?: () => Promise<void>
|
||||
}
|
||||
const client = getClient()
|
||||
|
||||
getActions(client, object._class).then(result => { actions = result })
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
const actions: Array<PopupItem> = [{ icon: IconFile, label: 'Application', action: async () => {} },
|
||||
{ icon: IconMoreH, label: 'Options', action: async () => {} }]
|
||||
|
||||
async function invokeAction(action: Resource<(object: Doc) => Promise<void>>) {
|
||||
dispatch('close')
|
||||
const impl = await getResource(action)
|
||||
await impl(object)
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="flex-col popup">
|
||||
{#each actions as action}
|
||||
<div class="flex-row-center menu-item" on:click={() => { dispatch('close') }}>
|
||||
<div class="flex-row-center menu-item" on:click={() => { invokeAction(action.action) }}>
|
||||
<div class="icon">
|
||||
{#if typeof (action.icon) === 'string'}
|
||||
<Icon icon={action.icon} size={'large'} />
|
||||
{:else}
|
||||
<svelte:component this={action.icon} size={'large'} />
|
||||
{/if}
|
||||
<Icon icon={action.icon} size={'large'} />
|
||||
</div>
|
||||
<div class="label"><Label label={action.label} /></div>
|
||||
</div>
|
||||
|
||||
@@ -58,11 +58,12 @@
|
||||
}
|
||||
return false
|
||||
}
|
||||
const showMenu = (ev: MouseEvent): void => {
|
||||
|
||||
const showMenu = (ev: MouseEvent, object: Doc): void => {
|
||||
const elRow: HTMLElement = findNode(ev.target as HTMLElement, 'tr-body')
|
||||
const elBtn: HTMLElement = findNode(ev.target as HTMLElement, 'menuRow')
|
||||
elRow.classList.add('fixed')
|
||||
showPopup(Menu, {}, elBtn, (() => {
|
||||
showPopup(Menu, { object }, elBtn, (() => {
|
||||
elRow.classList.remove('fixed')
|
||||
}))
|
||||
}
|
||||
@@ -100,7 +101,7 @@
|
||||
<div class="firstCell">
|
||||
<div class="control">
|
||||
<CheckBox bind:checked={checking} />
|
||||
<div class="menuRow" on:click={(ev) => showMenu(ev)}><MoreV size={'small'} /></div>
|
||||
<div class="menuRow" on:click={(ev) => showMenu(ev, object)}><MoreV size={'small'} /></div>
|
||||
</div>
|
||||
<svelte:component this={attribute.presenter} value={getValue(object, attribute.key)}/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user