From 1aea558c40d36f8f33322957f4a44bb6b6e8744b Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Wed, 6 Nov 2019 20:02:29 -0500 Subject: [PATCH] [+] Store selected time in cookies --- src/components/navigation/navigation.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/navigation/navigation.ts b/src/components/navigation/navigation.ts index 8f756b9..c05ef84 100644 --- a/src/components/navigation/navigation.ts +++ b/src/components/navigation/navigation.ts @@ -17,7 +17,7 @@ export default class Navigation extends Vue @Prop({required: true}) courses: Course[]; - private selectedTime = 'All Year'; + private selectedTime: string; // Instance public static instance: Navigation; @@ -25,6 +25,19 @@ export default class Navigation extends Vue /** * This is called when the instance is created. */ + public created() + { + // Check selected time + if (!this.$cookies.isKey('va.selected-time')) + { + this.$cookies.set('va.selected-time', 'All Year', '10y'); + } + this.selectedTime = this.$cookies.get('va.selected-time'); + } + + /** + * This is called when the instance is loaded. + */ public mounted() { // Set instance @@ -156,6 +169,10 @@ export default class Navigation extends Vue public selectTime(command: string) { this.selectedTime = command; + this.$cookies.set('va.selected-time', command, '10y'); + + // Call event + this.$emit('navigation:select-time', command); } /**