aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/courseware/CoursewareExportWidget.vue
blob: 858b66209b3137cd2d18002e9f66af437bfd1d1a (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
96
<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">
                        <translate>Seite exportieren</translate>
                    </button>
                </li>
                <li v-if="showExportPdf" class="cw-export-widget-export-pdf">
                    <button @click="pdfElement">
                        <translate>Seite als pdf-Dokument exportieren</translate>
                    </button>
                </li>
                <li v-if="showOer" class="cw-export-widget-oer">
                    <button @click="oerElement">
                        <translate>Seite auf %{oerTitle} veröffentlichen</translate>
                    </button>
                </li>
                <li v-if="!showExportArchiv && !showExportPdf && !showOer">
                    <translate>Keine Exportoptionen verfügbar</translate>
                </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',
            oerEnabled: 'oerEnabled',
            oerTitle: 'oerTitle',
            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.oerEnabled) {
                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>