diff --git a/src/App.vue b/src/App.vue
index 0e22d19..7d21b89 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -10,7 +10,11 @@
:decks="decks"
:numberOfSelectedDecks="numberOfSelectedDecks"
>
-
+
{{ snackbar.text }}
@@ -60,8 +64,10 @@ const AppProps = Vue.extend({
})
export default class App extends AppProps {
propertiesToSyncWithLocalStorage = [
- { key: "decks", defaultValue: [] }
+ { key: "decks", defaultValue: [] },
+ { key: "maxCardCount", defaultValue: "" }
] as SyncItem[];
+ maxCardCount = "";
decks = [] as Deck[];
snackbar = {
text: "",
@@ -96,7 +102,11 @@ export default class App extends AppProps {
mounted() {
readFromLocalStorage(this);
this.setSelectedStatusForAllDecks(false);
- continueCurrentLearningSessionIfPresent(this.$eventHub, this.$router, this.decks);
+ continueCurrentLearningSessionIfPresent(
+ this.$eventHub,
+ this.$router,
+ this.decks
+ );
}
get numberOfSelectedDecks() {
diff --git a/src/components/learn/Learn.vue b/src/components/learn/Learn.vue
index da6a9b3..a5d94eb 100644
--- a/src/components/learn/Learn.vue
+++ b/src/components/learn/Learn.vue
@@ -46,12 +46,12 @@ import {
saveLearningSessionManagerDataToLocalStorage,
getLearningSessionManagerDataFromLocalStorage
} from "../../helpers/learningSessionStorageHelper";
-import { getMaxCardCount } from "../../helpers/maxCardCountLocalStorageHelper";
const LearnProps = Vue.extend({
props: {
decks: { type: Array as () => Deck[] },
- numberOfSelectedDecks: Number
+ numberOfSelectedDecks: Number,
+ maxCardCount: String
}
});
@@ -62,7 +62,6 @@ const LearnProps = Vue.extend({
})
export default class Learn extends LearnProps {
numberOfStarsInRating = 5;
- maxCardCount = getMaxCardCount();
learningSessionManager = new LearningSessionManager([]);
isLearningSessionFinishedAndComponentWillBeDestroyedSoon = false;
curLearningElement = {
@@ -142,10 +141,10 @@ export default class Learn extends LearnProps {
(this.learningSessionManager.learningSession.currentElementIndex ===
this.learningSessionManager.learningSession.elements.length - 1 &&
this.learningSessionManager.cardsToSelectFrom.length === 0) ||
- (this.maxCardCount === 0
+ (this.maxCardCount === "0"
? false
: this.learningSessionManager.learningSession.currentElementIndex ===
- this.maxCardCount - 1);
+ parseInt(this.maxCardCount) - 1);
return endOfSession;
}
diff --git a/src/components/settings/MaxCardCountCard.vue b/src/components/settings/MaxCardCountCard.vue
index f2e04c3..f0bd7eb 100644
--- a/src/components/settings/MaxCardCountCard.vue
+++ b/src/components/settings/MaxCardCountCard.vue
@@ -4,7 +4,7 @@
Max Card Count
- Define the number of cards that will be in each learning session.
+ Limit the number of cards that will be in each learning session.
If the given deck(s) has(have) less cards it will default to the number of cards in the given deck(s). The value "0" stands for every card in the given deck(s).
-
+ >If the given deck(s) has(have) less cards it will default to the number of cards in the given deck(s).
+
- Update Maximum Cards
+ Deactivate Limit
@@ -29,18 +29,36 @@
import Vue from "vue";
import Component from "vue-class-component";
-import {
- getMaxCardCount,
- setMaxCardCount
-} from "../../helpers/maxCardCountLocalStorageHelper";
+import { Event } from '../../types';
+
+const MaxCardCountProps = Vue.extend({
+ props: {
+ maxCardCount: String
+ }
+});
@Component
-export default class MaxCardCount extends Vue {
+export default class MaxCardCount extends MaxCardCountProps {
+ noLimitString = "Currently no limit";
+ defaultLabel = "Maximum Cards";
showHelpText = false;
- maxCardCount: number | null = getMaxCardCount();
- updateMaxCardCount() {
- setMaxCardCount(this, this.maxCardCount);
+ get label() {
+ return this.maxCardCount === "0" || null
+ ? this.noLimitString
+ : this.defaultLabel;
+ }
+
+ get curMaxCardCount() {
+ return this.maxCardCount === "0" || null ? null : this.maxCardCount;
+ }
+
+ set curMaxCardCount(newValue) {
+ this.$eventHub.$emit(Event.UPDATE_MAX_CARD_COUNT, newValue);
+ }
+
+ deactivateMaxCardCount() {
+ this.$eventHub.$emit(Event.UPDATE_MAX_CARD_COUNT, "0");
}
}
diff --git a/src/components/settings/Settings.vue b/src/components/settings/Settings.vue
index d3e3fa8..6b25594 100644
--- a/src/components/settings/Settings.vue
+++ b/src/components/settings/Settings.vue
@@ -2,7 +2,7 @@
-
+
@@ -16,13 +16,19 @@ import Component from "vue-class-component";
import MaxCardCount from "./MaxCardCountCard.vue";
import ClearLocalStorage from "./ClearLocalStorage.vue";
+const SettingProps = Vue.extend({
+ props: {
+ maxCardCount: String
+ }
+});
+
@Component({
components: {
MaxCardCount,
ClearLocalStorage
}
})
-export default class Settings extends Vue {}
+export default class Settings extends SettingProps {}