Add action to export project documents (#10592)

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko
2026-03-06 12:24:47 +07:00
committed by GitHub
parent f94d564ec6
commit 7a7020292b
3 changed files with 51 additions and 2 deletions
+27
View File
@@ -897,6 +897,33 @@ export function createModel (builder: Builder): void {
documents.action.ExportDocuments
)
createAction(
builder,
{
action: view.actionImpl.ShowPopup,
actionProps: {
component: exportPlugin.component.ExportToWorkspaceModal,
fillProps: {
_objects: 'value'
},
props: {
projectDocExport: true,
docClass: documents.class.ControlledDocument
}
},
label: exportPlugin.string.ExportToWorkspace,
icon: exportPlugin.icon.Export,
input: 'any',
category: view.category.General,
target: documents.class.ProjectDocument,
context: {
mode: ['context', 'browser'],
group: 'copy'
}
},
documents.action.ExportProjectDocuments
)
createAction(
builder,
{
@@ -125,6 +125,7 @@ export const documentsPlugin = plugin(documentsId, {
EditDocSpace: '' as Ref<Action>,
TransferDocument: '' as Ref<Action>,
ExportDocuments: '' as Ref<Action<Document, any>>,
ExportProjectDocuments: '' as Ref<Action<Document, any>>,
ExportDocumentsFromSpace: '' as Ref<Action<DocumentSpace, any>>,
Print: '' as Ref<Action<Doc, { signed: boolean }>>,
PrintProjectDocument: '' as Ref<Action<Doc, { signed: boolean }>>,
@@ -24,7 +24,7 @@
type Space,
type Class
} from '@hcengineering/core'
import { Card, getCurrentWorkspaceUuid } from '@hcengineering/presentation'
import { Card, getClient, getCurrentWorkspaceUuid } from '@hcengineering/presentation'
import { DropdownLabels, DropdownLabelsIntl, Label } from '@hcengineering/ui'
import { getResource } from '@hcengineering/platform'
import login from '@hcengineering/login'
@@ -39,6 +39,7 @@
export let value: Doc | Doc[] | Space
export let docClass: Ref<Class<Doc>> | undefined = undefined
export let spaceExport: boolean | undefined = false
export let projectDocExport: boolean | undefined = false
const dispatch = createEventDispatcher()
@@ -117,14 +118,34 @@
$: canSave =
targetWorkspace !== undefined && _class != null && (spaceExport === true || filteredSelectedDocs.length > 0)
async function getExportDocuments (): Promise<Array<Doc>> {
if (docClass == null) {
console.error('Document class is required to export project documents')
return []
}
const client = getClient()
const innerIds = selectedDocs.map((d) => (d as any)?.document).filter((id) => id != null)
if (innerIds.length > 0) {
const docs = await client.findAll(docClass, {
_id: { $in: innerIds }
})
return filterDocsForExport(docs, exportFilterMode)
}
return []
}
async function handleExport (): Promise<void> {
if (!canSave || _class == null) return
loading = true
const effectiveDocs = projectDocExport === true ? await getExportDocuments() : filteredSelectedDocs
void exportToWorkspace(
_class,
exportQuery,
filteredSelectedDocs,
effectiveDocs,
targetWorkspace,
undefined,
exportFilterMode === 'skipArchivedObsolete',