mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-01 11:47:01 +00:00
refactor: use inline copy interaction via reusable composable
This commit is contained in:
@@ -44,15 +44,12 @@ const downloadSvg = () => {
|
||||
|
||||
_downloadSvg(barcodeSvgRef.value, `${props.barcodeValue}.png`)
|
||||
}
|
||||
const { isCopied, performCopy } = useIsCopied()
|
||||
|
||||
const copyAsPng = async () => {
|
||||
if (!barcodeSvgRef.value) return
|
||||
const success = await copySVGToClipboard(barcodeSvgRef.value)
|
||||
if (success) {
|
||||
message.success(t('msg.info.copiedToClipboard'))
|
||||
} else {
|
||||
message.error(t('msg.error.notSupported'))
|
||||
}
|
||||
if (!success) message.error(t('msg.error.notSupported'))
|
||||
}
|
||||
|
||||
const onBarcodeClick = (ev: MouseEvent) => {
|
||||
@@ -83,11 +80,12 @@ onMounted(generate)
|
||||
<template #title>
|
||||
{{ $t('labels.clickToCopy') }}
|
||||
</template>
|
||||
<NcButton size="small" type="secondary" @click="copyAsPng">
|
||||
<NcButton size="small" type="secondary" @click="performCopy(copyAsPng)">
|
||||
<template #icon>
|
||||
<GeneralIcon icon="copy" class="w-4 h-4" />
|
||||
<GeneralIcon v-if="isCopied" icon="check" class="h-4 w-4" />
|
||||
<GeneralIcon v-else icon="copy" class="h-4 w-4" />
|
||||
</template>
|
||||
{{ $t('general.copy') }}
|
||||
{{ isCopied ? $t('general.copied') : $t('general.copy') }}
|
||||
</NcButton>
|
||||
</NcTooltip>
|
||||
<NcTooltip>
|
||||
|
||||
Reference in New Issue
Block a user