diff --git a/src/components/UserPanel.vue b/src/components/UserPanel.vue index f512ac4c4..e0b6b86ed 100644 --- a/src/components/UserPanel.vue +++ b/src/components/UserPanel.vue @@ -1,19 +1,19 @@ @@ -129,8 +125,12 @@ function copyUserToken(){
{{ user.nickname }}
-
@{{ user.name }} -
+
+ @{{ user.name }} +
diff --git a/src/components/ui/VnLv.vue b/src/components/ui/VnLv.vue index 665404afc..0e4a055eb 100644 --- a/src/components/ui/VnLv.vue +++ b/src/components/ui/VnLv.vue @@ -2,6 +2,7 @@ import { computed } from 'vue'; import { dashIfEmpty } from 'src/filters'; +import { useClipboard } from 'src/composables/useClipboard'; const $props = defineProps({ label: { type: String, default: null }, value: { @@ -10,8 +11,19 @@ const $props = defineProps({ }, info: { type: String, default: null }, dash: { type: Boolean, default: true }, + copy: { type: Boolean, default: false }, }); const isBooleanValue = computed(() => typeof $props.value === 'boolean'); + +const { copyText } = useClipboard(); + +function copyValueText() { + copyText($props.value, { + component: { + copyValue: $props.value, + }, + }); +} diff --git a/src/composables/useClipboard.js b/src/composables/useClipboard.js new file mode 100644 index 000000000..008c24fa1 --- /dev/null +++ b/src/composables/useClipboard.js @@ -0,0 +1,17 @@ +import { useQuasar } from 'quasar'; +import { useI18n } from 'vue-i18n'; + +export function useClipboard() { + const quasar = useQuasar(); + const { t } = useI18n(); + /** + * + * @param {String} value Value to send to clipboardAPI + * @param {Object} {label, component} Refer to Quasar notify configuration. Label is the text to translate + */ + function copyText(value, { label = 'components.VnLv.copyText', component = {} }) { + navigator.clipboard.writeText(value); + quasar.notify({ type: 'positive', message: t(label, component) }); + } + return { copyText }; +} diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index 1a7a4c27e..2eb445680 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -1060,6 +1060,7 @@ export default { totalEntries: 'Total entries', }, }, + components: { topbar: {}, userPanel: { @@ -1083,5 +1084,8 @@ export default { addToPinned: 'Add to pinned', removeFromPinned: 'Remove from pinned', }, + VnLv: { + copyText: '{copyValue} has been copied to the clipboard', + }, }, }; diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 83de42ee0..2a9bcd615 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -1083,5 +1083,8 @@ export default { addToPinned: 'AƱadir a fijados', removeFromPinned: 'Eliminar de fijados', }, + VnLv: { + copyText: '{copyValue} se ha copiado al portapepeles', + }, }, }; diff --git a/src/pages/Customer/Card/CustomerSummary.vue b/src/pages/Customer/Card/CustomerSummary.vue index 4ebd6efab..c46b8a8de 100644 --- a/src/pages/Customer/Card/CustomerSummary.vue +++ b/src/pages/Customer/Card/CustomerSummary.vue @@ -81,7 +81,7 @@ const creditWarning = computed(() => { - + {