This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/views/list/ListGantt.vue

157 lines
3.4 KiB
Vue
Raw Normal View History

2019-04-29 21:41:39 +00:00
<template>
2022-10-11 11:22:57 +00:00
<ListWrapper class="list-gantt" :list-id="filters.listId" viewName="gantt">
2021-11-14 20:33:53 +00:00
<template #header>
<card>
<div class="gantt-options">
2022-08-02 12:09:29 +00:00
<div class="field">
<label class="label" for="range">{{ $t('list.gantt.range') }}</label>
<div class="control">
2022-10-10 19:44:59 +00:00
<Foo
ref="flatPickerEl"
2022-08-02 12:09:29 +00:00
:config="flatPickerConfig"
class="input"
id="range"
:placeholder="$t('list.gantt.range')"
2022-10-10 19:44:59 +00:00
v-model="flatPickerDateRange"
2022-08-02 12:09:29 +00:00
/>
</div>
2019-04-29 21:41:39 +00:00
</div>
2022-10-11 11:22:57 +00:00
<fancycheckbox class="is-block" v-model="filters.showTasksWithoutDates">
{{ $t('list.gantt.showTasksWithoutDates') }}
</fancycheckbox>
2019-04-29 21:41:39 +00:00
</div>
</card>
2021-11-14 20:33:53 +00:00
</template>
2021-11-14 20:33:53 +00:00
<template #default>
<div class="gantt-chart-container">
<card :padding="false" class="has-overflow">
<gantt-chart
2022-10-11 11:22:57 +00:00
:list-id="filters.listId"
2022-10-17 20:28:01 +00:00
:date-from="filters.dateFrom"
:date-to="filters.dateTo"
2022-10-17 21:20:52 +00:00
:show-tasks-without-dates="filters.showTasksWithoutDates"
/>
</card>
</div>
2021-11-14 20:33:53 +00:00
</template>
</ListWrapper>
2019-04-29 21:41:39 +00:00
</template>
2021-12-10 14:29:28 +00:00
<script setup lang="ts">
import {computed, ref, toRefs} from 'vue'
2022-10-10 19:44:59 +00:00
import Foo from '@/components/misc/flatpickr/Flatpickr.vue'
2022-10-11 11:22:57 +00:00
import type Flatpickr from 'flatpickr'
import {useI18n} from 'vue-i18n'
import type {RouteLocationNormalized} from 'vue-router'
2022-09-21 01:37:39 +00:00
import {useAuthStore} from '@/stores/auth'
2021-11-01 17:19:59 +00:00
2021-12-10 14:29:28 +00:00
import ListWrapper from './ListWrapper.vue'
import Fancycheckbox from '@/components/input/fancycheckbox.vue'
2022-10-10 19:44:59 +00:00
import {createAsyncComponent} from '@/helpers/createAsyncComponent'
import {useGanttFilter} from './helpers/useGanttFilter'
2022-10-11 11:22:57 +00:00
type Options = Flatpickr.Options.Options
2022-10-10 19:44:59 +00:00
2022-10-17 21:20:52 +00:00
const GanttChart = createAsyncComponent(() => import('@/components/tasks/gantt-chart.vue'))
2021-12-10 14:29:28 +00:00
2022-10-17 21:20:52 +00:00
const props = defineProps<{route: RouteLocationNormalized}>()
2021-11-01 17:19:59 +00:00
const {route} = toRefs(props)
const {filters} = useGanttFilter(route)
2022-10-10 19:44:59 +00:00
2022-10-17 21:20:52 +00:00
const flatPickerEl = ref<typeof Foo | null>(null)
const flatPickerDateRange = computed<Date[]>({
2022-10-10 19:44:59 +00:00
get: () => ([
2022-10-17 21:20:52 +00:00
new Date(filters.dateFrom),
new Date(filters.dateTo),
2022-10-10 19:44:59 +00:00
]),
set(newVal) {
2022-10-11 11:22:57 +00:00
const [dateFrom, dateTo] = newVal.map((date) => date?.toISOString())
2022-10-10 19:44:59 +00:00
2022-10-11 11:22:57 +00:00
// only set after whole range has been selected
if (!dateTo) return
Object.assign(filters, {dateFrom, dateTo})
2022-10-17 21:20:52 +00:00
},
2022-10-10 19:44:59 +00:00
})
2022-10-11 11:22:57 +00:00
const initialDateRange = [filters.dateFrom, filters.dateTo]
const {t} = useI18n({useScope: 'global'})
2022-09-21 01:37:39 +00:00
const authStore = useAuthStore()
2022-10-11 11:22:57 +00:00
const flatPickerConfig = computed<Options>(() => ({
2021-12-07 18:40:50 +00:00
altFormat: t('date.altFormatShort'),
2021-11-01 17:19:59 +00:00
altInput: true,
2022-10-10 19:44:59 +00:00
defaultDate: initialDateRange,
2021-11-01 17:19:59 +00:00
enableTime: false,
mode: 'range',
2021-11-01 17:19:59 +00:00
locale: {
2022-09-21 01:37:39 +00:00
firstDayOfWeek: authStore.settings.weekStart,
},
2021-11-01 17:19:59 +00:00
}))
</script>
<style lang="scss">
.gantt-chart-container {
padding-bottom: 1rem;
}
.gantt-options {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1rem;
@media screen and (max-width: $tablet) {
flex-direction: column;
}
2022-08-02 12:09:29 +00:00
.field {
margin-bottom: 0;
width: 33%;
&:not(:last-child) {
padding-right: .5rem;
}
@media screen and (max-width: $tablet) {
width: 100%;
2022-08-02 12:09:29 +00:00
max-width: 100%;
margin-top: .5rem;
padding-right: 0 !important;
}
2022-08-02 12:09:29 +00:00
&, .input {
font-size: .8rem;
}
2022-08-02 12:09:29 +00:00
.select, .select select {
height: auto;
width: 100%;
font-size: .8rem;
}
2022-08-02 12:09:29 +00:00
.label {
font-size: .9rem;
}
}
}
// vue-draggable overwrites
.vdr.active::before {
display: none;
}
.link-share-view:not(.has-background) .card.gantt-options {
border: none;
box-shadow: none;
.card-content {
padding: .5rem;
}
}
</style>