From 328eb36dfe27c2a02d1b41a02985c7d93e9182b7 Mon Sep 17 00:00:00 2001 From: JakubPapso Date: Fri, 8 Mar 2024 13:32:40 +0100 Subject: [PATCH] [project overview calendar] added year filter --- .../app/_layout/app/_components/a-header.vue | 2 +- .../projects/_components/a-project-calendar.vue | 16 +++++++++++----- .../projects/_components/a-project-filter.vue | 13 +++++++++++++ .../plugins/tm@dashboard/projects/projects.vue | 5 +++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/src/plugins/app/_layout/app/_components/a-header.vue b/app/src/plugins/app/_layout/app/_components/a-header.vue index 4bac408..04e4758 100644 --- a/app/src/plugins/app/_layout/app/_components/a-header.vue +++ b/app/src/plugins/app/_layout/app/_components/a-header.vue @@ -29,7 +29,7 @@

- {{ user.name.charAt(0) }}{{ user.surname.charAt(0) }} + {{ user.name?.charAt(0) }}{{ user.surname?.charAt(0) }}

diff --git a/app/src/plugins/tm@dashboard/projects/_components/a-project-calendar.vue b/app/src/plugins/tm@dashboard/projects/_components/a-project-calendar.vue index 0f832a4..48bd753 100644 --- a/app/src/plugins/tm@dashboard/projects/_components/a-project-calendar.vue +++ b/app/src/plugins/tm@dashboard/projects/_components/a-project-calendar.vue @@ -21,6 +21,10 @@ export default { month: { required: true + }, + + year: { + required: true } }, @@ -44,17 +48,19 @@ export default { }, mounted() { - const currentYear = new Date().getFullYear() const monthIndex = typeof this.month == 'string' ? parseInt(this.month) - 1 : this.month - 1 this.calendarOptions.events = this.events - this.$refs.fullCalendar?.getApi().gotoDate(new Date(currentYear, monthIndex, 1)) + this.$refs.fullCalendar?.getApi().gotoDate(new Date(this.year, monthIndex, 1)) }, watch: { month(selectedMonth) { - const currentYear = new Date().getFullYear() - this.$refs.fullCalendar?.getApi().gotoDate(new Date(currentYear, selectedMonth, 1)) - } + this.$refs.fullCalendar?.getApi().gotoDate(new Date(this.year, selectedMonth, 1)) + }, + + year(selectedYear) { + this.$refs.fullCalendar?.getApi().gotoDate(new Date(selectedYear, this.month, 1)) + }, }, } diff --git a/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue b/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue index 91d1e9e..57dc675 100644 --- a/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue +++ b/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue @@ -10,6 +10,8 @@ + +

Zobraziť ukončené

@@ -50,6 +52,7 @@ export default { employeeId: null, createdById: null, month: null, + year: new Date().getFullYear(), isFinished: false } } @@ -87,6 +90,16 @@ export default { return normalizedProjectCode.toLowerCase().includes(normalizedInput.toLowerCase()) }) return projects?.length ? projects.slice(0, 10) : this.projects.slice(0, 10) + }, + + years() { + const years = [] + const currentYear = new Date().getFullYear() + + for (let i = 0; i < 100; i++) + years.push({ title: currentYear - i, value: currentYear - i }) + + return years } }, diff --git a/app/src/plugins/tm@dashboard/projects/projects.vue b/app/src/plugins/tm@dashboard/projects/projects.vue index ab943fe..f524cbc 100644 --- a/app/src/plugins/tm@dashboard/projects/projects.vue +++ b/app/src/plugins/tm@dashboard/projects/projects.vue @@ -3,7 +3,7 @@ - +
@@ -108,7 +108,8 @@ export default { if (filter.teamId) urlQueryObject.team_id = filter.teamId if (filter.createdById) urlQueryObject.created_by = filter.createdById if (filter.isFinished) urlQueryObject.is_finished = filter.isFinished ? 1 : 0 - if (filter.month) urlQueryObject.created_at = filter.month + if (filter.month) urlQueryObject.month = filter.month + if (filter.year) urlQueryObject.year = filter.year const queryParameters = new URLSearchParams(urlQueryObject).toString()