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/Home.vue

111 lines
3.0 KiB
Vue
Raw Normal View History

2018-09-06 17:46:38 +00:00
<template>
2018-09-09 14:22:02 +00:00
<div class="content has-text-centered">
2024-02-07 11:18:19 +00:00
<h2 v-if="salutation">
{{ salutation }}
</h2>
2022-10-16 17:36:04 +00:00
2024-02-07 11:18:19 +00:00
<Message
v-if="deletionScheduledAt !== null"
variant="danger"
class="mb-4"
>
{{
$t('user.deletion.scheduled', {
date: formatDateShort(deletionScheduledAt),
dateSince: formatDateSince(deletionScheduledAt),
})
}}
<router-link :to="{name: 'user.settings', hash: '#deletion'}">
{{ $t('user.deletion.scheduledCancel') }}
</router-link>
2024-02-07 11:18:19 +00:00
</Message>
<AddTask
class="is-max-width-desktop"
2024-02-07 11:18:19 +00:00
@taskAdded="updateTaskKey"
/>
2023-03-25 13:54:20 +00:00
<template v-if="!hasTasks && !loading && migratorsEnabled">
<p class="mt-4">
{{ $t('home.project.importText') }}
</p>
<x-button
:to="{ name: 'migrate.start' }"
2024-02-07 11:18:19 +00:00
:shadow="false"
>
{{ $t('home.project.import') }}
</x-button>
</template>
2024-02-07 11:18:19 +00:00
<div
v-if="projectHistory.length > 0"
class="is-max-width-desktop has-text-left mt-4"
>
2021-07-06 20:22:57 +00:00
<h3>{{ $t('home.lastViewed') }}</h3>
2024-02-07 11:18:19 +00:00
<ProjectCardGrid
v-cy="'projectCardGrid'"
:projects="projectHistory"
/>
2021-07-06 20:22:57 +00:00
</div>
<ShowTasks
v-if="projectStore.hasProjects"
:key="showTasksKey"
2024-02-07 11:18:19 +00:00
class="show-tasks"
/>
2018-09-06 17:46:38 +00:00
</div>
</template>
<script lang="ts" setup>
import {ref, computed} from 'vue'
import Message from '@/components/misc/message.vue'
import ShowTasks from '@/views/tasks/ShowTasks.vue'
import ProjectCardGrid from '@/components/project/partials/ProjectCardGrid.vue'
import AddTask from '@/components/tasks/add-task.vue'
import {getHistory} from '@/modules/projectHistory'
import {parseDateOrNull} from '@/helpers/parseDateOrNull'
import {formatDateShort, formatDateSince} from '@/helpers/time/formatDate'
import {useDaytimeSalutation} from '@/composables/useDaytimeSalutation'
2022-09-24 13:20:40 +00:00
import {useBaseStore} from '@/stores/base'
import {useProjectStore} from '@/stores/projects'
2022-09-21 00:21:22 +00:00
import {useConfigStore} from '@/stores/config'
2022-09-21 01:37:39 +00:00
import {useAuthStore} from '@/stores/auth'
2022-09-24 13:20:40 +00:00
import {useTaskStore} from '@/stores/tasks'
const salutation = useDaytimeSalutation()
2022-09-24 13:20:40 +00:00
const baseStore = useBaseStore()
2022-09-21 01:37:39 +00:00
const authStore = useAuthStore()
2022-09-21 00:21:22 +00:00
const configStore = useConfigStore()
const projectStore = useProjectStore()
2022-09-24 13:20:40 +00:00
const taskStore = useTaskStore()
const projectHistory = computed(() => {
// If we don't check this, it tries to load the project background right after logging out
2022-09-21 01:37:39 +00:00
if(!authStore.authenticated) {
return []
}
return getHistory()
.map(l => projectStore.projects[l.id])
.filter(l => Boolean(l))
})
2022-09-21 00:21:22 +00:00
const migratorsEnabled = computed(() => configStore.availableMigrators?.length > 0)
2022-09-24 13:20:40 +00:00
const hasTasks = computed(() => baseStore.hasTasks)
const loading = computed(() => taskStore.isLoading)
2022-09-21 01:37:39 +00:00
const deletionScheduledAt = computed(() => parseDateOrNull(authStore.info?.deletionScheduledAt))
// This is to reload the tasks list after adding a new task through the global task add.
2022-09-24 13:20:40 +00:00
// FIXME: Should use pinia (somehow?)
const showTasksKey = ref(0)
function updateTaskKey() {
showTasksKey.value++
}
2018-09-06 17:46:38 +00:00
</script>
2022-11-15 16:25:52 +00:00
<style scoped lang="scss">
.show-tasks {
margin-top: 2rem;
}
</style>