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
|
<template>
<a href="#" @click.prevent="addContainer">
<div class="cw-blockadder-item" :class="['cw-blockadder-item-' + type]">
<header class="cw-blockadder-item-title">
{{ title }}
</header>
<p class="cw-blockadder-item-description">
{{ description }}
</p>
</div>
</a>
</template>
<script>
import { mapActions } from 'vuex';
export default {
name: 'courseware-container-adder-item',
components: {},
props: {
title: String,
description: String,
type: String,
colspan: String,
firstSection: String,
secondSection: String,
},
methods: {
...mapActions({
createContainer: 'createContainer',
companionSuccess: 'companionSuccess',
}),
async addContainer() {
let attributes = {};
attributes["container-type"] = this.type;
let sections = [];
if (this.type === 'list') {
sections = [{ name: this.firstSection, icon: '', blocks: [] }];
} else {
sections = [{ name: this.firstSection, icon: '', blocks: [] },{ name: this.secondSection, icon: '', blocks: [] }];
}
attributes.payload = {
colspan: this.colspan,
sections: sections,
};
await this.createContainer({ structuralElementId: this.$route.params.id, attributes: attributes });
this.companionSuccess({
info: this.$gettext('Der Abschnitt wurde erfolgreich eingefügt.'),
});
},
},
mounted() {},
};
</script>
|