Merge branch 'master' into limit-learning-session
This commit is contained in:
commit
71524a155e
4 changed files with 19 additions and 4 deletions
|
@ -71,7 +71,6 @@ import { Deck, Event, NavBarConfigItem } from '../../types';
|
|||
import navBarConfigJson from './navbar.json';
|
||||
|
||||
import * as selectedDeckDialogHelper from "../../helpers/selectedDeckDialogHelper";
|
||||
import * as quitLearningDialogHelper from "../../helpers/quitLearningDialogHelper";
|
||||
|
||||
const NavigationBarProps = Vue.extend({
|
||||
props: {
|
||||
|
@ -132,7 +131,7 @@ export default class NavigationBar extends NavigationBarProps {
|
|||
this.primaryDrawer.model = false;
|
||||
}
|
||||
quitLearning() {
|
||||
quitLearningDialogHelper.quitLearningDialog(this);
|
||||
this.$eventHub.$emit(Event.PREPARE_QUIT_LEARNING);
|
||||
}
|
||||
togglePrimaryDrawer() {
|
||||
this.primaryDrawer.model = !this.primaryDrawer.model;
|
||||
|
|
|
@ -41,6 +41,7 @@ import LearningSessionManager from "../../helpers/learningSessionManager";
|
|||
import FollowUpLearningSessionManager from "../../helpers/followUpLearningSessionManager";
|
||||
|
||||
import { finishLearningDialog } from "../../helpers/finishLearningDialogHelper";
|
||||
import { quitLearningDialog } from "../../helpers/quitLearningDialogHelper";
|
||||
import {
|
||||
saveLearningSessionManagerDataToLocalStorage,
|
||||
getLearningSessionManagerDataFromLocalStorage
|
||||
|
@ -88,10 +89,14 @@ export default class Learn extends LearnProps {
|
|||
this.$eventHub.$on(Event.SWIPE_RIGHT_IN_LEARN, () => {
|
||||
this.moveToPrev();
|
||||
});
|
||||
this.$eventHub.$on(Event.PREPARE_QUIT_LEARNING, () => {
|
||||
this.quitLearning();
|
||||
});
|
||||
}
|
||||
destroyed() {
|
||||
this.$eventHub.$off(Event.SWIPE_LEFT_IN_LEARN);
|
||||
this.$eventHub.$off(Event.SWIPE_RIGHT_IN_LEARN);
|
||||
this.$eventHub.$off(Event.PREPARE_QUIT_LEARNING);
|
||||
}
|
||||
|
||||
updateCurLearningElement() {
|
||||
|
@ -209,6 +214,10 @@ export default class Learn extends LearnProps {
|
|||
return bars;
|
||||
}
|
||||
|
||||
quitLearning() {
|
||||
quitLearningDialog(this, this.getBarsForFinishLearningDialog());
|
||||
}
|
||||
|
||||
updateVerticalCentering() {
|
||||
for (const el of document.getElementsByClassName("max-height")) {
|
||||
if (el.scrollHeight > el.clientHeight) {
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
import { Event, QuitLearningReason } from "../types";
|
||||
import { Event, QuitLearningReason, CustomDialogOptionsBarChartBar } from "../types";
|
||||
import { clearLearningSessionManagerDataInLocalStorage } from "./learningSessionStorageHelper";
|
||||
|
||||
export function quitLearningDialog(context: any) {
|
||||
export function quitLearningDialog(
|
||||
context: any,
|
||||
bars: CustomDialogOptionsBarChartBar[]
|
||||
) {
|
||||
context.$eventHub.$emit("showCustomDialog", {
|
||||
title: "Quit Learning?",
|
||||
message:
|
||||
"Do you really want to quit learning? Nevertheless, your progress is saved.",
|
||||
barChart: {
|
||||
bars,
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
name: "Cancel",
|
||||
|
|
|
@ -112,6 +112,7 @@ export enum Event {
|
|||
CLEAR_LOCAL_STORAGE = "clearLocalStorage",
|
||||
SHOW_CUSTOM_DIALOG = "showCustomDialog",
|
||||
QUIT_LEARNING = "quitLearning",
|
||||
PREPARE_QUIT_LEARNING = "prepareQuitLearning",
|
||||
SELECT_ALL_DECKS = "selectAllDecks",
|
||||
DESELECT_ALL_DECKS = "deselectAllDecks",
|
||||
SWIPE_LEFT_IN_LEARN = "swipeLeftInLearn",
|
||||
|
|
Loading…
Reference in a new issue