aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/courseware/widgets/CoursewareExportWidget.vue
blob: b31ee20b4a024f7e10e0357dac241cf5f9c6c46a (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
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
<template>
    <sidebar-widget :title="$gettext('Export')" v-if="structuralElement">
        <template #content>
            <ul class="widget-list widget-links cw-export-widget" v-if="structuralElement">
                <li v-if="showExportArchiv" class="cw-export-widget-export">
                    <button @click="exportElement">
                        {{ $gettext('Seiten exportieren') }}
                    </button>
                </li>
                <li v-if="showExportPdf" class="cw-export-widget-export-pdf">
                    <button @click="pdfElement">
                        {{ $gettext('PDF-Dokument erstellen') }}
                    </button>
                </li>
                <li v-if="showOer" class="cw-export-widget-oer">
                    <button @click="oerElement">
                        {{ $gettext('Auf OER Campus veröffentlichen') }}
                    </button>
                </li>
                <li v-if="!showExportArchiv && !showExportPdf && !showOer">
                    {{ $gettext('Keine Exportoptionen verfügbar') }}
                </li>
            </ul>
        </template>
    </sidebar-widget>
</template>

<script>
import SidebarWidget from '../../SidebarWidget.vue';
import CoursewareExport from '@/vue/mixins/courseware/export.js';
import { mapActions, mapGetters } from 'vuex';

export default {
    name: 'courseware-export-widget',
    props: ['structuralElement', 'canVisit'],
    components: {
        SidebarWidget
    },
    mixins: [CoursewareExport],
    computed: {
        ...mapGetters({
            context: 'context',
            oerCampusEnabled: 'oerCampusEnabled',
            userIsTeacher: 'userIsTeacher',
        }),
        canEdit() {
            if (!this.structuralElement) {
                return false;
            }
            return this.structuralElement.attributes['can-edit'];
        },
        showExportArchiv() {
            if (this.context.type === 'users') {
                return true;
            }

            return this.canEdit;
        },
        showExportPdf() {
            if (this.context.type === 'users') {
                return true;
            }

            return this.canVisit;
        },
        showOer() {
            if (!this.oerCampusEnabled) {
                return false;
            }

            if (this.context.type === 'users') {
                return true;
            }

            return this.userIsTeacher && this.canVisit;
        }
    },
    methods: {
        ...mapActions({
            showElementExportDialog: 'showElementExportDialog',
            showElementPdfExportDialog: 'showElementPdfExportDialog',
            showElementOerDialog: 'showElementOerDialog',
        }),
        exportElement() {
            this.showElementExportDialog(true);
        },
        pdfElement() {
            this.showElementPdfExportDialog(true);
        },
        oerElement() {
            this.showElementOerDialog(true);
        }
    },
};
</script>