فهرست منبع

Copy card link to clipboard. Thanks to xet7 ! Closes #1188

Lauri Ojansivu 7 سال پیش
والد
کامیت
84d40bd3e3

+ 2 - 1
CHANGELOG.md

@@ -9,7 +9,8 @@ This release adds the following new features:
 * [Ubuntu snap: Use version scriptlet](https://github.com/wekan/wekan/pull/1164);
 * [Gogs integration part 1](https://github.com/wekan/wekan/pull/1189);
 * [Add web manifest so Wekan can be used like standalone app on Desktop
-   with Chrome or Firefox](https://github.com/wekan/wekan/pull/1184).
+   with Chrome or Firefox](https://github.com/wekan/wekan/pull/1184);
+* [Copy card link to clipboard](https://github.com/wekan/wekan/issues/1188).
 
 and fixes the following bugs:
 

+ 4 - 1
client/components/cards/cardDetails.jade

@@ -141,7 +141,10 @@ template(name="cardMorePopup")
       span {{_ 'link-card'}}
       = ' '
       i.fa.colorful(class="{{#if board.isPublic}}fa-globe{{else}}fa-lock{{/if}}")
-      input.inline-input(type="text" readonly value="{{ absoluteUrl }}")
+      input.inline-input(type="text" id="cardURL" readonly value="{{ absoluteUrl }}")
+      button.js-copy-card-link-to-clipboard(class="btn") {{_ 'copy-card-link-to-clipboard'}}
+    span.clearfix
+    br
     | {{_ 'added'}}
     span.date(title=card.createdAt) {{ moment createdAt 'LLL' }}
     a.js-delete(title="{{_ 'card-delete-notice'}}") {{_ 'delete'}}

+ 41 - 15
client/components/cards/cardDetails.js

@@ -47,7 +47,7 @@ BlazeComponent.extendComponent({
     let offset = false;
     if (cardViewStart < 0) {
       offset = cardViewStart;
-    } else if(cardViewEnd > cardContainerWidth) {
+    } else if (cardViewEnd > cardContainerWidth) {
       offset = cardViewEnd - cardContainerWidth;
     }
 
@@ -76,16 +76,16 @@ BlazeComponent.extendComponent({
 
     return [{
       ...events,
-      'click .js-close-card-details'() {
+      'click .js-close-card-details' () {
         Utils.goBoardId(this.data().boardId);
       },
       'click .js-open-card-details-menu': Popup.open('cardDetailsActions'),
-      'submit .js-card-description'(evt) {
+      'submit .js-card-description' (evt) {
         evt.preventDefault();
         const description = this.currentComponent().getValue();
         this.data().setDescription(description);
       },
-      'submit .js-card-details-title'(evt) {
+      'submit .js-card-details-title' (evt) {
         evt.preventDefault();
         const title = this.currentComponent().getValue().trim();
         if (title) {
@@ -95,7 +95,7 @@ BlazeComponent.extendComponent({
       'click .js-member': Popup.open('cardMember'),
       'click .js-add-members': Popup.open('cardMembers'),
       'click .js-add-labels': Popup.open('cardLabels'),
-      'mouseenter .js-card-details'() {
+      'mouseenter .js-card-details' () {
         this.parentComponent().showOverlay.set(true);
         this.parentComponent().mouseHasEnterCardDetails = true;
       },
@@ -157,23 +157,23 @@ Template.cardDetailsActionsPopup.events({
   'click .js-start-date': Popup.open('editCardStartDate'),
   'click .js-due-date': Popup.open('editCardDueDate'),
   'click .js-move-card': Popup.open('moveCard'),
-  'click .js-move-card-to-top'(evt) {
+  'click .js-move-card-to-top' (evt) {
     evt.preventDefault();
     const minOrder = _.min(this.list().cards().map((c) => c.sort));
     this.move(this.listId, minOrder - 1);
   },
-  'click .js-move-card-to-bottom'(evt) {
+  'click .js-move-card-to-bottom' (evt) {
     evt.preventDefault();
     const maxOrder = _.max(this.list().cards().map((c) => c.sort));
     this.move(this.listId, maxOrder + 1);
   },
-  'click .js-archive'(evt) {
+  'click .js-archive' (evt) {
     evt.preventDefault();
     this.archive();
     Popup.close();
   },
   'click .js-more': Popup.open('cardMore'),
-  'click .js-toggle-watch-card'() {
+  'click .js-toggle-watch-card' () {
     const currentCard = this;
     const level = currentCard.findWatcher(Meteor.userId()) ? null : 'watching';
     Meteor.call('watch', 'card', currentCard._id, level, (err, ret) => {
@@ -182,12 +182,12 @@ Template.cardDetailsActionsPopup.events({
   },
 });
 
-Template.editCardTitleForm.onRendered(function() {
+Template.editCardTitleForm.onRendered(function () {
   autosize(this.$('.js-edit-card-title'));
 });
 
 Template.editCardTitleForm.events({
-  'keydown .js-edit-card-title'(evt) {
+  'keydown .js-edit-card-title' (evt) {
     // If enter key was pressed, submit the data
     if (evt.keyCode === 13) {
       $('.js-submit-edit-card-title-form').click();
@@ -196,7 +196,7 @@ Template.editCardTitleForm.events({
 });
 
 Template.moveCardPopup.events({
-  'click .js-select-list'() {
+  'click .js-select-list' () {
     // XXX We should *not* get the currentCard from the global state, but
     // instead from a “component” state.
     const card = Cards.findOne(Session.get('currentCard'));
@@ -207,7 +207,29 @@ Template.moveCardPopup.events({
 });
 
 Template.cardMorePopup.events({
-  'click .js-delete': Popup.afterConfirm('cardDelete', function() {
+  'click .js-copy-card-link-to-clipboard' () {
+    // Clipboard code from:
+    // https://stackoverflow.com/questions/6300213/copy-selected-text-to-the-clipboard-without-using-flash-must-be-cross-browser
+    const StringToCopyElement = document.getElementById('cardURL');
+    StringToCopyElement.select();
+    if (document.execCommand('copy')) {
+      StringToCopyElement.blur();
+    } else {
+      document.getElementById('cardURL').selectionStart = 0;
+      document.getElementById('cardURL').selectionEnd = 999;
+      document.execCommand('copy');
+      if (window.getSelection) {
+        if (window.getSelection().empty) { // Chrome
+          window.getSelection().empty();
+        } else if (window.getSelection().removeAllRanges) { // Firefox
+          window.getSelection().removeAllRanges();
+        }
+      } else if (document.selection) { // IE?
+        document.selection.empty();
+      }
+    }
+  },
+  'click .js-delete': Popup.afterConfirm('cardDelete', function () {
     Popup.close();
     Cards.remove(this._id);
     Utils.goBoardId(this.boardId);
@@ -216,8 +238,12 @@ Template.cardMorePopup.events({
 
 // Close the card details pane by pressing escape
 EscapeActions.register('detailsPane',
-  () => { Utils.goBoardId(Session.get('currentBoard')); },
-  () => { return !Session.equals('currentCard', null); }, {
+  () => {
+    Utils.goBoardId(Session.get('currentBoard'));
+  },
+  () => {
+    return !Session.equals('currentCard', null);
+  }, {
     noClickEscapeOn: '.js-card-details,.board-sidebar,#header',
   }
 );

+ 1 - 0
i18n/ar.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "التعليق فقط",
     "comment-only-desc": "يمكن التعليق على بطاقات فقط.",
     "computer": "حاسوب",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "إنشاء",
     "createBoardPopup-title": "إنشاء لوحة",
     "chooseBoardSourcePopup-title": "استيراد لوحة",

+ 1 - 0
i18n/br.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Krouiñ",
     "createBoardPopup-title": "Create Board",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/ca.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Només comentaris",
     "comment-only-desc": "Només pots fer comentaris a les fitxes",
     "computer": "Ordinador",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Crea",
     "createBoardPopup-title": "Crea tauler",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/cs.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Počítač",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Vytvořit",
     "createBoardPopup-title": "Vytvořit tablo",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/de.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Nur kommentierbar",
     "comment-only-desc": "Kann Karten nur Kommentieren",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Erstellen",
     "createBoardPopup-title": "Board erstellen",
     "chooseBoardSourcePopup-title": "Board importieren",

+ 1 - 0
i18n/en-GB.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Create",
     "createBoardPopup-title": "Create Board",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/en.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Create",
     "createBoardPopup-title": "Create Board",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/eo.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Komputilo",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Krei",
     "createBoardPopup-title": "Krei ",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/es.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Sólo comentario",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Ordenador",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Crear",
     "createBoardPopup-title": "Crear tablero",
     "chooseBoardSourcePopup-title": "Importar tablero",

+ 1 - 0
i18n/eu.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Iruzkinak besterik ez",
     "comment-only-desc": "Iruzkinak txarteletan soilik egin ditzake",
     "computer": "Ordenagailua",
+    "copy-card-link-to-clipboard": "Kopiatu txartela arbelera",
     "create": "Sortu",
     "createBoardPopup-title": "Sortu arbela",
     "chooseBoardSourcePopup-title": "Inportatu arbela",

+ 1 - 0
i18n/fa.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "صرفا یادداشت",
     "comment-only-desc": "صرفا یادداشت برروی کارت ها",
     "computer": "رایانه",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "ایجاد",
     "createBoardPopup-title": "ایجاد تخته",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/fi.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Vain kommentointi",
     "comment-only-desc": "Voi vain kommentoida kortteja",
     "computer": "Tietokone",
+    "copy-card-link-to-clipboard": "Kopioi kortin linkki leikepöydälle",
     "create": "Luo",
     "createBoardPopup-title": "Luo taulu",
     "chooseBoardSourcePopup-title": "Tuo taulu",

+ 1 - 0
i18n/fr.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Commentaire uniquement",
     "comment-only-desc": "Ne peut que commenter des cartes.",
     "computer": "Ordinateur",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Créer",
     "createBoardPopup-title": "Créer un tableau",
     "chooseBoardSourcePopup-title": "Importer un tableau",

+ 1 - 0
i18n/gl.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Computador",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Crear",
     "createBoardPopup-title": "Crear taboleiro",
     "chooseBoardSourcePopup-title": "Importar taboleiro",

+ 1 - 0
i18n/he.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "הערה בלבד",
     "comment-only-desc": "ניתן להעיר על כרטיסים בלבד.",
     "computer": "מחשב",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "יצירה",
     "createBoardPopup-title": "יצירת לוח",
     "chooseBoardSourcePopup-title": "יבוא לוח",

+ 1 - 0
i18n/hu.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Számítógép",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Létrehoz",
     "createBoardPopup-title": "Új tábla",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/id.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Hanya komentar",
     "comment-only-desc": "Bisa komen hanya di kartu",
     "computer": "Komputer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Buat",
     "createBoardPopup-title": "Buat Panel",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/it.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Solo commenti",
     "comment-only-desc": "Puoi commentare solo le schede.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Crea",
     "createBoardPopup-title": "Crea bacheca",
     "chooseBoardSourcePopup-title": "Importa bacheca",

+ 1 - 0
i18n/ja.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "コメントのみ",
     "comment-only-desc": "カードにのみコメント可能",
     "computer": "コンピューター",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "作成",
     "createBoardPopup-title": "ボードの作成",
     "chooseBoardSourcePopup-title": "ボードをインポート",

+ 1 - 0
i18n/ko.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "댓글만 입력 가능",
     "comment-only-desc": "카드에 댓글만 달수 있습니다.",
     "computer": "내 컴퓨터",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "생성",
     "createBoardPopup-title": "보드 생성",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/nb.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Create",
     "createBoardPopup-title": "Create Board",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/nl.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Alleen reageren",
     "comment-only-desc": "Kan alleen op kaarten reageren.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Aanmaken",
     "createBoardPopup-title": "Bord aanmaken",
     "chooseBoardSourcePopup-title": "Importeer bord",

+ 1 - 0
i18n/pl.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Komputer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Utwórz",
     "createBoardPopup-title": "Utwórz tablicę",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/pt-BR.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Somente comentários",
     "comment-only-desc": "Pode comentar apenas em cartões.",
     "computer": "Computador",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Criar",
     "createBoardPopup-title": "Criar Quadro",
     "chooseBoardSourcePopup-title": "Importar quadro",

+ 1 - 0
i18n/ro.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Create",
     "createBoardPopup-title": "Create Board",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/ru.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Только комментирование",
     "comment-only-desc": "Может комментировать только карточки.",
     "computer": "Загрузить с компьютера",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Создать",
     "createBoardPopup-title": "Создать доску",
     "chooseBoardSourcePopup-title": "Импортировать доску",

+ 1 - 0
i18n/sr.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Create",
     "createBoardPopup-title": "Create Board",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/sv.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Kommentera endast",
     "comment-only-desc": "Kan endast kommentera kort.",
     "computer": "Dator",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Skapa",
     "createBoardPopup-title": "Skapa anslagstavla",
     "chooseBoardSourcePopup-title": "Importera anslagstavla",

+ 1 - 0
i18n/ta.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Create",
     "createBoardPopup-title": "Create Board",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/th.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "คอมพิวเตอร์",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "สร้าง",
     "createBoardPopup-title": "สร้างบอร์ด",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/tr.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Sadece yorum",
     "comment-only-desc": "Sadece kartlara yorum yazabilir.",
     "computer": "Bilgisayar",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Oluştur",
     "createBoardPopup-title": "Pano Oluşturma",
     "chooseBoardSourcePopup-title": "Panoyu içe aktar",

+ 1 - 0
i18n/uk.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Create",
     "createBoardPopup-title": "Create Board",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/vi.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "Comment only",
     "comment-only-desc": "Can comment on cards only.",
     "computer": "Computer",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "Create",
     "createBoardPopup-title": "Create Board",
     "chooseBoardSourcePopup-title": "Import board",

+ 1 - 0
i18n/zh-CN.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "仅能评论",
     "comment-only-desc": "只能在卡片上评论。",
     "computer": "从本机上传",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "创建",
     "createBoardPopup-title": "创建看板",
     "chooseBoardSourcePopup-title": "导入看板",

+ 1 - 0
i18n/zh-TW.i18n.json

@@ -144,6 +144,7 @@
     "comment-only": "只可以發表評論",
     "comment-only-desc": "只可以對卡片發表評論",
     "computer": "從本機上傳",
+    "copy-card-link-to-clipboard": "Copy card link to clipboard",
     "create": "建立",
     "createBoardPopup-title": "建立看板",
     "chooseBoardSourcePopup-title": "Import board",