Fix star board.

Thanks to xet7 !
This commit is contained in:
Lauri Ojansivu 2025-11-05 20:50:28 +02:00
parent df9fba4765
commit 8711b476be
5 changed files with 45 additions and 18 deletions

View file

@ -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.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(
class="{{#if currentUser.isBoardAdmin}}js-change-visibility{{else}}is-disabled{{/if}}"
title="{{_ currentBoard.permission}}")
@ -38,6 +31,13 @@ template(name="boardHeaderBar")
if $eq watchLevel "muted"
| 🔕
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}}")
| {{sortCardsIcon}}
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.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(
class="{{#if currentUser.isBoardAdmin}}js-change-visibility{{else}}is-disabled{{/if}}"
title="{{_ currentBoard.permission}}")
@ -78,6 +74,11 @@ template(name="boardHeaderBar")
| 🔔
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}}")
| {{sortCardsIcon}}
if isSortActive

View file

@ -72,7 +72,10 @@ BlazeComponent.extendComponent({
{
'click .js-edit-board-title': Popup.open('boardChangeTitle'),
'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-change-visibility': Popup.open('boardChangeVisibility'),

View file

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

View file

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

View file

@ -1643,6 +1643,27 @@ Meteor.methods({
check(value, String);
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() {
const user = ReactiveCache.getCurrentUser();
user.toggleDesktopHandles(user.hasShowDesktopDragHandles());