diff --git a/src/components/home/TheNavigation.vue b/src/components/home/TheNavigation.vue index 051a7171..fbdf2e04 100644 --- a/src/components/home/TheNavigation.vue +++ b/src/components/home/TheNavigation.vue @@ -92,7 +92,7 @@ import {useStore} from 'vuex' import {useRouter} from 'vue-router' import {QUICK_ACTIONS_ACTIVE} from '@/store/mutation-types' -import Rights from '@/models/constants/rights.json' +import {RIGHTS as Rights} from '@/models/constants/rights' import Update from '@/components/home/update.vue' import ListSettingsDropdown from '@/components/list/list-settings-dropdown.vue' diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue index 08f318c5..c7d25333 100644 --- a/src/components/notifications/notifications.vue +++ b/src/components/notifications/notifications.vue @@ -52,7 +52,7 @@ import {computed, onMounted, onUnmounted, ref} from 'vue' import NotificationService from '@/services/notification' import BaseButton from '@/components/base/BaseButton.vue' import User from '@/components/misc/user.vue' -import names from '@/models/constants/notificationNames.json' +import NotificationModel, { NOTIFICATION_NAMES as names} from '@/models/notification' import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside' import {useStore} from 'vuex' import {useRouter} from 'vue-router' diff --git a/src/components/sharing/linkSharing.vue b/src/components/sharing/linkSharing.vue index e0b454e6..74cae27a 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 'vuex' import {useI18n} from 'vue-i18n' -import RIGHTS from '@/models/constants/rights.json' +import {RIGHTS} from '@/models/constants/rights' import LinkShareModel from '@/models/linkShare' import LinkShareService from '@/services/linkShare' diff --git a/src/components/sharing/userTeam.vue b/src/components/sharing/userTeam.vue index 56ea03dc..6920102c 100644 --- a/src/components/sharing/userTeam.vue +++ b/src/components/sharing/userTeam.vue @@ -158,7 +158,7 @@ import TeamListService from '@/services/teamList' import TeamService from '@/services/team' import TeamModel from '@/models/team' -import RIGHTS from '@/models/constants/rights.json' +import {RIGHTS} from '@/models/constants/rights' import Multiselect from '@/components/input/multiselect.vue' import Nothing from '@/components/misc/nothing.vue' import {success} from '@/message' diff --git a/src/components/tasks/gantt-component.vue b/src/components/tasks/gantt-component.vue index 37316b04..73f66ecf 100644 --- a/src/components/tasks/gantt-component.vue +++ b/src/components/tasks/gantt-component.vue @@ -179,11 +179,11 @@ import EditTask from './edit-task.vue' import TaskService from '../../services/task' import TaskModel from '../../models/task' -import priorities from '../../models/constants/priorities' +import {PRIORITIES as priorities} from '@/models/constants/priorities' import PriorityLabel from './partials/priorityLabel.vue' import TaskCollectionService from '../../services/taskCollection' import {mapState} from 'vuex' -import Rights from '../../models/constants/rights.json' +import {RIGHTS as Rights} from '@/models/constants/rights' import FilterPopup from '@/components/list/partials/filter-popup.vue' import BaseButton from '@/components/base/BaseButton.vue' diff --git a/src/components/tasks/partials/priorityLabel.vue b/src/components/tasks/partials/priorityLabel.vue index f56dfde5..380d711b 100644 --- a/src/components/tasks/partials/priorityLabel.vue +++ b/src/components/tasks/partials/priorityLabel.vue @@ -21,7 +21,7 @@ diff --git a/src/models/abstractModel.ts b/src/models/abstractModel.ts index fbf074e2..7507265b 100644 --- a/src/models/abstractModel.ts +++ b/src/models/abstractModel.ts @@ -1,12 +1,13 @@ import {objectToCamelCase} from '@/helpers/case' import {omitBy, isNil} from '@/helpers/utils' +import type {Right} from '@/models/constants/rights' export default class AbstractModel { /** * The max right the user has on this object, as returned by the x-max-right header from the api. */ - maxRight: number | null = null + maxRight: Right | null = null /** * The abstract constructor takes an object and merges its data with the default data of this model. diff --git a/src/models/constants/notificationNames.json b/src/models/constants/notificationNames.json deleted file mode 100644 index 62260fe3..00000000 --- a/src/models/constants/notificationNames.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "TASK_COMMENT": "task.comment", - "TASK_ASSIGNED": "task.assigned", - "TASK_DELETED": "task.deleted", - "LIST_CREATED": "list.created", - "TEAM_MEMBER_ADDED": "team.member.added" -} \ No newline at end of file diff --git a/src/models/constants/priorities.json b/src/models/constants/priorities.json deleted file mode 100644 index c38b195d..00000000 --- a/src/models/constants/priorities.json +++ /dev/null @@ -1,8 +0,0 @@ -{ -"UNSET": 0, -"LOW": 1, -"MEDIUM": 2, -"HIGH": 3, -"URGENT": 4, -"DO_NOW": 5 -} \ No newline at end of file diff --git a/src/models/constants/priorities.ts b/src/models/constants/priorities.ts new file mode 100644 index 00000000..b3cf85cb --- /dev/null +++ b/src/models/constants/priorities.ts @@ -0,0 +1,8 @@ +export const PRIORITIES = { + 'UNSET': 0, + 'LOW': 1, + 'MEDIUM': 2, + 'HIGH': 3, + 'URGENT': 4, + 'DO_NOW': 5, +} as const \ No newline at end of file diff --git a/src/models/constants/relationKinds.json b/src/models/constants/relationKinds.json deleted file mode 100644 index 4b3c2e51..00000000 --- a/src/models/constants/relationKinds.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - "subtask", - "parenttask", - "related", - "duplicates", - "blocking", - "blocked", - "precedes", - "follows", - "copiedfrom", - "copiedto" -] \ No newline at end of file diff --git a/src/models/constants/rights.json b/src/models/constants/rights.json deleted file mode 100644 index 61e6b145..00000000 --- a/src/models/constants/rights.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "READ": 0, - "READ_WRITE": 1, - "ADMIN": 2 -} \ No newline at end of file diff --git a/src/models/constants/rights.ts b/src/models/constants/rights.ts new file mode 100644 index 00000000..1c2aeb70 --- /dev/null +++ b/src/models/constants/rights.ts @@ -0,0 +1,7 @@ +export const RIGHTS = { + 'READ': 0, + 'READ_WRITE': 1, + 'ADMIN': 2, +} as const + +export type Right = typeof RIGHTS[keyof typeof RIGHTS] \ No newline at end of file diff --git a/src/models/constants/taskRepeatModes.json b/src/models/constants/taskRepeatModes.json deleted file mode 100644 index 7d172950..00000000 --- a/src/models/constants/taskRepeatModes.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "REPEAT_MODE_DEFAULT": 0, - "REPEAT_MODE_MONTH": 1, - "REPEAT_MODE_FROM_CURRENT_DATE": 2 -} \ No newline at end of file diff --git a/src/models/linkShare.ts b/src/models/linkShare.ts index 2d6b4ab1..a0c47577 100644 --- a/src/models/linkShare.ts +++ b/src/models/linkShare.ts @@ -1,5 +1,6 @@ import AbstractModel from './abstractModel' import UserModel from './user' +import {RIGHTS, type Right} from '@/models/constants/rights' export default class LinkShareModel extends AbstractModel { id: number @@ -28,7 +29,7 @@ export default class LinkShareModel extends AbstractModel { return { id: 0, hash: '', - right: 0, + right: RIGHTS.READ, sharedBy: UserModel, sharingType: 0, listId: 0, diff --git a/src/models/team.ts b/src/models/team.ts index 05285ca1..c4e894f6 100644 --- a/src/models/team.ts +++ b/src/models/team.ts @@ -1,6 +1,7 @@ import AbstractModel from './abstractModel' import UserModel from './user' import TeamMemberModel from './teamMember' +import {RIGHTS, type Right} from '@/models/constants/rights' export default class TeamModel extends AbstractModel { id: 0 @@ -32,7 +33,7 @@ export default class TeamModel extends AbstractModel { name: '', description: '', members: [], - right: 0, + right: RIGHTS.READ, createdBy: {}, created: null, diff --git a/src/models/teamShareBase.ts b/src/models/teamShareBase.ts index 84e0373b..88060c91 100644 --- a/src/models/teamShareBase.ts +++ b/src/models/teamShareBase.ts @@ -1,6 +1,6 @@ import AbstractModel from './abstractModel' import type TeamModel from './team' -import type {Right} from '@/models/constants/rights' +import {RIGHTS, type Right} from '@/models/constants/rights' /** * This class is a base class for common team sharing model. @@ -22,7 +22,7 @@ export default class TeamShareBaseModel extends AbstractModel { defaults() { return { teamId: 0, - right: 0, + right: RIGHTS.READ, created: null, updated: null, diff --git a/src/models/userShareBase.ts b/src/models/userShareBase.ts index 3d34ac3c..9ae20de1 100644 --- a/src/models/userShareBase.ts +++ b/src/models/userShareBase.ts @@ -1,6 +1,6 @@ import AbstractModel from './abstractModel' import type UserModel from './user' -import type {Right} from '@/models/constants/rights' +import {RIGHTS, type Right} from '@/models/constants/rights' export default class UserShareBaseModel extends AbstractModel { userId: UserModel['id'] @@ -18,7 +18,7 @@ export default class UserShareBaseModel extends AbstractModel { defaults() { return { userId: '', - right: 0, + right: RIGHTS.READ, created: null, updated: null, diff --git a/src/modules/parseTaskText.test.ts b/src/modules/parseTaskText.test.ts index 90208b88..dadb9ed0 100644 --- a/src/modules/parseTaskText.test.ts +++ b/src/modules/parseTaskText.test.ts @@ -3,7 +3,7 @@ import {beforeEach, afterEach, describe, it, expect, vi} from 'vitest' import {parseTaskText} from './parseTaskText' import {getDateFromText, getDateFromTextIn} from '../helpers/time/parseDate' import {calculateDayInterval} from '../helpers/time/calculateDayInterval' -import priorities from '../models/constants/priorities.json' +import {PRIORITIES} from '@/models/constants/priorities.ts' describe('Parse Task Text', () => { beforeEach(() => { @@ -571,12 +571,12 @@ describe('Parse Task Text', () => { }) describe('Priority', () => { - for (const p in priorities) { + for (const p in PRIORITIES) { it(`should parse priority ${p}`, () => { - const result = parseTaskText(`Lorem Ipsum !${priorities[p]}`) + const result = parseTaskText(`Lorem Ipsum !${PRIORITIES[p]}`) expect(result.text).toBe('Lorem Ipsum') - expect(result.priority).toBe(priorities[p]) + expect(result.priority).toBe(PRIORITIES[p]) }) } it(`should not parse an invalid priority`, () => { diff --git a/src/modules/parseTaskText.ts b/src/modules/parseTaskText.ts index 80c33e3d..c3c8ad7d 100644 --- a/src/modules/parseTaskText.ts +++ b/src/modules/parseTaskText.ts @@ -1,5 +1,5 @@ import {parseDate} from '../helpers/time/parseDate' -import _priorities from '../models/constants/priorities.json' +import {PRIORITIES} from '@/models/constants/priorities' const VIKUNJA_PREFIXES: Prefixes = { label: '*', @@ -27,16 +27,7 @@ export const PREFIXES = { [PrefixMode.Todoist]: TODOIST_PREFIXES, } -const priorities: Priorites = _priorities - -interface Priorites { - UNSET: number, - LOW: number, - MEDIUM: number, - HIGH: number, - URGENT: number, - DO_NOW: number, -} +const priorities = PRIORITIES enum RepeatType { Hours = 'hours', diff --git a/src/views/list/ListKanban.vue b/src/views/list/ListKanban.vue index 447d849e..fc17a243 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 from '../../models/constants/rights.json' +import {RIGHTS as Rights} from '@/models/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 c94caf30..eb0c58c5 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 from '../../models/constants/rights.json' +import {RIGHTS as Rights} from '@/models/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' diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue index 02aec44a..33ed7059 100644 --- a/src/views/tasks/TaskDetailView.vue +++ b/src/views/tasks/TaskDetailView.vue @@ -427,8 +427,8 @@ import {defineComponent} from 'vue' import TaskService from '../../services/task' import TaskModel from '../../models/task' -import priorites from '../../models/constants/priorities.json' -import rights from '../../models/constants/rights.json' +import { PRIORITIES as priorites } from '@/models/constants/priorities' +import {RIGHTS as rights} from '@/models/constants/rights' import PrioritySelect from '../../components/tasks/partials/prioritySelect.vue' import PercentDoneSelect from '../../components/tasks/partials/percentDoneSelect.vue' @@ -520,7 +520,6 @@ export default defineComponent({ // Used to avoid flashing of empty elements if the task content is not yet loaded. visible: false, - priorities: priorites, activeFields: { assignees: false, priority: false, diff --git a/src/views/teams/EditTeam.vue b/src/views/teams/EditTeam.vue index b5ccd729..8496d2f5 100644 --- a/src/views/teams/EditTeam.vue +++ b/src/views/teams/EditTeam.vue @@ -172,7 +172,7 @@ import TeamMemberService from '../../services/teamMember' import type TeamMemberModel from '../../models/teamMember' import type UserModel from '../../models/user' import UserService from '../../services/user' -import Rights from '../../models/constants/rights.json' +import {RIGHTS as Rights} from '@/models/constants/rights' import Multiselect from '@/components/input/multiselect.vue' import {useRoute, useRouter} from 'vue-router'