wip: add modelTypes
This commit is contained in:
parent
c1f5f92fa1
commit
3ecd28ad1a
|
@ -92,7 +92,7 @@ import {useStore} from '@/store'
|
|||
import {useRouter} from 'vue-router'
|
||||
|
||||
import {QUICK_ACTIONS_ACTIVE} from '@/store/mutation-types'
|
||||
import {RIGHTS as Rights} from '@/models/constants/rights'
|
||||
import {RIGHTS as Rights} from '@/modelTypes/constants/rights'
|
||||
|
||||
import Update from '@/components/home/update.vue'
|
||||
import ListSettingsDropdown from '@/components/list/list-settings-dropdown.vue'
|
||||
|
|
|
@ -180,7 +180,7 @@ import {ref, watch, computed, shallowReactive} from 'vue'
|
|||
import {useStore} from '@/store'
|
||||
import {useI18n} from 'vue-i18n'
|
||||
|
||||
import {RIGHTS} from '@/models/constants/rights'
|
||||
import {RIGHTS} from '@/modelTypes/constants/rights'
|
||||
import LinkShareModel, { type ILinkShare } from '@/models/linkShare'
|
||||
|
||||
import LinkShareService from '@/services/linkShare'
|
||||
|
|
|
@ -160,7 +160,7 @@ import TeamListModel, { type ITeamList } from '@/models/teamList'
|
|||
import TeamService from '@/services/team'
|
||||
import TeamModel, { type ITeam } from '@/models/team'
|
||||
|
||||
import {RIGHTS} from '@/models/constants/rights'
|
||||
import {RIGHTS} from '@/modelTypes/constants/rights'
|
||||
import Multiselect from '@/components/input/multiselect.vue'
|
||||
import Nothing from '@/components/misc/nothing.vue'
|
||||
import {success} from '@/message'
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
import type {Right} from './constants/rights'
|
||||
|
||||
export interface IAbstract {
|
||||
maxRight: Right | null
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// import type {IAbstract} from './IAbstract'
|
||||
|
||||
export type AvatarProvider = 'default' | 'initials' | 'gravatar' | 'marble' | 'upload'
|
||||
|
||||
// export interface IAvatar /* extends IAbstract */ {
|
||||
export interface IAvatar {
|
||||
avatarProvider: AvatarProvider
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import type {IAbstract} from './IAbstract'
|
||||
|
||||
export interface ICaldavToken /* extends IAbstract */ {
|
||||
id: number;
|
||||
|
||||
created: Date;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import type {IAbstract} from './IAbstract'
|
||||
|
||||
export interface IEmailUpdate /* extends IAbstract */ {
|
||||
newEmail: string
|
||||
password: string
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import type {IAbstract} from './IAbstract'
|
||||
|
||||
export interface IFile /* extends IAbstract */ {
|
||||
id: number
|
||||
mime: string
|
||||
name: string
|
||||
size: number
|
||||
|
||||
created: Date
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import type {IAbstract} from './IAbstract'
|
||||
|
||||
export interface ILabelTask /* extends IAbstract */ {
|
||||
id: number
|
||||
taskId: number
|
||||
labelId: number
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
isFavorite: boolean
|
||||
subscription: ISubscription
|
||||
position: number
|
||||
backgroundBlurHash: string
|
||||
|
||||
created: Date
|
||||
updated: Date
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
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'
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import type {IAbstract} from './IAbstract'
|
||||
|
||||
export interface IPasswordReset /* extends IAbstract */ {
|
||||
token: string
|
||||
newPassword: string
|
||||
email: string
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import type {IAbstract} from './IAbstract'
|
||||
|
||||
export interface IPasswordUpdate /* extends IAbstract */ {
|
||||
newPassword: string
|
||||
oldPassword: string
|
||||
}
|
|
@ -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: 0
|
||||
title: string
|
||||
description: string
|
||||
filters: IFilter
|
||||
|
||||
owner: IUser
|
||||
created: Date
|
||||
updated: Date
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
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 {IRepeats} from '@/types/IRepeats'
|
||||
|
||||
export const TASK_REPEAT_MODES = {
|
||||
'REPEAT_MODE_DEFAULT': 0,
|
||||
'REPEAT_MODE_MONTH': 1,
|
||||
'REPEAT_MODE_FROM_CURRENT_DATE': 2,
|
||||
} as const
|
||||
|
||||
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']
|
||||
}
|
|
@ -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']
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import type {ITeamShareBase} from './ITeamShareBase'
|
||||
import type {IList} from './IList'
|
||||
|
||||
export interface ITeamList extends ITeamShareBase {
|
||||
listId: IList['id']
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import type {IUser} from './IUser'
|
||||
import type {IList} from './IList'
|
||||
|
||||
export interface ITeamMember extends IUser {
|
||||
admin: boolean
|
||||
teamId: IList['id']
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import type {ITeamShareBase} from './ITeamShareBase'
|
||||
import type {INamespace} from './INamespace'
|
||||
|
||||
export interface ITeamNamespace extends ITeamShareBase {
|
||||
namespaceId: INamespace['id']
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import type {IAbstract} from './IAbstract'
|
||||
|
||||
export interface ITotp /* extends IAbstract */ {
|
||||
secret: string
|
||||
enabled: boolean
|
||||
url: string
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import type {IUserShareBase} from './IUserShareBase'
|
||||
import type {IList} from './IList'
|
||||
|
||||
export interface IUserList extends IUserShareBase {
|
||||
listId: IList['id']
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import type {IUserShareBase} from './IUserShareBase'
|
||||
import type {INamespace} from './INamespace'
|
||||
|
||||
export interface IUserNamespace extends IUserShareBase {
|
||||
namespaceId: INamespace['id']
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -1,12 +1,9 @@
|
|||
import {objectToCamelCase} from '@/helpers/case'
|
||||
import {omitBy, isNil} from '@/helpers/utils'
|
||||
import type {Right} from '@/models/constants/rights'
|
||||
import type {Right} from '@/modelTypes/constants/rights'
|
||||
import type {IAbstract} from '@/modelTypes/IAbstract'
|
||||
|
||||
export interface IAbstract {
|
||||
maxRight: Right | null
|
||||
}
|
||||
|
||||
export default class AbstractModel implements IAbstract {
|
||||
export default class AbstractModel<Model extends IAbstract = IAbstract> {
|
||||
|
||||
/**
|
||||
* The max right the user has on this object, as returned by the x-max-right header from the api.
|
||||
|
@ -19,18 +16,25 @@ export default class AbstractModel implements IAbstract {
|
|||
constructor(data : Object = {}) {
|
||||
data = objectToCamelCase(data)
|
||||
|
||||
console.log('AbstractModel:')
|
||||
console.log(this.title)
|
||||
console.log(this.defaults().title)
|
||||
console.log(data.title)
|
||||
console.log(omitBy(data, isNil).title)
|
||||
|
||||
// Put all data in our model while overriding those with a value of null or undefined with their defaults
|
||||
Object.assign(
|
||||
this,
|
||||
this.defaults(),
|
||||
omitBy(data, isNil),
|
||||
)
|
||||
console.log(this.title)
|
||||
}
|
||||
|
||||
/**
|
||||
* Default attributes that define the "empty" state.
|
||||
*/
|
||||
defaults(): Object {
|
||||
return {}
|
||||
defaults(): Model {
|
||||
return {} as Model
|
||||
}
|
||||
}
|
|
@ -1,14 +1,9 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import UserModel, {type IUser} from './user'
|
||||
import FileModel, {type IFile} from './file'
|
||||
|
||||
export interface IAttachment extends AbstractModel {
|
||||
id: number
|
||||
taskId: number
|
||||
createdBy: IUser
|
||||
file: IFile
|
||||
created: Date
|
||||
}
|
||||
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 {
|
||||
declare id: number
|
||||
|
@ -17,7 +12,7 @@ export default class AttachmentModel extends AbstractModel implements IAttachmen
|
|||
file: IFile
|
||||
created: Date
|
||||
|
||||
constructor(data) {
|
||||
constructor(data: Partial<IAttachment>) {
|
||||
super(data)
|
||||
this.createdBy = new UserModel(this.createdBy)
|
||||
this.file = new FileModel(this.file)
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
|
||||
export type AvatarProvider = 'default' | 'initials' | 'gravatar' | 'marble' | 'upload'
|
||||
|
||||
export interface IAvatar extends AbstractModel {
|
||||
avatarProvider: AvatarProvider
|
||||
}
|
||||
import type { IAvatar } from '@/modelTypes/IAvatar'
|
||||
|
||||
export default class AvatarModel extends AbstractModel implements IAvatar {
|
||||
declare avatarProvider: AvatarProvider
|
||||
declare avatarProvider: IAvatar['avatarProvider']
|
||||
|
||||
defaults() {
|
||||
return {
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
|
||||
export interface IBackgroundImage extends AbstractModel {
|
||||
id: number
|
||||
url: string
|
||||
thumb: string
|
||||
info: {
|
||||
author: string
|
||||
authorName: string
|
||||
}
|
||||
blurHash: string
|
||||
}
|
||||
import type {IBackgroundImage} from '@/modelTypes/IBackgroundImage'
|
||||
|
||||
export default class BackgroundImageModel extends AbstractModel implements IBackgroundImage {
|
||||
declare id: number
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import UserModel, { type IUser } from './user'
|
||||
import TaskModel, { type ITask } from './task'
|
||||
import UserModel from './user'
|
||||
import TaskModel from './task'
|
||||
|
||||
export interface IBucket extends AbstractModel {
|
||||
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 {
|
||||
declare id: number
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
|
||||
export interface ICaldavToken extends AbstractModel {
|
||||
id: number;
|
||||
created: Date;
|
||||
}
|
||||
import type {ICaldavToken} from '@/modelTypes/ICaldavToken'
|
||||
|
||||
export default class CaldavTokenModel extends AbstractModel implements ICaldavToken {
|
||||
declare id: number
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
|
||||
interface IEmailUpdate extends AbstractModel {
|
||||
newEmail: string
|
||||
password: string
|
||||
}
|
||||
import type {IEmailUpdate} from '@/modelTypes/IEmailUpdate'
|
||||
|
||||
export default class EmailUpdateModel extends AbstractModel implements IEmailUpdate {
|
||||
declare newEmail: string
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
|
||||
export interface IFile extends AbstractModel {
|
||||
id: number
|
||||
mime: string
|
||||
name: string
|
||||
size: number
|
||||
created: Date
|
||||
}
|
||||
import type {IFile} from '@/modelTypes/IFile'
|
||||
|
||||
export default class FileModel extends AbstractModel implements IFile {
|
||||
declare id: number
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import UserModel, { type IUser } from './user'
|
||||
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 AbstractModel {
|
||||
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 {
|
||||
declare id: number
|
||||
declare title: string
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
|
||||
export interface ILabelTask extends AbstractModel {
|
||||
id: number
|
||||
taskId: number
|
||||
labelId: number
|
||||
}
|
||||
import type { ILabelTask } from '@/modelTypes/ILabelTask'
|
||||
|
||||
export default class LabelTask extends AbstractModel implements ILabelTask {
|
||||
declare id: number
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import UserModel, { type IUser } from './user'
|
||||
import {RIGHTS, type Right} from '@/models/constants/rights'
|
||||
import UserModel from './user'
|
||||
|
||||
export interface ILinkShare extends AbstractModel {
|
||||
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 '@/modelTypes/constants/rights'
|
||||
import type {ILinkShare} from '@/modelTypes/ILinkShare'
|
||||
import type {IUser} from '@/modelTypes/IUser'
|
||||
|
||||
export default class LinkShareModel extends AbstractModel implements ILinkShare {
|
||||
declare id: number
|
||||
|
|
|
@ -1,37 +1,22 @@
|
|||
import AbstractModel 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 AbstractModel {
|
||||
id: number
|
||||
title: string
|
||||
description: string
|
||||
owner: IUser
|
||||
tasks: ITask[]
|
||||
namespaceId: INamespace['id']
|
||||
isArchived: boolean
|
||||
hexColor: string
|
||||
identifier: string
|
||||
backgroundInformation: any
|
||||
isFavorite: boolean
|
||||
subscription: ISubscription
|
||||
position: number
|
||||
backgroundBlurHash: string
|
||||
|
||||
created: Date
|
||||
updated: Date
|
||||
}
|
||||
|
||||
export default class ListModel extends AbstractModel implements IList {
|
||||
declare id: number
|
||||
declare title: string
|
||||
declare description: string
|
||||
owner: IUser
|
||||
tasks: ITask[]
|
||||
declare tasks: ITask[]
|
||||
declare namespaceId: INamespace['id']
|
||||
declare isArchived: boolean
|
||||
declare hexColor: string
|
||||
|
@ -51,9 +36,9 @@ export default class ListModel extends AbstractModel implements IList {
|
|||
this.owner = new UserModel(this.owner)
|
||||
|
||||
// Make all tasks to task models
|
||||
this.tasks = this.tasks.map(t => {
|
||||
this.tasks = this.tasks?.map(t => {
|
||||
return new TaskModel(t)
|
||||
})
|
||||
}) || []
|
||||
|
||||
if (this.hexColor !== '' && this.hexColor.substring(0, 1) !== '#') {
|
||||
this.hexColor = '#' + this.hexColor
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import ListModel, { type IList } from './list'
|
||||
import type { INamespace } from './namespace'
|
||||
import ListModel from './list'
|
||||
|
||||
export interface IListDuplicate extends AbstractModel {
|
||||
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 {
|
||||
declare listId: number
|
||||
|
|
|
@ -1,28 +1,19 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import ListModel, { type IList } from './list'
|
||||
import UserModel, { type IUser } from './user'
|
||||
import SubscriptionModel, { type ISubscription } from '@/models/subscription'
|
||||
import ListModel from './list'
|
||||
import UserModel from './user'
|
||||
import SubscriptionModel from '@/models/subscription'
|
||||
|
||||
export interface INamespace extends AbstractModel {
|
||||
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 {
|
||||
declare id: number
|
||||
declare title: string
|
||||
declare description: string
|
||||
owner: IUser
|
||||
lists: IList[]
|
||||
declare lists: IList[]
|
||||
declare isArchived: boolean
|
||||
declare hexColor: string
|
||||
declare subscription: ISubscription
|
||||
|
@ -37,9 +28,9 @@ export default class NamespaceModel extends AbstractModel implements INamespace
|
|||
this.hexColor = '#' + this.hexColor
|
||||
}
|
||||
|
||||
this.lists = this.lists.map(l => {
|
||||
this.lists = this.lists?.map(l => {
|
||||
return new ListModel(l)
|
||||
})
|
||||
}) || []
|
||||
|
||||
this.owner = new UserModel(this.owner)
|
||||
|
||||
|
|
|
@ -1,59 +1,17 @@
|
|||
import AbstractModel 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 UserModel from '@/models/user'
|
||||
import TaskModel from '@/models/task'
|
||||
import TaskCommentModel from '@/models/taskComment'
|
||||
import ListModel from '@/models/list'
|
||||
import TeamModel, { type ITeam } from '@/models/team'
|
||||
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
|
||||
}
|
||||
|
||||
interface NotificationMemberAdded extends Notification {
|
||||
member: IUser
|
||||
team: ITeam
|
||||
}
|
||||
|
||||
export interface INotification extends AbstractModel {
|
||||
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 {
|
||||
declare id: number
|
||||
declare name: string
|
||||
declare notification: NotificationTask | NotificationAssigned | NotificationDeleted | NotificationCreated | NotificationMemberAdded
|
||||
declare notification: INotification['notification']
|
||||
declare read: boolean
|
||||
readAt: Date | null
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
|
||||
export interface IPasswordReset extends AbstractModel {
|
||||
token: string
|
||||
newPassword: string
|
||||
email: string
|
||||
}
|
||||
import type {IPasswordReset} from '@/modelTypes/IPasswordReset'
|
||||
|
||||
export default class PasswordResetModel extends AbstractModel implements IPasswordReset {
|
||||
token: string
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import AbstractModel from '@/models/abstractModel'
|
||||
import AbstractModel from './abstractModel'
|
||||
|
||||
export interface IPasswordUpdate extends AbstractModel {
|
||||
newPassword: string
|
||||
oldPassword: string
|
||||
}
|
||||
import type {IPasswordUpdate} from '@/modelTypes/IPasswordUpdate'
|
||||
|
||||
export default class PasswordUpdateModel extends AbstractModel implements IPasswordUpdate {
|
||||
declare newPassword: string
|
||||
|
|
|
@ -1,38 +1,14 @@
|
|||
import AbstractModel from '@/models/abstractModel'
|
||||
import UserModel, { type IUser } from '@/models/user'
|
||||
import AbstractModel from './abstractModel'
|
||||
import UserModel from '@/models/user'
|
||||
|
||||
export interface ISavedFilter extends AbstractModel {
|
||||
id: 0
|
||||
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 {
|
||||
declare id: 0
|
||||
declare title: string
|
||||
declare description: string
|
||||
declare filters: {
|
||||
sortBy: ('done' | 'id')[]
|
||||
orderBy: ('asc' | 'desc')[]
|
||||
filterBy: 'done'[]
|
||||
filterValue: 'false'[]
|
||||
filterComparator: 'equals'[]
|
||||
filterConcat: 'and'
|
||||
filterIncludeNulls: boolean
|
||||
}
|
||||
declare filters: ISavedFilter['filters']
|
||||
|
||||
owner: IUser
|
||||
created: Date
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
import AbstractModel from '@/models/abstractModel'
|
||||
import UserModel, { type IUser } from '@/models/user'
|
||||
import AbstractModel from './abstractModel'
|
||||
import UserModel from '@/models/user'
|
||||
|
||||
export interface ISubscription extends AbstractModel {
|
||||
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 {
|
||||
declare id: number
|
||||
|
|
|
@ -1,63 +1,32 @@
|
|||
import type { Priority } from '@/models/constants/priorities'
|
||||
|
||||
import AbstractModel 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 AbstractModel from './abstractModel'
|
||||
import UserModel from '@/models/user'
|
||||
import LabelModel from '@/models/label'
|
||||
import AttachmentModel from '@/models/attachment'
|
||||
import SubscriptionModel from '@/models/subscription'
|
||||
|
||||
import type {Priority} from '@/modelTypes/constants/priorities'
|
||||
import {TASK_REPEAT_MODES, type ITask, type TaskRepeatMode} 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 {IRepeats} from '@/types/IRepeats'
|
||||
|
||||
import {parseDateOrNull} from '@/helpers/parseDateOrNull'
|
||||
import type { IBucket } from './bucket'
|
||||
|
||||
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 AbstractModel {
|
||||
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 {
|
||||
|
@ -98,20 +67,23 @@ export default class TaskModel extends AbstractModel implements ITask {
|
|||
declare bucketId: IBucket['id']
|
||||
|
||||
constructor(data: Partial<ITask>) {
|
||||
super(data)
|
||||
|
||||
console.log({titleData: data?.title})
|
||||
const result = super(data)
|
||||
console.log({titleResult: result?.title})
|
||||
console.log({titleSuper: this?.title})
|
||||
|
||||
this.id = Number(this.id)
|
||||
this.title = this.title?.trim()
|
||||
this.doneAt = parseDateOrNull(this.doneAt)
|
||||
|
||||
this.labels = this.labels
|
||||
.map(l => new LabelModel(l))
|
||||
.sort((f, s) => f.title > s.title ? 1 : -1)
|
||||
?.map(l => new LabelModel(l))
|
||||
.sort((f, s) => f.title > s.title ? 1 : -1) || []
|
||||
|
||||
// Parse the assignees into user models
|
||||
this.assignees = this.assignees.map(a => {
|
||||
return new UserModel(a)
|
||||
})
|
||||
this.assignees = this.assignees?.map(a => {
|
||||
return new UserModel(a)
|
||||
}) || []
|
||||
|
||||
this.dueDate = parseDateOrNull(this.dueDate)
|
||||
this.startDate = parseDateOrNull(this.startDate)
|
||||
|
@ -120,7 +92,7 @@ export default class TaskModel extends AbstractModel implements ITask {
|
|||
// Parse the repeat after into something usable
|
||||
this.parseRepeatAfter()
|
||||
|
||||
this.reminderDates = this.reminderDates.map(d => new Date(d))
|
||||
this.reminderDates = this.reminderDates?.map(d => new Date(d)) || []
|
||||
|
||||
// Cancel all scheduled notifications for this task to be sure to only have available notifications
|
||||
this.cancelScheduledNotifications().then(() => {
|
||||
|
@ -140,7 +112,7 @@ export default class TaskModel extends AbstractModel implements ITask {
|
|||
})
|
||||
|
||||
// Make all attachments to attachment models
|
||||
this.attachments = this.attachments.map(a => new AttachmentModel(a))
|
||||
this.attachments = this.attachments?.map(a => new AttachmentModel(a)) || []
|
||||
|
||||
// Set the task identifier to empty if the list does not have one
|
||||
if (this.identifier === `-${this.index}`) {
|
||||
|
@ -152,6 +124,7 @@ export default class TaskModel extends AbstractModel implements ITask {
|
|||
}
|
||||
|
||||
this.createdBy = new UserModel(this.createdBy)
|
||||
// console.log(JSON.parse(JSON.stringify(this)), this.created)
|
||||
this.created = new Date(this.created)
|
||||
this.updated = new Date(this.updated)
|
||||
|
||||
|
@ -207,11 +180,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 from './abstractModel'
|
||||
import type { ITask } from './task'
|
||||
import type { IUser } from './user'
|
||||
|
||||
export interface ITaskAssignee extends AbstractModel {
|
||||
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
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import UserModel, { type IUser } from './user'
|
||||
import type { ITask } from './task'
|
||||
import UserModel from './user'
|
||||
|
||||
export interface ITaskComment extends AbstractModel {
|
||||
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 {
|
||||
declare id: number
|
||||
|
|
|
@ -1,39 +1,17 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import UserModel, { type IUser } from './user'
|
||||
import type { ITask } from './task'
|
||||
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
|
||||
import type {ITaskRelation} from '@/modelTypes/ITaskRelation'
|
||||
import type {ITask} from '@/modelTypes/ITask'
|
||||
import type {IUser} from '@/modelTypes/IUser'
|
||||
|
||||
export const RELATION_KINDS = [...Object.values(RELATION_KIND)] as const
|
||||
|
||||
export type RelationKind = typeof RELATION_KINDS[number]
|
||||
|
||||
export interface ITaskRelation extends AbstractModel {
|
||||
id: number
|
||||
otherTaskId: ITask['id']
|
||||
taskId: ITask['id']
|
||||
relationKind: RelationKind
|
||||
|
||||
createdBy: IUser
|
||||
created: Date
|
||||
}
|
||||
import type {IRelationKind} from '@/types/IRelationKind'
|
||||
|
||||
export default class TaskRelationModel extends AbstractModel implements ITaskRelation {
|
||||
declare id: number
|
||||
declare otherTaskId: ITask['id']
|
||||
declare taskId: ITask['id']
|
||||
declare relationKind: RelationKind
|
||||
declare relationKind: IRelationKind
|
||||
|
||||
createdBy: IUser
|
||||
created: Date
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import UserModel, { type IUser } from './user'
|
||||
import TeamMemberModel, { type ITeamMember } from './teamMember'
|
||||
import {RIGHTS, type Right} from '@/models/constants/rights'
|
||||
import UserModel from './user'
|
||||
import TeamMemberModel from './teamMember'
|
||||
|
||||
export interface ITeam extends AbstractModel {
|
||||
id: number
|
||||
name: string
|
||||
description: string
|
||||
members: ITeamMember[]
|
||||
right: Right
|
||||
|
||||
createdBy: IUser
|
||||
created: Date
|
||||
updated: Date
|
||||
}
|
||||
import {RIGHTS, type Right} from '@/modelTypes/constants/rights'
|
||||
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 {
|
||||
declare id: number
|
||||
|
|
|
@ -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 {
|
||||
declare listId: IList['id']
|
||||
|
|
|
@ -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 {
|
||||
declare admin: boolean
|
||||
|
|
|
@ -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 {
|
||||
declare namespaceId: INamespace['id']
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import {RIGHTS, type Right} from '@/models/constants/rights'
|
||||
import type { ITeam } from './team'
|
||||
|
||||
export interface ITeamShareBase extends AbstractModel {
|
||||
teamId: ITeam['id']
|
||||
right: Right
|
||||
|
||||
created: Date
|
||||
updated: Date
|
||||
}
|
||||
import {RIGHTS, type Right} from '@/modelTypes/constants/rights'
|
||||
import type {ITeamShareBase} from '@/modelTypes/ITeamShareBase'
|
||||
import type {ITeam} from '@/modelTypes/ITeam'
|
||||
|
||||
/**
|
||||
* This class is a base class for common team sharing model.
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
|
||||
export interface ITotp extends AbstractModel {
|
||||
secret: string
|
||||
enabled: boolean
|
||||
url: string
|
||||
}
|
||||
import type {ITotp} from '@/modelTypes/ITotp'
|
||||
|
||||
export default class TotpModel extends AbstractModel implements ITotp{
|
||||
export default class TotpModel extends AbstractModel implements ITotp {
|
||||
declare secret: string
|
||||
declare enabled: boolean
|
||||
declare url: string
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import UserSettingsModel, { type IUserSettings } from '@/models/userSettings'
|
||||
import UserSettingsModel from '@/models/userSettings'
|
||||
|
||||
export interface IUser extends AbstractModel {
|
||||
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 {
|
||||
declare id: number
|
||||
|
|
|
@ -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 from './abstractModel'
|
||||
import type { IList } from './list'
|
||||
|
||||
export interface IUserSettings extends AbstractModel {
|
||||
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 {
|
||||
declare name: string
|
||||
|
@ -20,7 +11,7 @@ export default class UserSettingsModel extends AbstractModel implements IUserSet
|
|||
declare discoverableByEmail: boolean
|
||||
declare overdueTasksRemindersEnabled: boolean
|
||||
declare defaultListId: undefined | IList['id']
|
||||
declare weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6
|
||||
declare weekStart: IUserSettings['weekStart']
|
||||
declare timezone: string
|
||||
|
||||
defaults() {
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
import AbstractModel from './abstractModel'
|
||||
import {RIGHTS, type Right} from '@/models/constants/rights'
|
||||
import type { IUser } from './user'
|
||||
|
||||
export interface IUserShareBase extends AbstractModel {
|
||||
userId: IUser['id']
|
||||
right: Right
|
||||
|
||||
created: Date
|
||||
updated: Date
|
||||
}
|
||||
import {RIGHTS, type Right} from '@/modelTypes/constants/rights'
|
||||
import type {IUserShareBase} from '@/modelTypes/IUserShareBase'
|
||||
import type {IUser} from '@/modelTypes/IUser'
|
||||
|
||||
export default class UserShareBaseModel extends AbstractModel implements IUserShareBase {
|
||||
declare userId: IUser['id']
|
||||
|
|
|
@ -2,7 +2,7 @@ import axios , { type Method } from 'axios'
|
|||
import {objectToSnakeCase} from '@/helpers/case'
|
||||
import {getToken} from '@/helpers/auth'
|
||||
import AbstractModel, { type IAbstract } from '@/models/abstractModel'
|
||||
import type { Right } from '@/models/constants/rights'
|
||||
import type { Right } from '@/modelTypes/constants/rights'
|
||||
import type { IFile } from '@/models/file'
|
||||
|
||||
interface Paths {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import type {InjectionKey} from 'vue'
|
||||
import {createStore, useStore as baseUseStore, Store} from 'vuex'
|
||||
|
||||
|
||||
import {getBlobFromBlurHash} from '../helpers/getBlobFromBlurHash'
|
||||
import {
|
||||
BACKGROUND,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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'])
|
||||
|
||||
|
|
|
@ -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'])
|
||||
|
||||
|
|
|
@ -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'])
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
export interface IFilter {
|
||||
sortBy: ('done' | 'id')[]
|
||||
orderBy: ('asc' | 'desc')[]
|
||||
filterBy: 'done'[]
|
||||
filterValue: 'false'[]
|
||||
filterComparator: 'equals'[]
|
||||
filterConcat: 'and'
|
||||
filterIncludeNulls: boolean
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
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 IRelationKind = typeof RELATION_KINDS[number]
|
|
@ -230,7 +230,7 @@ import cloneDeep from 'lodash.clonedeep'
|
|||
|
||||
import BucketModel from '../../models/bucket'
|
||||
import {mapState} from 'vuex'
|
||||
import {RIGHTS as Rights} from '@/models/constants/rights'
|
||||
import {RIGHTS as Rights} from '@/modelTypes/constants/rights'
|
||||
import {LOADING, LOADING_MODULE} from '@/store/mutation-types'
|
||||
import ListWrapper from './ListWrapper.vue'
|
||||
import FilterPopup from '@/components/list/partials/filter-popup.vue'
|
||||
|
|
|
@ -144,7 +144,7 @@ import EditTask from '@/components/tasks/edit-task.vue'
|
|||
import AddTask from '@/components/tasks/add-task.vue'
|
||||
import SingleTaskInList from '@/components/tasks/partials/singleTaskInList.vue'
|
||||
import { useTaskList } from '@/composables/taskList'
|
||||
import {RIGHTS as Rights} from '@/models/constants/rights'
|
||||
import {RIGHTS as Rights} from '@/modelTypes/constants/rights'
|
||||
import FilterPopup from '@/components/list/partials/filter-popup.vue'
|
||||
import {HAS_TASKS} from '@/store/mutation-types'
|
||||
import Nothing from '@/components/misc/nothing.vue'
|
||||
|
@ -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) => {
|
||||
|
|
|
@ -428,7 +428,7 @@ import TaskService from '../../services/task'
|
|||
import TaskModel, { type ITask } from '@/models/task'
|
||||
|
||||
import { PRIORITIES as priorites } from '@/models/constants/priorities'
|
||||
import {RIGHTS as rights} from '@/models/constants/rights'
|
||||
import {RIGHTS as rights} from '@/modelTypes/constants/rights'
|
||||
|
||||
import PrioritySelect from '../../components/tasks/partials/prioritySelect.vue'
|
||||
import PercentDoneSelect from '../../components/tasks/partials/percentDoneSelect.vue'
|
||||
|
|
|
@ -170,7 +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 '@/models/constants/rights'
|
||||
import {RIGHTS as Rights} from '@/modelTypes/constants/rights'
|
||||
|
||||
import Multiselect from '@/components/input/multiselect.vue'
|
||||
import {useRoute, useRouter} from 'vue-router'
|
||||
|
|
Reference in New Issue