2018-09-06 19:46:38 +02:00
|
|
|
<template>
|
2018-09-09 16:22:02 +02:00
|
|
|
<div class="content has-text-centered">
|
2021-10-11 19:37:20 +02:00
|
|
|
<h2 v-if="userInfo">
|
2021-07-06 17:13:13 +02:00
|
|
|
{{ $t(`home.welcome${welcome}`, {username: userInfo.name !== '' ? userInfo.name : userInfo.username}) }}!
|
2021-01-17 20:53:09 +01:00
|
|
|
</h2>
|
2021-11-28 15:18:27 +01:00
|
|
|
<message variant="danger" v-if="deletionScheduledAt !== null">
|
2021-08-11 21:08:18 +02: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 15:18:27 +01:00
|
|
|
</message>
|
2021-07-17 23:21:46 +02:00
|
|
|
<add-task
|
|
|
|
:listId="defaultListId"
|
|
|
|
@taskAdded="updateTaskList"
|
|
|
|
class="is-max-width-desktop"
|
|
|
|
/>
|
2021-08-06 19:25:17 +02:00
|
|
|
<template v-if="!hasTasks && !loading">
|
|
|
|
<template v-if="defaultNamespaceId > 0">
|
|
|
|
<p class="mt-4">{{ $t('home.list.newText') }}</p>
|
|
|
|
<x-button
|
|
|
|
:to="{ name: 'list.create', params: { id: defaultNamespaceId } }"
|
|
|
|
:shadow="false"
|
|
|
|
class="ml-2"
|
|
|
|
>
|
|
|
|
{{ $t('home.list.new') }}
|
|
|
|
</x-button>
|
|
|
|
</template>
|
2021-01-17 20:53:09 +01:00
|
|
|
<p class="mt-4" v-if="migratorsEnabled">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('home.list.importText') }}
|
2021-01-17 20:53:09 +01:00
|
|
|
</p>
|
2021-04-15 17:21:20 +02:00
|
|
|
<x-button
|
|
|
|
v-if="migratorsEnabled"
|
|
|
|
:to="{ name: 'migrate.start' }"
|
|
|
|
:shadow="false">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('home.list.import') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
2020-06-15 18:47:17 +02:00
|
|
|
</template>
|
2021-09-29 21:29:09 +02:00
|
|
|
<div v-if="listHistory.length > 0" class="is-max-width-desktop has-text-left mt-4">
|
2021-07-06 22:22:57 +02:00
|
|
|
<h3>{{ $t('home.lastViewed') }}</h3>
|
|
|
|
<div class="is-flex list-cards-wrapper-2-rows">
|
|
|
|
<list-card
|
|
|
|
v-for="(l, k) in listHistory"
|
|
|
|
:key="`l${k}`"
|
|
|
|
:list="l"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-13 14:32:35 +01:00
|
|
|
<ShowTasks class="mt-4" :show-all="true" v-if="hasLists" :key="showTasksKey"/>
|
2018-09-06 19:46:38 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-11-30 21:06:15 +01:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import {ref, computed} from 'vue'
|
|
|
|
import {useStore} from 'vuex'
|
|
|
|
import {useNow} from '@vueuse/core'
|
|
|
|
|
|
|
|
import Message from '@/components/misc/message.vue'
|
|
|
|
import ShowTasks from '@/views/tasks/ShowTasks.vue'
|
2021-07-25 15:27:15 +02:00
|
|
|
import ListCard from '@/components/list/partials/list-card.vue'
|
2021-11-30 21:06:15 +01: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'
|
|
|
|
|
|
|
|
const now = useNow()
|
|
|
|
const welcome = computed(() => {
|
|
|
|
const hours = new Date(now.value).getHours()
|
|
|
|
|
|
|
|
if (hours < 5) {
|
|
|
|
return 'Night'
|
|
|
|
}
|
2018-09-06 19:46:38 +02:00
|
|
|
|
2021-11-30 21:06:15 +01:00
|
|
|
if (hours < 11) {
|
|
|
|
return 'Morning'
|
|
|
|
}
|
2021-07-06 17:13:13 +02:00
|
|
|
|
2021-11-30 21:06:15 +01:00
|
|
|
if (hours < 18) {
|
|
|
|
return 'Day'
|
|
|
|
}
|
2021-01-17 20:53:09 +01:00
|
|
|
|
2021-11-30 21:06:15 +01:00
|
|
|
if (hours < 23) {
|
|
|
|
return 'Evening'
|
|
|
|
}
|
2021-07-06 17:13:13 +02:00
|
|
|
|
2021-11-30 21:06:15 +01:00
|
|
|
return 'Night'
|
|
|
|
})
|
2021-01-17 20:53:09 +01:00
|
|
|
|
2021-11-30 21:06:15 +01:00
|
|
|
const store = useStore()
|
|
|
|
const listHistory = computed(() => {
|
|
|
|
const history = getHistory()
|
|
|
|
return history.map(l => {
|
|
|
|
return store.getters['lists/getListById'](l.id)
|
|
|
|
}).filter(l => l !== null)
|
|
|
|
})
|
2021-07-06 17:13:13 +02:00
|
|
|
|
|
|
|
|
2021-11-30 21:06:15 +01:00
|
|
|
const migratorsEnabled = computed(() => store.state.config.availableMigrators?.length > 0)
|
|
|
|
const userInfo = computed(() => store.state.auth.info)
|
|
|
|
const hasTasks = computed(() => store.state.hasTasks)
|
|
|
|
const defaultListId = computed(() => store.state.auth.defaultListId)
|
2021-12-04 14:56:25 +01:00
|
|
|
const defaultNamespaceId = computed(() => store.state.namespaces.namespaces?.[0]?.id || 0)
|
|
|
|
const hasLists = computed (() => store.state.namespaces.namespaces?.[0]?.lists.length > 0)
|
2021-11-30 21:06:15 +01:00
|
|
|
const loading = computed(() => store.state.loading && store.state.loadingModule === 'tasks')
|
|
|
|
const deletionScheduledAt = computed(() => parseDateOrNull(store.state.auth.info?.deletionScheduledAt))
|
2021-07-06 17:13:13 +02:00
|
|
|
|
2021-11-30 21:06:15 +01:00
|
|
|
// This is to reload the tasks list after adding a new task through the global task add.
|
|
|
|
// FIXME: Should use vuex (somehow?)
|
|
|
|
const showTasksKey = ref(0)
|
|
|
|
function updateTaskList() {
|
|
|
|
showTasksKey.value++
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2018-09-06 19:46:38 +02:00
|
|
|
</script>
|
2021-10-18 14:21:02 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.list-cards-wrapper-2-rows {
|
|
|
|
flex-wrap: wrap;
|
|
|
|
max-height: calc(#{$list-height * 2} + #{$list-spacing * 2} - 4px);
|
|
|
|
overflow: hidden;
|
2021-11-28 15:18:27 +01:00
|
|
|
|
2021-10-18 14:21:02 +02:00
|
|
|
@media screen and (max-width: $mobile) {
|
|
|
|
max-height: calc(#{$list-height * 4} + #{$list-spacing * 4} - 4px);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|