Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 17x 6x 6x 6x 6x 6x 3x 1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 2x 2x 2x 2x 1x 1x 1x 2x | <template>
<li class="pending-comment-row" :data-comment-id="comment.id" :data-status="comment.status">
<div class="d-flex gap-2 align-items-start">
<div class="flex-grow-1">
<div class="small text-muted mb-1">
<span v-if="comment.parentId">{{ t('comment.reply') }} · </span>
<time :datetime="comment.createdAt" :title="formatDateTime(comment.createdAt)">{{
formatRelative(comment.createdAt)
}}</time>
</div>
<p class="comment-text mb-1">{{ comment.body }}</p>
<div class="small">
<button
type="button"
class="btn btn-link btn-sm p-0 text-danger"
:disabled="busy"
@click="confirmingDelete = true"
>
<font-awesome-icon icon="fa-solid fa-trash" class="me-1" />
{{ t('comment.delete') }}
</button>
</div>
</div>
<span class="badge comment-status" :class="statusClass">
{{ t(`moderation.status.${comment.status}`) }}
</span>
</div>
<ConfirmModal
:is-open="confirmingDelete"
:title="t('comment.deleteTitle')"
:message="t('comment.deleteConfirm')"
:confirm-label="t('comment.delete')"
variant="danger"
@confirm="doDelete"
@cancel="confirmingDelete = false"
/>
</li>
</template>
<script setup lang="ts">
// @implements UC-MOD-001.1
import { computed, ref } from 'vue'
import ConfirmModal from '@/components/ConfirmModal.vue'
import { useUILanguage } from '@/composables/useUILanguage'
import { useDateFormat } from '@/composables/useDateFormat'
import { useCommentsStore, type Comment } from '@/stores/comments'
import { useToastStore } from '@/stores/toast'
import { getErrorMessage } from '@/utils/errors'
/**
* The user's own comment that is not publicly visible yet, in the open item's
* comments panel: awaiting community review or rejected. They see its status
* and may withdraw it. Nobody else sees it — the community alone decides it.
*/
const props = defineProps<{
comment: Comment
}>()
const emit = defineEmits<{
// Change to the item's comment counter
'count-change': [delta: number]
}>()
const { t } = useUILanguage()
const { formatRelative, formatDateTime } = useDateFormat()
const commentsStore = useCommentsStore()
const toastStore = useToastStore()
const busy = ref(false)
const confirmingDelete = ref(false)
const statusClass = computed(() =>
props.comment.status === 'rejected' ? 'bg-danger' : 'bg-secondary'
)
async function doDelete() {
confirmingDelete.value = false
busy.value = true
try {
const { countDelta } = await commentsStore.deleteComment(props.comment)
emit('count-change', countDelta)
toastStore.success(t('comment.deleteSuccess'))
} catch (err) {
toastStore.error(getErrorMessage(err, t('comment.deleteError'), t))
} finally {
busy.value = false
}
}
</script>
<style scoped>
.pending-comment-row {
padding: 0.5rem 0;
border-bottom: 1px solid var(--bw-border, rgba(0, 0, 0, 0.08));
}
.pending-comment-row:last-child {
border-bottom: 0;
}
.comment-text {
white-space: pre-wrap;
overflow-wrap: anywhere;
}
</style>
|