2018-09-06 17:46:38 +00:00
|
|
|
<template>
|
2018-09-09 14:22:02 +00:00
|
|
|
<div class="content has-text-centered">
|
2022-10-16 17:36:04 +00:00
|
|
|
<h2 v-if="salutation">{{ salutation }}</h2>
|
|
|
|
|
2021-12-12 11:00:24 +00:00
|
|
|
<message variant="danger" v-if="deletionScheduledAt !== null" class="mb-4">
|
2021-08-11 19:08:18 +00:00
|
|
|
{{
|
|
|
|
$t('user.deletion.scheduled', {
|
|
|
|
date: formatDateShort(deletionScheduledAt),
|
|
|
|
dateSince: formatDateSince(deletionScheduledAt),
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
<router-link :to="{name: 'user.settings', hash: '#deletion'}">
|
|
|
|
{{ $t('user.deletion.scheduledCancel') }}
|
|
|
|
</router-link>
|
2021-11-28 14:18:27 +00:00
|
|
|
</message>
|
2021-07-17 21:21:46 +00:00
|
|
|
<add-task
|
|
|
|
@taskAdded="updateTaskList"
|
|
|
|
class="is-max-width-desktop"
|
|
|
|
/>
|
2021-08-06 17:25:17 +00:00
|
|
|
<template v-if="!hasTasks && !loading">
|
|
|
|
<template v-if="defaultNamespaceId > 0">
|
|
|
|
<p class="mt-4">{{ $t('home.list.newText') }}</p>
|
|
|
|
<x-button
|
2021-11-17 17:04:53 +00:00
|
|
|
:to="{ name: 'list.create', params: { namespaceId: defaultNamespaceId } }"
|
2021-08-06 17:25:17 +00:00
|
|
|
:shadow="false"
|
|
|
|
class="ml-2"
|
|
|
|
>
|
|
|
|
{{ $t('home.list.new') }}
|
|
|
|
</x-button>
|
|
|
|
</template>
|
2021-01-17 19:53:09 +00:00
|
|
|
<p class="mt-4" v-if="migratorsEnabled">
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('home.list.importText') }}
|
2021-01-17 19:53:09 +00:00
|
|
|
</p>
|
2021-04-15 15:21:20 +00:00
|
|
|
<x-button
|
|
|
|
v-if="migratorsEnabled"
|
|
|
|
:to="{ name: 'migrate.start' }"
|
|
|
|
:shadow="false">
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('home.list.import') }}
|
2021-01-17 17:57:57 +00:00
|
|
|
</x-button>
|
2020-06-15 16:47:17 +00:00
|
|
|
</template>
|
2021-09-29 19:29:09 +00:00
|
|
|
<div v-if="listHistory.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>
|
2022-11-15 16:25:52 +00:00
|
|
|
<ListCardGrid :lists="listHistory" v-cy="'listCardGrid'" />
|
2021-07-06 20:22:57 +00:00
|
|
|
</div>
|
2022-02-06 19:11:13 +00:00
|
|
|
<ShowTasks
|
|
|
|
v-if="hasLists"
|
2022-11-15 16:25:52 +00:00
|
|
|
class="show-tasks"
|
2022-02-06 19:11:13 +00:00
|
|
|
:key="showTasksKey"
|
|
|
|
/>
|
2018-09-06 17:46:38 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-11-30 20:06:15 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import {ref, computed} from 'vue'
|
|
|
|
|
|
|
|
import Message from '@/components/misc/message.vue'
|
|
|
|
import ShowTasks from '@/views/tasks/ShowTasks.vue'
|
2022-11-15 16:25:52 +00:00
|
|
|
import ListCardGrid from '@/components/list/partials/ListCardGrid.vue'
|
2021-11-30 20:06:15 +00:00
|
|
|
import AddTask from '@/components/tasks/add-task.vue'
|
|
|
|
|
|
|
|
import {getHistory} from '@/modules/listHistory'
|
|
|
|
import {parseDateOrNull} from '@/helpers/parseDateOrNull'
|
|
|
|
import {formatDateShort, formatDateSince} from '@/helpers/time/formatDate'
|
2022-10-17 00:12:32 +00:00
|
|
|
import {useDaytimeSalutation} from '@/composables/useDaytimeSalutation'
|
2022-09-24 13:20:40 +00:00
|
|
|
|
|
|
|
import {useBaseStore} from '@/stores/base'
|
2022-09-21 16:21:25 +00:00
|
|
|
import {useListStore} from '@/stores/lists'
|
2022-09-21 00:21:22 +00:00
|
|
|
import {useConfigStore} from '@/stores/config'
|
2022-09-02 09:15:29 +00:00
|
|
|
import {useNamespaceStore} from '@/stores/namespaces'
|
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'
|
2022-10-17 11:14:07 +00:00
|
|
|
import type {IList} from '@/modelTypes/IList'
|
2021-11-30 20:06:15 +00:00
|
|
|
|
2022-10-17 00:12:32 +00:00
|
|
|
const salutation = useDaytimeSalutation()
|
2021-01-17 19:53:09 +00:00
|
|
|
|
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()
|
2022-09-02 09:15:29 +00:00
|
|
|
const namespaceStore = useNamespaceStore()
|
2022-09-21 16:21:25 +00:00
|
|
|
const listStore = useListStore()
|
2022-09-24 13:20:40 +00:00
|
|
|
const taskStore = useTaskStore()
|
|
|
|
|
2021-11-30 20:06:15 +00:00
|
|
|
const listHistory = computed(() => {
|
2022-07-21 13:53:08 +00:00
|
|
|
// If we don't check this, it tries to load the list background right after logging out
|
2022-09-21 01:37:39 +00:00
|
|
|
if(!authStore.authenticated) {
|
2022-07-21 13:53:08 +00:00
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
2022-01-04 16:54:00 +00:00
|
|
|
return getHistory()
|
2022-09-21 16:21:25 +00:00
|
|
|
.map(l => listStore.getListById(l.id))
|
2022-10-17 11:14:07 +00:00
|
|
|
.filter((l): l is IList => l !== null)
|
2021-11-30 20:06:15 +00:00
|
|
|
})
|
2021-07-06 15:13:13 +00:00
|
|
|
|
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)
|
2022-09-02 09:15:29 +00:00
|
|
|
const defaultNamespaceId = computed(() => namespaceStore.namespaces?.[0]?.id || 0)
|
|
|
|
const hasLists = computed(() => namespaceStore.namespaces?.[0]?.lists.length > 0)
|
2022-09-24 13:20:40 +00:00
|
|
|
const loading = computed(() => taskStore.isLoading)
|
2022-09-21 01:37:39 +00:00
|
|
|
const deletionScheduledAt = computed(() => parseDateOrNull(authStore.info?.deletionScheduledAt))
|
2021-07-06 15:13:13 +00:00
|
|
|
|
2021-11-30 20:06:15 +00:00
|
|
|
// 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?)
|
2021-11-30 20:06:15 +00:00
|
|
|
const showTasksKey = ref(0)
|
2022-02-06 19:11:13 +00:00
|
|
|
|
2021-11-30 20:06:15 +00:00
|
|
|
function updateTaskList() {
|
|
|
|
showTasksKey.value++
|
2020-09-05 20:35:52 +00:00
|
|
|
}
|
2018-09-06 17:46:38 +00:00
|
|
|
</script>
|
2021-10-18 12:21:02 +00:00
|
|
|
|
2022-11-15 16:25:52 +00:00
|
|
|
<style scoped lang="scss">
|
|
|
|
.show-tasks {
|
|
|
|
margin-top: 2rem;
|
2021-10-18 12:21:02 +00:00
|
|
|
}
|
|
|
|
</style>
|