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>
<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 {useRoute, useRouter} from 'vue-router'
import {useEventListener} from '@vueuse/core'
@ -66,12 +66,12 @@ function useRouteWithModal() {
}
})
const currentModal = shallowRef(null)
const currentModal = shallowRef<VNode>()
watchEffect(() => {
const hasBackdropView = historyState.value.backdropView
if (!hasBackdropView) {
currentModal.value = null
currentModal.value = undefined
return
}

View File

@ -1,9 +1,9 @@
import { computed, watchEffect } from 'vue'
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)
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 === '')
? 'Vikunja'
: `${title} | Vikunja`

View File

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

View File

@ -2,6 +2,12 @@ import AbstractModel from '@/models/abstractModel'
import UserModel from '@/models/user'
export default class SubscriptionModel extends AbstractModel {
id = 0
entity = ''
entityId = 0
created = null
user = UserModel
constructor(data) {
super(data)
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
export default class TaskModel extends AbstractModel {
index = 0
done = false
priority = 0
percentDone = 0
defaultColor = '198CFF'
constructor(data) {

View File

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

View File

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

View File

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

View File

@ -180,7 +180,7 @@
</template>
<script setup lang="ts">
import { toRef, computed } from 'vue'
import { toRef, computed, Ref } from 'vue'
import { useRouter } from 'vue-router'
import { useStorage } from '@vueuse/core'
@ -198,6 +198,7 @@ import Pagination from '@/components/misc/pagination.vue'
import Popup from '@/components/misc/popup.vue'
import { useTaskList } from '@/composables/taskList'
import TaskModel from '@/models/task'
const ACTIVE_COLUMNS_DEFAULT = {
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',
}
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 {
tasks,
loading,
params,
totalPages,
currentPage,
} = useTaskList(toRef(props, 'listId'))
} = taskList
const tasks : Ref<TaskModel[]> = taskList.tasks
Object.assign(params.value, {
filter_by: [],
@ -244,7 +262,7 @@ Object.assign(params.value, {
})
// FIXME: by doing this we can have multiple sort orders
function sort(property) {
function sort(property : keyof SortBy) {
const order = sortBy.value[property]
if (typeof order === 'undefined' || order === 'none') {
sortBy.value[property] = 'desc'

View File

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