Browse Source

Fix star board.

Thanks to xet7 !
Lauri Ojansivu 1 day ago
parent
commit
8711b476be

+ 12 - 11
client/components/boards/boardHeader.jade

@@ -16,13 +16,6 @@ template(name="boardHeaderBar")
               a.board-header-btn(class="{{#if currentUser.isBoardAdmin}}js-edit-board-title{{else}}is-disabled{{/if}}" title="{{_ 'edit'}}" value=title)
               a.board-header-btn(class="{{#if currentUser.isBoardAdmin}}js-edit-board-title{{else}}is-disabled{{/if}}" title="{{_ 'edit'}}" value=title)
                 | ✏️
                 | ✏️
 
 
-            a.board-header-btn.js-star-board(class="{{#if isStarred}}is-active{{/if}}"
-              title="{{#if isStarred}}{{_ 'star-board-short-unstar'}}{{else}}{{_ 'star-board-short-star'}}{{/if}}" aria-label="{{#if isStarred}}{{_ 'star-board-short-unstar'}}{{else}}{{_ 'star-board-short-star'}}{{/if}}")
-              | {{#if isStarred}}⭐{{else}}☆{{/if}}
-              if showStarCounter
-                span
-                  = currentBoard.stars
-
             a.board-header-btn(
             a.board-header-btn(
               class="{{#if currentUser.isBoardAdmin}}js-change-visibility{{else}}is-disabled{{/if}}"
               class="{{#if currentUser.isBoardAdmin}}js-change-visibility{{else}}is-disabled{{/if}}"
               title="{{_ currentBoard.permission}}")
               title="{{_ currentBoard.permission}}")
@@ -38,6 +31,13 @@ template(name="boardHeaderBar")
               if $eq watchLevel "muted"
               if $eq watchLevel "muted"
                 | 🔕
                 | 🔕
               span {{_ watchLevel}}
               span {{_ watchLevel}}
+            a.board-header-btn.js-star-board(title="{{_ 'star-board'}}")
+              if isStarred
+                | ⭐
+              else
+                | ☆
+              if showStarCounter
+                span.board-star-counter {{currentBoard.stars}}
             a.board-header-btn(title="{{_ 'sort-cards'}}" class="{{#if isSortActive }}emphasis{{else}} js-sort-cards {{/if}}")
             a.board-header-btn(title="{{_ 'sort-cards'}}" class="{{#if isSortActive }}emphasis{{else}} js-sort-cards {{/if}}")
               | {{sortCardsIcon}}
               | {{sortCardsIcon}}
               span {{#if isSortActive }}{{_ 'sort-is-on'}}{{else}}{{_ 'sort-cards'}}{{/if}}
               span {{#if isSortActive }}{{_ 'sort-is-on'}}{{else}}{{_ 'sort-cards'}}{{/if}}
@@ -61,10 +61,6 @@ template(name="boardHeaderBar")
             a.board-header-btn(class="{{#if currentUser.isBoardAdmin}}js-edit-board-title{{else}}is-disabled{{/if}}" title="{{_ 'edit'}}" value=title)
             a.board-header-btn(class="{{#if currentUser.isBoardAdmin}}js-edit-board-title{{else}}is-disabled{{/if}}" title="{{_ 'edit'}}" value=title)
               | ✏️
               | ✏️
 
 
-            a.board-header-btn.js-star-board(class="{{#if isStarred}}is-active{{/if}}"
-              title="{{#if isStarred}}{{_ 'click-to-unstar'}}{{else}}{{_ 'click-to-star'}}{{/if}} {{_ 'starred-boards-description'}}")
-              | {{#if isStarred}}⭐{{else}}☆{{/if}}
-
             a.board-header-btn(
             a.board-header-btn(
               class="{{#if currentUser.isBoardAdmin}}js-change-visibility{{else}}is-disabled{{/if}}"
               class="{{#if currentUser.isBoardAdmin}}js-change-visibility{{else}}is-disabled{{/if}}"
               title="{{_ currentBoard.permission}}")
               title="{{_ currentBoard.permission}}")
@@ -78,6 +74,11 @@ template(name="boardHeaderBar")
                 | 🔔
                 | 🔔
               if $eq watchLevel "muted"
               if $eq watchLevel "muted"
                 | 🔕
                 | 🔕
+            a.board-header-btn.js-star-board(title="{{_ 'star-board'}}")
+              if isStarred
+                | ⭐
+              else
+                | ☆
             a.board-header-btn(title="{{_ 'sort-cards'}}" class="{{#if isSortActive }}emphasis{{else}} js-sort-cards {{/if}}")
             a.board-header-btn(title="{{_ 'sort-cards'}}" class="{{#if isSortActive }}emphasis{{else}} js-sort-cards {{/if}}")
               | {{sortCardsIcon}}
               | {{sortCardsIcon}}
             if isSortActive
             if isSortActive

+ 4 - 1
client/components/boards/boardHeader.js

@@ -72,7 +72,10 @@ BlazeComponent.extendComponent({
       {
       {
         'click .js-edit-board-title': Popup.open('boardChangeTitle'),
         'click .js-edit-board-title': Popup.open('boardChangeTitle'),
         'click .js-star-board'() {
         'click .js-star-board'() {
-          ReactiveCache.getCurrentUser().toggleBoardStar(Session.get('currentBoard'));
+          const boardId = Session.get('currentBoard');
+          if (boardId) {
+            Meteor.call('toggleBoardStar', boardId);
+          }
         },
         },
         'click .js-open-board-menu': Popup.open('boardMenu'),
         'click .js-open-board-menu': Popup.open('boardMenu'),
         'click .js-change-visibility': Popup.open('boardChangeVisibility'),
         'click .js-change-visibility': Popup.open('boardChangeVisibility'),

+ 3 - 1
client/components/boards/boardsList.js

@@ -243,7 +243,9 @@ BlazeComponent.extendComponent({
         'click .js-add-board': Popup.open('createBoard'),
         'click .js-add-board': Popup.open('createBoard'),
         'click .js-star-board'(evt) {
         'click .js-star-board'(evt) {
           const boardId = this.currentData()._id;
           const boardId = this.currentData()._id;
-          ReactiveCache.getCurrentUser().toggleBoardStar(boardId);
+          if (boardId) {
+            Meteor.call('toggleBoardStar', boardId);
+          }
           evt.preventDefault();
           evt.preventDefault();
         },
         },
         'click .js-clone-board'(evt) {
         'click .js-clone-board'(evt) {

+ 5 - 5
client/components/users/userHeader.jade

@@ -12,11 +12,6 @@ template(name="headerUserBar")
 
 
 template(name="memberMenuPopup")
 template(name="memberMenuPopup")
   ul.pop-over-list
   ul.pop-over-list
-    // Bookmarks at the very top
-    li
-      a.js-open-bookmarks
-        | 🔖
-        | {{_ 'bookmarks'}}
     with currentUser
     with currentUser
       li
       li
         a.js-my-cards(href="{{pathFor 'my-cards'}}")
         a.js-my-cards(href="{{pathFor 'my-cards'}}")
@@ -32,6 +27,11 @@ template(name="memberMenuPopup")
           | {{_ 'globalSearch-title'}}
           | {{_ 'globalSearch-title'}}
       li
       li
         a(href="{{pathFor 'home'}}")
         a(href="{{pathFor 'home'}}")
+          | ⭐
+          | {{_ 'my-bookmarks'}}
+      li
+        a(href="{{pathFor 'home'}}")
+          | 🏠
           | 🏠
           | 🏠
           | {{_ 'all-boards'}}
           | {{_ 'all-boards'}}
       li
       li

+ 21 - 0
models/users.js

@@ -1643,6 +1643,27 @@ Meteor.methods({
     check(value, String);
     check(value, String);
     ReactiveCache.getCurrentUser().setListSortBy(value);
     ReactiveCache.getCurrentUser().setListSortBy(value);
   },
   },
+  toggleBoardStar(boardId) {
+    check(boardId, String);
+    if (!this.userId) {
+      throw new Meteor.Error('not-logged-in', 'User must be logged in');
+    }
+    const user = Users.findOne(this.userId);
+    if (!user) {
+      throw new Meteor.Error('user-not-found', 'User not found');
+    }
+    
+    // Check if board is already starred
+    const starredBoards = (user.profile && user.profile.starredBoards) || [];
+    const isStarred = starredBoards.includes(boardId);
+    
+    // Build update object
+    const updateObject = isStarred 
+      ? { $pull: { 'profile.starredBoards': boardId } }
+      : { $addToSet: { 'profile.starredBoards': boardId } };
+    
+    Users.update(this.userId, updateObject);
+  },
   toggleDesktopDragHandles() {
   toggleDesktopDragHandles() {
     const user = ReactiveCache.getCurrentUser();
     const user = ReactiveCache.getCurrentUser();
     user.toggleDesktopHandles(user.hasShowDesktopDragHandles());
     user.toggleDesktopHandles(user.hasShowDesktopDragHandles());