Browse Source

board page didn't always show the list counters

Martin Filser 2 years ago
parent
commit
ea3144492e

+ 0 - 2
client/components/boards/boardsList.js

@@ -220,12 +220,10 @@ BlazeComponent.extendComponent({
   },
   },
 
 
   hasOvertimeCards() {
   hasOvertimeCards() {
-    subManager.subscribe('board', this.currentData()._id, false);
     return this.currentData().hasOvertimeCards();
     return this.currentData().hasOvertimeCards();
   },
   },
 
 
   hasSpentTimeCards() {
   hasSpentTimeCards() {
-    subManager.subscribe('board', this.currentData()._id, false);
     return this.currentData().hasSpentTimeCards();
     return this.currentData().hasSpentTimeCards();
   },
   },
 
 

+ 15 - 19
client/components/settings/adminReports.js

@@ -124,7 +124,7 @@ class AdminReport extends BlazeComponent {
   }
   }
 
 
   abbreviate(text) {
   abbreviate(text) {
-    if (text.length > 30) {
+    if (text?.length > 30) {
       return `${text.substr(0, 29)}...`;
       return `${text.substr(0, 29)}...`;
     }
     }
     return text;
     return text;
@@ -162,17 +162,13 @@ class AdminReport extends BlazeComponent {
   collection = Boards;
   collection = Boards;
 
 
   userNames(members) {
   userNames(members) {
-    let text = '';
-    members.forEach(member => {
-      const user = ReactiveCache.getUser(member.userId);
-      text += text ? ', ' : '';
-      if (user) {
-        text += user.username;
-      } else {
-        text += member.userId
-      }
-    });
-    return text;
+    const ret = (members || [])
+      .map(_member => {
+        const _ret = ReactiveCache.getUser(_member.userId)?.username || _member.userId;
+        return _ret;
+      })
+      .join(", ");
+    return ret;
   }
   }
 }.register('boardsReport'));
 }.register('boardsReport'));
 
 
@@ -180,13 +176,13 @@ class AdminReport extends BlazeComponent {
   collection = Cards;
   collection = Cards;
 
 
   userNames(userIds) {
   userNames(userIds) {
-    let text = '';
-    userIds.forEach(userId => {
-      const user = ReactiveCache.getUser(userId);
-      text += text ? ', ' : '';
-      text += user.username;
-    });
-    return text;
+    const ret = (userIds || [])
+      .map(_userId => {
+        const _ret = ReactiveCache.getUser(_userId)?.username;
+        return _ret;
+      })
+      .join(", ");
+    return ret
   }
   }
 }.register('cardsReport'));
 }.register('cardsReport'));
 
 

+ 30 - 17
server/publications/boards.js

@@ -8,7 +8,7 @@ import Org from "../../models/org";
 import Team from "../../models/team";
 import Team from "../../models/team";
 import Attachments from '../../models/attachments';
 import Attachments from '../../models/attachments';
 
 
-Meteor.publish('boards', function() {
+Meteor.publishRelations('boards', function() {
   const userId = this.userId;
   const userId = this.userId;
   // Ensure that the user is connected. If it is not, we need to return an empty
   // Ensure that the user is connected. If it is not, we need to return an empty
   // array to tell the client to remove the previously published docs.
   // array to tell the client to remove the previously published docs.
@@ -32,7 +32,7 @@ Meteor.publish('boards', function() {
   // if(teamIdsUserBelongs && teamIdsUserBelongs != ''){
   // if(teamIdsUserBelongs && teamIdsUserBelongs != ''){
   //   teamsIds = teamIdsUserBelongs.split(',');
   //   teamsIds = teamIdsUserBelongs.split(',');
   // }
   // }
-  return Boards.find(
+  this.cursor(Boards.find(
     {
     {
       archived: false,
       archived: false,
       _id: { $in: Boards.userBoardIds(userId, false) },
       _id: { $in: Boards.userBoardIds(userId, false) },
@@ -47,24 +47,37 @@ Meteor.publish('boards', function() {
       // ],
       // ],
     },
     },
     {
     {
-      fields: {
-        _id: 1,
-        boardId: 1,
-        archived: 1,
-        slug: 1,
-        title: 1,
-        description: 1,
-        color: 1,
-        members: 1,
-        orgs: 1,
-        teams: 1,
-        permission: 1,
-        type: 1,
-        sort: 1,
-      },
       sort: { sort: 1 /* boards default sorting */ },
       sort: { sort: 1 /* boards default sorting */ },
     },
     },
+  ),
+    function(boardId, board) {
+      this.cursor(
+        Lists.find(
+          { boardId, archived: false },
+          { fields: {
+            _id: 1,
+            title: 1,
+            boardId: 1,
+            archived: 1,
+            sort: 1
+          }}
+        )
+      );
+      this.cursor(
+        Cards.find(
+          { boardId, archived: false },
+          { fields: {
+            _id: 1,
+            boardId: 1,
+            listId: 1,
+            archived: 1,
+            sort: 1
+          }}
+        )
+      );
+    }
   );
   );
+  return this.ready();
 });
 });
 
 
 Meteor.publish('boardsReport', function() {
 Meteor.publish('boardsReport', function() {