diff --git a/src/components/home/TheNavigation.vue b/src/components/home/TheNavigation.vue index 22dd35cf8..1c336c1a5 100644 --- a/src/components/home/TheNavigation.vue +++ b/src/components/home/TheNavigation.vue @@ -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' diff --git a/src/components/sharing/linkSharing.vue b/src/components/sharing/linkSharing.vue index e40eefa2b..7f9fbe1f7 100644 --- a/src/components/sharing/linkSharing.vue +++ b/src/components/sharing/linkSharing.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' diff --git a/src/components/sharing/userTeam.vue b/src/components/sharing/userTeam.vue index 5106ab3e1..1ae00df1b 100644 --- a/src/components/sharing/userTeam.vue +++ b/src/components/sharing/userTeam.vue @@ -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' diff --git a/src/modelTypes/IAbstract.ts b/src/modelTypes/IAbstract.ts new file mode 100644 index 000000000..ac9ac3bac --- /dev/null +++ b/src/modelTypes/IAbstract.ts @@ -0,0 +1,5 @@ +import type {Right} from './constants/rights' + +export interface IAbstract { + maxRight: Right | null +} \ No newline at end of file diff --git a/src/modelTypes/IAttachment.ts b/src/modelTypes/IAttachment.ts new file mode 100644 index 000000000..9cb9ce353 --- /dev/null +++ b/src/modelTypes/IAttachment.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/IAvatar.ts b/src/modelTypes/IAvatar.ts new file mode 100644 index 000000000..494f3f29b --- /dev/null +++ b/src/modelTypes/IAvatar.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/IBackgroundImage.ts b/src/modelTypes/IBackgroundImage.ts new file mode 100644 index 000000000..2274925fa --- /dev/null +++ b/src/modelTypes/IBackgroundImage.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/IBucket.ts b/src/modelTypes/IBucket.ts new file mode 100644 index 000000000..b61bf022e --- /dev/null +++ b/src/modelTypes/IBucket.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/ICaldavToken.ts b/src/modelTypes/ICaldavToken.ts new file mode 100644 index 000000000..cdf6621c8 --- /dev/null +++ b/src/modelTypes/ICaldavToken.ts @@ -0,0 +1,7 @@ +import type {IAbstract} from './IAbstract' + +export interface ICaldavToken /* extends IAbstract */ { + id: number; + + created: Date; +} \ No newline at end of file diff --git a/src/modelTypes/IEmailUpdate.ts b/src/modelTypes/IEmailUpdate.ts new file mode 100644 index 000000000..ad45ae351 --- /dev/null +++ b/src/modelTypes/IEmailUpdate.ts @@ -0,0 +1,6 @@ +import type {IAbstract} from './IAbstract' + +export interface IEmailUpdate /* extends IAbstract */ { + newEmail: string + password: string +} \ No newline at end of file diff --git a/src/modelTypes/IFile.ts b/src/modelTypes/IFile.ts new file mode 100644 index 000000000..3f5538541 --- /dev/null +++ b/src/modelTypes/IFile.ts @@ -0,0 +1,10 @@ +import type {IAbstract} from './IAbstract' + +export interface IFile /* extends IAbstract */ { + id: number + mime: string + name: string + size: number + + created: Date +} \ No newline at end of file diff --git a/src/modelTypes/ILabel.ts b/src/modelTypes/ILabel.ts new file mode 100644 index 000000000..e90116a00 --- /dev/null +++ b/src/modelTypes/ILabel.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/ILabelTask.ts b/src/modelTypes/ILabelTask.ts new file mode 100644 index 000000000..b46983da2 --- /dev/null +++ b/src/modelTypes/ILabelTask.ts @@ -0,0 +1,7 @@ +import type {IAbstract} from './IAbstract' + +export interface ILabelTask /* extends IAbstract */ { + id: number + taskId: number + labelId: number +} \ No newline at end of file diff --git a/src/modelTypes/ILinkShare.ts b/src/modelTypes/ILinkShare.ts new file mode 100644 index 000000000..d9c931c23 --- /dev/null +++ b/src/modelTypes/ILinkShare.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/IList.ts b/src/modelTypes/IList.ts new file mode 100644 index 000000000..65d96e06f --- /dev/null +++ b/src/modelTypes/IList.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/IListDuplicate.ts b/src/modelTypes/IListDuplicate.ts new file mode 100644 index 000000000..ca44f78b4 --- /dev/null +++ b/src/modelTypes/IListDuplicate.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/INamespace.ts b/src/modelTypes/INamespace.ts new file mode 100644 index 000000000..e965087c7 --- /dev/null +++ b/src/modelTypes/INamespace.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/INotification.ts b/src/modelTypes/INotification.ts new file mode 100644 index 000000000..a30662e6f --- /dev/null +++ b/src/modelTypes/INotification.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/IPasswordReset.ts b/src/modelTypes/IPasswordReset.ts new file mode 100644 index 000000000..f4d82c5d9 --- /dev/null +++ b/src/modelTypes/IPasswordReset.ts @@ -0,0 +1,7 @@ +import type {IAbstract} from './IAbstract' + +export interface IPasswordReset /* extends IAbstract */ { + token: string + newPassword: string + email: string +} \ No newline at end of file diff --git a/src/modelTypes/IPasswordUpdate.ts b/src/modelTypes/IPasswordUpdate.ts new file mode 100644 index 000000000..8a98a6d5b --- /dev/null +++ b/src/modelTypes/IPasswordUpdate.ts @@ -0,0 +1,6 @@ +import type {IAbstract} from './IAbstract' + +export interface IPasswordUpdate /* extends IAbstract */ { + newPassword: string + oldPassword: string +} \ No newline at end of file diff --git a/src/modelTypes/ISavedFilter.ts b/src/modelTypes/ISavedFilter.ts new file mode 100644 index 000000000..ad43f5adc --- /dev/null +++ b/src/modelTypes/ISavedFilter.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/ISubscription.ts b/src/modelTypes/ISubscription.ts new file mode 100644 index 000000000..c6f41f4ea --- /dev/null +++ b/src/modelTypes/ISubscription.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/ITask.ts b/src/modelTypes/ITask.ts new file mode 100644 index 000000000..c2a9f67e5 --- /dev/null +++ b/src/modelTypes/ITask.ts @@ -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'] +} \ No newline at end of file diff --git a/src/modelTypes/ITaskAssignee.ts b/src/modelTypes/ITaskAssignee.ts new file mode 100644 index 000000000..fde8714f1 --- /dev/null +++ b/src/modelTypes/ITaskAssignee.ts @@ -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'] +} \ No newline at end of file diff --git a/src/modelTypes/ITaskComment.ts b/src/modelTypes/ITaskComment.ts new file mode 100644 index 000000000..fad541a04 --- /dev/null +++ b/src/modelTypes/ITaskComment.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/ITaskRelation.ts b/src/modelTypes/ITaskRelation.ts new file mode 100644 index 000000000..ac58e09b2 --- /dev/null +++ b/src/modelTypes/ITaskRelation.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/ITeam.ts b/src/modelTypes/ITeam.ts new file mode 100644 index 000000000..4ac846559 --- /dev/null +++ b/src/modelTypes/ITeam.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/ITeamList.ts b/src/modelTypes/ITeamList.ts new file mode 100644 index 000000000..a1abd692d --- /dev/null +++ b/src/modelTypes/ITeamList.ts @@ -0,0 +1,6 @@ +import type {ITeamShareBase} from './ITeamShareBase' +import type {IList} from './IList' + +export interface ITeamList extends ITeamShareBase { + listId: IList['id'] +} \ No newline at end of file diff --git a/src/modelTypes/ITeamMember.ts b/src/modelTypes/ITeamMember.ts new file mode 100644 index 000000000..62a1d91ba --- /dev/null +++ b/src/modelTypes/ITeamMember.ts @@ -0,0 +1,7 @@ +import type {IUser} from './IUser' +import type {IList} from './IList' + +export interface ITeamMember extends IUser { + admin: boolean + teamId: IList['id'] +} diff --git a/src/modelTypes/ITeamNamespace.ts b/src/modelTypes/ITeamNamespace.ts new file mode 100644 index 000000000..e66a98bb6 --- /dev/null +++ b/src/modelTypes/ITeamNamespace.ts @@ -0,0 +1,6 @@ +import type {ITeamShareBase} from './ITeamShareBase' +import type {INamespace} from './INamespace' + +export interface ITeamNamespace extends ITeamShareBase { + namespaceId: INamespace['id'] +} \ No newline at end of file diff --git a/src/modelTypes/ITeamShareBase.ts b/src/modelTypes/ITeamShareBase.ts new file mode 100644 index 000000000..467a68306 --- /dev/null +++ b/src/modelTypes/ITeamShareBase.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/ITotp.ts b/src/modelTypes/ITotp.ts new file mode 100644 index 000000000..9d7427d95 --- /dev/null +++ b/src/modelTypes/ITotp.ts @@ -0,0 +1,7 @@ +import type {IAbstract} from './IAbstract' + +export interface ITotp /* extends IAbstract */ { + secret: string + enabled: boolean + url: string +} \ No newline at end of file diff --git a/src/modelTypes/IUser.ts b/src/modelTypes/IUser.ts new file mode 100644 index 000000000..f23c4bdc8 --- /dev/null +++ b/src/modelTypes/IUser.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/IUserList.ts b/src/modelTypes/IUserList.ts new file mode 100644 index 000000000..20787db7f --- /dev/null +++ b/src/modelTypes/IUserList.ts @@ -0,0 +1,6 @@ +import type {IUserShareBase} from './IUserShareBase' +import type {IList} from './IList' + +export interface IUserList extends IUserShareBase { + listId: IList['id'] +} \ No newline at end of file diff --git a/src/modelTypes/IUserNamespace.ts b/src/modelTypes/IUserNamespace.ts new file mode 100644 index 000000000..e2bd1b468 --- /dev/null +++ b/src/modelTypes/IUserNamespace.ts @@ -0,0 +1,6 @@ +import type {IUserShareBase} from './IUserShareBase' +import type {INamespace} from './INamespace' + +export interface IUserNamespace extends IUserShareBase { + namespaceId: INamespace['id'] +} \ No newline at end of file diff --git a/src/modelTypes/IUserSettings.ts b/src/modelTypes/IUserSettings.ts new file mode 100644 index 000000000..24bbf6498 --- /dev/null +++ b/src/modelTypes/IUserSettings.ts @@ -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 +} \ No newline at end of file diff --git a/src/modelTypes/IUserShareBase.ts b/src/modelTypes/IUserShareBase.ts new file mode 100644 index 000000000..5bd932a7b --- /dev/null +++ b/src/modelTypes/IUserShareBase.ts @@ -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 +} \ No newline at end of file diff --git a/src/models/constants/config.ts b/src/modelTypes/constants/config.ts similarity index 100% rename from src/models/constants/config.ts rename to src/modelTypes/constants/config.ts diff --git a/src/models/constants/priorities.ts b/src/modelTypes/constants/priorities.ts similarity index 100% rename from src/models/constants/priorities.ts rename to src/modelTypes/constants/priorities.ts diff --git a/src/models/constants/rights.ts b/src/modelTypes/constants/rights.ts similarity index 100% rename from src/models/constants/rights.ts rename to src/modelTypes/constants/rights.ts diff --git a/src/models/abstractModel.ts b/src/models/abstractModel.ts index 02b89b744..84ac3085f 100644 --- a/src/models/abstractModel.ts +++ b/src/models/abstractModel.ts @@ -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 { /** * 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 } } \ No newline at end of file diff --git a/src/models/attachment.ts b/src/models/attachment.ts index c5c9933c3..f88a8b081 100644 --- a/src/models/attachment.ts +++ b/src/models/attachment.ts @@ -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) { super(data) this.createdBy = new UserModel(this.createdBy) this.file = new FileModel(this.file) diff --git a/src/models/avatar.ts b/src/models/avatar.ts index 411e3cd3e..544b8513a 100644 --- a/src/models/avatar.ts +++ b/src/models/avatar.ts @@ -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 { diff --git a/src/models/backgroundImage.ts b/src/models/backgroundImage.ts index 21be0773e..4313e9473 100644 --- a/src/models/backgroundImage.ts +++ b/src/models/backgroundImage.ts @@ -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 diff --git a/src/models/bucket.ts b/src/models/bucket.ts index f4b437594..e5f820b96 100644 --- a/src/models/bucket.ts +++ b/src/models/bucket.ts @@ -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 diff --git a/src/models/caldavToken.ts b/src/models/caldavToken.ts index b2186b0a4..2412ce61f 100644 --- a/src/models/caldavToken.ts +++ b/src/models/caldavToken.ts @@ -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 diff --git a/src/models/emailUpdate.ts b/src/models/emailUpdate.ts index 4f6f4385c..584cea875 100644 --- a/src/models/emailUpdate.ts +++ b/src/models/emailUpdate.ts @@ -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 diff --git a/src/models/file.ts b/src/models/file.ts index 81240a792..af16ffbfd 100644 --- a/src/models/file.ts +++ b/src/models/file.ts @@ -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 diff --git a/src/models/label.ts b/src/models/label.ts index 75a104e30..393403d4c 100644 --- a/src/models/label.ts +++ b/src/models/label.ts @@ -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 diff --git a/src/models/labelTask.ts b/src/models/labelTask.ts index 496d6a69f..2d5b55ccd 100644 --- a/src/models/labelTask.ts +++ b/src/models/labelTask.ts @@ -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 diff --git a/src/models/linkShare.ts b/src/models/linkShare.ts index 10100ee42..0ed55ba0d 100644 --- a/src/models/linkShare.ts +++ b/src/models/linkShare.ts @@ -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 diff --git a/src/models/list.ts b/src/models/list.ts index 7ced89296..6fc68be2e 100644 --- a/src/models/list.ts +++ b/src/models/list.ts @@ -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 diff --git a/src/models/listDuplicateModel.ts b/src/models/listDuplicateModel.ts index e1a32cdf4..c475f21ab 100644 --- a/src/models/listDuplicateModel.ts +++ b/src/models/listDuplicateModel.ts @@ -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 diff --git a/src/models/namespace.ts b/src/models/namespace.ts index 5d8c608c6..ab568eb0b 100644 --- a/src/models/namespace.ts +++ b/src/models/namespace.ts @@ -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) diff --git a/src/models/notification.ts b/src/models/notification.ts index 4d9f48ab2..a9cf58794 100644 --- a/src/models/notification.ts +++ b/src/models/notification.ts @@ -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 diff --git a/src/models/passwordReset.ts b/src/models/passwordReset.ts index dd05f37a7..43df6c1c3 100644 --- a/src/models/passwordReset.ts +++ b/src/models/passwordReset.ts @@ -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 diff --git a/src/models/passwordUpdate.ts b/src/models/passwordUpdate.ts index 51640e323..be9a9ab58 100644 --- a/src/models/passwordUpdate.ts +++ b/src/models/passwordUpdate.ts @@ -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 diff --git a/src/models/savedFilter.ts b/src/models/savedFilter.ts index 168613067..1dd46cf05 100644 --- a/src/models/savedFilter.ts +++ b/src/models/savedFilter.ts @@ -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 diff --git a/src/models/subscription.ts b/src/models/subscription.ts index bd52d0d6d..e9d14c8af 100644 --- a/src/models/subscription.ts +++ b/src/models/subscription.ts @@ -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 diff --git a/src/models/task.ts b/src/models/task.ts index 88e2f141b..0594997d4 100644 --- a/src/models/task.ts +++ b/src/models/task.ts @@ -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) { - 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) } ///////////////// diff --git a/src/models/taskAssignee.ts b/src/models/taskAssignee.ts index 5ceb15ad8..e8b41006a 100644 --- a/src/models/taskAssignee.ts +++ b/src/models/taskAssignee.ts @@ -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 diff --git a/src/models/taskComment.ts b/src/models/taskComment.ts index 15ca3b6d3..22a210cc6 100644 --- a/src/models/taskComment.ts +++ b/src/models/taskComment.ts @@ -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 diff --git a/src/models/taskRelation.ts b/src/models/taskRelation.ts index bc924b47d..714a1777e 100644 --- a/src/models/taskRelation.ts +++ b/src/models/taskRelation.ts @@ -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 diff --git a/src/models/team.ts b/src/models/team.ts index b81c99d8e..78a8d8840 100644 --- a/src/models/team.ts +++ b/src/models/team.ts @@ -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 diff --git a/src/models/teamList.ts b/src/models/teamList.ts index d3bbb42ab..1b13b9acd 100644 --- a/src/models/teamList.ts +++ b/src/models/teamList.ts @@ -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'] diff --git a/src/models/teamMember.ts b/src/models/teamMember.ts index f699408ad..6ad7fb32d 100644 --- a/src/models/teamMember.ts +++ b/src/models/teamMember.ts @@ -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 diff --git a/src/models/teamNamespace.ts b/src/models/teamNamespace.ts index 2064d1412..1ffc2214f 100644 --- a/src/models/teamNamespace.ts +++ b/src/models/teamNamespace.ts @@ -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'] diff --git a/src/models/teamShareBase.ts b/src/models/teamShareBase.ts index c3e943701..9f31c9403 100644 --- a/src/models/teamShareBase.ts +++ b/src/models/teamShareBase.ts @@ -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. diff --git a/src/models/totp.ts b/src/models/totp.ts index a47044c5e..ef09fba90 100644 --- a/src/models/totp.ts +++ b/src/models/totp.ts @@ -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 diff --git a/src/models/user.ts b/src/models/user.ts index eaa472a75..6cbcec2f7 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -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 diff --git a/src/models/userList.ts b/src/models/userList.ts index d0b9cbd36..07a8f7ed4 100644 --- a/src/models/userList.ts +++ b/src/models/userList.ts @@ -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 { diff --git a/src/models/userNamespace.ts b/src/models/userNamespace.ts index 2a11a35e7..63e963364 100644 --- a/src/models/userNamespace.ts +++ b/src/models/userNamespace.ts @@ -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 { diff --git a/src/models/userSettings.ts b/src/models/userSettings.ts index a5db3f807..0e41017af 100644 --- a/src/models/userSettings.ts +++ b/src/models/userSettings.ts @@ -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() { diff --git a/src/models/userShareBase.ts b/src/models/userShareBase.ts index 8eda9ed29..30e15c945 100644 --- a/src/models/userShareBase.ts +++ b/src/models/userShareBase.ts @@ -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'] diff --git a/src/services/abstractService.ts b/src/services/abstractService.ts index cc7be8c0d..b56608b0a 100644 --- a/src/services/abstractService.ts +++ b/src/services/abstractService.ts @@ -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 { diff --git a/src/store/index.ts b/src/store/index.ts index 0033e07e1..34dc7c049 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,7 +1,6 @@ import type {InjectionKey} from 'vue' import {createStore, useStore as baseUseStore, Store} from 'vuex' - import {getBlobFromBlurHash} from '../helpers/getBlobFromBlurHash' import { BACKGROUND, diff --git a/src/store/modules/attachments.ts b/src/store/modules/attachments.ts index 208ab4cef..172696e41 100644 --- a/src/store/modules/attachments.ts +++ b/src/store/modules/attachments.ts @@ -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 = { namespaced: true, diff --git a/src/store/modules/auth.ts b/src/store/modules/auth.ts index 81f11ab97..b354ce88a 100644 --- a/src/store/modules/auth.ts +++ b/src/store/modules/auth.ts @@ -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 => { diff --git a/src/store/modules/kanban.ts b/src/store/modules/kanban.ts index c6e46d58a..194121309 100644 --- a/src/store/modules/kanban.ts +++ b/src/store/modules/kanban.ts @@ -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 diff --git a/src/store/modules/labels.ts b/src/store/modules/labels.ts index ce32db6d0..928b6b1e4 100644 --- a/src/store/modules/labels.ts +++ b/src/store/modules/labels.ts @@ -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']) diff --git a/src/store/modules/lists.ts b/src/store/modules/lists.ts index 0d18a2c04..be2e3fcfe 100644 --- a/src/store/modules/lists.ts +++ b/src/store/modules/lists.ts @@ -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']) diff --git a/src/store/modules/namespaces.ts b/src/store/modules/namespaces.ts index 0eccc99bb..d835c7095 100644 --- a/src/store/modules/namespaces.ts +++ b/src/store/modules/namespaces.ts @@ -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']) diff --git a/src/store/modules/tasks.ts b/src/store/modules/tasks.ts index 8289d848b..74507728b 100644 --- a/src/store/modules/tasks.ts +++ b/src/store/modules/tasks.ts @@ -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) { diff --git a/src/store/types.ts b/src/store/types.ts index 96f061dca..2cc467a1e 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -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, diff --git a/src/types/IFilter.ts b/src/types/IFilter.ts new file mode 100644 index 000000000..aca000ab6 --- /dev/null +++ b/src/types/IFilter.ts @@ -0,0 +1,9 @@ +export interface IFilter { + sortBy: ('done' | 'id')[] + orderBy: ('asc' | 'desc')[] + filterBy: 'done'[] + filterValue: 'false'[] + filterComparator: 'equals'[] + filterConcat: 'and' + filterIncludeNulls: boolean +} \ No newline at end of file diff --git a/src/types/IRelationKind.ts b/src/types/IRelationKind.ts new file mode 100644 index 000000000..06fbddeec --- /dev/null +++ b/src/types/IRelationKind.ts @@ -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] diff --git a/src/views/list/ListKanban.vue b/src/views/list/ListKanban.vue index fc17a2435..ea1b36195 100644 --- a/src/views/list/ListKanban.vue +++ b/src/views/list/ListKanban.vue @@ -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' diff --git a/src/views/list/ListList.vue b/src/views/list/ListList.vue index 27a995bae..f07c2f334 100644 --- a/src/views/list/ListList.vue +++ b/src/views/list/ListList.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) => { diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue index 993d8de74..535549ed9 100644 --- a/src/views/tasks/TaskDetailView.vue +++ b/src/views/tasks/TaskDetailView.vue @@ -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' diff --git a/src/views/teams/EditTeam.vue b/src/views/teams/EditTeam.vue index dfcdf0620..faaca77ed 100644 --- a/src/views/teams/EditTeam.vue +++ b/src/views/teams/EditTeam.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'