mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.2 KiB
97 lines
3.2 KiB
2 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import { enumColor, ref, timeAgo, useExpandedFormStoreOrThrow, watch } from '#imports'
|
||
2 years ago
|
|
||
2 years ago
|
const { loadCommentsAndLogs, commentsAndLogs, isCommentsLoading, commentsOnly, saveComment, isYou, comment } =
|
||
2 years ago
|
useExpandedFormStoreOrThrow()
|
||
2 years ago
|
|
||
2 years ago
|
const commentsWrapperEl = ref<HTMLDivElement>()
|
||
|
|
||
2 years ago
|
await loadCommentsAndLogs()
|
||
2 years ago
|
|
||
2 years ago
|
const showborder = ref(false)
|
||
|
|
||
2 years ago
|
watch(
|
||
|
commentsAndLogs,
|
||
|
() => {
|
||
2 years ago
|
// todo: replace setTimeout
|
||
|
setTimeout(() => {
|
||
2 years ago
|
if (commentsWrapperEl.value) commentsWrapperEl.value.scrollTop = commentsWrapperEl.value?.scrollHeight
|
||
2 years ago
|
}, 200)
|
||
2 years ago
|
},
|
||
|
{ immediate: true },
|
||
|
)
|
||
2 years ago
|
</script>
|
||
|
|
||
2 years ago
|
<template>
|
||
2 years ago
|
<div class="h-full flex flex-col w-full bg-[#eceff1] p-2">
|
||
2 years ago
|
<div ref="commentsWrapperEl" class="flex-1 min-h-[100px] overflow-y-auto scrollbar-thin-dull p-2 space-y-2">
|
||
2 years ago
|
<v-skeleton-loader v-if="isCommentsLoading && !commentsAndLogs" type="list-item-avatar-two-line@8" />
|
||
2 years ago
|
|
||
2 years ago
|
<template v-else>
|
||
|
<div v-for="log of commentsAndLogs" :key="log.id" class="flex gap-1 text-xs">
|
||
2 years ago
|
<MdiAccountCircle class="row-span-2" :class="isYou(log.user) ? 'text-pink-300' : 'text-blue-300 '" />
|
||
2 years ago
|
|
||
|
<div class="flex-1">
|
||
2 years ago
|
<p class="mb-1 caption edited-text text-[10px] text-gray-500">
|
||
2 years ago
|
{{ isYou(log.user) ? 'You' : log.user == null ? 'Shared base' : log.user }}
|
||
|
{{ log.op_type === 'COMMENT' ? 'commented' : log.op_sub_type === 'INSERT' ? 'created' : 'edited' }}
|
||
|
</p>
|
||
|
<p
|
||
|
v-if="log.op_type === 'COMMENT'"
|
||
2 years ago
|
class="block caption my-2 nc-chip w-full min-h-20px p-2 rounded"
|
||
2 years ago
|
:style="{ backgroundColor: enumColor.light[2] }"
|
||
|
>
|
||
|
{{ log.description }}
|
||
|
</p>
|
||
2 years ago
|
|
||
2 years ago
|
<p v-else v-dompurify-html="log.details" class="caption my-3" style="word-break: break-all" />
|
||
2 years ago
|
|
||
2 years ago
|
<p class="time text-right text-[10px] mb-0 mt-1 text-gray-500">
|
||
2 years ago
|
{{ timeAgo(log.created_at) }}
|
||
|
</p>
|
||
|
</div>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</template>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
<div class="border-1 my-2 w-full" />
|
||
2 years ago
|
<div class="p-0">
|
||
|
<div class="flex justify-center">
|
||
2 years ago
|
<!-- Comments only -->
|
||
2 years ago
|
<a-checkbox v-model:checked="commentsOnly" @change="loadCommentsAndLogs"
|
||
2 years ago
|
>{{ $t('labels.commentsOnly') }}<span class="text-[11px] text-gray-500"></span>
|
||
2 years ago
|
</a-checkbox>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
<div class="shrink mt-2 flex">
|
||
2 years ago
|
<a-input
|
||
|
v-model:value="comment"
|
||
2 years ago
|
class="!text-xs nc-comment-box"
|
||
2 years ago
|
ghost
|
||
2 years ago
|
:class="{ focus: showborder }"
|
||
|
@focusin="showborder = true"
|
||
|
@focusout="showborder = false"
|
||
|
@keyup.enter.prevent="saveComment"
|
||
|
>
|
||
2 years ago
|
<template #addonBefore>
|
||
2 years ago
|
<div class="flex items-center">
|
||
2 years ago
|
<mdi-account-circle class="text-lg text-pink-300" small @click="saveComment" />
|
||
2 years ago
|
</div>
|
||
|
</template>
|
||
2 years ago
|
<template #suffix>
|
||
2 years ago
|
<mdi-keyboard-return v-if="comment" class="text-sm" small @click="saveComment" />
|
||
2 years ago
|
</template>
|
||
|
</a-input>
|
||
|
</div>
|
||
2 years ago
|
</div>
|
||
|
</div>
|
||
|
</template>
|
||
2 years ago
|
|
||
2 years ago
|
<style scoped>
|
||
|
:deep(.red.lighten-4) {
|
||
2 years ago
|
@apply bg-red-100;
|
||
2 years ago
|
}
|
||
|
|
||
|
:deep(.green.lighten-4) {
|
||
2 years ago
|
@apply bg-green-100;
|
||
2 years ago
|
}
|
||
|
</style>
|