Commit 8c8336a0 authored by Curtis Adam's avatar Curtis Adam

Disable the reset filter button and turn it gray if no filter is active

parent d525d147
......@@ -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;
......
......@@ -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="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