fix ts errors in various files

This commit is contained in:
Dominik Pschenitschni 2022-01-30 16:47:23 +01:00
parent 98b41a22c6
commit de3c47dc69
Signed by: dpschen
GPG Key ID: B257AC0149F43A77
11 changed files with 58 additions and 20 deletions

View File

@ -44,7 +44,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {watch, computed, shallowRef, watchEffect, h} from 'vue' import {watch, computed, shallowRef, watchEffect, VNode, h} from 'vue'
import {useStore} from 'vuex' import {useStore} from 'vuex'
import {useRoute, useRouter} from 'vue-router' import {useRoute, useRouter} from 'vue-router'
import {useEventListener} from '@vueuse/core' import {useEventListener} from '@vueuse/core'
@ -66,12 +66,12 @@ function useRouteWithModal() {
} }
}) })
const currentModal = shallowRef(null) const currentModal = shallowRef<VNode>()
watchEffect(() => { watchEffect(() => {
const hasBackdropView = historyState.value.backdropView const hasBackdropView = historyState.value.backdropView
if (!hasBackdropView) { if (!hasBackdropView) {
currentModal.value = null currentModal.value = undefined
return return
} }

View File

@ -1,9 +1,9 @@
import { computed, watchEffect } from 'vue' import { computed, watchEffect } from 'vue'
import { setTitle } from '@/helpers/setTitle' import { setTitle } from '@/helpers/setTitle'
import { ComputedGetter, ComputedRef } from '@vue/reactivity' import { ComputedGetter } from '@vue/reactivity'
export function useTitle<T>(titleGetter: ComputedGetter<T>) : ComputedRef<T> { export function useTitle(titleGetter: ComputedGetter<string>) {
const titleRef = computed(titleGetter) const titleRef = computed(titleGetter)
watchEffect(() => setTitle(titleRef.value)) watchEffect(() => setTitle(titleRef.value))

View File

@ -1,4 +1,4 @@
export function setTitle(title) { export function setTitle(title : undefined | string) {
document.title = (typeof title === 'undefined' || title === '') document.title = (typeof title === 'undefined' || title === '')
? 'Vikunja' ? 'Vikunja'
: `${title} | Vikunja` : `${title} | Vikunja`

View File

@ -3,6 +3,12 @@ import UserModel from './user'
import FileModel from './file' import FileModel from './file'
export default class AttachmentModel extends AbstractModel { export default class AttachmentModel extends AbstractModel {
id = 0
taskId = 0
file = FileModel
createdBy = UserModel
created = null
constructor(data) { constructor(data) {
super(data) super(data)
this.createdBy = new UserModel(this.createdBy) this.createdBy = new UserModel(this.createdBy)

View File

@ -2,6 +2,12 @@ import AbstractModel from '@/models/abstractModel'
import UserModel from '@/models/user' import UserModel from '@/models/user'
export default class SubscriptionModel extends AbstractModel { export default class SubscriptionModel extends AbstractModel {
id = 0
entity = ''
entityId = 0
created = null
user = UserModel
constructor(data) { constructor(data) {
super(data) super(data)
this.user = new UserModel(this.user) this.user = new UserModel(this.user)

View File

@ -10,7 +10,11 @@ import {parseDateOrNull} from '@/helpers/parseDateOrNull'
const SUPPORTS_TRIGGERED_NOTIFICATION = 'Notification' in window && 'showTrigger' in Notification.prototype const SUPPORTS_TRIGGERED_NOTIFICATION = 'Notification' in window && 'showTrigger' in Notification.prototype
export default class TaskModel extends AbstractModel { export default class TaskModel extends AbstractModel {
index = 0
done = false
priority = 0
percentDone = 0
defaultColor = '198CFF' defaultColor = '198CFF'
constructor(data) { constructor(data) {

View File

@ -243,7 +243,7 @@ const router = createRouter({
path: '/tasks/:id', path: '/tasks/:id',
name: 'task.detail', name: 'task.detail',
component: TaskDetailViewModal, component: TaskDetailViewModal,
props: route => ({ taskId: parseInt(route.params.id) }), props: route => ({ taskId: parseInt(route.params.id as string) }),
}, },
{ {
path: '/tasks/by/upcoming', path: '/tasks/by/upcoming',
@ -344,28 +344,28 @@ const router = createRouter({
name: 'list.list', name: 'list.list',
component: ListList, component: ListList,
beforeEnter: (to) => saveListView(to.params.listId, to.name), beforeEnter: (to) => saveListView(to.params.listId, to.name),
props: route => ({ listId: parseInt(route.params.listId) }), props: route => ({ listId: parseInt(route.params.listId as string) }),
}, },
{ {
path: '/lists/:listId/gantt', path: '/lists/:listId/gantt',
name: 'list.gantt', name: 'list.gantt',
component: ListGantt, component: ListGantt,
beforeEnter: (to) => saveListView(to.params.listId, to.name), beforeEnter: (to) => saveListView(to.params.listId, to.name),
props: route => ({ listId: parseInt(route.params.listId) }), props: route => ({ listId: parseInt(route.params.listId as string) }),
}, },
{ {
path: '/lists/:listId/table', path: '/lists/:listId/table',
name: 'list.table', name: 'list.table',
component: ListTable, component: ListTable,
beforeEnter: (to) => saveListView(to.params.listId, to.name), beforeEnter: (to) => saveListView(to.params.listId, to.name),
props: route => ({ listId: parseInt(route.params.listId) }), props: route => ({ listId: parseInt(route.params.listId as string) }),
}, },
{ {
path: '/lists/:listId/kanban', path: '/lists/:listId/kanban',
name: 'list.kanban', name: 'list.kanban',
component: ListKanban, component: ListKanban,
beforeEnter: (to) => saveListView(to.params.listId, to.name), beforeEnter: (to) => saveListView(to.params.listId, to.name),
props: route => ({ listId: parseInt(route.params.listId) }), props: route => ({ listId: parseInt(route.params.listId as string) }),
}, },
{ {
path: '/teams', path: '/teams',

View File

@ -18,6 +18,8 @@ import lists from './modules/lists'
import attachments from './modules/attachments' import attachments from './modules/attachments'
import labels from './modules/labels' import labels from './modules/labels'
import ListModel from '@/models/list'
import ListService from '../services/list' import ListService from '../services/list'
import {checkAndSetApiUrl} from '@/helpers/checkAndSetApiUrl' import {checkAndSetApiUrl} from '@/helpers/checkAndSetApiUrl'
@ -37,10 +39,10 @@ export const store = createStore({
loading: false, loading: false,
loadingModule: null, loadingModule: null,
// This is used to highlight the current list in menu for all list related views // This is used to highlight the current list in menu for all list related views
currentList: { currentList: new ListModel({
id: 0, id: 0,
isArchived: false, isArchived: false,
}, }),
background: '', background: '',
hasTasks: false, hasTasks: false,
menuActive: true, menuActive: true,

View File

@ -0,0 +1 @@
declare module 'vue-flatpickr-component';

View File

@ -180,7 +180,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { toRef, computed } from 'vue' import { toRef, computed, Ref } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useStorage } from '@vueuse/core' import { useStorage } from '@vueuse/core'
@ -198,6 +198,7 @@ import Pagination from '@/components/misc/pagination.vue'
import Popup from '@/components/misc/popup.vue' import Popup from '@/components/misc/popup.vue'
import { useTaskList } from '@/composables/taskList' import { useTaskList } from '@/composables/taskList'
import TaskModel from '@/models/task'
const ACTIVE_COLUMNS_DEFAULT = { const ACTIVE_COLUMNS_DEFAULT = {
id: true, id: true,
@ -222,20 +223,37 @@ const props = defineProps({
}, },
}) })
const SORT_BY_DEFAULT = { type Order = 'asc' | 'desc' | 'none'
interface SortBy {
id : Order
done? : Order
title? : Order
priority? : Order
due_date? : Order
start_date? : Order
end_date? : Order
percent_done? : Order
created? : Order
updated? : Order
}
const SORT_BY_DEFAULT : SortBy = {
id: 'desc', id: 'desc',
} }
const activeColumns = useStorage('tableViewColumns', { ...ACTIVE_COLUMNS_DEFAULT }) const activeColumns = useStorage('tableViewColumns', { ...ACTIVE_COLUMNS_DEFAULT })
const sortBy = useStorage('tableViewSortBy', { ...SORT_BY_DEFAULT }) const sortBy = useStorage<SortBy>('tableViewSortBy', { ...SORT_BY_DEFAULT })
const taskList = useTaskList(toRef(props, 'listId'))
const { const {
tasks,
loading, loading,
params, params,
totalPages, totalPages,
currentPage, currentPage,
} = useTaskList(toRef(props, 'listId')) } = taskList
const tasks : Ref<TaskModel[]> = taskList.tasks
Object.assign(params.value, { Object.assign(params.value, {
filter_by: [], filter_by: [],
@ -244,7 +262,7 @@ Object.assign(params.value, {
}) })
// FIXME: by doing this we can have multiple sort orders // FIXME: by doing this we can have multiple sort orders
function sort(property) { function sort(property : keyof SortBy) {
const order = sortBy.value[property] const order = sortBy.value[property]
if (typeof order === 'undefined' || order === 'none') { if (typeof order === 'undefined' || order === 'none') {
sortBy.value[property] = 'desc' sortBy.value[property] = 'desc'

View File

@ -83,6 +83,7 @@ const currentList = computed(() => {
id: 0, id: 0,
title: '', title: '',
isArchived: false, isArchived: false,
maxRight: null,
} : store.state.currentList } : store.state.currentList
}) })