Fix the stars

Fixes #214
This commit is contained in:
Maxime Quandalle 2015-08-23 22:00:02 +02:00
parent f03fee5162
commit 9bea6a52d3
5 changed files with 17 additions and 28 deletions

View file

@ -7,8 +7,8 @@ template(name="headerBoard")
unless isSandstorm
if currentUser
a.board-header-btn.js-star-board(class="{{#if isStarred}}is-active{{/if}}"
title="{{#if currentBoard.isStarred}}{{_ 'click-to-unstar'}}{{else}}{{_ 'click-to-star'}}{{/if}} {{_ 'starred-boards-description'}}")
i.fa(class="fa-star{{#unless currentBoard.isStarred}}-o{{/unless}}")
title="{{#if isStarred}}{{_ 'click-to-unstar'}}{{else}}{{_ 'click-to-star'}}{{/if}} {{_ 'starred-boards-description'}}")
i.fa(class="fa-star{{#unless isStarred}}-o{{/unless}}")
if showStarCounter
span {{_ 'board-nb-stars' currentBoard.stars}}

View file

@ -29,9 +29,9 @@ BlazeComponent.extendComponent({
},
isStarred: function() {
var currentBoard = this.currentData();
var boardId = Session.get('currentBoard');
var user = Meteor.user();
return currentBoard && user && user.hasStarred(currentBoard._id);
return user && user.hasStarred(boardId);
},
// Only show the star counter if the number of star is greater than 2

View file

@ -6,8 +6,8 @@ template(name="boardList")
a.js-open-board(href="{{pathFor 'board' id=_id slug=slug}}")
span.details
span.board-list-item-name= title
i.fa.fa-star-o.js-star-board(
class="{{#if isStarred}}is-star-active{{/if}}"
i.fa.js-star-board(
class="fa-star{{#if isStarred}} is-star-active{{else}}-o{{/if}}"
title="{{_ 'star-board-title'}}")
else
ul.board-list.clearfix

View file

@ -9,25 +9,17 @@ BlazeComponent.extendComponent({
});
},
starredBoards: function() {
var cursor = Boards.find({
_id: { $in: Meteor.user().profile.starredBoards || [] }
}, {
sort: ['title']
});
return cursor.count() === 0 ? null : cursor;
},
isStarred: function() {
var user = Meteor.user();
return user && user.hasStarred(this._id);
return user && user.hasStarred(this.currentData()._id);
},
events: function() {
return [{
'click .js-add-board': Popup.open('createBoard'),
'click .js-star-board': function(evt) {
Meteor.user().toggleBoardStar(this._id);
var boardId = this.currentData()._id;
Meteor.user().toggleBoardStar(boardId);
evt.preventDefault();
}
}];

View file

@ -8,8 +8,10 @@
box-sizing: border-box
position: relative
&.starred .fa-star-o
opacity: 1
&.starred
.fa-star,
.fa-star-o
opacity: 1
a
background-color: #999
@ -47,6 +49,7 @@
:hover
background-color:#939393
.fa-star,
.fa-star-o
bottom: 0
font-size: 14px
@ -61,13 +64,14 @@
transition-property: color, font-size, background
.is-star-active
color: #e6bf00
color: white
li:hover a
color: #f6f6f6
.fa-star,
.fa-star-o
color: #fff
color: white
opacity: .75
&:hover
@ -75,15 +79,8 @@
opacity: 1
&.is-star-active
color: #e6bf00
opacity: 1
&:hover
color: #ffd91a
font-size: 16px
opacity: 1
.board-backgrounds-list
.board-background-select