mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-31 12:19:47 +02:00
Show actions button instead of 'Copy all' (#10537)
Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
// Copyright © 2026 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use it except in compliance with the License. You may obtain
|
||||
// you may not use this file except in compliance with the License. You may obtain
|
||||
// a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
-->
|
||||
<script lang="ts">
|
||||
import type { Class, Doc, DocumentQuery, Ref } from '@hcengineering/core'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { Button, IconCopy } from '@hcengineering/ui'
|
||||
import { ButtonMenu, IconCopy, IconMoreH, type DropdownIntlItem } from '@hcengineering/ui'
|
||||
import view from '@hcengineering/view'
|
||||
import { viewletContextStore } from '@hcengineering/view-resources'
|
||||
import { copyAsMarkdownTableFromResource, copyRelationshipTableAsMarkdown } from '../markdown/copyActions'
|
||||
@@ -17,13 +17,23 @@
|
||||
export let query: DocumentQuery<Doc> = {}
|
||||
export let config: Array<string | import('@hcengineering/view').BuildModelKey> = []
|
||||
|
||||
// TODO: Register actions separately and make common extension for viewlet actions
|
||||
const COPY_ALL_ACTION_ID = 'copy-all'
|
||||
|
||||
$: ctx = $viewletContextStore?.getLastContext()
|
||||
$: relationshipTableData = ctx?.relationshipTableData
|
||||
$: viewlet = ctx?.viewlet
|
||||
|
||||
$: hasData = relationshipTableData !== undefined || (_class !== undefined && query !== undefined)
|
||||
$: actions = [
|
||||
{
|
||||
id: COPY_ALL_ACTION_ID,
|
||||
label: view.string.CopyAll,
|
||||
icon: IconCopy
|
||||
}
|
||||
] satisfies DropdownIntlItem[]
|
||||
|
||||
async function handleClick (e: MouseEvent): Promise<void> {
|
||||
async function handleCopyAll (e: Event): Promise<void> {
|
||||
if (relationshipTableData !== undefined) {
|
||||
await copyRelationshipTableAsMarkdown(e, relationshipTableData)
|
||||
} else if (_class !== undefined && query !== undefined) {
|
||||
@@ -38,9 +48,16 @@
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function onActionSelected (event?: CustomEvent): Promise<void> {
|
||||
if (event == null || event.detail !== COPY_ALL_ACTION_ID) {
|
||||
return
|
||||
}
|
||||
|
||||
await handleCopyAll(event)
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if hasData}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<Button icon={IconCopy} label={view.string.CopyAll} on:click={handleClick} />
|
||||
<ButtonMenu size="small" noSelection icon={IconMoreH} items={actions} on:selected={onActionSelected} />
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user