aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/courseware/structural-element/CoursewareStructuralElementDialogAddChooser.vue
blob: 35a8c7ec8e8a10c95237dfce61ced84afdbe27a0 (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
<template>
    <studip-dialog
        :title="$gettext('Seite hinzufügen')"
        :closeText="$gettext('Schließen')"
        closeClass="cancel"
        height="320"
        width="680"
        @close="showElementAddChooserDialog(false)"
    >
        <template v-slot:dialogContent>
            <div class="square-button-panel">
                <studip-square-button
                    icon="add"
                    :title="$gettext('Neu erstellen')"
                    @click="selectType('new')"
                />
                <studip-square-button
                    icon="copy"
                    :title="$gettext('Bestehendes kopieren')"
                    @click="selectType('copy')"
                />
                <studip-square-button
                    v-if="inCourseContext && userIsTeacher"
                    icon="group"
                    :title="$gettext('Aus Arbeitsplatz verknüpfen')"
                    @click="selectType('link')"
                />
                <studip-square-button
                    icon="import"
                    :title="$gettext('Aus Datei importieren')"
                    @click="selectType('import')"
                />
                
            </div>
        </template>
    </studip-dialog>
</template>

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

export default {
    name: 'courseware-shelf-dialog-add-chooser',
    components: {
        StudipSquareButton,
    },
    computed: {
        ...mapGetters({
            context: 'context',
            userIsTeacher: 'userIsTeacher',
        }),
        inCourseContext() {
            return this.context.type === 'courses';
        },
    },
    methods: {
        ...mapActions({
            showElementAddDialog: 'showElementAddDialog',
            showElementAddChooserDialog: 'showElementAddChooserDialog',
            showElementImportDialog: 'showElementImportDialog',
            showElementCopyDialog: 'showElementCopyDialog',
            showElementLinkDialog: 'showElementLinkDialog',
        }),
        selectType(type) {
            switch (type) {
                case 'new':
                    this.showElementAddDialog(true);
                    break;
                case 'import':
                    this.showElementImportDialog(true);
                    break;
                case 'copy':
                    this.showElementCopyDialog(true);
                    break;
                case 'link':
                        this.showElementLinkDialog(true)
            }
            this.showElementAddChooserDialog(false);
        },
    },
};
</script>
<style scoped lang="scss">
.square-button-panel {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    justify-content: center;
}
</style>