[project overview calendar] added year filter

This commit is contained in:
JakubPapso committed 2024-03-08 13:32:40 +01:00
1 parent f13afeb72e
commit 328eb36dfe
4 files changed
+28 -8

No files matched your search

@@ -29,7 +29,7 @@
<v-btn class="menu-dropdown" v-bind="props"> <v-btn class="menu-dropdown" v-bind="props">
<div class="d-flex justify-between align-center"> <div class="d-flex justify-between align-center">
<p class="employee-select-avatar d-flex justify-center align-center" @click.stop="$router.push({name: 'Dashboard - User'})"> <p class="employee-select-avatar d-flex justify-center align-center" @click.stop="$router.push({name: 'Dashboard - User'})">
{{ user.name.charAt(0) }}{{ user.surname.charAt(0) }} {{ user.name?.charAt(0) }}{{ user.surname?.charAt(0) }}
</p> </p>
<div> <div>
@@ -21,6 +21,10 @@ export default {
month: { month: {
required: true required: true
},
year: {
required: true
} }
}, },
@@ -44,17 +48,19 @@ export default {
}, },
mounted() { mounted() {
const currentYear = new Date().getFullYear()
const monthIndex = typeof this.month == 'string' ? parseInt(this.month) - 1 : this.month - 1 const monthIndex = typeof this.month == 'string' ? parseInt(this.month) - 1 : this.month - 1
this.calendarOptions.events = this.events 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: { watch: {
month(selectedMonth) { month(selectedMonth) {
const currentYear = new Date().getFullYear() this.$refs.fullCalendar?.getApi().gotoDate(new Date(this.year, selectedMonth, 1))
this.$refs.fullCalendar?.getApi().gotoDate(new Date(currentYear, selectedMonth, 1)) },
}
year(selectedYear) {
this.$refs.fullCalendar?.getApi().gotoDate(new Date(selectedYear, this.month, 1))
},
}, },
} }
</script> </script>
@@ -10,6 +10,8 @@
<v-select v-model="filter.month" class="subheader-input" :items="months" label="Mesiac" variant="outlined" /> <v-select v-model="filter.month" class="subheader-input" :items="months" label="Mesiac" variant="outlined" />
<v-select v-model="filter.year" class="subheader-input" :items="years" label="Rok" variant="outlined" />
<div class="subheader-input switch"> <div class="subheader-input switch">
<p class="switch-label">Zobraziť ukončené</p> <p class="switch-label">Zobraziť ukončené</p>
<v-switch v-model="filter.isFinished" color="#6200EE" hide-details></v-switch> <v-switch v-model="filter.isFinished" color="#6200EE" hide-details></v-switch>
@@ -50,6 +52,7 @@ export default {
employeeId: null, employeeId: null,
createdById: null, createdById: null,
month: null, month: null,
year: new Date().getFullYear(),
isFinished: false isFinished: false
} }
} }
@@ -87,6 +90,16 @@ export default {
return normalizedProjectCode.toLowerCase().includes(normalizedInput.toLowerCase()) return normalizedProjectCode.toLowerCase().includes(normalizedInput.toLowerCase())
}) })
return projects?.length ? projects.slice(0, 10) : this.projects.slice(0, 10) 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
} }
}, },
@@ -3,7 +3,7 @@
<A-project-filter v-if="$store.getters['tm/isInitialized']" @filterChanged="onFilterChanged" /> <A-project-filter v-if="$store.getters['tm/isInitialized']" @filterChanged="onFilterChanged" />
<W-loadable class="non-projects" :content="filteredProjects" emptyMessage="Nenašli sa žiadne vyhovujúce projekty"> <W-loadable class="non-projects" :content="filteredProjects" emptyMessage="Nenašli sa žiadne vyhovujúce projekty">
<A-project-calendar :events="filteredProjects" :month="filter.month" @open-detail="openMasterTaskModal" /> <A-project-calendar :events="filteredProjects" :month="filter.month" :year="filter.year" @open-detail="openMasterTaskModal" />
</W-loadable> </W-loadable>
</div> </div>
</template> </template>
@@ -108,7 +108,8 @@ export default {
if (filter.teamId) urlQueryObject.team_id = filter.teamId if (filter.teamId) urlQueryObject.team_id = filter.teamId
if (filter.createdById) urlQueryObject.created_by = filter.createdById if (filter.createdById) urlQueryObject.created_by = filter.createdById
if (filter.isFinished) urlQueryObject.is_finished = filter.isFinished ? 1 : 0 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() const queryParameters = new URLSearchParams(urlQueryObject).toString()