consistently rename maxCardCount to CardLimit

+ remove snackbar as response due to it showing on every change
+ fix component name of ClearLocalStorage
+ disabled stepper in number input field
+ changed color of hint
This commit is contained in:
Rene Fischer 2020-08-24 19:50:16 +02:00
parent a5243c4d60
commit 68b0b844be
No known key found for this signature in database
GPG key ID: 5D8E12AC54D3C1B5
11 changed files with 107 additions and 100 deletions

View file

@ -13,7 +13,7 @@
<router-view <router-view
:decks="decks" :decks="decks"
:numberOfSelectedDecks="numberOfSelectedDecks" :numberOfSelectedDecks="numberOfSelectedDecks"
:maxCardCount="maxCardCount" :cardLimit="cardLimit"
/> />
<v-snackbar app v-model="snackbar.snackbar" :timeout="snackbar.timeout"> <v-snackbar app v-model="snackbar.snackbar" :timeout="snackbar.timeout">
{{ snackbar.text }} {{ snackbar.text }}
@ -65,9 +65,9 @@ const AppProps = Vue.extend({
export default class App extends AppProps { export default class App extends AppProps {
propertiesToSyncWithLocalStorage = [ propertiesToSyncWithLocalStorage = [
{ key: "decks", defaultValue: [] }, { key: "decks", defaultValue: [] },
{ key: "maxCardCount", defaultValue: "" } { key: "cardLimit", defaultValue: "" }
] as SyncItem[]; ] as SyncItem[];
maxCardCount = ""; cardLimit = "";
decks = [] as Deck[]; decks = [] as Deck[];
snackbar = { snackbar = {
text: "", text: "",

View file

@ -51,7 +51,7 @@ const LearnProps = Vue.extend({
props: { props: {
decks: { type: Array as () => Deck[] }, decks: { type: Array as () => Deck[] },
numberOfSelectedDecks: Number, numberOfSelectedDecks: Number,
maxCardCount: String cardLimit: String
} }
}); });
@ -141,10 +141,10 @@ export default class Learn extends LearnProps {
(this.learningSessionManager.learningSession.currentElementIndex === (this.learningSessionManager.learningSession.currentElementIndex ===
this.learningSessionManager.learningSession.elements.length - 1 && this.learningSessionManager.learningSession.elements.length - 1 &&
this.learningSessionManager.cardsToSelectFrom.length === 0) || this.learningSessionManager.cardsToSelectFrom.length === 0) ||
(this.maxCardCount === "0" (this.cardLimit === "0"
? false ? false
: this.learningSessionManager.learningSession.currentElementIndex === : this.learningSessionManager.learningSession.currentElementIndex ===
parseInt(this.maxCardCount) - 1); parseInt(this.cardLimit) - 1);
return endOfSession; return endOfSession;
} }

View file

@ -0,0 +1,89 @@
<template>
<v-col cols="12" sm="12" md="6" lg="6" xl="6">
<v-card height="100%" raised>
<v-card-title>Card Limit</v-card-title>
<v-card-text>
<p class="paragraph">
Limit the number of cards that will be in each learning session.
<v-icon
size="1em"
@click="showHelpText = !showHelpText"
class="mx-1"
>mdi-help-circle-outline</v-icon>
</p>
<p
class="description"
v-show="showHelpText"
>If the given deck(s) has (have) less cards it will default to the number of cards in the given deck(s).</p>
<v-text-field v-model="curcardLimit" type="number" min="1" :label="label" hide-details="auto" outlined></v-text-field>
</v-card-text>
<v-card-actions class="button-padding">
<v-spacer></v-spacer>
<v-btn color="red" @click="deactivatecardLimit" right>Deactivate Limit</v-btn>
</v-card-actions>
</v-card>
</v-col>
</template>
<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { Event } from "../../types";
const CardLimitProps = Vue.extend({
props: {
cardLimit: String
}
});
@Component
export default class CardLimit extends CardLimitProps {
noLimitString = "Currently no limit";
defaultLabel = "Card Limit";
showHelpText = false;
get label() {
return this.cardLimit === "0" || null
? this.noLimitString
: this.defaultLabel;
}
get curcardLimit() {
return this.cardLimit === "0" || null
? null
: this.cardLimit;
}
set curcardLimit(newValue) {
this.$eventHub.$emit(Event.UPDATE_CARD_LIMIT, newValue);
}
deactivatecardLimit() {
this.$eventHub.$emit(Event.UPDATE_CARD_LIMIT, "0");
}
}
</script>
<style scoped>
.button-padding {
padding: 16px;
}
.description {
align-items: center;
font-size: 0.875rem;
font-weight: 400;
padding: 0 16px;
color: rgba(255, 255, 255, 0.7);
}
p .v-icon {
color: inherit;
}
/* Disable stepper in number input */
::v-deep input::-webkit-outer-spin-button,
::v-deep input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
</style>

View file

@ -21,7 +21,7 @@ import Component from "vue-class-component";
import * as clearStorageDialogHelper from "../../helpers/clearStorageDialogHelper"; import * as clearStorageDialogHelper from "../../helpers/clearStorageDialogHelper";
@Component @Component
export default class MaxCardCount extends Vue { export default class ClearLocalStorage extends Vue {
clearLocalStorage() { clearLocalStorage() {
clearStorageDialogHelper.clearLocalStorageDialog(this); clearStorageDialogHelper.clearLocalStorageDialog(this);
} }

View file

@ -1,70 +0,0 @@
<template>
<v-col cols="12" sm="12" md="6" lg="6" xl="6">
<v-card height="100%" raised>
<v-card-title>Max Card Count</v-card-title>
<v-card-text>
<p>
Limit the number of cards that will be in each learning session.
<v-icon
size="1em"
@click="showHelpText = !showHelpText"
class="mx-1"
>mdi-help-circle-outline</v-icon>
</p>
<p
class="description"
v-show="showHelpText"
>If the given deck(s) has(have) less cards it will default to the number of cards in the given deck(s).</p>
<v-text-field v-model="curMaxCardCount" type="number" min="1" :label="label" outlined></v-text-field>
</v-card-text>
<v-card-actions class="button-padding">
<v-spacer></v-spacer>
<v-btn color="red" @click="deactivateMaxCardCount" right>Deactivate Limit</v-btn>
</v-card-actions>
</v-card>
</v-col>
</template>
<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { Event } from '../../types';
const MaxCardCountProps = Vue.extend({
props: {
maxCardCount: String
}
});
@Component
export default class MaxCardCount extends MaxCardCountProps {
noLimitString = "Currently no limit";
defaultLabel = "Maximum Cards";
showHelpText = false;
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");
}
}
</script>
<style scoped>
.button-padding {
padding: 16px;
}
</style>

View file

@ -2,7 +2,7 @@
<div> <div>
<v-container fluid> <v-container fluid>
<v-row> <v-row>
<MaxCardCount :maxCardCount="maxCardCount" /> <CardLimit :cardLimit="cardLimit" />
<ClearLocalStorage /> <ClearLocalStorage />
</v-row> </v-row>
</v-container> </v-container>
@ -13,18 +13,18 @@
import Vue from "vue"; import Vue from "vue";
import Component from "vue-class-component"; import Component from "vue-class-component";
import MaxCardCount from "./MaxCardCountCard.vue"; import CardLimit from "./CardLimit.vue";
import ClearLocalStorage from "./ClearLocalStorage.vue"; import ClearLocalStorage from "./ClearLocalStorage.vue";
const SettingProps = Vue.extend({ const SettingProps = Vue.extend({
props: { props: {
maxCardCount: String cardLimit: String
} }
}); });
@Component({ @Component({
components: { components: {
MaxCardCount, CardLimit,
ClearLocalStorage ClearLocalStorage
} }
}) })

View file

@ -8,7 +8,6 @@ import {
import { clearLocalStorage } from "./localStorageHelper"; import { clearLocalStorage } from "./localStorageHelper";
import { addDecksFromJSON, addDecksFromFile } from "./addDecksHelper"; import { addDecksFromJSON, addDecksFromFile } from "./addDecksHelper";
import { showSnackbar } from "./snackbarHelper"; import { showSnackbar } from "./snackbarHelper";
import { updateMaxCardCount } from "./updateMaxCardCount";
export function registerEventListenerForMainApp(context: any) { export function registerEventListenerForMainApp(context: any) {
context.$eventHub.$on(Event.DELETE_SELECTED_DECKS, () => { context.$eventHub.$on(Event.DELETE_SELECTED_DECKS, () => {
@ -47,7 +46,7 @@ export function registerEventListenerForMainApp(context: any) {
} }
context.$router.replace("/"); context.$router.replace("/");
}); });
context.$eventHub.$on(Event.UPDATE_MAX_CARD_COUNT, (newValue: string) => { context.$eventHub.$on(Event.UPDATE_CARD_LIMIT, (newValue: string) => {
updateMaxCardCount(context, newValue); context.cardLimit = newValue;
}); });
} }

View file

@ -1,11 +0,0 @@
import { showSnackbar } from "./snackbarHelper";
export function updateMaxCardCount(context: any, newValue: string) {
context.maxCardCount = newValue;
newValue !== "0"
? showSnackbar(
context,
"Successfully updated max card count to " + newValue + "."
)
: showSnackbar(context, "Successfully deactivated max card count.");
}

View file

@ -117,7 +117,7 @@ export enum Event {
DESELECT_ALL_DECKS = "deselectAllDecks", DESELECT_ALL_DECKS = "deselectAllDecks",
SWIPE_LEFT_IN_LEARN = "swipeLeftInLearn", SWIPE_LEFT_IN_LEARN = "swipeLeftInLearn",
SWIPE_RIGHT_IN_LEARN = "swipeRightInLearn", SWIPE_RIGHT_IN_LEARN = "swipeRightInLearn",
UPDATE_MAX_CARD_COUNT = "updateMaxCardCount", UPDATE_CARD_LIMIT = "updateCardLimit",
} }
export interface NavBarConfigItem { export interface NavBarConfigItem {

View file

@ -4,7 +4,7 @@
:decks="decks" :decks="decks"
:numberOfSelectedDecks="numberOfSelectedDecks" :numberOfSelectedDecks="numberOfSelectedDecks"
:learningSession="learningSession" :learningSession="learningSession"
:maxCardCount="maxCardCount" :cardLimit="cardLimit"
/> />
</div> </div>
</template> </template>
@ -22,7 +22,7 @@ const LearnProps = Vue.extend({
decks: { type: Array as () => Deck[] }, decks: { type: Array as () => Deck[] },
learningSession: { type: Object as () => LearningSession }, learningSession: { type: Object as () => LearningSession },
numberOfSelectedDecks: Number, numberOfSelectedDecks: Number,
maxCardCount: String cardLimit: String
} }
}); });

View file

@ -1,6 +1,6 @@
<template> <template>
<div class="settings"> <div class="settings">
<SettingsComponent :maxCardCount="maxCardCount" /> <SettingsComponent :cardLimit="cardLimit" />
</div> </div>
</template> </template>
@ -12,7 +12,7 @@ import SettingsComponent from "../components/settings/Settings.vue";
const SettingProps = Vue.extend({ const SettingProps = Vue.extend({
props: { props: {
maxCardCount: String cardLimit: String
} }
}); });