aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/forum/ForumApp.vue
blob: 7b926e0fcd0fd95acdf1fbbcdafaf7912deae051 (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
<script setup>
import {onMounted} from 'vue';
import {useForumConfig} from '@/vue/store/pinia/forum/ForumConfig';

const CSRF = STUDIP.CSRF_TOKEN;
const forumConfig = useForumConfig();
const fetchConfigs = async () => {
    try {
        const response = await STUDIP.jsonapi.withPromises().GET(`courses/${STUDIP.URLHelper.parameters.cid}/forum-configs`);

        forumConfig.$patch({
            isModerator: response.meta['is-moderator'],
            isAdmin: response.meta['is-admin'],
            isTutor: response.meta['is-tutor'],
            anonymousPost: response.meta['anonymous-post'],
            tileLayout: response.meta['tile-layout']
        });
    } catch (error) {
        STUDIP.Report.error(error);
    }
}

onMounted(async () => {
    if (STUDIP.USER_ID === 'nobody') {
        forumConfig.$patch({
            allowGuestAccess: true
        });
    } else {
        await fetchConfigs();
    }
});
</script>

<template>
    <div class="forum">
        <div class="forum__container use-utility-classes">
            <div>
                <slot />
            </div>
            <div class="forum__sidebar">
                <slot name="sidebar" />
            </div>
        </div>

        <form id="forum-delete-form" method="post">
            <input type="hidden" :name="CSRF.name" :value="CSRF.value" />
        </form>
    </div>
</template>