feat: convert model methods to named functions
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
<div :key="c.id" class="media comment" v-for="c in comments">
|
||||
<figure class="media-left is-hidden-mobile">
|
||||
<img
|
||||
:src="c.author.getAvatarUrl(48)"
|
||||
:src="getAvatarUrl(c.author, 48)"
|
||||
alt=""
|
||||
class="image is-avatar"
|
||||
height="48"
|
||||
@ -27,13 +27,13 @@
|
||||
<div class="media-content">
|
||||
<div class="comment-info">
|
||||
<img
|
||||
:src="c.author.getAvatarUrl(20)"
|
||||
:src="getAvatarUrl(c.author, 20)"
|
||||
alt=""
|
||||
class="image is-avatar d-print-none"
|
||||
height="20"
|
||||
width="20"
|
||||
/>
|
||||
<strong>{{ c.author.getDisplayName() }}</strong>
|
||||
<strong>{{ getDisplayName(c.author) }}</strong>
|
||||
<span v-tooltip="formatDateLong(c.created)" class="has-text-grey">
|
||||
{{ formatDateSince(c.created) }}
|
||||
</span>
|
||||
@ -166,6 +166,7 @@ import type {ITask} from '@/modelTypes/ITask'
|
||||
import {uploadFile} from '@/helpers/attachments'
|
||||
import {success} from '@/message'
|
||||
import {formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
|
||||
import {getAvatarUrl, getDisplayName} from '@/models/user'
|
||||
import {useConfigStore} from '@/stores/config'
|
||||
import {useAuthStore} from '@/stores/auth'
|
||||
|
||||
@ -196,7 +197,7 @@ const newComment = reactive(new TaskCommentModel())
|
||||
const saved = ref<ITask['id'] | null>(null)
|
||||
const saving = ref<ITask['id'] | null>(null)
|
||||
|
||||
const userAvatar = computed(() => authStore.info.getAvatarUrl(48))
|
||||
const userAvatar = computed(() => getAvatarUrl(authStore.info, 48))
|
||||
const currentUserId = computed(() => authStore.info.id)
|
||||
const enabled = computed(() => configStore.taskCommentsEnabled)
|
||||
const actions = computed(() => {
|
||||
|
@ -3,7 +3,7 @@
|
||||
<time :datetime="formatISO(task.created)" v-tooltip="formatDateLong(task.created)">
|
||||
<i18n-t keypath="task.detail.created" scope="global">
|
||||
<span>{{ formatDateSince(task.created) }}</span>
|
||||
{{ task.createdBy.getDisplayName() }}
|
||||
{{ getDisplayName(task.createdBy) }}
|
||||
</i18n-t>
|
||||
</time>
|
||||
<template v-if="+new Date(task.created) !== +new Date(task.updated)">
|
||||
@ -30,6 +30,7 @@
|
||||
import {computed, toRefs, type PropType} from 'vue'
|
||||
import type {ITask} from '@/modelTypes/ITask'
|
||||
import {formatISO, formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
|
||||
import {getDisplayName} from '@/models/user'
|
||||
|
||||
const props = defineProps({
|
||||
task: {
|
||||
|
@ -38,7 +38,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {ref, shallowReactive, computed, watch, onMounted, onBeforeUnmount, type PropType} from 'vue'
|
||||
import {ref, shallowReactive, computed, watch, onMounted, onBeforeUnmount, toRef, type PropType} from 'vue'
|
||||
import {useI18n} from 'vue-i18n'
|
||||
import flatPickr from 'vue-flatpickr-component'
|
||||
|
||||
@ -63,12 +63,12 @@ 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>()
|
||||
const lastValue = ref<Date>()
|
||||
const changeInterval = ref<number>()
|
||||
const changeInterval = ref<ReturnType<typeof setInterval>>()
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
toRef(props, 'modelValue'),
|
||||
(value) => {
|
||||
task.value = value
|
||||
task.value = { ...value }
|
||||
dueDate.value = value.dueDate
|
||||
lastValue.value = value.dueDate
|
||||
},
|
||||
@ -123,7 +123,6 @@ async function updateDueDate() {
|
||||
return
|
||||
}
|
||||
|
||||
// FIXME: direct prop manipulation
|
||||
const newTask = await taskService.update({
|
||||
...task.value,
|
||||
dueDate: new Date(dueDate.value),
|
||||
|
Reference in New Issue
Block a user