mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-10 03:37:43 +02:00
* feat: Ability to select multiple docs and to export to pdf Signed-off-by: Artem Savchenko <armisav@gmail.com> * Add loading indicator Signed-off-by: Artem Savchenko <armisav@gmail.com> * Fix layout Signed-off-by: Artem Savchenko <armisav@gmail.com> * Add scroller Signed-off-by: Artem Savchenko <armisav@gmail.com> --------- Signed-off-by: Artem Savchenko <armisav@gmail.com>
72 lines
1.3 KiB
TypeScript
72 lines
1.3 KiB
TypeScript
//
|
|
// Copyright © 2024 Hardcore Engineering Inc.
|
|
//
|
|
import { type Doc } from '@hcengineering/core'
|
|
import { type Resources } from '@hcengineering/platform'
|
|
import { showPopup } from '@hcengineering/ui'
|
|
import { getPrintBaseURL } from '@hcengineering/print'
|
|
|
|
import PrintToPDF from './components/PrintToPDF.svelte'
|
|
import PrintBulkToPDF from './components/PrintBulkToPDF.svelte'
|
|
import DOCXViewer from './components/DOCXViewer.svelte'
|
|
|
|
export async function print (
|
|
object: Doc | Doc[],
|
|
evt: Event,
|
|
props: {
|
|
signed: boolean
|
|
}
|
|
): Promise<void> {
|
|
const signed = props?.signed ?? false
|
|
const docs = Array.isArray(object) ? object : [object]
|
|
|
|
if (docs.length === 0) {
|
|
return
|
|
}
|
|
if (docs.length === 1) {
|
|
showPopup(
|
|
PrintToPDF,
|
|
{
|
|
object: docs[0],
|
|
signed
|
|
},
|
|
'float'
|
|
)
|
|
return
|
|
}
|
|
showPopup(
|
|
PrintBulkToPDF,
|
|
{
|
|
objects: docs,
|
|
signed
|
|
},
|
|
'float'
|
|
)
|
|
}
|
|
|
|
export async function canPrint (): Promise<boolean> {
|
|
let printURL = ''
|
|
try {
|
|
printURL = getPrintBaseURL()
|
|
} catch (err) {
|
|
// do nothing
|
|
}
|
|
|
|
return printURL?.length > 0
|
|
}
|
|
|
|
export default async (): Promise<Resources> => ({
|
|
component: {
|
|
PrintToPDF,
|
|
PrintBulkToPDF,
|
|
DOCXViewer
|
|
},
|
|
actionImpl: {
|
|
Print: print
|
|
},
|
|
function: {
|
|
CanPrint: canPrint,
|
|
CanConvert: canPrint
|
|
}
|
|
})
|