aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/courseware/layouts/CoursewareTalkBubble.vue
blob: b3df5715c908ab9c51db26803662e0bc7077ef57 (plain)
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
<template>
    <div :class="{ 'cw-talk-bubble-own-post': payload.own }" class="cw-talk-bubble-wrapper">
        <div v-if="!payload.own" class="cw-talk-bubble-avatar">
            <img :src="payload.user_avatar" />
        </div>
        <div class="cw-talk-bubble">
            <div class="cw-talk-bubble-content">
                <header v-if="!payload.own" class="cw-talk-bubble-header">
                    <a :href="userProfileUrl">{{ payload.user_formatted_name }}</a>
                </header>
                <div class="cw-talk-bubble-talktext">
                    <span>{{ payload.content }}</span>
                    <div class="cw-talk-bubble-footer">
                        <span class="cw-talk-bubble-talktext-time"><iso-date :date="payload.chdate" /></span>
                        <button v-if="userIsTeacher || payload.own" :title="$gettext('Löschen')"
                            @click="showDeleteDialog = true">
                            <studip-icon shape="trash" />
                        </button>
                    </div>
                </div>
            </div>
        </div>
        <studip-dialog v-if="showDeleteDialog" :title="$gettext('Eintrag löschen')"
            :question="$gettext('Möchten Sie diesen Eintrag löschen?')" height="180" width="360" @confirm="deletePost"
            @close="closeDeleteDialog">
        </studip-dialog>
    </div>
</template>

<script>
import IsoDate from './IsoDate.vue';
import { mapGetters } from 'vuex';

export default {
    name: 'courseware-talk-bubble',
    components: { IsoDate },
    emits: ['delete'],
    props: {
        payload: Object,
    },
    data() {
        return {
            showDeleteDialog: false
        }
    },
    computed: {
        ...mapGetters({
            userIsTeacher: 'userIsTeacher'
        }),
        userProfileUrl() {
            const username = this.payload.username;
            return STUDIP.URLHelper.getURL('dispatch.php/profile', { username });
        }
    },
    methods: {
        closeDeleteDialog() {
            this.showDeleteDialog = false;
        },
        deletePost() {
            this.closeDeleteDialog();
            this.$emit('delete');
        }
    }
};
</script>