Merge pull request #27 from fancy-flashcard/barchart-on-quit

show barchart to evaluate learning when quitting
This commit is contained in:
Niko Lockenvitz 2020-08-22 16:46:43 +02:00 committed by GitHub
commit da455998b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 5 deletions

View file

@ -1,6 +1,6 @@
{
"name": "ffc",
"version": "2.0.0",
"version": "2.1.0",
"author": "Niko Lockenvitz & Rene-Pascal Fischer",
"license": "MIT",
"private": true,

View file

@ -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;

View file

@ -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
@ -86,10 +87,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() {
@ -203,6 +208,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) {

View file

@ -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",

View file

@ -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",