Compare commits

..

28 Commits

Author SHA1 Message Date
Dominik Pschenitschni 4bc5666101
fix: createNewTask typing
continuous-integration/drone/pr Build is failing Details
2022-07-21 19:22:36 +02:00
Dominik Pschenitschni 9116ab2ed4
fix: merge duplicate types 2022-07-21 19:16:13 +02:00
Dominik Pschenitschni 66eeb174f8
fix: use correct model for generics 2022-07-21 18:56:31 +02:00
Dominik Pschenitschni fd659535ef
feat: improve store typing 2022-07-21 18:46:07 +02:00
Dominik Pschenitschni a6e5154f24
feat: extend mode interface from class instead from interface 2022-07-21 18:35:37 +02:00
Dominik Pschenitschni 2ec00f9ca0
fix: add lodash.clonedeep types 2022-07-21 19:33:02 +02:00
Dominik Pschenitschni 759b84d0f4
feat: use lib ESNext setting for typescript 2022-07-21 19:33:02 +02:00
Dominik Pschenitschni 4622c39c00
feat: improve store and model typing 2022-07-21 19:33:01 +02:00
Dominik Pschenitschni bb47ce2589
feat: improve types 2022-07-21 19:31:39 +02:00
Dominik Pschenitschni 098aa4c0dd
chore: better variable typing 2022-07-21 19:31:38 +02:00
Dominik Pschenitschni aaf426c166
chore: remove unnecessary defineComponent 2022-07-21 19:30:54 +02:00
Dominik Pschenitschni 006603b09c
chore: remove global mixing 2022-07-21 19:30:54 +02:00
Dominik Pschenitschni 686423b718
chore: remove date mixins 2022-07-21 19:30:54 +02:00
Dominik Pschenitschni 096149cc3e
feat: function attribute typing 2022-07-21 19:30:54 +02:00
Dominik Pschenitschni 4d0dda37f6
feat: constants 2022-07-21 19:30:53 +02:00
Dominik Pschenitschni bb584254d4
chore: improve type imports 2022-07-21 19:15:08 +02:00
Dominik Pschenitschni c0e874b8e3
feat: add properties to models 2022-07-21 19:15:08 +02:00
Dominik Pschenitschni b8d77671fa
feat: convert abstractService to ts 2022-07-21 19:15:07 +02:00
kolaente 4666087aa9
feat: add issue template
continuous-integration/drone/push Build is passing Details
Resolves #2177

(cherry picked from commit 5442306b7cf2b1e2e68c57cb9b3a464c31565fe6)
2022-07-21 16:49:21 +02:00
kolaente 56147dc9fb
fix: transition error when deleting a task
continuous-integration/drone/push Build is passing Details
2022-07-21 16:14:12 +02:00
kolaente ff48178051
fix: general user settings empty when loading the settings page
continuous-integration/drone/push Build is failing Details
Resolves #2183
2022-07-21 16:11:45 +02:00
kolaente cb3f269937
fix(kanban): reset loading state after creating a task
continuous-integration/drone/push Build is passing Details
Resolves: #2184
2022-07-21 15:57:03 +02:00
kolaente 4c560f1a03
fix: don't try to load lists after logging out
continuous-integration/drone/push Build is failing Details
Resolves #329
2022-07-21 15:53:15 +02:00
renovate 0fe2a16a7c fix(deps): update dependency @github/hotkey to v2.0.1 (#2182)
continuous-integration/drone/push Build is passing Details
Reviewed-on: #2182
Co-authored-by: renovate <renovatebot@kolaente.de>
Co-committed-by: renovate <renovatebot@kolaente.de>
2022-07-21 13:35:54 +00:00
kolaente 9cebf5305a
feat: allow for easy reset of a repeating amount
continuous-integration/drone/push Build is passing Details
Resolves #2179
2022-07-21 15:10:48 +02:00
kolaente 71c8540c74
fix: don't allow negative repeat amounts
continuous-integration/drone/push Build is passing Details
Partial fix for #2179
2022-07-21 15:06:17 +02:00
kolaente 8183fce829
fix: user menu dropdown
continuous-integration/drone/push Build is passing Details
#2178
2022-07-21 14:08:14 +02:00
kolaente 3becf8738b
fix: logo spacing for link shares
continuous-integration/drone/push Build is passing Details
Resolves #1142
2022-07-21 01:00:21 +02:00
158 changed files with 1367 additions and 675 deletions

44
.gitea/issue_template.md Normal file
View File

@ -0,0 +1,44 @@
<!--
Please fill out this issue template to report a bug.
If you want to propose a new feature, please open a discussion thread in the forum: https://community.vikunja.io
-->
**Version information:**
Frontend Version:
API Version:
Browser and OS Version:
**Steps to reproduce:**
<!--
Add clear steps to reproduce the bug. Provide screenshots where applicable.
-->
1.
2.
...
**Expected behavior:**
<!--
Describe what happened.
-->
**Actual behavior:**
<!--
Describe what happened instead.
-->
**Checklist:**
* [ ] I have provided all required information
* [ ] I am using the latest release or the latest unstable build
* [ ] I was able to reproduce the bug on [try](https://try.vikunja.io)

View File

@ -18,11 +18,12 @@
"browserslist:update": "npx browserslist@latest --update-db"
},
"dependencies": {
"@github/hotkey": "2.0.0",
"@github/hotkey": "2.0.1",
"@kyvg/vue3-notification": "2.3.5",
"@sentry/tracing": "7.7.0",
"@sentry/vue": "7.7.0",
"@types/is-touch-device": "1.0.0",
"@types/lodash.clonedeep": "^4.5.7",
"@types/sortablejs": "1.13.0",
"@vueuse/core": "8.9.4",
"@vueuse/router": "8.9.4",

View File

@ -18,7 +18,7 @@
import {computed, watch, type Ref} from 'vue'
import {useRouter} from 'vue-router'
import {useRouteQuery} from '@vueuse/router'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useI18n} from 'vue-i18n'
import isTouchDevice from 'is-touch-device'
import {success} from '@/message'

View File

@ -71,7 +71,7 @@
<script lang="ts" setup>
import {computed, ref, watch} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useI18n} from 'vue-i18n'
import flatPickr from 'vue-flatpickr-component'

View File

@ -11,7 +11,7 @@
<script setup lang="ts">
import {computed} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import BaseButton from '@/components/base/BaseButton.vue'

View File

@ -48,44 +48,38 @@
</x-button>
</template>
<BaseButton
<dropdown-item
:to="{name: 'user.settings'}"
class="dropdown-item"
>
{{ $t('user.settings.title') }}
</BaseButton>
<BaseButton
</dropdown-item>
<dropdown-item
v-if="imprintUrl"
:href="imprintUrl"
class="dropdown-item"
>
{{ $t('navigation.imprint') }}
</BaseButton>
<BaseButton
</dropdown-item>
<dropdown-item
v-if="privacyPolicyUrl"
:href="privacyPolicyUrl"
class="dropdown-item"
>
{{ $t('navigation.privacy') }}
</BaseButton>
<BaseButton
</dropdown-item>
<dropdown-item
@click="$store.commit('keyboardShortcutsActive', true)"
class="dropdown-item"
>
{{ $t('keyboardShortcuts.title') }}
</BaseButton>
<BaseButton
</dropdown-item>
<dropdown-item
:to="{name: 'about'}"
class="dropdown-item"
>
{{ $t('about.title') }}
</BaseButton>
<BaseButton
</dropdown-item>
<dropdown-item
@click="logout()"
class="dropdown-item"
>
{{ $t('user.auth.logout') }}
</BaseButton>
</dropdown-item>
</dropdown>
</div>
</div>
@ -94,7 +88,7 @@
<script setup lang="ts">
import {ref, computed, onMounted, nextTick} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useRouter} from 'vue-router'
import {QUICK_ACTIONS_ACTIVE} from '@/store/mutation-types'
@ -103,6 +97,7 @@ import {RIGHTS as Rights} from '@/models/constants/rights'
import Update from '@/components/home/update.vue'
import ListSettingsDropdown from '@/components/list/list-settings-dropdown.vue'
import Dropdown from '@/components/misc/dropdown.vue'
import DropdownItem from '@/components/misc/dropdown-item.vue'
import Notifications from '@/components/notifications/notifications.vue'
import Logo from '@/components/home/Logo.vue'
import BaseButton from '@/components/base/BaseButton.vue'

View File

@ -61,7 +61,7 @@
<script lang="ts" setup>
import {watch, computed, shallowRef, watchEffect, type VNode, h} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useRoute, useRouter} from 'vue-router'
import {useEventListener} from '@vueuse/core'

View File

@ -6,7 +6,7 @@
>
<div class="container has-text-centered link-share-view">
<div class="column is-10 is-offset-1">
<Logo class="logo" />
<Logo class="logo"/>
<h1
:style="{ 'opacity': currentList.title === '' ? '0': '1' }"
class="title">
@ -14,7 +14,7 @@
</h1>
<div class="box has-text-left view">
<router-view/>
<PoweredByLink />
<PoweredByLink/>
</div>
</div>
</div>
@ -23,7 +23,7 @@
<script lang="ts" setup>
import {computed} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import Logo from '@/components/home/Logo.vue'
import PoweredByLink from './PoweredByLink.vue'
@ -35,14 +35,15 @@ const background = computed(() => store.state.background)
<style lang="scss" scoped>
.link-share-container.has-background .view {
background-color: transparent;
border: none;
background-color: transparent;
border: none;
}
.logo {
max-width: 300px;
width: 90%;
margin: 2rem 0 1.5rem;
height: 100px;
}
.column {
@ -55,6 +56,6 @@ const background = computed(() => store.state.background)
// FIXME: this should be defined somewhere deep
.link-share-view .card {
background-color: var(--white);
background-color: var(--white);
}
</style>

View File

@ -141,7 +141,7 @@
<script setup lang="ts">
import {ref, computed, onMounted, onBeforeMount} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import draggable from 'zhyswan-vuedraggable'
import type {SortableEvent} from 'sortablejs'
@ -156,8 +156,8 @@ import {calculateItemPosition} from '@/helpers/calculateItemPosition'
import {getNamespaceTitle} from '@/helpers/getNamespaceTitle'
import {getListTitle} from '@/helpers/getListTitle'
import {useEventListener} from '@vueuse/core'
import type NamespaceModel from '@/models/namespace'
import type ListModel from '@/models/list'
import type { IList } from '@/models/list'
import type { INamespace } from '@/models/namespace'
const drag = ref(false)
const dragOptions = {
@ -172,7 +172,7 @@ const loading = computed(() => store.state.loading && store.state.loadingModule
const namespaces = computed(() => {
return (store.state.namespaces.namespaces as NamespaceModel[]).filter(n => !n.isArchived)
return (store.state.namespaces.namespaces as INamespace[]).filter(n => !n.isArchived)
})
const activeLists = computed(() => {
return namespaces.value.map(({lists}) => {
@ -195,7 +195,7 @@ useEventListener('resize', resize)
onMounted(() => resize())
function toggleFavoriteList(list: ListModel) {
function toggleFavoriteList(list: IList) {
// The favorites pseudo list is always favorite
// Archived lists cannot be marked favorite
if (list.id === -1 || list.isArchived) {
@ -209,14 +209,14 @@ function resize() {
store.commit(MENU_ACTIVE, window.innerWidth >= 770)
}
function toggleLists(namespaceId: NamespaceModel['id']) {
function toggleLists(namespaceId: INamespace['id']) {
listsVisible.value[namespaceId] = !listsVisible.value[namespaceId]
}
const listsVisible = ref<{ [id: NamespaceModel['id']]: boolean }>({})
const listsVisible = ref<{ [id: INamespace['id']]: boolean }>({})
// FIXME: async action will be unfinished when component mounts
onBeforeMount(async () => {
const namespaces = await store.dispatch('namespaces/loadNamespaces') as NamespaceModel[]
const namespaces = await store.dispatch('namespaces/loadNamespaces') as INamespace[]
namespaces.forEach(n => {
if (typeof listsVisible.value[n.id] === 'undefined') {
listsVisible.value[n.id] = true
@ -224,7 +224,7 @@ onBeforeMount(async () => {
})
})
function updateActiveLists(namespace: NamespaceModel, activeLists: ListModel[]) {
function updateActiveLists(namespace: INamespace, activeLists: IList[]) {
// This is a bit hacky: since we do have to filter out the archived items from the list
// for vue draggable updating it is not as simple as replacing it.
// To work around this, we merge the active lists with the archived ones. Doing so breaks the order
@ -241,7 +241,7 @@ function updateActiveLists(namespace: NamespaceModel, activeLists: ListModel[])
})
}
const listUpdating = ref<{ [id: NamespaceModel['id']]: boolean }>({})
const listUpdating = ref<{ [id: INamespace['id']]: boolean }>({})
async function saveListPosition(e: SortableEvent) {
if (!e.newIndex) return

View File

@ -76,24 +76,24 @@
</template>
<script setup lang="ts">
import {ref, computed, watchEffect} from 'vue'
import {useStore} from 'vuex'
import {ref, computed, watchEffect, type PropType} from 'vue'
import {useStore} from '@/store'
import {getSavedFilterIdFromListId} from '@/helpers/savedFilter'
import Dropdown from '@/components/misc/dropdown.vue'
import DropdownItem from '@/components/misc/dropdown-item.vue'
import TaskSubscription from '@/components/misc/subscription.vue'
import ListModel from '@/models/list'
import type SubscriptionModel from '@/models/subscription'
import type {IList} from '@/models/list'
import type { ISubscription } from '@/models/subscription'
const props = defineProps({
list: {
type: ListModel,
type: Object as PropType<IList>,
required: true,
},
})
const subscription = ref<SubscriptionModel | null>(null)
const subscription = ref<ISubscription | null>(null)
watchEffect(() => {
subscription.value = props.list.subscription ?? null
})

View File

@ -37,15 +37,15 @@
<script lang="ts" setup>
import {type PropType, ref, watch} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import ListService from '@/services/list'
import {getBlobFromBlurHash} from '@/helpers/getBlobFromBlurHash'
import {colorIsDark} from '@/helpers/color/colorIsDark'
import type ListModel from '@/models/list'
import BaseButton from '@/components/base/BaseButton.vue'
import type { IList } from '@/models/list'
const background = ref<string | null>(null)
const backgroundLoading = ref(false)
@ -53,7 +53,7 @@ const blurHashUrl = ref('')
const props = defineProps({
list: {
type: Object as PropType<ListModel>,
type: Object as PropType<IList>,
required: true,
},
showArchived: {
@ -86,7 +86,7 @@ async function loadBackground() {
const store = useStore()
function toggleFavoriteList(list: ListModel) {
function toggleFavoriteList(list: IList) {
// The favorites pseudo list is always favorite
// Archived lists cannot be marked favorite
if (list.id === -1 || list.isArchived) {

View File

@ -33,7 +33,7 @@
</template>
<script lang="ts" setup>
import {useStore} from 'vuex'
import {useStore} from '@/store'
import Shortcut from '@/components/misc/shortcut.vue'
import Message from '@/components/misc/message.vue'

View File

@ -8,7 +8,7 @@
<script lang="ts" setup>
import {computed} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import BaseButton from '@/components/base/BaseButton.vue'

View File

@ -30,7 +30,7 @@ import Logo from '@/components/home/Logo.vue'
import Message from '@/components/misc/message.vue'
import Legal from '@/components/misc/legal.vue'
import ApiConfig from '@/components/misc/api-config.vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {computed} from 'vue'
import {useRoute} from 'vue-router'
import {useI18n} from 'vue-i18n'

View File

@ -42,7 +42,7 @@
<script lang="ts" setup>
import {ref, computed} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import Logo from '@/assets/logo.svg?component'
import ApiConfig from '@/components/misc/api-config.vue'

View File

@ -39,7 +39,7 @@ import BaseButton from '@/components/base/BaseButton.vue'
import DropdownItem from '@/components/misc/dropdown-item.vue'
import SubscriptionService from '@/services/subscription'
import SubscriptionModel from '@/models/subscription'
import SubscriptionModel, { type ISubscription } from '@/models/subscription'
import {success} from '@/message'
@ -51,7 +51,7 @@ const props = defineProps({
default: true,
},
subscription: {
type: Object as PropType<SubscriptionModel>,
type: Object as PropType<ISubscription>,
default: null,
},
type: {

View File

@ -54,15 +54,16 @@
</template>
<script setup lang="ts">
import {ref, onMounted} from 'vue'
import {ref, onMounted, type PropType} from 'vue'
import Dropdown from '@/components/misc/dropdown.vue'
import DropdownItem from '@/components/misc/dropdown-item.vue'
import TaskSubscription from '@/components/misc/subscription.vue'
import type { INamespace } from '@/models/namespace'
const props = defineProps({
namespace: {
type: Object, // NamespaceModel
type: Object as PropType<INamespace>,
required: true,
},
})

View File

@ -52,9 +52,9 @@ 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 NotificationModel, { NOTIFICATION_NAMES as names} from '@/models/notification'
import { NOTIFICATION_NAMES as names, type INotification} from '@/models/notification'
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useRouter} from 'vue-router'
import {formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
@ -63,7 +63,7 @@ const LOAD_NOTIFICATIONS_INTERVAL = 10000
const store = useStore()
const router = useRouter()
const allNotifications = ref<NotificationModel[]>([])
const allNotifications = ref<INotification[]>([])
const showNotifications = ref(false)
const popup = ref(null)

View File

@ -177,17 +177,17 @@
<script setup lang="ts">
import {ref, watch, computed, shallowReactive} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useI18n} from 'vue-i18n'
import {RIGHTS} from '@/models/constants/rights'
import LinkShareModel from '@/models/linkShare'
import type ListModel from '@/models/list'
import LinkShareModel, { type ILinkShare } from '@/models/linkShare'
import LinkShareService from '@/services/linkShare'
import {useCopyToClipboard} from '@/composables/useCopyToClipboard'
import {success} from '@/message'
import type { IList } from '@/models/list'
const props = defineProps({
listId: {
@ -198,7 +198,7 @@ const props = defineProps({
const {t} = useI18n({useScope: 'global'})
const linkShares = ref<LinkShareModel[]>([])
const linkShares = ref<ILinkShare[]>([])
const linkShareService = shallowReactive(new LinkShareService())
const selectedRight = ref(RIGHTS.READ)
const name = ref('')
@ -217,7 +217,7 @@ watch(
const store = useStore()
const frontendUrl = computed(() => store.state.config.frontendUrl)
async function load(listId: ListModel['id']) {
async function load(listId: IList['id']) {
// If listId == 0 the list on the calling component wasn't already loaded, so we just bail out here
if (listId === 0) {
return
@ -226,7 +226,7 @@ async function load(listId: ListModel['id']) {
linkShares.value = await linkShareService.getAll({listId})
}
async function add(listId: ListModel['id']) {
async function add(listId: IList['id']) {
const newLinkShare = new LinkShareModel({
right: selectedRight.value,
listId,
@ -242,7 +242,7 @@ async function add(listId: ListModel['id']) {
await load(listId)
}
async function remove(listId: ListModel['id']) {
async function remove(listId: IList['id']) {
try {
await linkShareService.delete(new LinkShareModel({
id: linkIdToDelete.value,

View File

@ -139,22 +139,26 @@ export default {name: 'userTeamShare'}
<script setup lang="ts">
import {ref, reactive, computed, shallowReactive, type ShallowReactive, type Ref} from 'vue'
import type {PropType} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useI18n} from 'vue-i18n'
import UserNamespaceService from '@/services/userNamespace'
import UserNamespaceModel from '@/models/userNamespace'
import UserListModel from '@/models/userList'
import UserNamespaceModel, { type IUserNamespace } from '@/models/userNamespace'
import UserListService from '@/services/userList'
import UserListModel, { type IUserList } from '@/models/userList'
import UserService from '@/services/user'
import UserModel from '@/models/user'
import UserModel, { type IUser } from '@/models/user'
import TeamNamespaceService from '@/services/teamNamespace'
import TeamNamespaceModel from '@/models/teamNamespace'
import TeamListModel from '@/models/teamList'
import TeamNamespaceModel, { type ITeamNamespace } from '@/models/teamNamespace'
import TeamListService from '@/services/teamList'
import TeamListModel, { type ITeamList } from '@/models/teamList'
import TeamService from '@/services/team'
import TeamModel from '@/models/team'
import TeamModel, { type ITeam } from '@/models/team'
import {RIGHTS} from '@/models/constants/rights'
import Multiselect from '@/components/input/multiselect.vue'
@ -183,10 +187,10 @@ const props = defineProps({
const {t} = useI18n({useScope: 'global'})
// This user service is either a userNamespaceService or a userListService, depending on the type we are using
let stuffService: ShallowReactive<UserNamespaceService | UserListService | TeamListService | TeamNamespaceService>
let stuffModel: UserNamespaceModel | UserListModel | TeamListModel | TeamNamespaceModel
let searchService: ShallowReactive<UserService | TeamService>
let sharable: Ref<UserModel | TeamModel>
let stuffService: UserNamespaceService | UserListService | TeamListService | TeamNamespaceService
let stuffModel: IUserNamespace | IUserList | ITeamList | ITeamNamespace
let searchService: UserService | TeamService
let sharable: Ref<IUser | ITeam>
const searchLabel = ref('')
const selectedRight = ref({})

View File

@ -43,7 +43,7 @@
<script setup lang="ts">
import {ref, watch, unref, shallowReactive} from 'vue'
import {useI18n} from 'vue-i18n'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {tryOnMounted, debouncedWatch, useWindowSize, type MaybeRef} from '@vueuse/core'
import TaskService from '@/services/task'

View File

@ -76,14 +76,14 @@
</template>
<script setup lang="ts">
import {ref, reactive, computed, shallowReactive, watch, nextTick} from 'vue'
import {ref, reactive, computed, shallowReactive, watch, nextTick, type PropType} from 'vue'
import {useRouter} from 'vue-router'
import {useI18n} from 'vue-i18n'
import Editor from '@/components/input/AsyncEditor'
import TaskService from '@/services/task'
import TaskModel from '@/models/task'
import TaskModel, { type ITask } from '@/models/task'
import EditLabels from './partials/editLabels.vue'
import Reminders from './partials/reminders.vue'
import ColorPicker from '../input/colorPicker.vue'
@ -95,7 +95,7 @@ const router = useRouter()
const props = defineProps({
task: {
type: TaskModel,
type: Object as PropType<ITask>,
required: true,
},
})
@ -103,7 +103,7 @@ const props = defineProps({
const taskService = shallowReactive(new TaskService())
const editorActive = ref(false)
let taskEditTask: TaskModel | undefined
let taskEditTask: ITask | undefined
// FIXME: this initialization should not be necessary here

View File

@ -147,8 +147,7 @@
import {defineComponent} from 'vue'
import AttachmentService from '../../../services/attachment'
import AttachmentModel from '../../../models/attachment'
import type FileModel from '@/models/file'
import AttachmentModel, { type IAttachment } from '@/models/attachment'
import User from '@/components/misc/user.vue'
import {mapState} from 'vuex'
@ -157,6 +156,7 @@ import { uploadFiles, generateAttachmentUrl } from '@/helpers/attachments'
import {formatDate, formatDateSince, formatDateLong} from '@/helpers/time/formatDate'
import BaseButton from '@/components/base/BaseButton'
import type { IFile } from '@/models/file'
export default defineComponent({
name: 'attachments',
@ -192,7 +192,7 @@ export default defineComponent({
setup(props) {
const copy = useCopyToClipboard()
function copyUrl(attachment: AttachmentModel) {
function copyUrl(attachment: IAttachment) {
copy(generateAttachmentUrl(props.taskId, attachment.id))
}
@ -235,7 +235,7 @@ export default defineComponent({
formatDateSince,
formatDateLong,
downloadAttachment(attachment: AttachmentModel) {
downloadAttachment(attachment: IAttachment) {
this.attachmentService.download(attachment)
},
uploadNewAttachment() {
@ -245,7 +245,7 @@ export default defineComponent({
this.uploadFiles(this.$refs.files.files)
},
uploadFiles(files: FileModel[]) {
uploadFiles(files: IFile[]) {
uploadFiles(this.attachmentService, this.taskId, files)
},
async deleteAttachment() {

View File

@ -10,15 +10,15 @@
</template>
<script setup lang="ts">
import {computed} from 'vue'
import {computed, type PropType} from 'vue'
import { useI18n } from 'vue-i18n'
import {getChecklistStatistics} from '@/helpers/checklistFromText'
import TaskModel from '@/models/task'
import type {ITask} from '@/models/task'
const props = defineProps({
task: {
type: TaskModel,
type: Object as PropType<ITask>,
required: true,
},
})

View File

@ -153,18 +153,18 @@
<script setup lang="ts">
import {ref, reactive, computed, shallowReactive, watch, nextTick} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useI18n} from 'vue-i18n'
import Editor from '@/components/input/AsyncEditor'
import TaskCommentService from '@/services/taskComment'
import TaskCommentModel from '@/models/taskComment'
import TaskCommentModel, { type ITaskComment } from '@/models/taskComment'
import {uploadFile} from '@/helpers/attachments'
import {success} from '@/message'
import {formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
import type TaskModel from '@/models/task'
import type { ITask } from '@/models/task'
const props = defineProps({
taskId: {
type: Number,
@ -178,7 +178,7 @@ const props = defineProps({
const {t} = useI18n({useScope: 'global'})
const store = useStore()
const comments = ref<TaskCommentModel[]>([])
const comments = ref<ITaskComment[]>([])
const showDeleteModal = ref(false)
const commentToDelete = reactive(new TaskCommentModel())
@ -188,8 +188,8 @@ const commentEdit = reactive(new TaskCommentModel())
const newComment = reactive(new TaskCommentModel())
const saved = ref<TaskModel['id'] | null>(null)
const saving = ref<TaskModel['id'] | null>(null)
const saved = ref<ITask['id'] | null>(null)
const saving = ref<ITask['id'] | null>(null)
const userAvatar = computed(() => store.state.auth.info.getAvatarUrl(48))
const currentUserId = computed(() => store.state.auth.info.id)
@ -215,7 +215,7 @@ function attachmentUpload(...args) {
const taskCommentService = shallowReactive(new TaskCommentService())
async function loadComments(taskId: TaskModel['id']) {
async function loadComments(taskId: ITask['id']) {
if (!enabled.value) {
return
}
@ -259,12 +259,12 @@ async function addComment() {
}
}
function toggleEdit(comment: TaskCommentModel) {
function toggleEdit(comment: ITaskComment) {
isCommentEdit.value = !isCommentEdit.value
Object.assign(commentEdit, comment)
}
function toggleDelete(commentId: TaskCommentModel['id']) {
function toggleDelete(commentId: ITaskComment['id']) {
showDeleteModal.value = !showDeleteModal.value
commentToDelete.id = commentId
}
@ -294,7 +294,7 @@ async function editComment() {
}
}
async function deleteComment(commentToDelete: TaskCommentModel) {
async function deleteComment(commentToDelete: ITaskComment) {
try {
await taskCommentService.delete(commentToDelete)
const index = comments.value.findIndex(({id}) => id === commentToDelete.id)

View File

@ -27,13 +27,13 @@
</template>
<script lang="ts" setup>
import {computed, toRefs} from 'vue'
import TaskModel from '@/models/task'
import {computed, toRefs, type PropType} from 'vue'
import type { ITask } from '@/models/task'
import {formatISO, formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
const props = defineProps({
task: {
type: TaskModel,
type: Object as PropType<ITask>,
required: true,
},
})

View File

@ -38,17 +38,17 @@
</template>
<script setup lang="ts">
import {ref, shallowReactive, computed, watch, onMounted, onBeforeUnmount} from 'vue'
import {useStore} from 'vuex'
import {ref, shallowReactive, computed, watch, onMounted, onBeforeUnmount, type PropType} from 'vue'
import {useStore} from '@/store'
import {useI18n} from 'vue-i18n'
import flatPickr from 'vue-flatpickr-component'
import TaskService from '@/services/task'
import TaskModel from '@/models/task'
import { type ITask } from '@/models/task'
const props = defineProps({
modelValue: {
type: TaskModel,
type: Object as PropType<ITask>,
required: true,
},
})
@ -58,7 +58,7 @@ const {t} = useI18n({useScope: 'global'})
const store = useStore()
const taskService = shallowReactive(new TaskService())
const task = ref<TaskModel>()
const task = ref<ITask>()
// We're saving the due date seperately to prevent null errors in very short periods where the task is null.
const dueDate = ref<Date>()

View File

@ -30,17 +30,17 @@
</template>
<script setup lang="ts">
import {ref,computed, watch} from 'vue'
import {useStore} from 'vuex'
import {ref,computed, watch, type PropType} from 'vue'
import {useStore} from '@/store'
import Editor from '@/components/input/AsyncEditor'
import TaskModel from '@/models/task'
import type { ITask } from '@/models/task'
const props = defineProps({
modelValue: {
type: TaskModel,
type: Object as PropType<ITask>,
required: true,
},
attachmentUpload: {
@ -54,7 +54,7 @@ const props = defineProps({
const emit = defineEmits(['update:modelValue'])
const task = ref<TaskModel>({description: ''})
const task = ref<ITask>({description: ''})
const saved = ref(false)
// Since loading is global state, this variable ensures we're only showing the saving icon when saving the description.

View File

@ -29,7 +29,7 @@
<script setup lang="ts">
import {ref, shallowReactive, watch, type PropType} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useI18n} from 'vue-i18n'
import User from '@/components/misc/user.vue'
@ -37,9 +37,9 @@ import Multiselect from '@/components/input/multiselect.vue'
import BaseButton from '@/components/base/BaseButton.vue'
import {includesById} from '@/helpers/utils'
import type UserModel from '@/models/user'
import ListUserService from '@/services/listUsers'
import {success} from '@/message'
import type { IUser } from '@/models/user'
const props = defineProps({
taskId: {
@ -54,7 +54,7 @@ const props = defineProps({
default: false,
},
modelValue: {
type: Array as PropType<UserModel[]>,
type: Array as PropType<IUser[]>,
default: () => [],
},
})
@ -65,7 +65,7 @@ const {t} = useI18n({useScope: 'global'})
const listUserService = shallowReactive(new ListUserService())
const foundUsers = ref([])
const assignees = ref<UserModel[]>([])
const assignees = ref<IUser[]>([])
watch(
() => props.modelValue,
@ -78,13 +78,13 @@ watch(
},
)
async function addAssignee(user: UserModel) {
async function addAssignee(user: IUser) {
await store.dispatch('tasks/addAssignee', {user: user, taskId: props.taskId})
emit('update:modelValue', assignees.value)
success({message: t('task.assignee.assignSuccess')})
}
async function removeAssignee(user: UserModel) {
async function removeAssignee(user: IUser) {
await store.dispatch('tasks/removeAssignee', {user: user, taskId: props.taskId})
// Remove the assignee from the list

View File

@ -40,10 +40,10 @@
<script setup lang="ts">
import {type PropType, ref, computed, shallowReactive, watch} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useI18n} from 'vue-i18n'
import LabelModel from '@/models/label'
import LabelModel, { type ILabel } from '@/models/label'
import LabelTaskService from '@/services/labelTask'
import {success} from '@/message'
@ -52,7 +52,7 @@ import Multiselect from '@/components/input/multiselect.vue'
const props = defineProps({
modelValue: {
type: Array as PropType<LabelModel[]>,
type: Array as PropType<ILabel[]>,
default: () => [],
},
taskId: {
@ -71,7 +71,7 @@ const store = useStore()
const {t} = useI18n({useScope: 'global'})
const labelTaskService = shallowReactive(new LabelTaskService())
const labels = ref<LabelModel[]>([])
const labels = ref<ILabel[]>([])
const query = ref('')
watch(
@ -92,7 +92,7 @@ function findLabel(newQuery: string) {
query.value = newQuery
}
async function addLabel(label: LabelModel, showNotification = true) {
async function addLabel(label: ILabel, showNotification = true) {
const bubble = () => {
emit('update:modelValue', labels.value)
emit('change', labels.value)
@ -110,7 +110,7 @@ async function addLabel(label: LabelModel, showNotification = true) {
}
}
async function removeLabel(label: LabelModel) {
async function removeLabel(label: ILabel) {
if (props.taskId !== 0) {
await store.dispatch('tasks/removeLabel', {label, taskId: props.taskId})
}

View File

@ -32,18 +32,18 @@
</template>
<script setup lang="ts">
import {ref, computed} from 'vue'
import {useStore} from 'vuex'
import {ref, computed, type PropType} from 'vue'
import {useStore} from '@/store'
import BaseButton from '@/components/base/BaseButton.vue'
import Done from '@/components/misc/Done.vue'
import TaskModel from '@/models/task'
import type {ITask} from '@/models/task'
import { useRouter } from 'vue-router'
import { useCopyToClipboard } from '@/composables/useCopyToClipboard'
const props = defineProps({
task: {
type: TaskModel,
type: Object as PropType<ITask>,
required: true,
},
canWrite: {

View File

@ -74,7 +74,7 @@ import User from '../../../components/misc/user.vue'
import Done from '@/components/misc/Done.vue'
import Labels from '../../../components/tasks/partials/labels.vue'
import ChecklistSummary from './checklist-summary.vue'
import TaskModel, {TASK_DEFAULT_COLOR} from '@/models/task'
import {TASK_DEFAULT_COLOR, type ITask} from '@/models/task'
import {formatDateLong, formatISO, formatDateSince} from '@/helpers/time/formatDate'
import {colorIsDark} from '@/helpers/color/colorIsDark'
@ -96,7 +96,7 @@ export default defineComponent({
},
props: {
task: {
type: Object as PropType<TaskModel>,
type: Object as PropType<ITask>,
required: true,
},
loading: {
@ -117,7 +117,7 @@ export default defineComponent({
formatISO,
formatDateSince,
colorIsDark,
async toggleTaskDone(task: TaskModel) {
async toggleTaskDone(task: ITask) {
this.loadingInternal = true
try {
const done = !task.done

View File

@ -11,12 +11,12 @@
</template>
<script setup lang="ts">
import type LabelModel from '@/models/label'
import type { PropType } from 'vue'
import type { ILabel } from '@/models/label'
defineProps({
labels: {
type: Array as PropType<LabelModel[]>,
type: Array as PropType<ILabel[]>,
required: true,
},
})

View File

@ -19,17 +19,14 @@
<script lang="ts" setup>
import {reactive, ref, watch} from 'vue'
import type {PropType} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
import {useI18n} from 'vue-i18n'
import ListModel from '@/models/list'
import ListModel, { type IList } from '@/models/list'
import Multiselect from '@/components/input/multiselect.vue'
const props = defineProps({
modelValue: {
type: Object as PropType<ListModel>,
validator(value) {
return value instanceof ListModel
},
type: Object as PropType<IList>,
required: false,
},
})
@ -38,7 +35,7 @@ const emit = defineEmits(['update:modelValue'])
const store = useStore()
const {t} = useI18n({useScope: 'global'})
const list: ListModel= reactive(new ListModel())
const list: IList = reactive(new ListModel())
watch(
() => props.modelValue,
@ -57,7 +54,7 @@ function findLists(query: string) {
foundLists.value = store.getters['lists/searchList'](query)
}
function select(l: ListModel | null) {
function select(l: IList | null) {
Object.assign(list, l)
emit('update:modelValue', list)
}

View File

@ -1,9 +1,15 @@
<template>
<div class="control repeat-after-input">
<div class="buttons has-addons is-centered mt-2">
<x-button variant="secondary" class="is-small" @click="() => setRepeatAfter(1, 'days')">{{ $t('task.repeat.everyDay') }}</x-button>
<x-button variant="secondary" class="is-small" @click="() => setRepeatAfter(1, 'weeks')">{{ $t('task.repeat.everyWeek') }}</x-button>
<x-button variant="secondary" class="is-small" @click="() => setRepeatAfter(1, 'months')">{{ $t('task.repeat.everyMonth') }}</x-button>
<x-button variant="secondary" class="is-small" @click="() => setRepeatAfter(1, 'days')">
{{ $t('task.repeat.everyDay') }}
</x-button>
<x-button variant="secondary" class="is-small" @click="() => setRepeatAfter(1, 'weeks')">
{{ $t('task.repeat.everyWeek') }}
</x-button>
<x-button variant="secondary" class="is-small" @click="() => setRepeatAfter(1, 'months')">
{{ $t('task.repeat.everyMonth') }}
</x-button>
</div>
<div class="is-flex is-align-items-center mb-2">
<label for="repeatMode" class="is-fullwidth">
@ -32,6 +38,7 @@
:placeholder="$t('task.repeat.specifyAmount')"
v-model="repeatAfter.amount"
type="number"
min="0"
/>
</div>
<div class="control">
@ -56,12 +63,14 @@
<script setup lang="ts">
import {ref, reactive, watch, type PropType} from 'vue'
import {TASK_REPEAT_MODES, type RepeatAfter} from '@/models/task'
import type TaskModel from '@/models/task'
import {useI18n} from 'vue-i18n'
import {error} from '@/message'
import {TASK_REPEAT_MODES, type ITask, type RepeatAfter} from '@/models/task'
const props = defineProps({
modelValue: {
type: Object as PropType<TaskModel>,
type: Object as PropType<ITask>,
default: () => ({}),
required: true,
},
@ -71,9 +80,11 @@ const props = defineProps({
},
})
const {t} = useI18n()
const emit = defineEmits(['update:modelValue', 'change'])
const task = ref<TaskModel>()
const task = ref<ITask>()
const repeatAfter = reactive({
amount: 0,
type: '',
@ -94,7 +105,12 @@ function updateData() {
if (!task.value || task.value.repeatMode !== TASK_REPEAT_MODES.REPEAT_MODE_DEFAULT && repeatAfter.amount === 0) {
return
}
if (repeatAfter.amount < 0) {
error({message: t('task.repeat.invalidAmount')})
return
}
Object.assign(task.value.repeatAfter, repeatAfter)
emit('update:modelValue', task.value)
emit('change')

View File

@ -98,7 +98,7 @@
<script lang="ts">
import {defineComponent} from 'vue'
import TaskModel from '../../../models/task'
import TaskModel, { type ITask } from '../../../models/task'
import PriorityLabel from './priorityLabel.vue'
import TaskService from '../../../services/task'
import BaseButton from '@/components/base/BaseButton.vue'
@ -129,7 +129,7 @@ export default defineComponent({
},
props: {
theTask: {
type: TaskModel,
type: Object as PropType<ITask>,
required: true,
},
isArchived: {

View File

@ -1,5 +1,5 @@
import {ref, computed} from 'vue'
import {useStore} from 'vuex'
import {useStore} from '@/store'
export function useNameSpaceSearch() {
const query = ref('')

View File

@ -1,22 +1,27 @@
import AttachmentModel from '@/models/attachment'
import FileModel from '@/models/file'
import AttachmentModel, { type IAttachment } from '@/models/attachment'
import type {IFile} from '@/models/file'
import AttachmentService from '@/services/attachment'
import { store } from '@/store'
export function uploadFile(taskId: number, file: FileModel, onSuccess: () => Function) {
export function uploadFile(taskId: number, file: IFile, onSuccess: () => Function) {
const attachmentService = new AttachmentService()
const files = [file]
return uploadFiles(attachmentService, taskId, files, onSuccess)
}
export async function uploadFiles(attachmentService: AttachmentService, taskId: number, files: FileModel[], onSuccess : Function = () => {}) {
export async function uploadFiles(
attachmentService: AttachmentService,
taskId: number,
files: IFile[],
onSuccess: Function = () => {},
) {
const attachmentModel = new AttachmentModel({taskId})
const response = await attachmentService.create(attachmentModel, files)
console.debug(`Uploaded attachments for task ${taskId}, response was`, response)
response.success?.map((attachment: AttachmentModel) => {
response.success?.map((attachment: IAttachment) => {
store.dispatch('tasks/addTaskAttachment', {
taskId,
attachment,

View File

@ -1,8 +1,7 @@
import {i18n} from '@/i18n'
import type { IList } from '@/models/list'
import type ListModal from '@/models/list'
export function getListTitle(l: ListModal) {
export function getListTitle(l: IList) {
if (l.id === -1) {
return i18n.global.t('list.pseudo.favorites.title')
}

View File

@ -1,7 +1,7 @@
import {i18n} from '@/i18n'
import NamespaceModel from '@/models/namespace'
import type {INamespace} from '@/models/namespace'
export const getNamespaceTitle = (n: NamespaceModel) => {
export const getNamespaceTitle = (n: INamespace) => {
if (n.id === -1) {
return i18n.global.t('namespace.pseudo.sharedLists.title')
}

View File

@ -1,18 +1,10 @@
import {createNewIndexer} from '../indexes'
import type {LabelState} from '@/store/types'
import type {ILabel} from '@/models/label'
const {search} = createNewIndexer('labels', ['title', 'description'])
export interface label {
id: number,
title: string,
}
interface labelState {
labels: {
[k: number]: label,
},
}
/**
* Checks if a list of labels is available in the store and filters them then query
* @param {Object} state
@ -20,7 +12,7 @@ interface labelState {
* @param {String} query
* @returns {Array}
*/
export function filterLabelsByQuery(state: labelState, labelsToHide: label[], query: string) {
export function filterLabelsByQuery(state: LabelState, labelsToHide: ILabel[], query: string) {
const labelIdsToHide: number[] = labelsToHide.map(({id}) => id)
return search(query)
@ -36,6 +28,6 @@ export function filterLabelsByQuery(state: labelState, labelsToHide: label[], qu
* @param {Array} ids
* @returns {Array}
*/
export function getLabelsByIds(state: labelState, ids: number[]) {
export function getLabelsByIds(state: LabelState, ids: ILabel['id'][]) {
return Object.values(state.labels).filter(({id}) => ids.includes(id))
}

View File

@ -0,0 +1,6 @@
// https://stackoverflow.com/a/32108184/10924593
export function objectIsEmpty(obj: any): boolean {
return obj
&& Object.keys(obj).length === 0
&& Object.getPrototypeOf(obj) === Object.prototype
}

View File

@ -1,4 +1,4 @@
import ListModel from '@/models/list'
import type {IList} from '@/models/list'
const key = 'collapsedBuckets'
@ -11,7 +11,10 @@ const getAllState = () => {
return JSON.parse(saved)
}
export const saveCollapsedBucketState = (listId: ListModel['id'], collapsedBuckets) => {
export const saveCollapsedBucketState = (
listId: IList['id'],
collapsedBuckets,
) => {
const state = getAllState()
state[listId] = collapsedBuckets
for (const bucketId in state[listId]) {
@ -22,7 +25,7 @@ export const saveCollapsedBucketState = (listId: ListModel['id'], collapsedBucke
localStorage.setItem(key, JSON.stringify(state))
}
export const getCollapsedBucketState = (listId : ListModel['id']) => {
export const getCollapsedBucketState = (listId : IList['id']) => {
const state = getAllState()
if (typeof state[listId] !== 'undefined') {
return state[listId]

View File

@ -1,6 +1,6 @@
import ListModel from '@/models/list'
import type {IList} from '@/models/list'
export function getSavedFilterIdFromListId(listId: ListModel['id']) {
export function getSavedFilterIdFromListId(listId: IList['id']) {
let filterId = listId * -1 - 1
// FilterIds from listIds are always positive
if (filterId < 0) {

View File

@ -1,8 +1,8 @@
export function findIndexById(array : [], id : string | number) {
export function findIndexById<T extends {id: string | number}>(array : T[], id : string | number) {
return array.findIndex(({id: currentId}) => currentId === id)
}
export function findById(array : [], id : string | number) {
export function findById<T extends {id: string | number}>(array : T[], id : string | number) {
return array.find(({id: currentId}) => currentId === id)
}

View File

@ -783,7 +783,8 @@
"days": "Days",
"weeks": "Weeks",
"months": "Months",
"years": "Years"
"years": "Years",
"invalidAmount": "Please enter more than 0."
},
"quickAddMagic": {
"hint": "You can use Quick Add Magic",

View File

@ -14,7 +14,7 @@ import Notifications from '@kyvg/vue3-notification'
import './registerServiceWorker'
// Vuex
import {store} from './store'
import { store, key } from './store'
// i18n
import {i18n} from './i18n'
@ -104,7 +104,7 @@ if (window.SENTRY_ENABLED) {
import('./sentry').then(sentry => sentry.default(app, router))
}
app.use(store)
app.use(store, key) // pass the injection key
app.use(router)
app.use(i18n)

View File

@ -2,7 +2,11 @@ import {objectToCamelCase} from '@/helpers/case'
import {omitBy, isNil} from '@/helpers/utils'
import type {Right} from '@/models/constants/rights'
export default class AbstractModel {
export interface IAbstract {
maxRight: Right | null
}
export default class AbstractModel implements IAbstract {
/**
* The max right the user has on this object, as returned by the x-max-right header from the api.

View File

@ -1,12 +1,20 @@
import AbstractModel from './abstractModel'
import UserModel from './user'
import FileModel from './file'
import UserModel, {type IUser} from './user'
import FileModel, {type IFile} from './file'
export default class AttachmentModel extends AbstractModel {
export interface IAttachment extends AbstractModel {
id: number
taskId: number
createdBy: UserModel
file: FileModel
createdBy: IUser
file: IFile
created: Date
}
export default class AttachmentModel extends AbstractModel implements IAttachment {
declare id: number
declare taskId: number
createdBy: IUser
file: IFile
created: Date
constructor(data) {

View File

@ -1,9 +1,13 @@
import AbstractModel from './abstractModel'
export type AVATAR_PROVIDERS = 'default' | 'initials' | 'gravatar' | 'marble' | 'upload'
export type AvatarProvider = 'default' | 'initials' | 'gravatar' | 'marble' | 'upload'
export default class AvatarModel extends AbstractModel {
avatarProvider: AVATAR_PROVIDERS
export interface IAvatar extends AbstractModel {
avatarProvider: AvatarProvider
}
export default class AvatarModel extends AbstractModel implements IAvatar {
declare avatarProvider: AvatarProvider
defaults() {
return {

View File

@ -1,6 +1,6 @@
import AbstractModel from './abstractModel'
export default class BackgroundImageModel extends AbstractModel {
export interface IBackgroundImage extends AbstractModel {
id: number
url: string
thumb: string
@ -9,6 +9,17 @@ export default class BackgroundImageModel extends AbstractModel {
authorName: string
}
blurHash: string
}
export default class BackgroundImageModel extends AbstractModel implements IBackgroundImage {
declare id: number
declare url: string
declare thumb: string
declare info: {
author: string
authorName: string
}
declare blurHash: string
defaults() {
return {

View File

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

View File

@ -1,8 +1,13 @@
import AbstractModel from './abstractModel'
export default class CaldavTokenModel extends AbstractModel {
id: number
created: Date
export interface ICaldavToken extends AbstractModel {
id: number;
created: Date;
}
export default class CaldavTokenModel extends AbstractModel implements ICaldavToken {
declare id: number
declare created: Date
constructor(data? : Object) {
super(data)

View File

@ -1,8 +1,13 @@
import AbstractModel from './abstractModel'
export default class EmailUpdateModel extends AbstractModel {
interface IEmailUpdate extends AbstractModel {
newEmail: string
password: string
}
export default class EmailUpdateModel extends AbstractModel implements IEmailUpdate {
declare newEmail: string
declare password: string
defaults() {
return {

View File

@ -1,11 +1,19 @@
import AbstractModel from './abstractModel'
export default class FileModel extends AbstractModel {
export interface IFile extends AbstractModel {
id: number
mime: string
name: string
size: number
created: Date
}
export default class FileModel extends AbstractModel implements IFile {
declare id: number
declare mime: string
declare name: string
declare size: number
created: Date
constructor(data) {
super(data)

View File

@ -1,19 +1,33 @@
import AbstractModel from './abstractModel'
import UserModel from './user'
import UserModel, { type IUser } from './user'
import {colorIsDark} from '@/helpers/color/colorIsDark'
const DEFAULT_LABEL_BACKGROUND_COLOR = 'e8e8e8'
export default class LabelModel extends AbstractModel {
export interface ILabel extends AbstractModel {
id: number
title: string
hexColor: string
description: string
createdBy: UserModel
createdBy: IUser
listId: number
textColor: string
created: Date
updated: Date
}
export default class LabelModel extends AbstractModel implements ILabel {
declare id: number
declare title: string
declare hexColor: string
declare description: string
declare createdBy: IUser
declare listId: number
declare textColor: string
created: Date
updated: Date
constructor(data) {
super(data)

View File

@ -1,9 +1,15 @@
import AbstractModel from './abstractModel'
export default class LabelTask extends AbstractModel {
export interface ILabelTask extends AbstractModel {
id: number
taskId: number
labelId: number
}
export default class LabelTask extends AbstractModel implements ILabelTask {
declare id: number
declare taskId: number
declare labelId: number
defaults() {
return {

View File

@ -1,18 +1,31 @@
import AbstractModel from './abstractModel'
import UserModel from './user'
import UserModel, { type IUser } from './user'
import {RIGHTS, type Right} from '@/models/constants/rights'
export default class LinkShareModel extends AbstractModel {
export interface ILinkShare extends AbstractModel {
id: number
hash: string
right: Right
sharedBy: UserModel
sharedBy: IUser
sharingType: number // FIXME: use correct numbers
listId: number
name: string
password: string
created: Date
updated: Date
}
export default class LinkShareModel extends AbstractModel implements ILinkShare {
declare id: number
declare hash: string
declare right: Right
sharedBy: IUser
declare sharingType: number // FIXME: use correct numbers
declare listId: number
declare name: string
declare password: string
created: Date
updated: Date
constructor(data) {
// The constructor of AbstractModel handles all the default parsing.

View File

@ -1,28 +1,49 @@
import AbstractModel from './abstractModel'
import TaskModel from './task'
import UserModel from './user'
import type NamespaceModel from './namespace'
import {getSavedFilterIdFromListId} from '@/helpers/savedFilter'
import SubscriptionModel from '@/models/subscription'
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'
export default class ListModel extends AbstractModel {
import {getSavedFilterIdFromListId} from '@/helpers/savedFilter'
export interface IList extends AbstractModel {
id: number
title: string
description: string
owner: UserModel
tasks: TaskModel[]
namespaceId: NamespaceModel['id']
owner: IUser
tasks: ITask[]
namespaceId: INamespace['id']
isArchived: boolean
hexColor: string
identifier: string
backgroundInformation: any
isFavorite: boolean
subscription: SubscriptionModel
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 namespaceId: INamespace['id']
declare isArchived: boolean
declare hexColor: string
declare identifier: string
declare backgroundInformation: any
declare isFavorite: boolean
declare subscription: ISubscription
declare position: number
declare backgroundBlurHash: string
created: Date
updated: Date
constructor(data) {
super(data)

View File

@ -1,11 +1,17 @@
import AbstractModel from './abstractModel'
import ListModel from './list'
import NamespaceModel from './namespace'
import ListModel, { type IList } from './list'
import type { INamespace } from './namespace'
export default class ListDuplicateModel extends AbstractModel {
export interface IListDuplicate extends AbstractModel {
listId: number
namespaceId: NamespaceModel['id']
list: ListModel
namespaceId: INamespace['id']
list: IList
}
export default class ListDuplicateModel extends AbstractModel implements IListDuplicate {
declare listId: number
declare namespaceId: INamespace['id']
list: IList
constructor(data) {
super(data)

View File

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

View File

@ -1,10 +1,10 @@
import AbstractModel from '@/models/abstractModel'
import {parseDateOrNull} from '@/helpers/parseDateOrNull'
import UserModel from '@/models/user'
import TaskModel from '@/models/task'
import TaskCommentModel from '@/models/taskComment'
import UserModel, { type IUser } from '@/models/user'
import TaskModel, { type ITask } from '@/models/task'
import TaskCommentModel, { type ITaskComment } from '@/models/taskComment'
import ListModel from '@/models/list'
import TeamModel from '@/models/team'
import TeamModel, { type ITeam } from '@/models/team'
export const NOTIFICATION_NAMES = {
'TASK_COMMENT': 'task.comment',
@ -15,32 +15,32 @@ export const NOTIFICATION_NAMES = {
} as const
interface Notification {
doer: UserModel
doer: IUser
}
interface NotificationTask extends Notification {
task: TaskModel
comment: TaskCommentModel
task: ITask
comment: ITaskComment
}
interface NotificationAssigned extends Notification {
task: TaskModel
assignee: UserModel
task: ITask
assignee: IUser
}
interface NotificationDeleted extends Notification {
task: TaskModel
task: ITask
}
interface NotificationCreated extends Notification {
task: TaskModel
task: ITask
}
interface NotificationMemberAdded extends Notification {
member: UserModel
team: TeamModel
member: IUser
team: ITeam
}
export default class NotificationModel extends AbstractModel {
export interface INotification extends AbstractModel {
id: number
name: string
notification: NotificationTask | NotificationAssigned | NotificationDeleted | NotificationCreated | NotificationMemberAdded
@ -48,6 +48,16 @@ export default class NotificationModel extends AbstractModel {
readAt: Date | null
created: Date
}
export default class NotificationModel extends AbstractModel implements INotification {
declare id: number
declare name: string
declare notification: NotificationTask | NotificationAssigned | NotificationDeleted | NotificationCreated | NotificationMemberAdded
declare read: boolean
readAt: Date | null
created: Date
constructor(data) {
super(data)

View File

@ -1,9 +1,15 @@
import AbstractModel from './abstractModel'
export default class PasswordResetModel extends AbstractModel {
export interface IPasswordReset extends AbstractModel {
token: string
newPassword: string
email: string
}
export default class PasswordResetModel extends AbstractModel implements IPasswordReset {
token: string
declare newPassword: string
declare email: string
constructor(data) {
super(data)

View File

@ -1,8 +1,13 @@
import AbstractModel from './abstractModel'
import AbstractModel from '@/models/abstractModel'
export default class PasswordUpdateModel extends AbstractModel {
export interface IPasswordUpdate extends AbstractModel {
newPassword: string
oldPassword: string
}
export default class PasswordUpdateModel extends AbstractModel implements IPasswordUpdate {
declare newPassword: string
declare oldPassword: string
defaults() {
return {

View File

@ -1,7 +1,7 @@
import AbstractModel from '@/models/abstractModel'
import UserModel from '@/models/user'
import UserModel, { type IUser } from '@/models/user'
export default class SavedFilterModel extends AbstractModel {
export interface ISavedFilter extends AbstractModel {
id: 0
title: string
description: string
@ -15,7 +15,26 @@ export default class SavedFilterModel extends AbstractModel {
filterIncludeNulls: boolean
}
owner: any
owner: IUser
created: Date
updated: Date
}
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
}
owner: IUser
created: Date
updated: Date

View File

@ -1,11 +1,20 @@
import AbstractModel from '@/models/abstractModel'
import UserModel from '@/models/user'
import UserModel, { type IUser } from '@/models/user'
export default class SubscriptionModel extends AbstractModel {
export interface ISubscription extends AbstractModel {
id: number
entity: string // FIXME: correct type?
entityId: number // FIXME: correct type?
user: UserModel
user: IUser
created: Date
}
export default class SubscriptionModel extends AbstractModel implements ISubscription {
declare id: number
declare entity: string // FIXME: correct type?
declare entityId: number // FIXME: correct type?
user: IUser
created: Date

View File

@ -1,12 +1,15 @@
import AbstractModel from './abstractModel'
import UserModel from './user'
import LabelModel from './label'
import AttachmentModel from './attachment'
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 SubscriptionModel from '@/models/subscription'
import {parseDateOrNull} from '@/helpers/parseDateOrNull'
import type ListModel from './list'
import type { Priority } from './constants/priorities'
import type { IBucket } from './bucket'
const SUPPORTS_TRIGGERED_NOTIFICATION = 'Notification' in window && 'showTrigger' in Notification.prototype
export const TASK_DEFAULT_COLOR = '#1973ff'
@ -19,48 +22,82 @@ export const TASK_REPEAT_MODES = {
export type TaskRepeatMode = typeof TASK_REPEAT_MODES[keyof typeof TASK_REPEAT_MODES]
export interface RepeatAfter {
type: 'hours' | 'weeks' | 'months' | 'years' | 'days'
amount: number
}
export default class TaskModel extends AbstractModel {
export interface ITask extends AbstractModel {
id: number
title: string
description: string
done: boolean
doneAt: Date | null
priority: Priority
labels: LabelModel[]
assignees: UserModel[]
labels: ILabel[]
assignees: IUser[]
dueDate: Date | null
startDate: Date | null
endDate: Date | null
repeatAfter: number | RepeatAfter
repeatAfter: number | IRepeats
repeatFromCurrentDate: boolean
repeatMode: TaskRepeatMode
reminderDates: Date[]
parentTaskId: TaskModel['id']
parentTaskId: ITask['id']
hexColor: string
percentDone: number
relatedTasks: { [relationKind: string]: TaskModel } // FIXME: use relationKinds
attachments: AttachmentModel[]
relatedTasks: { [relationKind: string]: ITask } // FIXME: use relationKinds
attachments: IAttachment[]
identifier: string
index: number
isFavorite: boolean
subscription: SubscriptionModel
subscription: ISubscription
position: number
kanbanPosition: number
createdBy: UserModel
createdBy: IUser
created: Date
updated: Date
listId: ListModel['id'] // Meta, only used when creating a new task
listId: IList['id'] // Meta, only used when creating a new task
bucketId: IBucket['id']
}
constructor(data: Partial<TaskModel>) {
export default class TaskModel extends AbstractModel implements ITask {
id: number
title: string
declare description: string
declare done: boolean
doneAt: Date | null
declare priority: Priority
labels: ILabel[]
assignees: IUser[]
dueDate: Date | null
startDate: Date | null
endDate: Date | null
declare repeatAfter: number | IRepeats
declare repeatFromCurrentDate: boolean
declare repeatMode: TaskRepeatMode
reminderDates: Date[]
declare parentTaskId: ITask['id']
declare hexColor: string
declare percentDone: number
declare relatedTasks: { [relationKind: string]: ITask } // FIXME: use relationKinds
attachments: IAttachment[]
declare identifier: string
declare index: number
declare isFavorite: boolean
declare subscription: ISubscription
declare position: number
declare kanbanPosition: number
createdBy: IUser
created: Date
updated: Date
listId: IList['id'] // Meta, only used when creating a new task
declare bucketId: IBucket['id']
constructor(data: Partial<ITask>) {
super(data)
this.id = Number(this.id)
@ -157,6 +194,7 @@ export default class TaskModel extends AbstractModel {
updated: null,
listId: 0, // Meta, only used when creating a new task
bucketId: 0,
}
}

View File

@ -1,11 +1,17 @@
import AbstractModel from './abstractModel'
import type UserModel from './user'
import type TaskModel from './task'
import type { ITask } from './task'
import type { IUser } from './user'
export default class TaskAssigneeModel extends AbstractModel {
export interface ITaskAssignee extends AbstractModel {
created: Date
userId: UserModel['id']
taskId: TaskModel['id']
userId: IUser['id']
taskId: ITask['id']
}
export default class TaskAssigneeModel extends AbstractModel implements ITaskAssignee {
created: Date
declare userId: IUser['id']
declare taskId: ITask['id']
constructor(data) {
super(data)

View File

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

View File

@ -1,6 +1,6 @@
import AbstractModel from './abstractModel'
import UserModel from './user'
import type TaskModel from './task'
import UserModel, { type IUser } from './user'
import type { ITask } from './task'
export const RELATION_KIND = {
'SUBTASK': 'subtask',
@ -19,13 +19,23 @@ export const RELATION_KINDS = [...Object.values(RELATION_KIND)] as const
export type RelationKind = typeof RELATION_KINDS[number]
export default class TaskRelationModel extends AbstractModel {
export interface ITaskRelation extends AbstractModel {
id: number
otherTaskId: TaskModel['id']
taskId: TaskModel['id']
otherTaskId: ITask['id']
taskId: ITask['id']
relationKind: RelationKind
createdBy: UserModel
createdBy: IUser
created: Date
}
export default class TaskRelationModel extends AbstractModel implements ITaskRelation {
declare id: number
declare otherTaskId: ITask['id']
declare taskId: ITask['id']
declare relationKind: RelationKind
createdBy: IUser
created: Date
constructor(data) {

View File

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

View File

@ -1,8 +1,12 @@
import TeamShareBaseModel from './teamShareBase'
import type ListModel from './list'
import type { IList } from './list'
export default class TeamListModel extends TeamShareBaseModel {
listId: ListModel['id']
export interface ITeamList extends TeamShareBaseModel {
listId: IList['id']
}
export default class TeamListModel extends TeamShareBaseModel implements ITeamList {
declare listId: IList['id']
defaults() {
return {

View File

@ -1,9 +1,14 @@
import UserModel from './user'
import type ListModel from './list'
import type { IList } from './list'
export default class TeamMemberModel extends UserModel {
export interface ITeamMember extends UserModel {
admin: boolean
teamId: ListModel['id']
teamId: IList['id']
}
export default class TeamMemberModel extends UserModel implements ITeamMember {
declare admin: boolean
declare teamId: IList['id']
defaults() {
return {

View File

@ -1,8 +1,12 @@
import TeamShareBaseModel from './teamShareBase'
import type NamespaceModel from './namespace'
import type { INamespace } from './namespace'
export default class TeamNamespaceModel extends TeamShareBaseModel {
namespaceId: NamespaceModel['id']
export interface ITeamNamespace extends TeamShareBaseModel {
namespaceId: INamespace['id']
}
export default class TeamNamespaceModel extends TeamShareBaseModel implements ITeamNamespace {
declare namespaceId: INamespace['id']
defaults() {
return {

View File

@ -1,14 +1,22 @@
import AbstractModel from './abstractModel'
import type TeamModel from './team'
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
}
/**
* This class is a base class for common team sharing model.
* It is extended in a way so it can be used for namespaces as well for lists.
*/
export default class TeamShareBaseModel extends AbstractModel {
teamId: TeamModel['id']
right: Right
export default class TeamShareBaseModel extends AbstractModel implements ITeamShareBase {
declare teamId: ITeam['id']
declare right: Right
created: Date
updated: Date

View File

@ -1,9 +1,15 @@
import AbstractModel from './abstractModel'
export default class TotpModel extends AbstractModel {
export interface ITotp extends AbstractModel {
secret: string
enabled: boolean
url: string
}
export default class TotpModel extends AbstractModel implements ITotp{
declare secret: string
declare enabled: boolean
declare url: string
defaults() {
return {

View File

@ -1,7 +1,7 @@
import AbstractModel from './abstractModel'
import UserSettingsModel from '@/models/userSettings'
import UserSettingsModel, { type IUserSettings } from '@/models/userSettings'
export default class UserModel extends AbstractModel {
export interface IUser extends AbstractModel {
id: number
email: string
username: string
@ -9,7 +9,18 @@ export default class UserModel extends AbstractModel {
created: Date
updated: Date
settings: UserSettingsModel
settings: IUserSettings
}
export default class UserModel extends AbstractModel implements IUser {
declare id: number
declare email: string
declare username: string
declare name: string
created: Date
updated: Date
settings: IUserSettings
constructor(data) {
super(data)
@ -28,6 +39,7 @@ export default class UserModel extends AbstractModel {
email: '',
username: '',
name: '',
created: null,
updated: null,
settings: null,

View File

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

View File

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

View File

@ -1,16 +1,27 @@
import AbstractModel from './abstractModel'
import type ListModel from './list'
import type { IList } from './list'
export default class UserSettingsModel extends AbstractModel {
export interface IUserSettings extends AbstractModel {
name: string
emailRemindersEnabled: boolean
discoverableByName: boolean
discoverableByEmail: boolean
overdueTasksRemindersEnabled: boolean
defaultListId: undefined | ListModel['id']
defaultListId: undefined | IList['id']
weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6
timezone: string
}
export default class UserSettingsModel extends AbstractModel implements IUserSettings {
declare name: string
declare emailRemindersEnabled: boolean
declare discoverableByName: boolean
declare discoverableByEmail: boolean
declare overdueTasksRemindersEnabled: boolean
declare defaultListId: undefined | IList['id']
declare weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6
declare timezone: string
defaults() {
return {

View File

@ -1,13 +1,21 @@
import AbstractModel from './abstractModel'
import type UserModel from './user'
import {RIGHTS, type Right} from '@/models/constants/rights'
import type { IUser } from './user'
export default class UserShareBaseModel extends AbstractModel {
userId: UserModel['id']
export interface IUserShareBase extends AbstractModel {
userId: IUser['id']
right: Right
created: Date
updated: Date
}
export default class UserShareBaseModel extends AbstractModel implements IUserShareBase {
declare userId: IUser['id']
declare right: Right
created: Date
updated: Date
constructor(data) {
super(data)

View File

@ -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.ts'
import {PRIORITIES} from '@/models/constants/priorities'
describe('Parse Task Text', () => {
beforeEach(() => {

View File

@ -1,5 +1,6 @@
import {parseDate} from '../helpers/time/parseDate'
import {PRIORITIES} from '@/models/constants/priorities'
import {REPEAT_TYPES, type IRepeats, type RepeatType} from '@/types/IRepeats'
const VIKUNJA_PREFIXES: Prefixes = {
label: '*',
@ -27,24 +28,9 @@ export const PREFIXES = {
[PrefixMode.Todoist]: TODOIST_PREFIXES,
}
const priorities = PRIORITIES
enum RepeatType {
Hours = 'hours',
Days = 'days',
Weeks = 'weeks',
Months = 'months',
Years = 'years',
}
interface Repeats {
type: RepeatType,
amount: number,
}
interface repeatParsedResult {
textWithoutMatched: string,
repeats: Repeats | null,
repeats: IRepeats | null,
}
export interface ParsedTaskText {
@ -54,7 +40,7 @@ export interface ParsedTaskText {
list: string | null,
priority: number | null,
assignees: string[],
repeats: Repeats | null,
repeats: IRepeats | null,
}
interface Prefixes {
@ -144,7 +130,7 @@ const getPriority = (text: string, prefix: string): number | null => {
}
for (const p of ps) {
for (const pi of Object.values(priorities)) {
for (const pi of Object.values(PRIORITIES)) {
if (pi === parseInt(p)) {
return parseInt(p)
}
@ -199,55 +185,55 @@ const getRepeats = (text: string): repeatParsedResult => {
default:
amount = results[3] ? parseInt(results[3]) : 1
}
let type: RepeatType = RepeatType.Hours
let type: RepeatType = REPEAT_TYPES.Hours
switch (results[0]) {
case 'biennially':
type = RepeatType.Years
type = REPEAT_TYPES.Years
amount = 2
break
case 'bianually':
case 'semiannually':
type = RepeatType.Months
type = REPEAT_TYPES.Months
amount = 6
break
case 'yearly':
case 'anually':
type = RepeatType.Years
type = REPEAT_TYPES.Years
break
case 'daily':
type = RepeatType.Days
type = REPEAT_TYPES.Days
break
case 'hourly':
type = RepeatType.Hours
type = REPEAT_TYPES.Hours
break
case 'monthly':
type = RepeatType.Months
type = REPEAT_TYPES.Months
break
case 'weekly':
type = RepeatType.Weeks
type = REPEAT_TYPES.Weeks
break
default:
switch (results[5]) {
case 'hour':
case 'hours':
type = RepeatType.Hours
type = REPEAT_TYPES.Hours
break
case 'day':
case 'days':
type = RepeatType.Days
type = REPEAT_TYPES.Days
break
case 'week':
case 'weeks':
type = RepeatType.Weeks
type = REPEAT_TYPES.Weeks
break
case 'month':
case 'months':
type = RepeatType.Months
type = REPEAT_TYPES.Months
break
case 'year':
case 'years':
type = RepeatType.Years
type = REPEAT_TYPES.Years
break
}
}

View File

@ -1,9 +1,9 @@
import axios, {Method} from 'axios'
import axios , { type Method } from 'axios'
import {objectToSnakeCase} from '@/helpers/case'
import {getToken} from '@/helpers/auth'
import AbstractModel from '@/models/abstractModel'
import AbstractModel, { type IAbstract } from '@/models/abstractModel'
import type { Right } from '@/models/constants/rights'
import type FileModel from '@/models/file'
import type { IFile } from '@/models/file'
interface Paths {
create : string
@ -11,6 +11,7 @@ interface Paths {
getAll : string
update : string
delete : string
reset?: string
}
function convertObject(o: Record<string, unknown>) {
@ -38,7 +39,7 @@ function prepareParams(params: Record<string, unknown | unknown[]>) {
return objectToSnakeCase(params)
}
export default class AbstractService<Model extends AbstractModel = AbstractModel> {
export default class AbstractService<Model extends IAbstract = IAbstract> {
/////////////////////////////
// Initial variable definitions
@ -278,7 +279,7 @@ export default class AbstractService<Model extends AbstractModel = AbstractModel
* This is a more abstract implementation which only does a get request.
* Services which need more flexibility can use this.
*/
async getM(url : string, model = new AbstractModel({}) as Model, params: Record<string, unknown> = {}) {
async getM(url : string, model : Model = new AbstractModel({}), params: Record<string, unknown> = {}) {
const cancel = this.setLoading()
model = this.beforeGet(model)
@ -294,7 +295,7 @@ export default class AbstractService<Model extends AbstractModel = AbstractModel
}
}
async getBlobUrl(url : string, method = 'GET' as Method, data = {}) {
async getBlobUrl(url : string, method : Method = 'GET', data = {}) {
const response = await this.http({
url,
method,
@ -311,7 +312,7 @@ export default class AbstractService<Model extends AbstractModel = AbstractModel
* @param params Optional query parameters
* @param page The page to get
*/
async getAll(model : Model = new AbstractModel({}) as Model, params = {}, page = 1) {
async getAll(model : Model = new AbstractModel({}), params = {}, page = 1) {
if (this.paths.getAll === '') {
throw new Error('This model is not able to get data.')
}
@ -417,10 +418,10 @@ export default class AbstractService<Model extends AbstractModel = AbstractModel
/**
* Uploads a file to a url.
* @param url
* @param file {FileModel}
* @param file {IFile}
* @param fieldName The name of the field the file is uploaded to.
*/
uploadFile(url : string, file: FileModel, fieldName : string) {
uploadFile(url : string, file: IFile, fieldName : string) {
return this.uploadBlob(url, new Blob([file]), fieldName, file.name)
}

View File

@ -1,8 +1,8 @@
import AbstractService from './abstractService'
import AttachmentModel from '../models/attachment'
import AttachmentModel, { type IAttachment } from '../models/attachment'
import {formatISO} from 'date-fns'
import {downloadBlob} from '@/helpers/downloadBlob'
import type FileModel from '@/models/file'
import type { IFile } from '@/models/file'
export default class AttachmentService extends AbstractService<AttachmentModel> {
constructor() {
@ -13,7 +13,7 @@ export default class AttachmentService extends AbstractService<AttachmentModel>
})
}
processModel(model: AttachmentModel) {
processModel(model: IAttachment) {
model.created = formatISO(new Date(model.created))
return model
}
@ -34,11 +34,11 @@ export default class AttachmentService extends AbstractService<AttachmentModel>
return data
}
getBlobUrl(model: AttachmentModel) {
getBlobUrl(model: IAttachment) {
return AbstractService.prototype.getBlobUrl.call(this, '/tasks/' + model.taskId + '/attachments/' + model.id)
}
async download(model: AttachmentModel) {
async download(model: IAttachment) {
const url = await this.getBlobUrl(model)
return downloadBlob(url, model.file.name)
}
@ -48,7 +48,7 @@ export default class AttachmentService extends AbstractService<AttachmentModel>
* @param files
* @returns {Promise<any|never>}
*/
create(model: AttachmentModel, files: FileModel[]) {
create(model: IAttachment, files: IFile[]) {
const data = new FormData()
for (let i = 0; i < files.length; i++) {
// TODO: Validation of file size

View File

@ -1,7 +1,7 @@
import AbstractService from './abstractService'
import AvatarModel from '../models/avatar'
import AvatarModel, { type IAvatar } from '../models/avatar'
export default class AvatarService extends AbstractService {
export default class AvatarService extends AbstractService<IAvatar> {
constructor() {
super({
get: '/user/settings/avatar',

View File

@ -1,8 +1,8 @@
import AbstractService from './abstractService'
import BackgroundImageModel from '../models/backgroundImage'
import ListModel from '../models/list'
import BackgroundImageModel, { type IBackgroundImage } from '../models/backgroundImage'
import ListModel from '@/models/list'
export default class BackgroundUnsplashService extends AbstractService {
export default class BackgroundUnsplashService extends AbstractService<IBackgroundImage> {
constructor() {
super({
getAll: '/backgrounds/unsplash/search',

View File

@ -1,6 +1,6 @@
import AbstractService from './abstractService'
import ListModel from '../models/list'
import type FileModel from '@/models/file'
import ListModel, { type IList } from '../models/list'
import type { IFile } from '@/models/file'
export default class BackgroundUploadService extends AbstractService {
constructor() {
@ -22,7 +22,7 @@ export default class BackgroundUploadService extends AbstractService {
* @param file
* @returns {Promise<any|never>}
*/
create(listId: ListModel['id'], file: FileModel) {
create(listId: IList['id'], file: IFile) {
return this.uploadFile(
this.getReplacedRoute(this.paths.create, {listId}),
file,

View File

@ -1,8 +1,8 @@
import AbstractService from './abstractService'
import BucketModel from '../models/bucket'
import BucketModel, { type IBucket } from '../models/bucket'
import TaskService from '@/services/task'
export default class BucketService extends AbstractService {
export default class BucketService extends AbstractService<IBucket> {
constructor() {
super({
getAll: '/lists/{listId}/buckets',

View File

@ -1,8 +1,8 @@
import {formatISO} from 'date-fns'
import CaldavTokenModel from '../models/caldavToken'
import CaldavTokenModel, {type ICaldavToken} from '../models/caldavToken'
import AbstractService from './abstractService'
export default class CaldavTokenService extends AbstractService {
export default class CaldavTokenService extends AbstractService<ICaldavToken> {
constructor() {
super({
getAll: '/user/settings/token/caldav',
@ -11,7 +11,7 @@ export default class CaldavTokenService extends AbstractService {
})
}
processModel(model: Partial<CaldavTokenModel>) {
processModel(model: Partial<ICaldavToken>) {
return {
...model,
created: formatISO(new Date(model.created)),

View File

@ -1,9 +1,9 @@
import AbstractService from './abstractService'
import LabelModel from '../models/label'
import LabelModel, { type ILabel } from '@/models/label'
import {formatISO} from 'date-fns'
import {colorFromHex} from '@/helpers/color/colorFromHex'
export default class LabelService extends AbstractService {
export default class LabelService extends AbstractService<ILabel> {
constructor() {
super({
create: '/labels',

View File

@ -1,7 +1,7 @@
import AbstractService from './abstractService'
import LabelTask from '../models/labelTask'
import LabelTask, {type ILabelTask} from '@/models/labelTask'
export default class LabelTaskService extends AbstractService {
export default class LabelTaskService extends AbstractService<ILabelTask> {
constructor() {
super({
create: '/tasks/{taskId}/labels',

View File

@ -1,8 +1,8 @@
import AbstractService from './abstractService'
import LinkShareModel from '../models/linkShare'
import LinkShareModel, { type ILinkShare } from '@/models/linkShare'
import {formatISO} from 'date-fns'
export default class ListService extends AbstractService {
export default class LinkShareService extends AbstractService<ILinkShare> {
constructor() {
super({
getAll: '/lists/{listId}/shares',

View File

@ -1,10 +1,10 @@
import AbstractService from './abstractService'
import ListModel from '../models/list'
import ListModel, { type IList } from '@/models/list'
import TaskService from './task'
import {formatISO} from 'date-fns'
import {colorFromHex} from '@/helpers/color/colorFromHex'
export default class ListService extends AbstractService {
export default class ListService extends AbstractService<IList> {
constructor() {
super({
create: '/namespaces/{namespaceId}/lists',

View File

@ -1,7 +1,7 @@
import AbstractService from './abstractService'
import listDuplicateModel from '../models/listDuplicateModel'
import listDuplicateModel, {type IListDuplicate} from '../models/listDuplicateModel'
export default class ListDuplicateService extends AbstractService {
export default class ListDuplicateService extends AbstractService<IListDuplicate> {
constructor() {
super({
create: '/lists/{listId}/duplicate',

View File

@ -1,9 +1,9 @@
import AbstractService from './abstractService'
import NamespaceModel from '../models/namespace'
import NamespaceModel, { type INamespace } from '../models/namespace'
import {formatISO} from 'date-fns'
import {colorFromHex} from '@/helpers/color/colorFromHex'
export default class NamespaceService extends AbstractService {
export default class NamespaceService extends AbstractService<INamespace> {
constructor() {
super({
create: '/namespaces',

View File

@ -1,8 +1,8 @@
import AbstractService from '@/services/abstractService'
import {formatISO} from 'date-fns'
import NotificationModel from '@/models/notification'
import NotificationModel, { type INotification } from '@/models/notification'
export default class NotificationService extends AbstractService {
export default class NotificationService extends AbstractService<INotification> {
constructor() {
super({
getAll: '/notifications',

View File

@ -1,7 +1,7 @@
import AbstractService from './abstractService'
import PasswordResetModel from '../models/passwordReset'
import PasswordResetModel, { type IPasswordReset } from '../models/passwordReset'
export default class PasswordResetService extends AbstractService {
export default class PasswordResetService extends AbstractService<IPasswordReset> {
constructor() {
super({})

View File

@ -1,6 +1,7 @@
import type { IPasswordUpdate } from '@/models/passwordUpdate'
import AbstractService from './abstractService'
export default class PasswordUpdateService extends AbstractService {
export default class PasswordUpdateService extends AbstractService<IPasswordUpdate> {
constructor() {
super({
update: '/user/password',

View File

@ -1,8 +1,8 @@
import AbstractService from '@/services/abstractService'
import SavedFilterModel from '@/models/savedFilter'
import SavedFilterModel, { type ISavedFilter } from '@/models/savedFilter'
import {objectToCamelCase} from '@/helpers/case'
export default class SavedFilterService extends AbstractService {
export default class SavedFilterService extends AbstractService<ISavedFilter> {
constructor() {
super({
get: '/filters/{id}',

Some files were not shown because too many files have changed in this diff Show More