aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/courseware/structural-element/CoursewareStructuralElementDialogExportChooser.vue
blob: be5dd8d52ddbc62b80889f9e3022f45e24921a63 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
    <studip-dialog
        :title="$gettext('Seite exportieren')"
        :closeText="$gettext('Schließen')"
        closeClass="cancel"
        height="320"
        width="610"
        @close="showElementExportChooserDialog(false)"
    >
        <template v-slot:dialogContent>
            <div class="square-button-panel">
                <studip-square-button
                    v-if="showExportArchiv"
                    icon="file-archive"
                    :title="$gettext('ZIP Datei herunterladen')"
                    @click="selectType('archiv')"
                />
                <studip-square-button
                    v-if="showExportPdf"
                    icon="file-pdf"
                    :title="$gettext('PDF Datei herunterladen')"
                    @click="selectType('pdf')"
                />
                <studip-square-button
                    v-if="showOer"
                    icon="oer-campus"
                    :title="$gettext('Auf OER Campus veröffentlichen')"
                    @click="selectType('oer')"
                />
            </div>
            <courseware-companion-box
                v-if="!showExportArchiv && !showExportPdf && !showOer"
                mood="pointing"
                :msgCompanion="$gettext('Keine Exportoptionen verfügbar.')"
            />
        </template>
    </studip-dialog>
</template>

<script>
import CoursewareCompanionBox from '../layouts/CoursewareCompanionBox.vue';
import StudipSquareButton from './../../StudipSquareButton.vue';
import { mapActions, mapGetters } from 'vuex';

export default {
    name: 'courseware-structural-element-dialog-export-chooser',
    props: ['canEdit', 'canVisit'],
    components: {
        CoursewareCompanionBox,
        StudipSquareButton,
    },
    computed: {
        ...mapGetters({
            context: 'context',
            oerCampusEnabled: 'oerCampusEnabled',
            userIsTeacher: 'userIsTeacher',
        }),
        inCourseContext() {
            return this.context.type === 'courses';
        },
        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',
            showElementExportChooserDialog: 'showElementExportChooserDialog',
            showElementPdfExportDialog: 'showElementPdfExportDialog',
            showElementOerDialog: 'showElementOerDialog',
        }),
        selectType(type) {
            switch (type) {
                case 'archiv':
                    this.showElementExportDialog(true);
                    break;
                case 'pdf':
                    this.showElementPdfExportDialog(true);
                    break;
                case 'oer':
                    this.showElementOerDialog(true);
                    break;
            }
            this.showElementExportChooserDialog(false);
        },
    },
};
</script>
<style scoped lang="scss">
.square-button-panel {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    justify-content: center;
}
</style>