feat: add modelTypes

This commit is contained in:
Dominik Pschenitschni 2022-08-04 20:57:43 +02:00
parent 8416b1f448
commit 7d4ba6249e
No known key found for this signature in database
GPG key ID: B257AC0149F43A77
91 changed files with 751 additions and 513 deletions

View file

@ -52,7 +52,7 @@ import {computed, onMounted, onUnmounted, ref} from 'vue'
import NotificationService from '@/services/notification'
import BaseButton from '@/components/base/BaseButton.vue'
import User from '@/components/misc/user.vue'
import { NOTIFICATION_NAMES as names, type INotification} from '@/models/notification'
import { NOTIFICATION_NAMES as names, type INotification} from '@/modelTypes/INotification'
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
import {useStore} from '@/store'
import {useRouter} from 'vue-router'

View file

@ -49,7 +49,7 @@
/>
</i18n-t>
<span>
{{ a.file.getHumanSize() }}
{{ getHumanSize(a.file.size) }}
</span>
<span v-if="a.file.mime">
{{ a.file.mime }}
@ -157,6 +157,7 @@ import {formatDate, formatDateSince, formatDateLong} from '@/helpers/time/format
import BaseButton from '@/components/base/BaseButton'
import type { IFile } from '@/models/file'
import { getHumanSize } from '@/helpers/getHumanSize'
export default defineComponent({
name: 'attachments',
@ -231,6 +232,7 @@ export default defineComponent({
})
},
methods: {
getHumanSize,
formatDate,
formatDateSince,
formatDateLong,

View file

@ -144,7 +144,8 @@ import {defineComponent} from 'vue'
import TaskService from '../../../services/task'
import TaskModel from '../../../models/task'
import TaskRelationService from '../../../services/taskRelation'
import TaskRelationModel, {RELATION_KINDS} from '@/models/taskRelation'
import TaskRelationModel from '@/models/taskRelation'
import { RELATION_KIND, RELATION_KINDS } from '@/types/IRelationKind'
import BaseButton from '@/components/base/BaseButton.vue'
import Multiselect from '@/components/input/multiselect.vue'
@ -158,7 +159,7 @@ export default defineComponent({
foundTasks: [],
relationKinds: RELATION_KINDS,
newTaskRelationTask: new TaskModel(),
newTaskRelationKind: 'related',
newTaskRelationKind: RELATION_KIND.RELATED,
taskRelationService: new TaskRelationService(),
showDeleteModal: false,
relationToDelete: {},

View file

@ -66,7 +66,10 @@ import {ref, reactive, watch, type PropType} from 'vue'
import {useI18n} from 'vue-i18n'
import {error} from '@/message'
import {TASK_REPEAT_MODES, type ITask, type RepeatAfter} from '@/models/task'
import {TASK_REPEAT_MODES} from '@/types/IRepeatMode'
import type {IRepeatAfter} from '@/types/IRepeatAfter'
import type {ITask} from '@/modelTypes/ITask'
const props = defineProps({
modelValue: {
@ -116,7 +119,7 @@ function updateData() {
emit('change')
}
function setRepeatAfter(amount: number, type: RepeatAfter['type']) {
function setRepeatAfter(amount: number, type: IRepeatAfter['type']) {
Object.assign(repeatAfter, { amount, type})
updateData()
}

View file

@ -1,4 +1,4 @@
export function colorIsDark(color) {
export function colorIsDark(color: string | undefined) {
if (typeof color === 'undefined') {
return true // Defaults to dark
}

View file

@ -0,0 +1,18 @@
const SIZES = [
'B',
'KB',
'MB',
'GB',
'TB',
] as const
export function getHumanSize(inputSize: number) {
let iterator = 0
let size = inputSize
while (size > 1024) {
size /= 1024
iterator++
}
return Number(Math.round(Number(size + 'e2')) + 'e-2') + ' ' + SIZES[iterator]
}

View file

@ -0,0 +1,43 @@
import { REPEAT_TYPES, type IRepeatAfter } from '@/types/IRepeatAfter'
import { nativeEnum, number, object, preprocess } from 'zod'
export const RepeatsSchema = preprocess(
(repeats: unknown) => {
// Parses the "repeat after x seconds" from the task into a usable js object inside the task.
if (typeof repeats !== 'number') {
return repeats
}
const repeatAfterHours = (repeats / 60) / 60
const repeatAfter : IRepeatAfter = {
type: 'hours',
amount: repeatAfterHours,
}
// if its dividable by 24, its something with days, otherwise hours
if (repeatAfterHours % 24 === 0) {
const repeatAfterDays = repeatAfterHours / 24
if (repeatAfterDays % 7 === 0) {
repeatAfter.type = 'weeks'
repeatAfter.amount = repeatAfterDays / 7
} else if (repeatAfterDays % 30 === 0) {
repeatAfter.type = 'months'
repeatAfter.amount = repeatAfterDays / 30
} else if (repeatAfterDays % 365 === 0) {
repeatAfter.type = 'years'
repeatAfter.amount = repeatAfterDays / 365
} else {
repeatAfter.type = 'days'
repeatAfter.amount = repeatAfterDays
}
}
return repeatAfter
},
object({
type: nativeEnum(REPEAT_TYPES),
amount: number().int(),
}),
)

View file

@ -0,0 +1,5 @@
import type {Right} from '@/constants/rights'
export interface IAbstract {
maxRight: Right | null // FIXME: should this be readonly?
}

View file

@ -0,0 +1,11 @@
import type {IAbstract} from './IAbstract'
import type {IFile} from './IFile'
import type {IUser} from './IUser'
export interface IAttachment extends IAbstract {
id: number
taskId: number
createdBy: IUser
file: IFile
created: Date
}

View file

@ -0,0 +1,7 @@
import type {IAbstract} from './IAbstract'
export type AvatarProvider = 'default' | 'initials' | 'gravatar' | 'marble' | 'upload'
export interface IAvatar extends IAbstract {
avatarProvider: AvatarProvider
}

View file

@ -0,0 +1,12 @@
import type {IAbstract} from './IAbstract'
export interface IBackgroundImage extends IAbstract {
id: number
url: string
thumb: string
info: {
author: string
authorName: string
}
blurHash: string
}

17
src/modelTypes/IBucket.ts Normal file
View file

@ -0,0 +1,17 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ITask} from './ITask'
export interface IBucket extends IAbstract {
id: number
title: string
listId: number
limit: number
tasks: ITask[]
isDoneBucket: boolean
position: number
createdBy: IUser
created: Date
updated: Date
}

View file

@ -0,0 +1,7 @@
import type {IAbstract} from './IAbstract'
export interface ICaldavToken extends IAbstract {
id: number;
created: Date;
}

View file

@ -0,0 +1,6 @@
import type {IAbstract} from './IAbstract'
export interface IEmailUpdate extends IAbstract {
newEmail: string
password: string
}

10
src/modelTypes/IFile.ts Normal file
View file

@ -0,0 +1,10 @@
import type {IAbstract} from './IAbstract'
export interface IFile extends IAbstract {
id: number
mime: string
name: string
size: number
created: Date
}

15
src/modelTypes/ILabel.ts Normal file
View file

@ -0,0 +1,15 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
export interface ILabel extends IAbstract {
id: number
title: string
hexColor: string
description: string
createdBy: IUser
listId: number
textColor: string
created: Date
updated: Date
}

View file

@ -0,0 +1,7 @@
import type {IAbstract} from './IAbstract'
export interface ILabelTask extends IAbstract {
id: number
taskId: number
labelId: number
}

View file

@ -0,0 +1,17 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type { Right } from '@/constants/rights'
export interface ILinkShare extends IAbstract {
id: number
hash: string
right: Right
sharedBy: IUser
sharingType: number // FIXME: use correct numbers
listId: number
name: string
password: string
created: Date
updated: Date
}

26
src/modelTypes/IList.ts Normal file
View file

@ -0,0 +1,26 @@
import type {IAbstract} from './IAbstract'
import type {ITask} from './ITask'
import type {IUser} from './IUser'
import type {ISubscription} from './ISubscription'
import type {INamespace} from './INamespace'
export interface IList extends IAbstract {
id: number
title: string
description: string
owner: IUser
tasks: ITask[]
namespaceId: INamespace['id']
isArchived: boolean
hexColor: string
identifier: string
backgroundInformation: any // FIXME: improve type
isFavorite: boolean
subscription: ISubscription
position: number
backgroundBlurHash: string
created: Date
updated: Date
}

View file

@ -0,0 +1,9 @@
import type {IAbstract} from './IAbstract'
import type {IList} from './IList'
import type {INamespace} from './INamespace'
export interface IListDuplicate extends IAbstract {
listId: number
namespaceId: INamespace['id']
list: IList
}

View file

@ -0,0 +1,18 @@
import type {IAbstract} from './IAbstract'
import type {IList} from './IList'
import type {IUser} from './IUser'
import type {ISubscription} from './ISubscription'
export interface INamespace extends IAbstract {
id: number
title: string
description: string
owner: IUser
lists: IList[]
isArchived: boolean
hexColor: string
subscription: ISubscription
created: Date
updated: Date
}

View file

@ -0,0 +1,51 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ITask} from './ITask'
import type {ITaskComment} from './ITaskComment'
import type {ITeam} from './ITeam'
import type { IList } from './IList'
export const NOTIFICATION_NAMES = {
'TASK_COMMENT': 'task.comment',
'TASK_ASSIGNED': 'task.assigned',
'TASK_DELETED': 'task.deleted',
'LIST_CREATED': 'list.created',
'TEAM_MEMBER_ADDED': 'team.member.added',
} as const
interface Notification {
doer: IUser
}
interface NotificationTask extends Notification {
task: ITask
comment: ITaskComment
}
interface NotificationAssigned extends Notification {
task: ITask
assignee: IUser
}
interface NotificationDeleted extends Notification {
task: ITask
}
interface NotificationCreated extends Notification {
task: ITask
list: IList
}
interface NotificationMemberAdded extends Notification {
member: IUser
team: ITeam
}
export interface INotification extends IAbstract {
id: number
name: string
notification: NotificationTask | NotificationAssigned | NotificationDeleted | NotificationCreated | NotificationMemberAdded
read: boolean
readAt: Date | null
created: Date
}

View file

@ -0,0 +1,7 @@
import type {IAbstract} from './IAbstract'
export interface IPasswordReset extends IAbstract {
token: string
newPassword: string
email: string
}

View file

@ -0,0 +1,6 @@
import type {IAbstract} from './IAbstract'
export interface IPasswordUpdate extends IAbstract {
newPassword: string
oldPassword: string
}

View file

@ -0,0 +1,14 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {IFilter} from '@/types/IFilter'
export interface ISavedFilter extends IAbstract {
id: number
title: string
description: string
filters: IFilter
owner: IUser
created: Date
updated: Date
}

View file

@ -0,0 +1,11 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
export interface ISubscription extends IAbstract {
id: number
entity: string // FIXME: correct type?
entityId: number // FIXME: correct type?
user: IUser
created: Date
}

50
src/modelTypes/ITask.ts Normal file
View file

@ -0,0 +1,50 @@
import type { Priority } from '@/constants/priorities'
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ILabel} from './ILabel'
import type {IAttachment} from './IAttachment'
import type {ISubscription} from './ISubscription'
import type {IList} from './IList'
import type {IBucket} from './IBucket'
import type {IRelationKind} from '@/types/IRelationKind'
import type {IRepeatAfter} from '@/types/IRepeatAfter'
import type {IRepeatMode} from '@/types/IRepeatMode'
export interface ITask extends IAbstract {
id: number
title: string
description: string
done: boolean
doneAt: Date | null
priority: Priority
labels: ILabel[]
assignees: IUser[]
dueDate: Date | null
startDate: Date | null
endDate: Date | null
repeatAfter: number | IRepeatAfter
repeatFromCurrentDate: boolean
repeatMode: IRepeatMode
reminderDates: Date[]
parentTaskId: ITask['id']
hexColor: string
percentDone: number
relatedTasks: Partial<Record<IRelationKind, ITask>>,
attachments: IAttachment[]
identifier: string
index: number
isFavorite: boolean
subscription: ISubscription
position: number
kanbanPosition: number
createdBy: IUser
created: Date
updated: Date
listId: IList['id'] // Meta, only used when creating a new task
bucketId: IBucket['id']
}

View file

@ -0,0 +1,9 @@
import type {IAbstract} from './IAbstract'
import type {ITask} from './ITask'
import type {IUser} from './IUser'
export interface ITaskAssignee extends IAbstract {
created: Date
userId: IUser['id']
taskId: ITask['id']
}

View file

@ -0,0 +1,13 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ITask} from './ITask'
export interface ITaskComment extends IAbstract {
id: number
taskId: ITask['id']
comment: string
author: IUser
created: Date
updated: Date
}

View file

@ -0,0 +1,15 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ITask} from './ITask'
import type {IRelationKind} from '@/types/IRelationKind'
export interface ITaskRelation extends IAbstract {
id: number
otherTaskId: ITask['id']
taskId: ITask['id']
relationKind: IRelationKind
createdBy: IUser
created: Date
}

16
src/modelTypes/ITeam.ts Normal file
View file

@ -0,0 +1,16 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ITeamMember} from './ITeamMember'
import type {Right} from '@/constants/rights'
export interface ITeam extends IAbstract {
id: number
name: string
description: string
members: ITeamMember[]
right: Right
createdBy: IUser
created: Date
updated: Date
}

View file

@ -0,0 +1,6 @@
import type {ITeamShareBase} from './ITeamShareBase'
import type {IList} from './IList'
export interface ITeamList extends ITeamShareBase {
listId: IList['id']
}

View file

@ -0,0 +1,7 @@
import type {IUser} from './IUser'
import type {IList} from './IList'
export interface ITeamMember extends IUser {
admin: boolean
teamId: IList['id']
}

View file

@ -0,0 +1,6 @@
import type {ITeamShareBase} from './ITeamShareBase'
import type {INamespace} from './INamespace'
export interface ITeamNamespace extends ITeamShareBase {
namespaceId: INamespace['id']
}

View file

@ -0,0 +1,11 @@
import type {IAbstract} from './IAbstract'
import type {ITeam} from './ITeam'
import type {Right} from '@/constants/rights'
export interface ITeamShareBase extends IAbstract {
teamId: ITeam['id']
right: Right
created: Date
updated: Date
}

7
src/modelTypes/ITotp.ts Normal file
View file

@ -0,0 +1,7 @@
import type {IAbstract} from './IAbstract'
export interface ITotp extends IAbstract {
secret: string
enabled: boolean
url: string
}

13
src/modelTypes/IUser.ts Normal file
View file

@ -0,0 +1,13 @@
import type {IAbstract} from './IAbstract'
import type {IUserSettings} from './IUserSettings'
export interface IUser extends IAbstract {
id: number
email: string
username: string
name: string
created: Date
updated: Date
settings: IUserSettings
}

View file

@ -0,0 +1,6 @@
import type {IUserShareBase} from './IUserShareBase'
import type {IList} from './IList'
export interface IUserList extends IUserShareBase {
listId: IList['id']
}

View file

@ -0,0 +1,6 @@
import type {IUserShareBase} from './IUserShareBase'
import type {INamespace} from './INamespace'
export interface IUserNamespace extends IUserShareBase {
namespaceId: INamespace['id']
}

View file

@ -0,0 +1,14 @@
import type {IAbstract} from './IAbstract'
import type {IList} from './IList'
export interface IUserSettings extends IAbstract {
name: string
emailRemindersEnabled: boolean
discoverableByName: boolean
discoverableByEmail: boolean
overdueTasksRemindersEnabled: boolean
defaultListId: undefined | IList['id']
weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6
timezone: string
}

View file

@ -0,0 +1,11 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {Right} from '@/constants/rights'
export interface IUserShareBase extends IAbstract {
userId: IUser['id']
right: Right
created: Date
updated: Date
}

View file

@ -1,13 +1,11 @@
import {objectToCamelCase} from '@/helpers/case'
import {omitBy, isNil} from '@/helpers/utils'
import type {Right} from '@/constants/rights'
export interface IAbstract {
maxRight: Right | null // FIXME: should this be readonly?
}
import type {IAbstract} from '@/modelTypes/IAbstract'
export default abstract class AbstractModel<Model extends IAbstract = IAbstract> implements IAbstract {
/**
* The max right the user has on this object, as returned by the x-max-right header from the api.
*/

View file

@ -1,14 +1,9 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import UserModel, {type IUser} from './user'
import FileModel, {type IFile} from './file'
export interface IAttachment extends IAbstract {
id: number
taskId: number
createdBy: IUser
file: IFile
created: Date
}
import AbstractModel from './abstractModel'
import UserModel from './user'
import FileModel from './file'
import type { IUser } from '@/modelTypes/IUser'
import type { IFile } from '@/modelTypes/IFile'
import type { IAttachment } from '@/modelTypes/IAttachment'
export default class AttachmentModel extends AbstractModel implements IAttachment {
id = 0

View file

@ -1,13 +1,8 @@
import AbstractModel, { type IAbstract } from './abstractModel'
export type AvatarProvider = 'default' | 'initials' | 'gravatar' | 'marble' | 'upload'
export interface IAvatar extends IAbstract {
avatarProvider: AvatarProvider
}
import AbstractModel from './abstractModel'
import type { IAvatar } from '@/modelTypes/IAvatar'
export default class AvatarModel extends AbstractModel implements IAvatar {
avatarProvider: AvatarProvider = 'default'
avatarProvider: IAvatar['avatarProvider'] = 'default'
constructor(data: Partial<IAvatar>) {
super()

View file

@ -1,15 +1,5 @@
import AbstractModel, { type IAbstract } from './abstractModel'
export interface IBackgroundImage extends IAbstract {
id: number
url: string
thumb: string
info: {
author: string
authorName: string
}
blurHash: string
}
import AbstractModel from './abstractModel'
import type {IBackgroundImage} from '@/modelTypes/IBackgroundImage'
export default class BackgroundImageModel extends AbstractModel implements IBackgroundImage {
id = 0

View file

@ -1,20 +1,10 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import UserModel, { type IUser } from './user'
import TaskModel, { type ITask } from './task'
import AbstractModel from './abstractModel'
import UserModel from './user'
import TaskModel from './task'
export interface IBucket extends IAbstract {
id: number
title: string
listId: number
limit: number
tasks: ITask[]
isDoneBucket: boolean
position: number
createdBy: IUser
created: Date
updated: Date
}
import type {IBucket} from '@/modelTypes/IBucket'
import type {ITask} from '@/modelTypes/ITask'
import type {IUser} from '@/modelTypes/IUser'
export default class BucketModel extends AbstractModel implements IBucket {
id = 0

View file

@ -1,15 +1,12 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import AbstractModel from './abstractModel'
export interface ICaldavToken extends IAbstract {
id: number;
created: Date;
}
import type {ICaldavToken} from '@/modelTypes/ICaldavToken'
export default class CaldavTokenModel extends AbstractModel implements ICaldavToken {
id: number
created: Date
constructor(data? : Partial<CaldavTokenModel>) {
constructor(data: Partial<CaldavTokenModel>) {
super()
this.assignData(data)

View file

@ -1,9 +1,6 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import AbstractModel from './abstractModel'
interface IEmailUpdate extends IAbstract {
newEmail: string
password: string
}
import type {IEmailUpdate} from '@/modelTypes/IEmailUpdate'
export default class EmailUpdateModel extends AbstractModel implements IEmailUpdate {
newEmail = ''

View file

@ -1,12 +1,5 @@
import AbstractModel, { type IAbstract } from './abstractModel'
export interface IFile extends IAbstract {
id: number
mime: string
name: string
size: number
created: Date
}
import AbstractModel from './abstractModel'
import type {IFile} from '@/modelTypes/IFile'
export default class FileModel extends AbstractModel implements IFile {
id = 0
@ -21,23 +14,4 @@ export default class FileModel extends AbstractModel implements IFile {
this.created = new Date(this.created)
}
getHumanSize() {
const sizes = {
0: 'B',
1: 'KB',
2: 'MB',
3: 'GB',
4: 'TB',
}
let it = 0
let size = this.size
while (size > 1024) {
size /= 1024
it++
}
return Number(Math.round(size + 'e2') + 'e-2') + ' ' + sizes[it]
}
}

View file

@ -1,22 +1,13 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import UserModel, { type IUser } from './user'
import AbstractModel from './abstractModel'
import UserModel from './user'
import type {ILabel} from '@/modelTypes/ILabel'
import type {IUser} from '@/modelTypes/IUser'
import {colorIsDark} from '@/helpers/color/colorIsDark'
const DEFAULT_LABEL_BACKGROUND_COLOR = 'e8e8e8'
export interface ILabel extends IAbstract {
id: number
title: string
hexColor: string
description: string
createdBy: IUser
listId: number
textColor: string
created: Date
updated: Date
}
export default class LabelModel extends AbstractModel implements ILabel {
id = 0
title = ''

View file

@ -1,10 +1,6 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import AbstractModel from './abstractModel'
export interface ILabelTask extends IAbstract {
id: number
taskId: number
labelId: number
}
import type { ILabelTask } from '@/modelTypes/ILabelTask'
export default class LabelTask extends AbstractModel implements ILabelTask {
id = 0

View file

@ -1,19 +1,9 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import UserModel, { type IUser } from './user'
import {RIGHTS, type Right} from '@/constants/rights'
import AbstractModel from './abstractModel'
import UserModel from './user'
export interface ILinkShare extends IAbstract {
id: number
hash: string
right: Right
sharedBy: IUser
sharingType: number // FIXME: use correct numbers
listId: number
name: string
password: string
created: Date
updated: Date
}
import {RIGHTS, type Right} from '@/constants/rights'
import type {ILinkShare} from '@/modelTypes/ILinkShare'
import type {IUser} from '@/modelTypes/IUser'
export default class LinkShareModel extends AbstractModel implements ILinkShare {
id = 0

View file

@ -1,31 +1,16 @@
import AbstractModel, { type IAbstract } from '@/models/abstractModel'
import TaskModel, { type ITask } from '@/models/task'
import UserModel, { type IUser } from '@/models/user'
import SubscriptionModel, { type ISubscription } from '@/models/subscription'
import type { INamespace } from '@/models/namespace'
import AbstractModel from './abstractModel'
import TaskModel from '@/models/task'
import UserModel from '@/models/user'
import SubscriptionModel from '@/models/subscription'
import type {IList} from '@/modelTypes/IList'
import type {IUser} from '@/modelTypes/IUser'
import type {ITask} from '@/modelTypes/ITask'
import type {INamespace} from '@/modelTypes/INamespace'
import type {ISubscription} from '@/modelTypes/ISubscription'
import {getSavedFilterIdFromListId} from '@/helpers/savedFilter'
export interface IList extends IAbstract {
id: number
title: string
description: string
owner: IUser
tasks: ITask[]
namespaceId: INamespace['id']
isArchived: boolean
hexColor: string
identifier: string
backgroundInformation: any // FIXME: improve type
isFavorite: boolean
subscription: ISubscription
position: number
backgroundBlurHash: string
created: Date
updated: Date
}
export default class ListModel extends AbstractModel implements IList {
id = 0
title = ''

View file

@ -1,12 +1,9 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import ListModel, { type IList } from './list'
import type { INamespace } from './namespace'
import AbstractModel from './abstractModel'
import ListModel from './list'
export interface IListDuplicate extends IAbstract {
listId: number
namespaceId: INamespace['id']
list: IList
}
import type {IListDuplicate} from '@/modelTypes/IListDuplicate'
import type {INamespace} from '@/modelTypes/INamespace'
import type {IList} from '@/modelTypes/IList'
export default class ListDuplicateModel extends AbstractModel implements IListDuplicate {
listId = 0

View file

@ -1,21 +1,12 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import ListModel, { type IList } from './list'
import UserModel, { type IUser } from './user'
import SubscriptionModel, { type ISubscription } from '@/models/subscription'
import AbstractModel from './abstractModel'
import ListModel from './list'
import UserModel from './user'
import SubscriptionModel from '@/models/subscription'
export interface INamespace extends IAbstract {
id: number
title: string
description: string
owner: IUser
lists: IList[]
isArchived: boolean
hexColor: string
subscription: ISubscription
created: Date
updated: Date
}
import type {INamespace} from '@/modelTypes/INamespace'
import type {IUser} from '@/modelTypes/IUser'
import type {IList} from '@/modelTypes/IList'
import type {ISubscription} from '@/modelTypes/ISubscription'
export default class NamespaceModel extends AbstractModel implements INamespace {
id = 0

View file

@ -1,60 +1,17 @@
import AbstractModel, { type IAbstract } from '@/models/abstractModel'
import AbstractModel from './abstractModel'
import {parseDateOrNull} from '@/helpers/parseDateOrNull'
import UserModel, { type IUser } from '@/models/user'
import TaskModel, { type ITask } from '@/models/task'
import TaskCommentModel, { type ITaskComment } from '@/models/taskComment'
import ListModel, { type IList } from '@/models/list'
import TeamModel, { type ITeam } from '@/models/team'
import UserModel from '@/models/user'
import TaskModel from '@/models/task'
import TaskCommentModel from '@/models/taskComment'
import ListModel from '@/models/list'
import TeamModel from '@/models/team'
export const NOTIFICATION_NAMES = {
'TASK_COMMENT': 'task.comment',
'TASK_ASSIGNED': 'task.assigned',
'TASK_DELETED': 'task.deleted',
'LIST_CREATED': 'list.created',
'TEAM_MEMBER_ADDED': 'team.member.added',
} as const
interface Notification {
doer: IUser
}
interface NotificationTask extends Notification {
task: ITask
comment: ITaskComment
}
interface NotificationAssigned extends Notification {
task: ITask
assignee: IUser
}
interface NotificationDeleted extends Notification {
task: ITask
}
interface NotificationCreated extends Notification {
task: ITask
list: IList
}
interface NotificationMemberAdded extends Notification {
member: IUser
team: ITeam
}
export interface INotification extends IAbstract {
id: number
name: string
notification: NotificationTask | NotificationAssigned | NotificationDeleted | NotificationCreated | NotificationMemberAdded
read: boolean
readAt: Date | null
created: Date
}
import {NOTIFICATION_NAMES, type INotification} from '@/modelTypes/INotification'
export default class NotificationModel extends AbstractModel implements INotification {
id = 0
name = ''
notification: NotificationTask | NotificationAssigned | NotificationDeleted | NotificationCreated | NotificationMemberAdded = null
notification: INotification['notification'] = null
read = false
readAt: Date | null = null

View file

@ -1,10 +1,6 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import AbstractModel from './abstractModel'
export interface IPasswordReset extends IAbstract {
token: string
newPassword: string
email: string
}
import type {IPasswordReset} from '@/modelTypes/IPasswordReset'
export default class PasswordResetModel extends AbstractModel implements IPasswordReset {
token = ''

View file

@ -1,9 +1,6 @@
import AbstractModel, { type IAbstract } from '@/models/abstractModel'
import AbstractModel from './abstractModel'
export interface IPasswordUpdate extends IAbstract {
newPassword: string
oldPassword: string
}
import type {IPasswordUpdate} from '@/modelTypes/IPasswordUpdate'
export default class PasswordUpdateModel extends AbstractModel implements IPasswordUpdate {
newPassword = ''

View file

@ -1,38 +1,14 @@
import AbstractModel, { type IAbstract } from '@/models/abstractModel'
import UserModel, { type IUser } from '@/models/user'
import AbstractModel from './abstractModel'
import UserModel from '@/models/user'
export interface ISavedFilter extends IAbstract {
id: number
title: string
description: string
filters: {
sortBy: ('done' | 'id')[]
orderBy: ('asc' | 'desc')[]
filterBy: 'done'[]
filterValue: 'false'[]
filterComparator: 'equals'[]
filterConcat: 'and'
filterIncludeNulls: boolean
}
owner: IUser
created: Date
updated: Date
}
import type {ISavedFilter} from '@/modelTypes/ISavedFilter'
import type {IUser} from '@/modelTypes/IUser'
export default class SavedFilterModel extends AbstractModel implements ISavedFilter {
id = 0
title = ''
description = ''
filters: {
sortBy: ('done' | 'id')[]
orderBy: ('asc' | 'desc')[]
filterBy: 'done'[]
filterValue: 'false'[]
filterComparator: 'equals'[]
filterConcat: 'and'
filterIncludeNulls: boolean
} = {
filters: ISavedFilter['filters'] = {
sortBy: ['done', 'id'],
orderBy: ['asc', 'desc'],
filterBy: ['done'],

View file

@ -1,14 +1,8 @@
import AbstractModel, { type IAbstract } from '@/models/abstractModel'
import UserModel, { type IUser } from '@/models/user'
import AbstractModel from './abstractModel'
import UserModel from '@/models/user'
export interface ISubscription extends IAbstract {
id: number
entity: string // FIXME: correct type?
entityId: number // FIXME: correct type?
user: IUser
created: Date
}
import type {ISubscription} from '@/modelTypes/ISubscription'
import type {IUser} from '@/modelTypes/IUser'
export default class SubscriptionModel extends AbstractModel implements ISubscription {
id = 0

View file

@ -1,63 +1,35 @@
import { PRIORITIES, type Priority } from '@/constants/priorities'
import AbstractModel, { type IAbstract } from '@/models/abstractModel'
import UserModel, { type IUser } from '@/models/user'
import LabelModel, { type ILabel } from '@/models/label'
import AttachmentModel, {type IAttachment} from '@/models/attachment'
import SubscriptionModel, { type ISubscription } from '@/models/subscription'
import type { IList } from '@/models/list'
import type {IRepeats} from '@/types/IRepeats'
import type {ITask} from '@/modelTypes/ITask'
import type {ILabel} from '@/modelTypes/ILabel'
import type {IUser} from '@/modelTypes/IUser'
import type {IAttachment} from '@/modelTypes/IAttachment'
import type {IList} from '@/modelTypes/IList'
import type {ISubscription} from '@/modelTypes/ISubscription'
import type {IBucket} from '@/modelTypes/IBucket'
import type {IRepeatAfter} from '@/types/IRepeatAfter'
import {TASK_REPEAT_MODES, type IRepeatMode} from '@/types/IRepeatMode'
import {parseDateOrNull} from '@/helpers/parseDateOrNull'
import type { IBucket } from './bucket'
import type { IRelationKind } from '@/types/IRelationKind'
import AbstractModel from './abstractModel'
import LabelModel from './label'
import UserModel from './user'
import AttachmentModel from './attachment'
import SubscriptionModel from './subscription'
const SUPPORTS_TRIGGERED_NOTIFICATION = 'Notification' in window && 'showTrigger' in Notification.prototype
export const TASK_DEFAULT_COLOR = '#1973ff'
export const TASK_REPEAT_MODES = {
'REPEAT_MODE_DEFAULT': 0,
'REPEAT_MODE_MONTH': 1,
'REPEAT_MODE_FROM_CURRENT_DATE': 2,
} as const
export function getHexColor(hexColor: string) {
if (hexColor === '' || hexColor === '#') {
return TASK_DEFAULT_COLOR
}
export type TaskRepeatMode = typeof TASK_REPEAT_MODES[keyof typeof TASK_REPEAT_MODES]
export interface ITask extends IAbstract {
id: number
title: string
description: string
done: boolean
doneAt: Date | null
priority: Priority
labels: ILabel[]
assignees: IUser[]
dueDate: Date | null
startDate: Date | null
endDate: Date | null
repeatAfter: number | IRepeats
repeatFromCurrentDate: boolean
repeatMode: TaskRepeatMode
reminderDates: Date[]
parentTaskId: ITask['id']
hexColor: string
percentDone: number
relatedTasks: { [relationKind: string]: ITask } // FIXME: use relationKinds
attachments: IAttachment[]
identifier: string
index: number
isFavorite: boolean
subscription: ISubscription
position: number
kanbanPosition: number
createdBy: IUser
created: Date
updated: Date
listId: IList['id'] // Meta, only used when creating a new task
bucketId: IBucket['id']
return hexColor
}
export default class TaskModel extends AbstractModel implements ITask {
@ -73,14 +45,14 @@ export default class TaskModel extends AbstractModel implements ITask {
dueDate: Date | null = 0
startDate: Date | null = 0
endDate: Date | null = 0
repeatAfter: number | IRepeats = 0
repeatAfter: number | IRepeatAfter = 0
repeatFromCurrentDate = false
repeatMode: TaskRepeatMode = TASK_REPEAT_MODES.REPEAT_MODE_DEFAULT
repeatMode: IRepeatMode = TASK_REPEAT_MODES.REPEAT_MODE_DEFAULT
reminderDates: Date[] = []
parentTaskId: ITask['id'] = 0
hexColor = ''
percentDone = 0
relatedTasks: { [relationKind: string]: ITask } = {}
relatedTasks: Partial<Record<IRelationKind, ITask>> = {}
attachments: IAttachment[] = []
identifier = ''
index = 0
@ -168,11 +140,7 @@ export default class TaskModel extends AbstractModel implements ITask {
}
getHexColor() {
if (this.hexColor === '' || this.hexColor === '#') {
return TASK_DEFAULT_COLOR
}
return this.hexColor
return getHexColor(this.hexColor)
}
/////////////////

View file

@ -1,12 +1,8 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import type { ITask } from './task'
import type { IUser } from './user'
import AbstractModel from './abstractModel'
export interface ITaskAssignee extends IAbstract {
created: Date
userId: IUser['id']
taskId: ITask['id']
}
import type {ITaskAssignee} from '@/modelTypes/ITaskAssignee'
import type {IUser} from '@/modelTypes/IUser'
import type {ITask} from '@/modelTypes/ITask'
export default class TaskAssigneeModel extends AbstractModel implements ITaskAssignee {
created: Date = null

View file

@ -1,16 +1,9 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import UserModel, { type IUser } from './user'
import type { ITask } from './task'
import AbstractModel from './abstractModel'
import UserModel from './user'
export interface ITaskComment extends IAbstract {
id: number
taskId: ITask['id']
comment: string
author: IUser
created: Date
updated: Date
}
import type {ITaskComment} from '@/modelTypes/ITaskComment'
import type {ITask} from '@/modelTypes/ITask'
import type {IUser} from '@/modelTypes/IUser'
export default class TaskCommentModel extends AbstractModel implements ITaskComment {
id = 0

View file

@ -1,39 +1,16 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import UserModel, { type IUser } from './user'
import type { ITask } from './task'
import AbstractModel from './abstractModel'
import UserModel from './user'
export const RELATION_KIND = {
'SUBTASK': 'subtask',
'PARENTTASK': 'parenttask',
'RELATED': 'related',
'DUPLICATES': 'duplicates',
'BLOCKING': 'blocking',
'BLOCKED': 'blocked',
'PROCEDES': 'precedes',
'FOLLOWS': 'follows',
'COPIEDFROM': 'copiedfrom',
'COPIEDTO': 'copiedto',
} as const
export const RELATION_KINDS = [...Object.values(RELATION_KIND)] as const
export type RelationKind = typeof RELATION_KINDS[number]
export interface ITaskRelation extends IAbstract {
id: number
otherTaskId: ITask['id']
taskId: ITask['id']
relationKind: RelationKind
createdBy: IUser
created: Date
}
import type {ITaskRelation} from '@/modelTypes/ITaskRelation'
import type {ITask} from '@/modelTypes/ITask'
import type {IUser} from '@/modelTypes/IUser'
import type {IRelationKind} from '@/types/IRelationKind'
export default class TaskRelationModel extends AbstractModel implements ITaskRelation {
id = 0
otherTaskId: ITask['id'] = 0
taskId: ITask['id'] = 0
relationKind: RelationKind = ''
relationKind: IRelationKind = ''
createdBy: IUser = UserModel
created: Date = null

View file

@ -1,19 +1,11 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import UserModel, { type IUser } from './user'
import TeamMemberModel, { type ITeamMember } from './teamMember'
import AbstractModel from './abstractModel'
import UserModel from './user'
import TeamMemberModel from './teamMember'
import {RIGHTS, type Right} from '@/constants/rights'
export interface ITeam extends IAbstract {
id: number
name: string
description: string
members: ITeamMember[]
right: Right
createdBy: IUser
created: Date
updated: Date
}
import type {ITeam} from '@/modelTypes/ITeam'
import type {ITeamMember} from '@/modelTypes/ITeamMember'
import type {IUser} from '@/modelTypes/IUser'
export default class TeamModel extends AbstractModel implements ITeam {
id = 0

View file

@ -1,9 +1,7 @@
import TeamShareBaseModel from './teamShareBase'
import type { IList } from './list'
export interface ITeamList extends TeamShareBaseModel {
listId: IList['id']
}
import type {ITeamList} from '@/modelTypes/ITeamList'
import type {IList} from '@/modelTypes/IList'
export default class TeamListModel extends TeamShareBaseModel implements ITeamList {
listId: IList['id'] = 0

View file

@ -1,10 +1,7 @@
import UserModel from './user'
import type { IList } from './list'
export interface ITeamMember extends UserModel {
admin: boolean
teamId: IList['id']
}
import type {ITeamMember} from '@/modelTypes/ITeamMember'
import type {IList} from '@/modelTypes/IList'
export default class TeamMemberModel extends UserModel implements ITeamMember {
admin = false

View file

@ -1,9 +1,7 @@
import TeamShareBaseModel from './teamShareBase'
import type { INamespace } from './namespace'
export interface ITeamNamespace extends TeamShareBaseModel {
namespaceId: INamespace['id']
}
import type {ITeamNamespace} from '@/modelTypes/ITeamNamespace'
import type {INamespace} from '@/modelTypes/INamespace'
export default class TeamNamespaceModel extends TeamShareBaseModel implements ITeamNamespace {
namespaceId: INamespace['id'] = 0

View file

@ -1,14 +1,8 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import AbstractModel from './abstractModel'
import {RIGHTS, type Right} from '@/constants/rights'
import type { ITeam } from './team'
export interface ITeamShareBase extends IAbstract {
teamId: ITeam['id']
right: Right
created: Date
updated: Date
}
import type {ITeamShareBase} from '@/modelTypes/ITeamShareBase'
import type {ITeam} from '@/modelTypes/ITeam'
/**
* This class is a base class for common team sharing model.

View file

@ -1,10 +1,6 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import AbstractModel from './abstractModel'
export interface ITotp extends IAbstract {
secret: string
enabled: boolean
url: string
}
import type {ITotp} from '@/modelTypes/ITotp'
export default class TotpModel extends AbstractModel implements ITotp {
secret = ''

View file

@ -1,16 +1,8 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import UserSettingsModel, { type IUserSettings } from '@/models/userSettings'
import AbstractModel from './abstractModel'
import UserSettingsModel from '@/models/userSettings'
export interface IUser extends IAbstract {
id: number
email: string
username: string
name: string
created: Date
updated: Date
settings: IUserSettings
}
import type { IUser } from '@/modelTypes/IUser'
import type { IUserSettings } from '@/modelTypes/IUserSettings'
export default class UserModel extends AbstractModel implements IUser {
id = 0

View file

@ -1,9 +1,7 @@
import UserShareBaseModel from './userShareBase'
import type { IList } from './list'
export interface IUserList extends UserShareBaseModel {
listId: IList['id']
}
import type {IUserList} from '@/modelTypes/IUserList'
import type {IList} from '@/modelTypes/IList'
// This class extends the user share model with a 'rights' parameter which is used in sharing
export default class UserListModel extends UserShareBaseModel implements IUserList {

View file

@ -1,9 +1,7 @@
import UserShareBaseModel from './userShareBase'
import type { INamespace } from './namespace'
export interface IUserNamespace extends UserShareBaseModel {
namespaceId: INamespace['id']
}
import type {INamespace} from '@/modelTypes/INamespace'
import type {IUserNamespace} from '@/modelTypes/IUserNamespace'
// This class extends the user share model with a 'rights' parameter which is used in sharing
export default class UserNamespaceModel extends UserShareBaseModel implements IUserNamespace {

View file

@ -1,17 +1,8 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import type { IList } from './list'
import AbstractModel from './abstractModel'
export interface IUserSettings extends IAbstract {
name: string
emailRemindersEnabled: boolean
discoverableByName: boolean
discoverableByEmail: boolean
overdueTasksRemindersEnabled: boolean
defaultListId: undefined | IList['id']
weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6
timezone: string
}
import type {IUserSettings} from '@/modelTypes/IUserSettings'
import type {IList} from '@/modelTypes/IList'
export default class UserSettingsModel extends AbstractModel implements IUserSettings {
name = ''
@ -20,7 +11,7 @@ export default class UserSettingsModel extends AbstractModel implements IUserSet
discoverableByEmail = false
overdueTasksRemindersEnabled = true
defaultListId: undefined | IList['id'] = undefined
weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 0
weekStart: IUserSettings['weekStart'] = 0
timezone = ''
constructor(data: Partial<IUserSettings>) {

View file

@ -1,14 +1,8 @@
import AbstractModel, { type IAbstract } from './abstractModel'
import AbstractModel from './abstractModel'
import {RIGHTS, type Right} from '@/constants/rights'
import type { IUser } from './user'
export interface IUserShareBase extends IAbstract {
userId: IUser['id']
right: Right
created: Date
updated: Date
}
import type {IUserShareBase} from '@/modelTypes/IUserShareBase'
import type {IUser} from '@/modelTypes/IUser'
export default class UserShareBaseModel extends AbstractModel implements IUserShareBase {
userId: IUser['id'] = ''

View file

@ -1,6 +1,6 @@
import {parseDate} from '../helpers/time/parseDate'
import {PRIORITIES} from '@/constants/priorities'
import {REPEAT_TYPES, type IRepeats, type RepeatType} from '@/types/IRepeats'
import {REPEAT_TYPES, type IRepeatAfter, type IRepeatType} from '@/types/IRepeatAfter'
const VIKUNJA_PREFIXES: Prefixes = {
label: '*',
@ -30,7 +30,7 @@ export const PREFIXES = {
interface repeatParsedResult {
textWithoutMatched: string,
repeats: IRepeats | null,
repeats: IRepeatAfter | null,
}
export interface ParsedTaskText {
@ -40,7 +40,7 @@ export interface ParsedTaskText {
list: string | null,
priority: number | null,
assignees: string[],
repeats: IRepeats | null,
repeats: IRepeatAfter | null,
}
interface Prefixes {
@ -185,7 +185,7 @@ const getRepeats = (text: string): repeatParsedResult => {
default:
amount = results[3] ? parseInt(results[3]) : 1
}
let type: RepeatType = REPEAT_TYPES.Hours
let type: IRepeatType = REPEAT_TYPES.Hours
switch (results[0]) {
case 'biennially':

View file

@ -1,7 +1,6 @@
import type {InjectionKey} from 'vue'
import {createStore, useStore as baseUseStore, Store} from 'vuex'
import {getBlobFromBlurHash} from '../helpers/getBlobFromBlurHash'
import {
BACKGROUND,

View file

@ -2,7 +2,7 @@ import type { Module } from 'vuex'
import {findIndexById} from '@/helpers/utils'
import type { AttachmentState, RootStoreState } from '@/store/types'
import type { IAttachment } from '@/models/attachment'
import type { IAttachment } from '@/modelTypes/IAttachment'
const store : Module<AttachmentState, RootStoreState> = {
namespaced: true,

View file

@ -12,7 +12,7 @@ import {success} from '@/message'
import {redirectToProvider} from '@/helpers/redirectToProvider'
import type { RootStoreState, AuthState, Info} from '@/store/types'
import {AUTH_TYPES} from '@/store/types'
import type { IUserSettings } from '@/models/userSettings'
import type { IUserSettings } from '@/modelTypes/IUserSettings'
const defaultSettings = settings => {

View file

@ -9,9 +9,9 @@ import BucketService from '../../services/bucket'
import {setLoading} from '../helper'
import TaskCollectionService from '@/services/taskCollection'
import type { RootStoreState, KanbanState } from '@/store/types'
import type { ITask } from '@/models/task'
import type { IList } from '@/models/list'
import type { IBucket } from '@/models/bucket'
import type { ITask } from '@/modelTypes/ITask'
import type { IList } from '@/modelTypes/IList'
import type { IBucket } from '@/modelTypes/IBucket'
const TASKS_PER_BUCKET = 25

View file

@ -7,7 +7,7 @@ import {setLoading} from '@/store/helper'
import type { LabelState, RootStoreState } from '@/store/types'
import {getLabelsByIds, filterLabelsByQuery} from '@/helpers/labels'
import {createNewIndexer} from '@/indexes'
import type { ILabel } from '@/models/label'
import type { ILabel } from '@/modelTypes/ILabel'
const {add, remove, update} = createNewIndexer('labels', ['title', 'description'])

View file

@ -5,7 +5,7 @@ import {setLoading} from '@/store/helper'
import {removeListFromHistory} from '@/modules/listHistory'
import {createNewIndexer} from '@/indexes'
import type {ListState, RootStoreState} from '@/store/types'
import type {IList} from '@/models/list'
import type {IList} from '@/modelTypes/IList'
const {add, remove, search, update} = createNewIndexer('lists', ['title', 'description'])

View file

@ -4,8 +4,8 @@ import NamespaceService from '../../services/namespace'
import {setLoading} from '@/store/helper'
import {createNewIndexer} from '@/indexes'
import type {NamespaceState, RootStoreState} from '@/store/types'
import type {INamespace} from '@/models/namespace'
import type {IList} from '@/models/list'
import type {INamespace} from '@/modelTypes/INamespace'
import type {IList} from '@/modelTypes/IList'
const {add, remove, search, update} = createNewIndexer('namespaces', ['title', 'description'])

View file

@ -4,22 +4,27 @@ import {formatISO} from 'date-fns'
import TaskService from '@/services/task'
import TaskAssigneeService from '@/services/taskAssignee'
import TaskAssigneeModel from '@/models/taskAssignee'
import LabelTaskModel from '@/models/labelTask'
import LabelTaskService from '@/services/labelTask'
import UserService from '@/services/user'
import {HAS_TASKS} from '../mutation-types'
import {setLoading} from '../helper'
import {getQuickAddMagicMode} from '@/helpers/quickAddMagicMode'
import {parseTaskText} from '@/modules/parseTaskText'
import TaskModel, { type ITask } from '@/models/task'
import TaskAssigneeModel from '@/models/taskAssignee'
import LabelTaskModel from '@/models/labelTask'
import TaskModel from '@/models/task'
import LabelTask from '@/models/labelTask'
import LabelModel, { type ILabel } from '@/models/label'
import UserService from '@/services/user'
import LabelModel from '@/models/label'
import type {ILabel} from '@/modelTypes/ILabel'
import type {ITask} from '@/modelTypes/ITask'
import type { IUser } from '@/modelTypes/IUser'
import type { IAttachment } from '@/modelTypes/IAttachment'
import type { IList } from '@/modelTypes/IList'
import type { RootStoreState, TaskState } from '@/store/types'
import type { IUser } from '@/models/user'
import type { IAttachment } from '@/models/attachment'
import type { IList } from '@/models/list'
// IDEA: maybe use a small fuzzy search here to prevent errors
function findPropertyByValue(object, key, value) {

View file

@ -1,9 +1,9 @@
import type { IBucket } from '@/models/bucket'
import type { IUserSettings } from '@/models/userSettings'
import type { IList } from '@/models/list'
import type { IAttachment } from '@/models/attachment'
import type { ILabel } from '@/models/label'
import type { INamespace } from '@/models/namespace'
import type { IBucket } from '@/modelTypes/IBucket'
import type { IUserSettings } from '@/modelTypes/IUserSettings'
import type { IList } from '@/modelTypes/IList'
import type { IAttachment } from '@/modelTypes/IAttachment'
import type { ILabel } from '@/modelTypes/ILabel'
import type { INamespace } from '@/modelTypes/INamespace'
export interface RootStoreState {
loading: boolean,

9
src/types/IFilter.ts Normal file
View file

@ -0,0 +1,9 @@
export interface IFilter {
sortBy: ('done' | 'id')[]
orderBy: ('asc' | 'desc')[]
filterBy: 'done'[]
filterValue: 'false'[]
filterComparator: 'equals'[]
filterConcat: 'and'
filterIncludeNulls: boolean
}

View file

@ -0,0 +1,16 @@
export enum RELATION_KIND {
'SUBTASK' = 'subtask',
'PARENTTASK' = 'parenttask',
'RELATED' = 'related',
'DUPLICATES' = 'duplicates',
'BLOCKING' = 'blocking',
'BLOCKED' = 'blocked',
'PROCEDES' = 'precedes',
'FOLLOWS' = 'follows',
'COPIEDFROM' = 'copiedfrom',
'COPIEDTO' = 'copiedto',
}
export type IRelationKind = typeof RELATION_KIND[keyof typeof RELATION_KIND]
export const RELATION_KINDS = [...Object.values(RELATION_KIND)] as const

View file

@ -6,9 +6,9 @@ export const REPEAT_TYPES = {
Years: 'years',
} as const
export type RepeatType = typeof REPEAT_TYPES[keyof typeof REPEAT_TYPES]
export type IRepeatType = typeof REPEAT_TYPES[keyof typeof REPEAT_TYPES]
export interface IRepeats {
type: RepeatType,
export interface IRepeatAfter {
type: IRepeatType,
amount: number,
}

7
src/types/IRepeatMode.ts Normal file
View file

@ -0,0 +1,7 @@
export const TASK_REPEAT_MODES = {
'REPEAT_MODE_DEFAULT': 0,
'REPEAT_MODE_MONTH': 1,
'REPEAT_MODE_FROM_CURRENT_DATE': 2,
} as const
export type IRepeatMode = typeof TASK_REPEAT_MODES[keyof typeof TASK_REPEAT_MODES]

View file

@ -156,7 +156,7 @@ import {calculateItemPosition} from '../../helpers/calculateItemPosition'
import type { ITask } from '@/models/task'
function sortTasks(tasks: ITask[]) {
if (tasks === null || tasks === []) {
if (tasks === null || Array.isArray(tasks) && tasks.length === 0) {
return
}
return tasks.sort((a, b) => {

View file

@ -170,6 +170,7 @@ import {useStore} from '@/store'
import TeamService from '@/services/team'
import TeamMemberService from '@/services/teamMember'
import UserService from '@/services/user'
import {RIGHTS as Rights} from '@/constants/rights'
import Multiselect from '@/components/input/multiselect.vue'