feat: improve store and model typing
This commit is contained in:
parent
c9e85cb52b
commit
3766b5e51b
98 changed files with 1050 additions and 507 deletions
|
|
@ -159,12 +159,12 @@ 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)
|
||||
|
|
|
|||
Reference in a new issue