Redirect to current route from site without date
This commit is contained in:
parent
d2b414f328
commit
eb195dfd29
@ -4,46 +4,51 @@ import { FETCH_MONTH_BUDGET } from "../store/action-types";
|
|||||||
import { TITLE } from "../store/mutation-types";
|
import { TITLE } from "../store/mutation-types";
|
||||||
import Currency from "../components/Currency.vue";
|
import Currency from "../components/Currency.vue";
|
||||||
|
|
||||||
|
interface Date {
|
||||||
|
Year:Number,
|
||||||
|
Month:Number,
|
||||||
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$store.commit(TITLE, "Budget for " + this.month + " " + this.year);
|
this.$store.commit(TITLE, "Budget for " + this.month + " " + this.year);
|
||||||
return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.$data.Year, month: this.$data.Month });
|
return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.year, month: this.month });
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
year() {
|
year() {
|
||||||
return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.$data.Year, month: this.$data.Month });
|
return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.year, month: this.month });
|
||||||
},
|
},
|
||||||
month() {
|
month() {
|
||||||
return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.$data.Year, month: this.$data.Month });
|
return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.year, month: this.month });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
props: ["budgetid", "year", "month"],
|
props: ["budgetid", "year", "month"],
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
Year: (this.year || new Date().getFullYear()) as number,
|
|
||||||
Month: (this.month || new Date().getMonth()) as number
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
Categories() {
|
Categories() {
|
||||||
return this.$store.getters.Categories(this.$data.Year, this.$data.Month);
|
return this.$store.getters.Categories(this.year, this.month);
|
||||||
},
|
},
|
||||||
previous() {
|
previous() : Date {
|
||||||
return {
|
return {
|
||||||
Year: new Date(this.$data.Year, this.$data.Month - 1, 1).getFullYear(),
|
Year: new Date(this.year, this.month - 1, 1).getFullYear(),
|
||||||
Month: new Date(this.$data.Year, this.$data.Month - 1, 1).getMonth(),
|
Month: new Date(this.year, this.month - 1, 1).getMonth(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
current() {
|
current() : Date {
|
||||||
return {
|
return {
|
||||||
Year: new Date().getFullYear(),
|
Year: new Date().getFullYear(),
|
||||||
Month: new Date().getMonth(),
|
Month: new Date().getMonth(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
next() {
|
selected() : Date {
|
||||||
return {
|
return {
|
||||||
Year: new Date(this.$data.Year, this.$data.Month + 1, 1).getFullYear(),
|
Year: this.year,
|
||||||
Month: new Date(this.$data.Year, this.$data.Month + 1, 1).getMonth(),
|
Month: Number(this.month) + 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
next() : Date {
|
||||||
|
return {
|
||||||
|
Year: new Date(this.year, Number(this.month) + 1, 1).getFullYear(),
|
||||||
|
Month: new Date(this.year, Number(this.month) + 1, 1).getMonth(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -57,7 +62,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<h1>
|
<h1>
|
||||||
Budget for {{Month}}/{{Year}}
|
Budget for {{selected.Month}}/{{selected.Year}}
|
||||||
</h1>
|
</h1>
|
||||||
<div>
|
<div>
|
||||||
<router-link :to="'/budget/'+$store.getters.CurrentBudget.ID +'/' + previous.Year + '/' + previous.Month">Previous Month</router-link> -
|
<router-link :to="'/budget/'+$store.getters.CurrentBudget.ID +'/' + previous.Year + '/' + previous.Month">Previous Month</router-link> -
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory, RouteLocationNormalized } from 'vue-router'
|
||||||
import DashboardCard from '../components/Card.vue';
|
|
||||||
import Dashboard from '../pages/Dashboard.vue';
|
import Dashboard from '../pages/Dashboard.vue';
|
||||||
import Login from '../pages/Login.vue';
|
import Login from '../pages/Login.vue';
|
||||||
import Index from '../pages/Index.vue';
|
import Index from '../pages/Index.vue';
|
||||||
@ -14,7 +13,9 @@ const routes = [
|
|||||||
{ path: "/dashboard", name: "Dashboard", component: Dashboard },
|
{ path: "/dashboard", name: "Dashboard", component: Dashboard },
|
||||||
{ path: "/login", name: "Login", component: Login },
|
{ path: "/login", name: "Login", component: Login },
|
||||||
{ path: "/register", name: "Register", component: Register },
|
{ path: "/register", name: "Register", component: Register },
|
||||||
{ path: "/budget/:budgetid", name: "Budget", components: { default: Budgeting, sidebar: BudgetSidebar }, props: true },
|
{ path: "/budget/:budgetid", name: "Budget", redirect: (to : RouteLocationNormalized) =>
|
||||||
|
'/budget/' + to.params.budgetid + '/' + new Date().getFullYear() + '/' + new Date().getMonth()
|
||||||
|
},
|
||||||
{ path: "/budget/:budgetid/:year/:month", name: "Budget with date", components: { default: Budgeting, sidebar: BudgetSidebar }, props: true },
|
{ path: "/budget/:budgetid/:year/:month", name: "Budget with date", components: { default: Budgeting, sidebar: BudgetSidebar }, props: true },
|
||||||
{ path: "/budget/:budgetid/Settings", name: "Budget Settings", components: { default: Settings, sidebar: BudgetSidebar }, props: true },
|
{ path: "/budget/:budgetid/Settings", name: "Budget Settings", components: { default: Settings, sidebar: BudgetSidebar }, props: true },
|
||||||
{ path: "/budget/:budgetid/account/:accountid", name: "Account", components: { default: Account, sidebar: BudgetSidebar }, props: true },
|
{ path: "/budget/:budgetid/account/:accountid", name: "Account", components: { default: Account, sidebar: BudgetSidebar }, props: true },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user