From ae10b0a8bc60d5cd75742da0a306b619ee58c1de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr>
Date: Thu, 6 Jan 2022 18:29:39 +0100
Subject: [PATCH] add copy shared link button and paste to clipboard

---
 src/router/index.js                  |  1 -
 src/views/project/Project_detail.vue | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/router/index.js b/src/router/index.js
index 72e2709c..4dafe78e 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -5,7 +5,6 @@ import Index from '../views/Index.vue'
 Vue.use(VueRouter)
 
 let projectBase = "projet"
-console.log("window.location.pathname", window.location.pathname)
 if (window.location.pathname.includes("projet-partage")) {
   projectBase = "projet-partage"
 }
diff --git a/src/views/project/Project_detail.vue b/src/views/project/Project_detail.vue
index 58d661af..ada30a7a 100644
--- a/src/views/project/Project_detail.vue
+++ b/src/views/project/Project_detail.vue
@@ -93,6 +93,11 @@
                 >
                   <i class="inverted grey pencil alternate icon"></i>
                 </router-link>
+                <button
+                  v-if="!$route.path.includes('projet-partage')" class="ui button teal" @click="copyLink">
+                  <i class="ui icon clipboard"></i>
+                  Copier le lien de partage
+                </button>
               </div>
               <div class="ui hidden divider"></div>
               <div class="sub header">
@@ -809,6 +814,16 @@ export default {
       return false;
     },
 
+    copyLink() {
+      const sharedLink = window.location.href.replace("projet", "projet-partage");
+      navigator.clipboard.writeText(sharedLink).then(()=> {
+          console.log("success")
+        }, () => {
+          console.log("failed")
+        }
+      )
+    },
+
     checkForOfflineFeature() {
       let arraysOffline = [];
       let localStorageArray = localStorage.getItem("geocontrib_offline");
-- 
GitLab