Commit 6781ceb6 authored by Curtis Adam's avatar Curtis Adam

Display card count and difficulty inside the leitner chart card set filter

parent b9c1242f
......@@ -15,6 +15,7 @@
@import '../imports/ui/forms/cardsetForm.scss';
@import '../imports/ui/profile/profile.scss';
@import '../imports/ui/learn/learn.scss';
@import '../imports/ui/learn/progress.scss';
@import '../imports/ui/admin/admin.scss';
@import '../imports/ui/access_denied/access_denied.scss';
@import '../imports/ui/markdeep/content.scss';
......
......@@ -2194,7 +2194,7 @@ $themes: (
color: $button_difficulty0_note !important;
}
#setDifficulty .btn-orange.active {
#setDifficulty .btn-orange.active, .label-difficulty0 {
color: $white !important;
background-color: $button_difficulty0_note !important;
}
......@@ -2203,7 +2203,7 @@ $themes: (
color: $button_difficulty1 !important;
}
#setDifficulty .btn-info.active {
#setDifficulty .btn-info.active, .label-difficulty1 {
color: $white !important;
background-color: $button_difficulty1 !important;
}
......@@ -2212,7 +2212,7 @@ $themes: (
color: $button_difficulty2 !important;
}
#setDifficulty .btn-success.active {
#setDifficulty .btn-success.active, .label-difficulty2 {
color: $white !important;
background-color: $button_difficulty2 !important;
}
......@@ -2221,7 +2221,7 @@ $themes: (
color: $button_difficulty3 !important;
}
#setDifficulty .btn-danger.active {
#setDifficulty .btn-danger.active, .label-difficulty3 {
color: $white !important;
background-color: $button_difficulty3 !important;
}
......
......@@ -125,6 +125,13 @@ Template.registerHelper("getKindText", function (kind, displayType = 0) {
}
});
Template.registerHelper("getDifficultyLabel", function (cardType, difficulty) {
if (!CardType.gotDifficultyLevel(cardType)) {
difficulty = 0;
}
return '<span class="label label-difficulty' + difficulty + '" data-id="difficulty" title="' + TAPi18n.__('difficulty' + difficulty) + '">' + TAPi18n.__('difficulty' + difficulty) + '</span>';
});
Template.registerHelper("getShuffleLabel", function (shuffled = false) {
if (Route.isRepetitorium()) {
shuffled = false;
......
......@@ -227,7 +227,7 @@
class="col-xs-12 resultName" data-id="{{this._id}}">
{{this.name}}
</a>
<span class="badge resultBadge cardsetBadge" data-id="{{this._id}}">
<span class="badge resultBadge cardsetBadge" data-id="{{this._id}}" title="{{_ "cardset.info.quantity"}}">
{{this.quantity}}
</span>
</template>
......
......@@ -48,9 +48,31 @@
<span class="sr-only"></span>
</button>
<ul class="dropdown-menu btn-raised longButton">
<li class="cardset" value="-1" data="-1"><a href="#">{{_ "leitnerProgress.indexDefault"}}</a>
<li class="cardset" value="-1" data="-1" data-name="{{_ "leitnerProgress.indexDefault"}}">
<a href="#">
<div id="activeCardset">
{{_ "leitnerProgress.indexDefault"}}
</div>
<div class="col-xs-12 cardset-details">
<span class="badge" title="{{_ "cardset.info.quantity"}}">
{{getCardsets true}}
</span>
</div>
</a>
</li>
{{{getCardsets}}}
{{#each getCardsets}}
<li class="cardset" value="{{this._id}}" data-id="{{this._id}}" data-name="{{this.name}}">
<a href="#">
{{this.name}}
<div class="col-xs-12 cardset-details">
<span class="badge" title="{{_ "cardset.info.quantity"}}">
{{this.quantity}}
</span>
{{{getDifficultyLabel this.cardType this.difficulty}}}
</div>
</a>
</li>
{{/each}}
</ul>
</div>
</div>
......
......@@ -94,19 +94,28 @@ Template.progress.events({
*/
Template.graphCardsetFilter.helpers({
getCardsets: function () {
let cardsetList = "";
getCardsets: function (countLeitnerCards = false) {
let cardsetList = [];
let cardsetLeitnerCount = 0;
let cardGroups = Cardsets.findOne({_id: Router.current().params._id}).cardGroups;
let cardsets = Cardsets.find({_id: {$in: cardGroups}}, {
fields: {_id: 1, name: 1, cardType: 1},
fields: {_id: 1, name: 1, cardType: 1, difficulty: 1, quantity: 1},
sort: {name: 1}
}).fetch();
for (let i = 0; i < cardsets.length; i++) {
if (CardType.gotLearningModes(cardsets[i].cardType)) {
cardsetList += '<li class="cardset" value="' + cardsets[i]._id + ' + " data="' + cardsets[i]._id + '"><a href="#">' + cardsets[i].name + '</a></li>';
if (countLeitnerCards) {
cardsetLeitnerCount += cardsets[i].quantity;
} else {
cardsetList.push(cardsets[i]);
}
}
}
return cardsetList;
if (countLeitnerCards) {
return cardsetLeitnerCount;
} else {
return cardsetList;
}
},
isShuffledCardset: function () {
if (Route.isLeitnerProgress()) {
......@@ -121,9 +130,10 @@ Template.graphCardsetFilter.helpers({
});
Template.graphCardsetFilter.events({
'click .cardset': function (evt) {
let cardset = $(evt.currentTarget).attr("data");
$('#setCardsetFiter').html($(evt.currentTarget).text());
$('#setCardsetFiter').val(cardset);
LeitnerProgress.updateGraph(cardset);
let cardset_id = $(evt.currentTarget).attr("data-id");
let cardset_name = $(evt.currentTarget).attr("data-name");
$('#setCardsetFiter').html(cardset_name);
$('#setCardsetFiter').val(cardset_id);
LeitnerProgress.updateGraph(cardset_id);
}
});
#setLeitnerProgressCardsetFilter {
.cardset-details {
padding: 0 !important;
}
.cardset {
padding-top: 2px !important;
padding-bottom: 7px !important;
}
.label, .badge {
font-size: $font_size_cardset_badges !important;
}
}
......@@ -152,6 +152,9 @@ $font_weight_cardset_form_list: normal;
//cookie consent
$text_decoration_cookie_consent_link: none;
//leitner_progress
$font_size_cardset_badges: 11px;
html {
position: relative;
min-height: 100%;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment