feat: add modelTypes
This commit is contained in:
@ -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.
|
||||
*/
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 = ''
|
||||
|
@ -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]
|
||||
}
|
||||
}
|
||||
|
@ -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 = ''
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 = ''
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 = ''
|
||||
|
@ -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 = ''
|
||||
|
@ -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'],
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
/////////////////
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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 = ''
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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>) {
|
||||
|
@ -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'] = ''
|
||||
|
Reference in New Issue
Block a user