Jelajahi Sumber

Merge branch 'Rayene123-add-toggle-watch-icon-on-card'

Lauri Ojansivu 1 bulan lalu
induk
melakukan
50b874629c

+ 32 - 26
client/components/boards/boardsList.js

@@ -239,34 +239,40 @@ BlazeComponent.extendComponent({
           evt.preventDefault();
         },
         'click .js-clone-board'(evt) {
-          let title = getSlug(ReactiveCache.getBoard(this.currentData()._id).title) || 'cloned-board';
-          Meteor.call(
-            'copyBoard',
-            this.currentData()._id,
-            {
-              sort: ReactiveCache.getBoards({ archived: false }).length,
-              type: 'board',
-              title: ReactiveCache.getBoard(this.currentData()._id).title,
-            },
-            (err, res) => {
-              if (err) {
-                console.error(err);
-              } else {
-                Session.set('fromBoard', null);
-                subManager.subscribe('board', res, false);
-                FlowRouter.go('board', {
-                  id: res,
-                  slug: title,
-                });
-              }
-            },
-          );
-          evt.preventDefault();
+          if (confirm(TAPi18n.__('duplicate-board-confirm')) {
+            let title =
+              getSlug(ReactiveCache.getBoard(this.currentData()._id).title) ||
+              'cloned-board';
+            Meteor.call(
+              'copyBoard',
+              this.currentData()._id,
+              {
+                sort: ReactiveCache.getBoards({ archived: false }).length,
+                type: 'board',
+                title: ReactiveCache.getBoard(this.currentData()._id).title,
+              },
+              (err, res) => {
+                if (err) {
+                  console.error(err);
+                } else {
+                  Session.set('fromBoard', null);
+                  subManager.subscribe('board', res, false);
+                  FlowRouter.go('board', {
+                    id: res,
+                    slug: title,
+                  });
+                }
+              },
+            );
+            evt.preventDefault();
+          }
         },
         'click .js-archive-board'(evt) {
-          const boardId = this.currentData()._id;
-          Meteor.call('archiveBoard', boardId);
-          evt.preventDefault();
+          if (confirm(TAPi18n.__('archive-board-confirm')) {
+            const boardId = this.currentData()._id;
+            Meteor.call('archiveBoard', boardId);
+            evt.preventDefault();
+          }
         },
         'click .js-accept-invite'() {
           const boardId = this.currentData()._id;

+ 9 - 0
client/components/cards/minicard.jade

@@ -225,3 +225,12 @@ template(name="minicardDetailsActionsPopup")
         a.js-link
           i.fa.fa-link
           | {{_ 'link-card'}}
+      li
+      a.js-toggle-watch-card
+        if isWatching
+          i.fa.fa-eye
+          |  {{_ 'unwatch'}}
+        else
+          i.fa.fa-eye-slash
+          |  {{_ 'watch'}}
+

+ 14 - 0
client/components/cards/minicard.js

@@ -46,6 +46,10 @@ BlazeComponent.extendComponent({
     }
     return ret;
   },
+  isWatching() {
+    const card = this.currentData();
+    return card.findWatcher(Meteor.userId());
+  },
 
   showMembers() {
     // cache "board" to reduce the mini-mongodb access
@@ -125,6 +129,9 @@ Template.minicard.helpers({
       ? Meteor.connection._lastSessionId
       : null;
   },
+  isWatching() {
+    return this.findWatcher(Meteor.userId());
+  }
 });
 
 BlazeComponent.extendComponent({
@@ -178,4 +185,11 @@ Template.minicardDetailsActionsPopup.events({
     this.archive();
     Utils.goBoardId(this.boardId);
   }),
+  '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) => {
+      if (!err && ret) Popup.back();
+    });
+  },
 });

+ 2 - 0
imports/i18n/data/en.i18n.json

@@ -125,6 +125,7 @@
   "archive": "Move to Archive",
   "archive-all": "Move All to Archive",
   "archive-board": "Move Board to Archive",
+  "archive-board-confirm": "Are you sure you want to archive this board?",
   "archive-card": "Move Card to Archive",
   "archive-list": "Move List to Archive",
   "archive-swimlane": "Move Swimlane to Archive",
@@ -896,6 +897,7 @@
   "oidc-button-text": "Customize the OIDC button text",
   "default-authentication-method": "Default Authentication Method",
   "duplicate-board": "Duplicate Board",
+  "duplicate-board-confirm": "Are you sure you want to duplicate this board?",
   "org-number": "The number of organizations is: ",
   "team-number": "The number of teams is: ",
   "people-number": "The number of people is: ",