EdTextRefLink.vue 2.0 KB

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