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
|
<template>
<button
class="cw-manager-filing"
:class="{ 'cw-manager-filing-active': active, 'cw-manager-filing-disabled': disabled }"
:aria-pressed="active"
@click="toggleFiling"
>
<span v-if="itemType === 'element'"><translate>Seite an dieser Stelle einfügen</translate> </span>
<span v-if="itemType === 'container'"><translate>Abschnitt an dieser Stelle einfügen</translate> </span>
<span v-if="itemType === 'block'"><translate>Block an dieser Stelle einfügen</translate> </span>
</button>
</template>
<script>
export default {
name: 'courseware-manager-filing',
props: {
parentId: String,
parentItem: Object,
itemType: String, // element || container || block
},
data() {
return {
active: false,
disabled: false,
data: {},
};
},
computed: {
filingData() {
return this.$store.getters.filingData;
},
},
methods: {
toggleFiling() {
if (this.disabled) {
return false;
}
if (this.active) {
this.$store.dispatch('cwManagerFilingData', {});
} else {
this.$store.dispatch('cwManagerFilingData', { parentId: this.parentId, itemType: this.itemType, parentItem: this.parentItem });
}
},
},
watch: {
filingData(newValue, oldValue) {
if (Object.keys(newValue).length !== 0) {
if (newValue.parentId === this.parentId && newValue.itemType === this.itemType) {
this.active = true;
} else {
this.disabled = true;
}
} else {
this.active = false;
this.disabled = false;
if (Object.keys(oldValue).length !== 0) {
if (oldValue.parentId === this.parentId && oldValue.itemType === this.itemType) {
this.$emit('deactivated');
}
}
}
},
},
};
</script>
|