Commit 12160338 authored by Curtis Adam's avatar Curtis Adam

Merge branch '52-visualize-the-states-of-the-two-buttons-filter-and-cloud' into 'staging'

Resolve "Visualize the states of the two buttons "Filter" and "Cloud"."

Closes #52

See merge request arsnova/cards!90
parents 3dc68fd7 8c8336a0
......@@ -2373,6 +2373,12 @@ $themes: (
border-color: $danger_background !important;
}
#resetBtn.btn-default, #resetBtnMobile.btn-default {
color: white !important;
background-color: $primary !important;
border-color: $primary !important;
}
.btn-demo.active {
color: $demo_text !important;
background-color: $demo_background !important;
......
......@@ -947,7 +947,10 @@
"from": "Ab",
"noResults": "Keine Karteien oder Repetitorien vorhanden oder keine Ergebnisse für diese Filtereinstellung",
"sort": "Sortieren ",
"displayMode": "Wolke"
"displayMode": {
"wordcloud": "Wolke",
"list": "Liste"
}
},
"infinite-scroll": {
"remainingCardsets": "__current__ von __total__ Karteien",
......
......@@ -158,32 +158,20 @@ export let Filter = class Filter {
this.setActiveFilter(this.workloadFilter(), "_id");
}
static setDefaultFilter (filterType) {
static getDefaultFilter () {
return this.setDefaultFilter(FilterNavigation.getRouteId(), true);
}
static setDefaultFilter (filterType, returnDefault = false) {
let filter = {};
filter.topic = undefined;
if (Route.isWorkload()) {
filter._id = this.workloadFilter();
}
if (Route.isMyCardsets() || FilterNavigation.gotAuthorFilter(filterType)) {
if (Route.isMyCardsets()) {
filter.owner = Meteor.userId();
} else {
filter.owner = undefined;
}
}
if (FilterNavigation.gotCardTypeFilter(filterType)) {
filter.cardType = undefined;
}
if (FilterNavigation.gotDifficultyFilter(filterType)) {
filter.difficulty = undefined;
filter.noDifficulty = undefined;
}
if (FilterNavigation.gotBonusFilter(filterType)) {
filter.learningActive = undefined;
}
if (FilterNavigation.gotWordCloudFilter(filterType)) {
filter.wordcloud = undefined;
}
if (FilterNavigation.gotKindFilter(filterType)) {
let kind = [];
if (FilterNavigation.gotPersonalKindFilter(filterType)) {
......@@ -199,8 +187,6 @@ export let Filter = class Filter {
kind.push(this.getProKindTag());
}
filter.kind = kind;
} else {
filter.kind = undefined;
}
if (FilterNavigation.gotDefaultSortName(filterType)) {
filter.name = 1;
......@@ -208,11 +194,14 @@ export let Filter = class Filter {
if (FilterNavigation.gotDefaultSortDateUpdated(filterType)) {
filter.dateUpdated = -1;
}
filter.noModule = undefined;
if (!Route.isWorkload()) {
filter.shuffled = Route.isRepetitorium();
}
this.setActiveFilter(filter);
if (returnDefault) {
return filter;
} else {
this.setActiveFilter(filter);
}
}
static getFilterQuery () {
......
import {Route} from "./route.js";
import {Session} from "meteor/session";
import {Filter} from "./filter";
//0: Themen-Pool / Pool
//1: Kartei anlegen / My Cardsets
......@@ -138,4 +139,18 @@ export let FilterNavigation = class FilterNavigation {
return 5;
}
}
static getFilterButton () {
let activeFilter = Filter.getActiveFilter();
let defaultFilter = Filter.getDefaultFilter();
if (JSON.stringify(activeFilter) === JSON.stringify(defaultFilter)) {
$('#resetBtn').removeClass('btn-warning').addClass('btn-default');
$('#resetBtnMobile').removeClass('btn-warning').addClass('btn-default');
return {disabled: 'disabled'};
} else {
$('#resetBtn').removeClass('btn-default').addClass('btn-warning');
$('#resetBtnMobile').removeClass('btn-default').addClass('btn-warning');
return {};
}
}
};
<template name="filterItemDisplayModeButton">
<li class="dropdown hidden-xs">
<a id="displayModeBtn"
role="button">{{_ "filter-pool.displayMode"}}
role="button">
{{#if isWordcloudActive}}
{{_ "filter-pool.displayMode.wordcloud"}}
{{else}}
{{_ "filter-pool.displayMode.list"}}
{{/if}}
</a>
</li>
</template>
......@@ -25,6 +25,12 @@ Template.filterItemDisplayModeButton.onRendered(function () {
});
});
Template.filterItemDisplayModeButton.helpers({
isWordcloudActive: function () {
return Session.get('filterDisplayWordcloud');
}
});
Template.filterItemDisplayModeButton.events({
'click #displayModeBtn': function () {
if (Session.get('filterDisplayWordcloud')) {
......
<template name="filterItemResetButton">
<li>
<button class="resetFilters btn btn-raised btn-danger visible-md visible-lg" id="resetBtn"
role="button"><i class="glyphicon glyphicon-filter"></i> {{_ "set-list.reset"}}
<button class="resetFilters btn btn-raised visible-md visible-lg" id="resetBtn"
role="button" {{isDisabled}}><i class="glyphicon glyphicon-filter"></i> {{_ "set-list.reset"}}
</button>
</li>
</template>
import {Template} from "meteor/templating";
import {FilterNavigation} from "../../../../api/filterNavigation.js";
import "./resetButton.html";
/*
* ############################################################################
* filterItemResetButton
* ############################################################################
*/
Template.filterItemResetButton.onRendered(function () {
FilterNavigation.getFilterButton();
});
Template.filterItemResetButton.helpers({
isDisabled: function () {
return FilterNavigation.getFilterButton();
}
});
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