EdTextRefLink.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="textrefcopylink">
  3. <span class="mdi mdi-open-in-new" />
  4. <div class="popup">
  5. <button
  6. type="button"
  7. :title="btnuuidtitle"
  8. class="copy-btn"
  9. v-clipboard:copy="uuid"
  10. v-clipboard:success="onCopy"
  11. v-clipboard:error="onError"
  12. >
  13. {{ uuid }} <span class="mdi mdi-clipboard-outline" />
  14. </button>
  15. <button
  16. type="button"
  17. :title="btnurltitle"
  18. class="copy-btn"
  19. v-clipboard:copy="linkhref"
  20. v-clipboard:success="onCopy"
  21. v-clipboard:error="onError"
  22. >
  23. {{ linkhref }} <span class="mdi mdi-clipboard-outline" />
  24. </button>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. export default {
  30. name: 'EdTextRefLink',
  31. props: {
  32. uuid: String
  33. },
  34. computed: {
  35. linkhref () {
  36. return `${window.apipath}/items/${this.uuid}`
  37. },
  38. btnuuidtitle () {
  39. return `Copy to clipboard ${this.uuid}`
  40. },
  41. btnurltitle () {
  42. return `Copy to clipboard ${this.linkhref}`
  43. }
  44. },
  45. methods: {
  46. onCopy (e) {
  47. this.$swal({
  48. text: `copié dans le press papier : ${e.text}`,
  49. toast: true,
  50. position: 'bottom-end',
  51. timer: 2000,
  52. icon: 'success',
  53. showConfirmButton: false
  54. })
  55. },
  56. onError (e) {
  57. this.$swal('erreur')
  58. }
  59. // onClickCopyClipboard (e, s) {
  60. // e.preventDefault()
  61. // console.log('onClickCopyClipboard', s, e)
  62. // // navigator.clipboard.writeText(e.target.getAttribute('href'))
  63. // this.$copyText(s === 'ref' ? this.uuid : this.linkhref)
  64. // .then(function (r) {
  65. // console.log(this, r)
  66. // // alert('Copied')
  67. // this.$swal(`${s === 'ref' ? this.uuid : this.linkhref} copied`)
  68. // }, function (r) {
  69. // console.log(r)
  70. // alert('Can not copy')
  71. // })
  72. // return false
  73. // }
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. </style>