Commit 6122caa9 authored by Curtis Adam's avatar Curtis Adam

Refactor the filter navigation to only display if there are results

parent 69a72cd5
......@@ -160,6 +160,8 @@ $themes: (
$item_description_text: map-get($map, "item_description_text");
$item_text: map-get($map, "item_text");
$item_content_link: map-get($map, "item_content_link");
$no_results_background: map-get($map, "no_results_background");
$no_results_text: map-get($map, "no_results_text");
//difficulty colors
$button_difficulty0_note: map-get($map, "button_difficulty0_note");
$button_difficulty1: map-get($map, "button_difficulty1");
......@@ -1633,5 +1635,10 @@ $themes: (
background-color: $thm_orange !important;
color: white !important;
}
.no-results, .no-results-filtered {
background-color: $no_results_background !important;
color: $no_results_text !important;
}
}
}
......@@ -180,6 +180,8 @@
"item_description_text": black,
"item_text": white,
"item_content_link": white,
"no_results_background": white,
"no_results_text": black,
//difficulty colors
"button_difficulty0_note": $thm_orange,
"button_difficulty1": #5cb85c,
......
......@@ -182,6 +182,8 @@
"item_description_text": $thm_gray,
"item_text": white,
"item_content_link": white,
"no_results_background": white,
"no_results_text": $thm_gray,
//difficulty colors
"button_difficulty0_note": $thm_orange,
"button_difficulty1": #5cb85c,
......
......@@ -624,7 +624,8 @@
"wordcloudTrue": "Von der .cards-Redaktion empfohlen",
"wordcloudFalse": "Ohne Empfehlung",
"wordcloudEveryting": "Alle",
"from": "Ab"
"from": "Ab",
"noResults": "Keine Ergebnisse für diese Filtereinstellung"
},
"infinite-scroll": {
"remainingCardsets": "__current__ von __total__ Karteien",
......
......@@ -657,7 +657,8 @@
"wordcloudTrue": "In Word-Cloud",
"wordcloudFalse": "Not in Word-Cloud",
"wordcloudEveryting": "All",
"from": "From"
"from": "From",
"noResults": "Keine Ergebnisse für diese Filtereinstellung"
},
"infinite-scroll": {
"remainingCardsets": "__current__ of __total__ Cardsets",
......
......@@ -173,3 +173,30 @@
{{countCards this._id}}
</span>
</template>
<template name="noFilterResults">
<div class="col-xs-12 no-results-filtered">
<div class="no-result-text">
{{_ "filter-pool.noResults"}}
</div>
</div>
</template>
<template name="noResults">
<div class="col-xs-12 no-results {{#if isActiveRoute regex='pool'}}no-navigation{{/if}}">
<div class="no-result-text">
{{#if isActiveRoute 'create'}}
{{_ "set-list-empty.emptytextlist"}}
{{/if}}
{{#if isActiveRoute 'learn'}}
{{_ "set-list-learn-empty.emptytextlist"}}
{{/if}}
{{#if isActiveRoute regex='alldecks|pool'}}
{{_ "set-list-empty.emptypooltextlist"}}
{{/if}}
{{#if isActiveRoute 'courseIterations'}}
{{_ "courseIteration.list.empty"}}
{{/if}}
</div>
</div>
</template>
......@@ -27,7 +27,7 @@
<template name="shuffle">
{{#if canShuffle}}
{{#unless isShuffleRoute}}
{{#if shuffleList.count}}
{{#if shuffleList 0}}
<a href="shuffle" id="shuffleCardsets" class="btn btn-raised btn-success" role="button">{{_
"set-list.shuffleCardsets"}}</a>
{{/if}}
......@@ -65,16 +65,20 @@
"set-list.shuffleRemove"}}</button>
{{/if}}
</div>
<br>
{{#if shuffleList.count}}
{{#if shuffleList 0}}
{{> filterNavigation}}
{{#each shuffleList}}
{{#unless isActiveCardset}}
{{> cardsetCourseIterationResultRow extendContext 'index' @index}}
{{/unless}}
{{/each}}
{{#if shuffleList 1}}
{{#each shuffleList 2}}
{{#unless isActiveCardset}}
{{> cardsetCourseIterationResultRow extendContext 'index' @index}}
{{/unless}}
{{/each}}
{{> infiniteScroll}}
{{else}}
{{> noFilterResults}}
{{/if}}
{{else}}
{{> cardsetEmpty}}
{{> noResults}}
{{/if}}
</div>
{{/unless}}
......@@ -83,13 +87,11 @@
<template name="create">
<div class="col-md-12" id="set-list-region">
{{#if cardsetList.count}}
{{#if isActiveRoute 'create'}}
<button id="newCardSet" type="button" class="btn btn-raised btn-success saveSet" data-toggle="modal"
data-target="#setCardsetCourseIterationFormModal" {{disableIfOffline}} {{disableIfShuffle}}>
{{_ "set-list-empty.newset"}}
</button>
{{/if}}
{{#if isActiveRoute 'create'}}
<button id="newCardSet" type="button" class="btn btn-raised btn-success saveSet" data-toggle="modal"
data-target="#setCardsetCourseIterationFormModal" {{disableIfOffline}} {{disableIfShuffle}}>
{{_ "set-list-empty.newset"}}
</button>
{{/if}}
{{> shuffle}}
{{#if isActiveRoute 'create'}}
......@@ -97,74 +99,44 @@
{{_ "import.cardset"}} <input type="file" id="importCardset" style="display: none;">
</label>
{{/if}}
{{> filterNavigation}}
{{#if cardsetList.count}}
{{#each cardsetList}}
{{> cardsetCourseIterationResultRow extendContext 'index' @index}}
{{/each}}
{{> infiniteScroll}}
{{else}}
{{#if isActiveRoute 'create'}}
{{> cardsetEmpty}}
{{#if cardsetList 0}}
{{> filterNavigation}}
{{#if cardsetList 1}}
{{#each cardsetList 2}}
{{> cardsetCourseIterationResultRow extendContext 'index' @index}}
{{/each}}
{{> infiniteScroll}}
{{else}}
{{> poolCardsetEmpty}}
{{> noFilterResults}}
{{/if}}
{{else}}
{{> noResults}}
{{/if}}
</div>
</template>
<template name="cardsetEmpty">
<div class="empty-list">
<div align="center" height="60" colspan="3" class="emptyCellList set-list-empty">
{{#if isActiveRoute 'create'}}
<span class="emptyTextList">
{{_ "set-list-empty.emptytextlist"}}
</span>
<br>
<button id="setListEmpty" class="btn btn-raised btn-success btn-newSet" data-toggle="modal"
data-target="#setCardsetCourseIterationFormModal">{{_ "set-list-empty.newset"}}</button>
{{/if}}
{{#if isActiveRoute 'learn'}}
<span class="emptyTextList">
{{#if canShuffle}}
{{_ "set-list-learn-empty.emptytextlist"}}
{{else}}
{{_ "set-list-learn-empty.emptytextlistNoShuffle"}}
{{/if}}
</span>
<br>
<button id="browseCardset" class="btn btn-raised btn-success btn-newSet">{{_
"set-list-learn-empty.browseCardset"}}</button>
<button id="browseCourse" class="btn btn-raised btn-success btn-newSet" data-toggle="modal"
data-target="#underDevelopmentModal">{{_
"set-list-learn-empty.browseCourse"}}</button>
{{/if}}
</div>
</div>
</template>
<template name="learn">
{{> selectModeForm}}
{{> cardsetsConfirmLearnForm}}
<div id="learn-list-region" class="col-md-12">
{{#if learnList.count}}
<a id="browseCardset" class="btn btn-raised btn-success">{{_
"set-list-learn-empty.browseCardset"}}</a>
<a id="browseCourse" class="btn btn-raised btn-success" data-toggle="modal"
data-target="#underDevelopmentModal">{{_
"set-list-learn-empty.browseCourse"}}</a>
{{/if}}
{{> shuffle}}
{{#if learnList.count}}
<a id="browseCardset" class="btn btn-raised btn-success">{{_
"set-list-learn-empty.browseCardset"}}</a>
<a id="browseCourse" class="btn btn-raised btn-success" data-toggle="modal"
data-target="#underDevelopmentModal">{{_
"set-list-learn-empty.browseCourse"}}</a>
{{#if learnList 0}}
{{> filterNavigation}}
{{#each learnList}}
{{> cardsetCourseIterationResultRow extendContext 'index' @index}}
{{/each}}
{{> infiniteScroll}}
{{#if learnList 1}}
{{#each learnList 2}}
{{> cardsetCourseIterationResultRow extendContext 'index' @index}}
{{/each}}
{{> infiniteScroll}}
{{else}}
{{> noFilterResults}}
{{/if}}
{{else}}
{{> cardsetEmpty}}
{{> noResults}}
{{/if}}
{{> cardsetsConfirmLearnForm}}
</div>
</template>
......
......@@ -25,12 +25,28 @@ Meteor.subscribe("cardsets");
*/
Template.create.helpers({
cardsetList: function () {
prepareQuery();
return Cardsets.find(Session.get('filterQuery'), {
sort: Session.get('poolSortTopic'),
limit: Session.get('itemsLimit')
});
cardsetList: function (returnType) {
let query = {};
if (returnType !== 0) {
prepareQuery();
query = Session.get('filterQuery');
}
if (Router.current().route.getName() === "create") {
query.owner = Meteor.userId();
}
switch (returnType) {
case 0:
case 1:
return Cardsets.find(query, {
sort: Session.get('poolSortTopic'),
limit: Session.get('itemsLimit')
}).count();
case 2:
return Cardsets.find(query, {
sort: Session.get('poolSortTopic'),
limit: Session.get('itemsLimit')
});
}
}
});
......@@ -72,7 +88,7 @@ Template.create.onRendered(function () {
*/
Template.learn.helpers({
learnList: function () {
learnList: function (returnType) {
var leitnerCards = Leitner.find({
user_id: Meteor.userId()
});
......@@ -92,11 +108,23 @@ Template.learn.helpers({
learnCardsets.push(wozniakCard.cardset_id);
}
});
prepareQuery();
let query = {};
if (returnType !== 0) {
prepareQuery();
query = Session.get('filterQuery');
}
Session.set('cardsetIdFilter', learnCardsets);
let query = Session.get('filterQuery');
query._id = {$in: Session.get('cardsetIdFilter')};
return Cardsets.find(query, {sort: Session.get('poolSortTopic'), limit: Session.get('itemsLimit')});
switch (returnType) {
case 0:
case 1:
return Cardsets.find(query, {
sort: Session.get('poolSortTopic'),
limit: Session.get('itemsLimit')
}).count();
case 2:
return Cardsets.find(query, {sort: Session.get('poolSortTopic'), limit: Session.get('itemsLimit')});
}
}
});
......@@ -149,27 +177,50 @@ Template.shuffle.helpers({
shuffleInfoText: function () {
return TAPi18n.__('set-list.shuffleInfoText');
},
shuffleList: function () {
shuffleList: function (resultType) {
if (Router.current().route.getName() === "editshuffle") {
Session.set("ShuffledCardsets", Cardsets.findOne({_id: Router.current().params._id}).cardGroups);
}
return Cardsets.find({
$or: [
{owner: Meteor.userId()},
{kind: {$in: ["free", "edu"]}}
]
}, {
fields: {
name: 1,
description: 1,
quantity: 1,
cardType: 1,
difficulty: 1,
kind: 1,
owner: 1
},
sort: {name: 1}
});
switch (resultType) {
case 0:
case 1:
return Cardsets.find({
$or: [
{owner: Meteor.userId()},
{kind: {$in: ["free", "edu"]}}
]
}, {
fields: {
name: 1,
description: 1,
quantity: 1,
cardType: 1,
difficulty: 1,
kind: 1,
owner: 1
},
limit: Session.get('itemsLimit')
}).count();
case 2:
return Cardsets.find({
$or: [
{owner: Meteor.userId()},
{kind: {$in: ["free", "edu"]}}
]
}, {
fields: {
name: 1,
description: 1,
quantity: 1,
cardType: 1,
difficulty: 1,
kind: 1,
owner: 1
},
sort: {name: 1}, limit: Session.get('itemsLimit')
});
}
},
gotShuffledCards: function () {
if (ActiveRoute.name('shuffle')) {
......
......@@ -14,41 +14,27 @@
<template name="courseIterationsList">
<div id="course-list-region" class="col-md-12">
{{#if courseIterationsList.count}}
<button id="createCourse" type="button" class="btn btn-raised btn-success saveSet" data-toggle="modal"
data-target="#setCardsetCourseIterationFormModal" {{disableIfOffline}}>
{{_ "courseIteration.list.createCourse"}}
</button>
<button id="createCourse" type="button" class="btn btn-raised btn-success saveSet" data-toggle="modal"
data-target="#setCardsetCourseIterationFormModal" {{disableIfOffline}}>
{{_ "courseIteration.list.createCourse"}}
</button>
{{#if courseIterationsList 0}}
{{> shuffle}}
{{> filterNavigation}}
{{#each courseIterationsList}}
{{> cardsetCourseIterationResultRow extendContext 'index' @index}}
{{/each}}
{{> infiniteScroll}}
{{#if courseIterationsList 1}}
{{#each courseIterationsList 2}}
{{> cardsetCourseIterationResultRow extendContext 'index' @index}}
{{/each}}
{{> infiniteScroll}}
{{else}}
{{> noFilterResults}}
{{/if}}
{{else}}
{{> shuffle}}
{{> courseIterationsEmpty}}
{{> noResults}}
{{/if}}
</div>
</template>
<template name="courseIterationsEmpty">
<div class="empty-list">
<div align="center" height="60" colspan="3" class="emptyCellList set-list-empty">
<span class="emptyTextList">
{{_ "courseIteration.list.empty"}}
</span>
<br>
<button id="createCourse" type="button" class="btn btn-raised btn-success saveSet btn-newSet"
data-toggle="modal"
data-target="#setCardsetCourseIterationFormModal" {{disableIfOffline}}>
{{_ "courseIteration.list.createCourse"}}
</button>
<br>
<br>
</div>
</div>
</template>
<template name="courseIterationDeleteForm">
<div class="modal fade" id="confirmDeleteCourseIterationModal" tabindex="-1" role="dialog"
aria-labelledby="confirmDeleteCourseIterationModalTitle">
......
......@@ -37,10 +37,25 @@ Template.courseIterations.onRendered(function () {
*/
Template.courseIterationsList.helpers({
courseIterationsList: function () {
let query = Session.get('filterQuery');
prepareQuery();
return CourseIterations.find(query, {sort: Session.get('poolSortTopic'), limit: Session.get('itemsLimit')});
courseIterationsList: function (resultType) {
let query = {};
if (resultType !== 0) {
query = Session.get('filterQuery');
prepareQuery();
}
switch (resultType) {
case 0:
case 1:
return CourseIterations.find(query, {
sort: Session.get('poolSortTopic'),
limit: Session.get('itemsLimit')
}).count();
case 2:
return CourseIterations.find(query, {
sort: Session.get('poolSortTopic'),
limit: Session.get('itemsLimit')
});
}
}
});
......@@ -54,18 +69,6 @@ Template.courseIterationsList.events({
}
});
/*
* ############################################################################
* courseIterationsEmpty
* ############################################################################
*/
Template.courseIterationsEmpty.events({
'click #createCourse': function () {
cleanModal();
}
});
/*
* ############################################################################
* courseIterationDeleteForm
......
......@@ -11,8 +11,7 @@
</div>
<br>
{{/if}}
<nav class="navbar navbar-default {{#if isActiveRoute 'pool'}}{{#unless
selectingCardsetToLearn}}pool-filter-margin{{/unless}}{{/if}}">
<nav class="navbar navbar-default {{#if isActiveRoute regex='pool'}}no-navigation{{/if}}">
<div class="container-fluid" id="filter-nav-wrapper">
<div class="navbar-header">
<button class="resetFilters btn btn-raised btn-danger hidden-lg float-left" id="resetBtnMobile"
......@@ -357,13 +356,16 @@
</label>
{{/if}}
<label class="btn btn-info btn-sm active">
<input type="checkbox" autocomplete="off" value="free" checked=""> {{_ 'access-level.free.short'}}
<input type="checkbox" autocomplete="off" value="free" checked=""> {{_
'access-level.free.short'}}
</label>
<label class="btn btn-success btn-sm active">
<input type="checkbox" autocomplete="off" value="edu" checked=""> {{_ 'access-level.edu.short'}}
<input type="checkbox" autocomplete="off" value="edu" checked=""> {{_
'access-level.edu.short'}}
</label>
<label class="btn btn-danger btn-sm active">
<input type="checkbox" autocomplete="off" value="pro" checked=""> {{_ 'access-level.pro.short'}}
<input type="checkbox" autocomplete="off" value="pro" checked=""> {{_
'access-level.pro.short'}}
</label>
</div>
</ul>
......
@media (min-width: 768px) {
.pool-filter-margin {
margin-top: 56px;
}
}
#filter-nav-wrapper, #filter-nav {
padding: 0;
text-align: left;
......@@ -133,3 +127,20 @@
font-size: $font_size_infinite_scroll_text !important;
font-weight: $font_weight_infinite_scroll_text !important;
}
.no-results, .no-results-filtered {
display: table;
height: 100px;
text-align:center;
}
.no-navigation {
@media (min-width: 768px) {
margin-top: 56px;
}
}
.no-result-text {
display: table-cell;
vertical-align: middle;
}
......@@ -14,14 +14,18 @@
</template>
<template name="category">
{{> filterNavigation}}
{{#if getDecks.count}}
{{#each getDecks}}
{{#if getDecks 0}}
{{> filterNavigation}}
{{#if getDecks 1}}
{{#each getDecks 2}}
{{> cardsetCourseIterationResultRow extendContext 'index' @index}}
{{/each}}
{{> infiniteScroll}}
{{/each}}
{{> infiniteScroll}}
{{else}}
{{> noFilterResults}}
{{/if}}
{{else}}
{{> poolCardsetEmpty}}
{{> noResults}}
{{/if}}
</template>
......@@ -56,12 +60,3 @@
</div>
<!-- /.modal -->
</template>
<template name="poolCardsetEmpty">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 empty-list panel panel-default cardsetInfo ">
<br>
<span class="emptyTextList">{{_ "set-list-empty.emptypooltextlist"}}</span>
<br>
<br>
</div>
</template>
......@@ -19,9 +19,22 @@ Meteor.subscribe("cardsets");
*/
Template.category.helpers({
getDecks: function () {
prepareQuery();
return Cardsets.find(Session.get('filterQuery'), {sort: Session.get('poolSortTopic'), limit: Session.get('itemsLimit')});
getDecks: function (resultType) {
let query = {};
if (resultType !== 0) {
prepareQuery();
query = Session.get('filterQuery');
}
switch (resultType) {
case 0:
case 1:
return Cardsets.find(query, {
sort: Session.get('poolSortTopic'),
limit: Session.get('itemsLimit')
}).count();
case 2:
return Cardsets.find(query, {sort: Session.get('poolSortTopic'), limit: Session.get('itemsLimit')});
}
}
});
......
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