Skip to content
Snippets Groups Projects
Commit 96b3139e authored by Ron Lucke's avatar Ron Lucke Committed by Marcus Eibrink-Lunzenauer
Browse files

fix #887

Closes #887 and #1257

Merge request studip/studip!871
parent 64066b31
Branches
No related tags found
No related merge requests found
Showing
with 422 additions and 143 deletions
...@@ -18,7 +18,7 @@ class BlocksShow extends JsonApiController ...@@ -18,7 +18,7 @@ class BlocksShow extends JsonApiController
'container', 'container',
'owner', 'owner',
'editor', 'editor',
'edit_blocker', 'edit-blocker',
'user-data-field', 'user-data-field',
'user-progress', 'user-progress',
]; ];
......
...@@ -19,6 +19,7 @@ class StructuralElementsShow extends JsonApiController ...@@ -19,6 +19,7 @@ class StructuralElementsShow extends JsonApiController
'ancestors', 'ancestors',
'children', 'children',
'containers', 'containers',
'containers.edit-blocker',
'containers.blocks', 'containers.blocks',
'containers.blocks.edit-blocker', 'containers.blocks.edit-blocker',
'containers.blocks.editor', 'containers.blocks.editor',
...@@ -27,6 +28,7 @@ class StructuralElementsShow extends JsonApiController ...@@ -27,6 +28,7 @@ class StructuralElementsShow extends JsonApiController
'containers.blocks.user-progress', 'containers.blocks.user-progress',
'course', 'course',
'editor', 'editor',
'edit-blocker',
'owner', 'owner',
'parent', 'parent',
]; ];
......
...@@ -752,6 +752,14 @@ ribbon end ...@@ -752,6 +752,14 @@ ribbon end
font-weight: 700; font-weight: 700;
line-height: 2em; line-height: 2em;
font-size: 1.1em; font-size: 1.1em;
&.cw-default-container-blocker-warning {
font-weight: 400;
}
}
img {
vertical-align: text-bottom;
} }
.cw-container-actions { .cw-container-actions {
...@@ -892,6 +900,15 @@ form.cw-container-dialog-edit-form { ...@@ -892,6 +900,15 @@ form.cw-container-dialog-edit-form {
font-weight: 700; font-weight: 700;
line-height: 2em; line-height: 2em;
font-size: 1.1em; font-size: 1.1em;
&.cw-default-block-invisible-info,
&.cw-default-block-blocker-warning {
font-weight: 400;
}
}
img {
vertical-align: text-bottom;
} }
.cw-block-actions { .cw-block-actions {
...@@ -1908,6 +1925,9 @@ v i e w w i d g e t ...@@ -1908,6 +1925,9 @@ v i e w w i d g e t
.cw-action-widget-trash{ .cw-action-widget-trash{
@include background-icon(trash, clickable); @include background-icon(trash, clickable);
} }
.cw-action-widget-remove-lock{
@include background-icon(lock-unlocked, clickable);
}
} }
.cw-export-widget { .cw-export-widget {
.cw-export-widget-export{ .cw-export-widget-export{
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
containerClass="cw-container-accordion" containerClass="cw-container-accordion"
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
@showEdit="setShowEdit"
@storeContainer="storeContainer" @storeContainer="storeContainer"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
@sortBlocks="enableSort" @sortBlocks="enableSort"
...@@ -114,6 +115,7 @@ export default { ...@@ -114,6 +115,7 @@ export default {
}, },
data() { data() {
return { return {
showEdit: false,
currentContainer: {}, currentContainer: {},
currentSections: [], currentSections: [],
unallocatedBlocks: [], unallocatedBlocks: [],
...@@ -180,6 +182,9 @@ export default { ...@@ -180,6 +182,9 @@ export default {
this.currentSections = sections; this.currentSections = sections;
}, },
setShowEdit(state) {
this.showEdit = state;
},
addSection() { addSection() {
this.currentContainer.attributes.payload.sections.push({ name: '', icon: '', blocks: [] }); this.currentContainer.attributes.payload.sections.push({ name: '', icon: '', blocks: [] });
}, },
...@@ -243,8 +248,10 @@ export default { ...@@ -243,8 +248,10 @@ export default {
}, },
watch: { watch: {
blocks() { blocks() {
if (!this.showEdit) {
this.initCurrentData(); this.initCurrentData();
} }
} }
}
}; };
</script> </script>
...@@ -10,12 +10,17 @@ ...@@ -10,12 +10,17 @@
<translate>Vollbild einschalten</translate> <translate>Vollbild einschalten</translate>
</button> </button>
</li> </li>
<li v-if="canEdit" class="cw-action-widget-edit"> <li v-if="canEdit && !blockedByAnotherUser" class="cw-action-widget-edit">
<button @click="editElement"> <button @click="editElement">
<translate>Seite bearbeiten</translate> <translate>Seite bearbeiten</translate>
</button> </button>
</li> </li>
<li v-if="canEdit" class="cw-action-widget-sort"> <li v-if="canEdit && blockedByAnotherUser" class="cw-action-widget-remove-lock">
<button @click="removeElementLock">
<translate>Sperre aufheben</translate>
</button>
</li>
<li v-if="canEdit && !blockedByAnotherUser" class="cw-action-widget-sort">
<button @click="sortContainers"> <button @click="sortContainers">
<translate>Abschnitte sortieren</translate> <translate>Abschnitte sortieren</translate>
</button> </button>
...@@ -35,7 +40,7 @@ ...@@ -35,7 +40,7 @@
<translate>Lesezeichen setzen</translate> <translate>Lesezeichen setzen</translate>
</button> </button>
</li> </li>
<li v-if="!isRoot && canEdit" class="cw-action-widget-trash"> <li v-if="!isRoot && canEdit && !blockedByAnotherUser" class="cw-action-widget-trash">
<button @click="deleteElement"> <button @click="deleteElement">
<translate>Seite löschen</translate> <translate>Seite löschen</translate>
</button> </button>
...@@ -60,6 +65,11 @@ export default { ...@@ -60,6 +65,11 @@ export default {
userId: 'userId', userId: 'userId',
consumeMode: 'consumeMode', consumeMode: 'consumeMode',
showToolbar: 'showToolbar', showToolbar: 'showToolbar',
blocked: 'currentElementBlocked',
blockerId: 'currentElementBlockerId',
blockedByThisUser: 'currentElementBlockedByThisUser',
blockedByAnotherUser: 'currentElementBlockedByAnotherUser',
}), }),
isRoot() { isRoot() {
if (!this.structuralElement) { if (!this.structuralElement) {
...@@ -77,18 +87,6 @@ export default { ...@@ -77,18 +87,6 @@ export default {
currentId() { currentId() {
return this.structuralElement?.id; return this.structuralElement?.id;
}, },
blocked() {
return this.structuralElement?.relationships['edit-blocker'].data !== null;
},
blockerId() {
return this.blocked ? this.structuralElement?.relationships['edit-blocker'].data?.id : null;
},
blockedByThisUser() {
return this.blocked && this.userId === this.blockerId;
},
blockedByAnotherUser() {
return this.blocked && this.userId !== this.blockerId;
},
tocText() { tocText() {
return this.showToolbar ? this.$gettext('Inhaltsverzeichnis ausblenden') : this.$gettext('Inhaltsverzeichnis anzeigen'); return this.showToolbar ? this.$gettext('Inhaltsverzeichnis ausblenden') : this.$gettext('Inhaltsverzeichnis anzeigen');
}, },
...@@ -102,6 +100,7 @@ export default { ...@@ -102,6 +100,7 @@ export default {
showElementAddDialog: 'showElementAddDialog', showElementAddDialog: 'showElementAddDialog',
showElementDeleteDialog: 'showElementDeleteDialog', showElementDeleteDialog: 'showElementDeleteDialog',
showElementInfoDialog: 'showElementInfoDialog', showElementInfoDialog: 'showElementInfoDialog',
showElementRemoveLockDialog: 'showElementRemoveLockDialog',
setStructuralElementSortMode: 'setStructuralElementSortMode', setStructuralElementSortMode: 'setStructuralElementSortMode',
companionInfo: 'companionInfo', companionInfo: 'companionInfo',
addBookmark: 'addBookmark', addBookmark: 'addBookmark',
...@@ -109,9 +108,11 @@ export default { ...@@ -109,9 +108,11 @@ export default {
setConsumeMode: 'coursewareConsumeMode', setConsumeMode: 'coursewareConsumeMode',
setViewMode: 'coursewareViewMode', setViewMode: 'coursewareViewMode',
setShowToolbar: 'coursewareShowToolbar', setShowToolbar: 'coursewareShowToolbar',
setSelectedToolbarItem: 'coursewareSelectedToolbarItem' setSelectedToolbarItem: 'coursewareSelectedToolbarItem',
loadStructuralElement: 'loadStructuralElement',
}), }),
async editElement() { async editElement() {
await this.loadStructuralElement(this.currentId);
if (this.blockedByAnotherUser) { if (this.blockedByAnotherUser) {
this.companionInfo({ info: this.$gettext('Diese Seite wird bereits bearbeitet.') }); this.companionInfo({ info: this.$gettext('Diese Seite wird bereits bearbeitet.') });
...@@ -130,10 +131,36 @@ export default { ...@@ -130,10 +131,36 @@ export default {
} }
this.showElementEditDialog(true); this.showElementEditDialog(true);
}, },
sortContainers() { async removeElementLock() {
this.showElementRemoveLockDialog(true);
},
async sortContainers() {
await this.loadStructuralElement(this.currentId);
if (this.blockedByAnotherUser) {
this.companionInfo({ info: this.$gettext('Diese Seite wird bereits bearbeitet.') });
return false;
}
try {
await this.lockObject({ id: this.currentId, type: 'courseware-structural-elements' });
} catch (error) {
if (error.status === 409) {
this.companionInfo({ info: this.$gettext('Diese Seite wird bereits bearbeitet.') });
} else {
console.log(error);
}
return false;
}
this.setStructuralElementSortMode(true); this.setStructuralElementSortMode(true);
}, },
async deleteElement() { async deleteElement() {
await this.loadStructuralElement(this.currentId);
if (this.blockedByAnotherUser) {
this.companionInfo({ info: this.$gettextInterpolate('Löschen nicht möglich, da %{blockingUserName} die Seite bearbeitet.', {blockingUserName: this.blockingUserName}) });
return false;
}
await this.lockObject({ id: this.currentId, type: 'courseware-structural-elements' }); await this.lockObject({ id: this.currentId, type: 'courseware-structural-elements' });
this.showElementDeleteDialog(true); this.showElementDeleteDialog(true);
}, },
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="true" :preview="true"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
...@@ -167,11 +168,12 @@ ...@@ -167,11 +168,12 @@
import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue'; import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue';
import CoursewareFileChooser from './CoursewareFileChooser.vue'; import CoursewareFileChooser from './CoursewareFileChooser.vue';
import CoursewareFolderChooser from './CoursewareFolderChooser.vue'; import CoursewareFolderChooser from './CoursewareFolderChooser.vue';
import { blockMixin } from './block-mixin.js';
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
export default { export default {
name: 'courseware-audio-block', name: 'courseware-audio-block',
mixins: [blockMixin],
components: { components: {
CoursewareDefaultBlock, CoursewareDefaultBlock,
CoursewareFileChooser, CoursewareFileChooser,
......
...@@ -5,11 +5,12 @@ ...@@ -5,11 +5,12 @@
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="true" :preview="true"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
<template #content> <template #content>
<TwentyTwenty :before="currentBeforeUrl" :after="currentAfterUrl" /> <TwentyTwenty v-if="!isEmpty" :before="currentBeforeUrl" :after="currentAfterUrl" />
</template> </template>
<template v-if="canEdit" #edit> <template v-if="canEdit" #edit>
<form class="default" @submit.prevent=""> <form class="default" @submit.prevent="">
...@@ -61,12 +62,14 @@ ...@@ -61,12 +62,14 @@
<script> <script>
import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue'; import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue';
import CoursewareFileChooser from './CoursewareFileChooser.vue'; import CoursewareFileChooser from './CoursewareFileChooser.vue';
import { blockMixin } from './block-mixin.js';
import TwentyTwenty from 'vue-twentytwenty'; import TwentyTwenty from 'vue-twentytwenty';
import 'vue-twentytwenty/dist/vue-twentytwenty.css'; import 'vue-twentytwenty/dist/vue-twentytwenty.css';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
export default { export default {
name: 'courseware-before-after-block', name: 'courseware-before-after-block',
mixins: [blockMixin],
components: { components: {
CoursewareDefaultBlock, CoursewareDefaultBlock,
CoursewareFileChooser, CoursewareFileChooser,
...@@ -145,6 +148,7 @@ export default { ...@@ -145,6 +148,7 @@ export default {
this.currentAfterFile = this.afterFile; this.currentAfterFile = this.afterFile;
}); });
this.loadImages();
this.initCurrentData(); this.initCurrentData();
}, },
methods: { methods: {
...@@ -153,6 +157,23 @@ export default { ...@@ -153,6 +157,23 @@ export default {
loadFileRefs: 'loadFileRefs', loadFileRefs: 'loadFileRefs',
companionWarning: 'companionWarning', companionWarning: 'companionWarning',
}), }),
loadImages() {
this.loadFileRefs(this.block.id).then((response) => {
for (let i = 0; i < response.length; i++) {
if (response[i].id === this.beforeFileId) {
this.beforeFile = response[i];
}
if (response[i].id === this.afterFileId) {
this.afterFile = response[i];
}
}
this.currentBeforeFile = this.beforeFile;
this.currentAfterFile = this.afterFile;
});
},
initCurrentData() { initCurrentData() {
this.currentBeforeSource = this.beforeSource; this.currentBeforeSource = this.beforeSource;
this.currentBeforeFileId = this.beforeFileId; this.currentBeforeFileId = this.beforeFileId;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
@setVisibility="setVisibility" @setVisibility="setVisibility"
@showInfo="showInfo" @showInfo="showInfo"
@deleteBlock="deleteBlock" @deleteBlock="deleteBlock"
@removeLock="removeLock"
/> />
</div> </div>
</template> </template>
...@@ -27,32 +28,30 @@ export default { ...@@ -27,32 +28,30 @@ export default {
}, },
block: Object, block: Object,
}, },
data() {
return {
menuItems: [],
};
},
computed: { computed: {
...mapGetters({ ...mapGetters({
userId: 'userId', userId: 'userId',
userIsTeacher: 'userIsTeacher',
}), }),
blocked() { blocked() {
return this.block?.relationships['edit-blocker'].data !== null; return this.block?.relationships?.['edit-blocker']?.data !== null;
}, },
blockerId() { blockerId() {
return this.blocked ? this.block?.relationships['edit-blocker'].data?.id : null; return this.blocked ? this.block?.relationships?.['edit-blocker']?.data?.id : null;
},
blockedByThisUser() {
return this.blocked && this.userId === this.blockerId;
}, },
blockedByAnotherUser() {
return this.blocked && this.userId !== this.blockerId;
}, },
mounted() { menuItems() {
let menuItems = [];
if (this.canEdit) { if (this.canEdit) {
if (!this.deleteOnly) { if (!this.deleteOnly) {
this.menuItems.push({ if (!this.blocked) {
id: 1, menuItems.push({ id: 1, label: this.$gettext('Block bearbeiten'), icon: 'edit', emit: 'editBlock' });
label: this.$gettext('Block bearbeiten'), menuItems.push({
icon: 'edit',
emit: 'editBlock',
});
this.menuItems.push({
id: 2, id: 2,
label: this.block.attributes.visible label: this.block.attributes.visible
? this.$gettext('unsichtbar setzen') ? this.$gettext('unsichtbar setzen')
...@@ -60,24 +59,38 @@ export default { ...@@ -60,24 +59,38 @@ export default {
icon: this.block.attributes.visible ? 'visibility-visible' : 'visibility-invisible', // do we change the icons ? icon: this.block.attributes.visible ? 'visibility-visible' : 'visibility-invisible', // do we change the icons ?
emit: 'setVisibility', emit: 'setVisibility',
}); });
this.menuItems.push({ }
id: 7, if (this.blocked && this.blockedByAnotherUser && this.userIsTeacher) {
label: this.$gettext('Informationen zum Block'), menuItems.push({
icon: 'info', id: 8,
emit: 'showInfo', label: this.$gettext('Sperre aufheben'),
icon: 'lock-unlocked',
emit: 'removeLock',
}); });
} }
this.menuItems.push({ if (!this.blocked || this.blockedByThisUser) {
menuItems.push({
id: 9, id: 9,
label: this.$gettext('Block löschen'), label: this.$gettext('Block löschen'),
icon: 'trash', icon: 'trash',
emit: 'deleteBlock', emit: 'deleteBlock'
}); });
} }
menuItems.push({
this.menuItems.sort((a, b) => { id: 7,
label: this.$gettext('Informationen zum Block'),
icon: 'info',
emit: 'showInfo',
});
}
}
menuItems.sort((a, b) => {
return a.id > b.id ? 1 : b.id > a.id ? -1 : 0; return a.id > b.id ? 1 : b.id > a.id ? -1 : 0;
}); });
return menuItems;
}
}, },
methods: { methods: {
...mapActions({ ...mapActions({
...@@ -116,12 +129,12 @@ export default { ...@@ -116,12 +129,12 @@ export default {
await this.unlockObject({ id: this.block.id, type: 'courseware-blocks' }); await this.unlockObject({ id: this.block.id, type: 'courseware-blocks' });
}, },
copyToClipboard() {
// use JSONAPI to copy to clipboard
},
deleteBlock() { deleteBlock() {
this.$emit('deleteBlock'); this.$emit('deleteBlock');
}, },
removeLock() {
this.$emit('removeLock');
}
}, },
}; };
</script> </script>
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="true" :preview="true"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
...@@ -147,11 +148,12 @@ ...@@ -147,11 +148,12 @@
import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue'; import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue';
import CoursewareFileChooser from './CoursewareFileChooser.vue'; import CoursewareFileChooser from './CoursewareFileChooser.vue';
import CoursewareFolderChooser from './CoursewareFolderChooser.vue'; import CoursewareFolderChooser from './CoursewareFolderChooser.vue';
import { blockMixin } from './block-mixin.js';
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
export default { export default {
name: 'courseware-canvas-block', name: 'courseware-canvas-block',
mixins: [blockMixin],
components: { components: {
CoursewareDefaultBlock, CoursewareDefaultBlock,
CoursewareFileChooser, CoursewareFileChooser,
...@@ -261,6 +263,7 @@ export default { ...@@ -261,6 +263,7 @@ export default {
this.initCurrentData(); this.initCurrentData();
this.buildCanvas(); this.buildCanvas();
}); });
this.loadImageFile();
}, },
methods: { methods: {
...mapActions({ ...mapActions({
...@@ -286,6 +289,14 @@ export default { ...@@ -286,6 +289,14 @@ export default {
this.Text = JSON.parse(this.canvasDraw.Text); this.Text = JSON.parse(this.canvasDraw.Text);
} }
}, },
loadImageFile() {
this.loadFileRefs(this.block.id).then((response) => {
this.file = response[0];
this.currentFile = this.file;
this.initCurrentData();
this.buildCanvas();
});
},
updateCurrentFile(file) { updateCurrentFile(file) {
this.currentFile = file; this.currentFile = file;
this.currentFileId = file.id; this.currentFileId = file.id;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="true" :preview="true"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
...@@ -84,12 +85,14 @@ ...@@ -84,12 +85,14 @@
<script> <script>
import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue'; import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue';
import { blockMixin } from './block-mixin.js';
import Chart from 'chart.js'; import Chart from 'chart.js';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import StudipIcon from '../StudipIcon.vue'; import StudipIcon from '../StudipIcon.vue';
export default { export default {
name: 'courseware-chart-block', name: 'courseware-chart-block',
mixins: [blockMixin],
components: { components: {
CoursewareDefaultBlock, CoursewareDefaultBlock,
StudipIcon, StudipIcon,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="true" :preview="true"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
...@@ -35,12 +36,14 @@ ...@@ -35,12 +36,14 @@
<script> <script>
import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue'; import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue';
import { blockMixin } from './block-mixin.js';
import hljs from 'highlight.js'; import hljs from 'highlight.js';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
export default { export default {
name: 'courseware-code-block', name: 'courseware-code-block',
mixins: [blockMixin],
components: { components: {
CoursewareDefaultBlock, CoursewareDefaultBlock,
}, },
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="true" :preview="true"
:defaultGrade="false" :defaultGrade="false"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
......
...@@ -5,11 +5,13 @@ ...@@ -5,11 +5,13 @@
@editContainer="editContainer" @editContainer="editContainer"
@deleteContainer="deleteContainer" @deleteContainer="deleteContainer"
@sortBlocks="sortBlocks" @sortBlocks="sortBlocks"
@removeLock="removeLock"
/> />
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex';
export default { export default {
name: 'courseware-container-actions', name: 'courseware-container-actions',
props: { props: {
...@@ -17,20 +19,47 @@ export default { ...@@ -17,20 +19,47 @@ export default {
container: Object, container: Object,
}, },
computed: { computed: {
...mapGetters({
userId: 'userId',
userIsTeacher: 'userIsTeacher',
}),
blocked() {
return this.container?.relationships?.['edit-blocker']?.data !== null;
},
blockerId() {
return this.blocked ? this.container?.relationships?.['edit-blocker']?.data?.id : null;
},
blockedByThisUser() {
return this.blocked && this.userId === this.blockerId;
},
blockedByAnotherUser() {
return this.blocked && this.userId !== this.blockerId;
},
menuItems() { menuItems() {
if (this.container.attributes["container-type"] === 'list') { let menuItems = [];
return [ if (!this.blockedByAnotherUser) {
{ id: 1, label: this.$gettext('Blöcke sortieren'), icon: 'arr_1sort', emit: 'sortBlocks' }, if (this.container.attributes["container-type"] !== 'list') {
{ id: 2, label: this.$gettext('Abschnitt löschen'), icon: 'trash', emit: 'deleteContainer' } menuItems.push({ id: 1, label: this.$gettext('Abschnitt bearbeiten'), icon: 'edit', emit: 'editContainer' });
]; }
} else { menuItems.push({ id: 2, label: this.$gettext('Blöcke sortieren'), icon: 'arr_1sort', emit: 'sortBlocks' });
return [ menuItems.push({ id: 3, label: this.$gettext('Abschnitt löschen'), icon: 'trash', emit: 'deleteContainer' });
{ id: 1, label: this.$gettext('Abschnitt bearbeiten'), icon: 'edit', emit: 'editContainer' },
{ id: 2, label: this.$gettext('Blöcke sortieren'), icon: 'arr_1sort', emit: 'sortBlocks' },
{ id: 3, label: this.$gettext('Abschnitt löschen'), icon: 'trash', emit: 'deleteContainer' },
];
} }
if (this.blocked && this.blockedByAnotherUser && this.userIsTeacher) {
menuItems.push({
id: 4,
label: this.$gettext('Sperre aufheben'),
icon: 'lock-unlocked',
emit: 'removeLock',
});
}
menuItems.sort((a, b) => {
return a.id > b.id ? 1 : b.id > a.id ? -1 : 0;
});
return menuItems;
}, },
}, },
methods: { methods: {
menuAction(action) { menuAction(action) {
...@@ -44,6 +73,9 @@ export default { ...@@ -44,6 +73,9 @@ export default {
}, },
sortBlocks() { sortBlocks() {
this.$emit('sortBlocks'); this.$emit('sortBlocks');
},
removeLock() {
this.$emit('removeLock');
} }
}, },
}; };
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="true" :preview="true"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
...@@ -84,9 +85,10 @@ ...@@ -84,9 +85,10 @@
<script> <script>
import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue'; import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { blockMixin } from './block-mixin.js';
export default { export default {
name: 'courseware-date-block', name: 'courseware-date-block',
mixins: [blockMixin],
components: { components: {
CoursewareDefaultBlock, CoursewareDefaultBlock,
}, },
...@@ -196,8 +198,6 @@ export default { ...@@ -196,8 +198,6 @@ export default {
containerId: this.block.relationships.container.data.id, containerId: this.block.relationships.container.data.id,
}); });
} }
}, },
}, },
}; };
......
...@@ -3,12 +3,15 @@ ...@@ -3,12 +3,15 @@
<div class="cw-content-wrapper" :class="[showEditMode ? 'cw-content-wrapper-active' : '']"> <div class="cw-content-wrapper" :class="[showEditMode ? 'cw-content-wrapper-active' : '']">
<header v-if="showEditMode" class="cw-block-header"> <header v-if="showEditMode" class="cw-block-header">
<span class="cw-sortable-handle"></span> <span class="cw-sortable-handle"></span>
<span v-if="!block.attributes.visible" class="cw-default-block-invisible-info"> <studip-icon v-if="!block.attributes.visible" shape="visibility-invisible" />
<studip-icon shape="visibility-invisible" /> <studip-icon v-if="blockedByAnotherUser" shape="lock-locked" />
</span>
<span>{{ blockTitle }}</span> <span>{{ blockTitle }}</span>
<span v-if="blockedByAnotherUser" class="cw-default-block-blocker-warning">
| {{ $gettextInterpolate('wird im Moment von %{ userName } bearbeitet', { userName: this.blockingUserName }) }}
</span>
<span v-if="!block.attributes.visible" class="cw-default-block-invisible-info"> <span v-if="!block.attributes.visible" class="cw-default-block-invisible-info">
(<translate>unsichtbar für Nutzende ohne Schreibrecht</translate>) | {{ $gettext('unsichtbar für Nutzende ohne Schreibrecht') }}
</span> </span>
<courseware-block-actions <courseware-block-actions
:block="block" :block="block"
...@@ -18,6 +21,7 @@ ...@@ -18,6 +21,7 @@
@showInfo="displayFeature('Info')" @showInfo="displayFeature('Info')"
@showExportOptions="displayFeature('ExportOptions')" @showExportOptions="displayFeature('ExportOptions')"
@deleteBlock="displayDeleteDialog()" @deleteBlock="displayDeleteDialog()"
@removeLock="displayRemoveLockDialog()"
/> />
</header> </header>
<div v-if="showContent" class="cw-block-content"> <div v-if="showContent" class="cw-block-content">
...@@ -59,8 +63,18 @@ ...@@ -59,8 +63,18 @@
height="180" height="180"
width="360" width="360"
@confirm="executeDelete" @confirm="executeDelete"
@close="showDeleteDialog = false" @close="closeDeleteDialog"
></studip-dialog> ></studip-dialog>
<studip-dialog
v-if="showRemoveLockDialog"
:title="textRemoveLockTitle"
:question="textRemoveLockAlert"
height="200"
width="450"
@confirm="executeRemoveLock"
@close="showRemoveLockDialog = false"
></studip-dialog>
</div> </div>
</template> </template>
...@@ -118,15 +132,19 @@ export default { ...@@ -118,15 +132,19 @@ export default {
showContent: true, showContent: true,
showEditModeShortcut: false, showEditModeShortcut: false,
showDeleteDialog: false, showDeleteDialog: false,
showRemoveLockDialog: false,
currentComments: [], currentComments: [],
textDeleteTitle: this.$gettext('Block unwiderruflich löschen'), textDeleteTitle: this.$gettext('Block unwiderruflich löschen'),
textDeleteAlert: this.$gettext('Möchten Sie diesen Block wirklich löschen?'), textDeleteAlert: this.$gettext('Möchten Sie diesen Block wirklich löschen?'),
textRemoveLockTitle: this.$gettext('Sperre aufheben'),
textRemoveLockAlert: this.$gettext('Möchten Sie die Sperre dieses Blocks wirklich aufheben?'),
}; };
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
blockTypes: 'blockTypes', blockTypes: 'blockTypes',
userId: 'userId', userId: 'userId',
userById: 'users/byId',
viewMode: 'viewMode', viewMode: 'viewMode',
containerById: 'courseware-containers/byId', containerById: 'courseware-containers/byId',
}), }),
...@@ -141,10 +159,10 @@ export default { ...@@ -141,10 +159,10 @@ export default {
return this.viewMode === 'discuss'; return this.viewMode === 'discuss';
}, },
blocked() { blocked() {
return this.block?.relationships['edit-blocker'].data !== null; return this.block?.relationships?.['edit-blocker']?.data !== null;
}, },
blockerId() { blockerId() {
return this.blocked ? this.block?.relationships['edit-blocker'].data?.id : null; return this.blocked ? this.block?.relationships?.['edit-blocker']?.data?.id : null;
}, },
blockedByThisUser() { blockedByThisUser() {
return this.blocked && this.userId === this.blockerId; return this.blocked && this.userId === this.blockerId;
...@@ -152,6 +170,16 @@ export default { ...@@ -152,6 +170,16 @@ export default {
blockedByAnotherUser() { blockedByAnotherUser() {
return this.blocked && this.userId !== this.blockerId; return this.blocked && this.userId !== this.blockerId;
}, },
blockingUser() {
if (this.blockedByAnotherUser) {
return this.userById({id: this.blockerId});
}
return null;
},
blockingUserName() {
return this.blockingUser ? this.blockingUser.attributes['formatted-name'] : '';
},
blockTitle() { blockTitle() {
const type = this.block.attributes['block-type']; const type = this.block.attributes['block-type'];
...@@ -171,10 +199,12 @@ export default { ...@@ -171,10 +199,12 @@ export default {
methods: { methods: {
...mapActions({ ...mapActions({
companionInfo: 'companionInfo', companionInfo: 'companionInfo',
companionWarning: 'companionWarning',
deleteBlock: 'deleteBlockInContainer', deleteBlock: 'deleteBlockInContainer',
lockObject: 'lockObject', lockObject: 'lockObject',
unlockObject: 'unlockObject', unlockObject: 'unlockObject',
loadContainer: 'loadContainer', loadContainer: 'loadContainer',
loadBlock: 'courseware-blocks/loadById',
updateContainer: 'updateContainer', updateContainer: 'updateContainer',
}), }),
async displayFeature(element) { async displayFeature(element) {
...@@ -188,26 +218,16 @@ export default { ...@@ -188,26 +218,16 @@ export default {
this.showContent = true; this.showContent = true;
if (element) { if (element) {
if (element === 'Edit') { if (element === 'Edit') {
await this.loadContainer(this.block.relationships.container.data.id); await this.loadBlock({ id: this.block.id, options: { include: 'edit-blocker' } });
if (!this.blocked) { if (!this.blocked) {
try {
await this.lockObject({ id: this.block.id, type: 'courseware-blocks' }); await this.lockObject({ id: this.block.id, type: 'courseware-blocks' });
} catch(error) {
if (error.status === 403) {
this.companionInfo({ info: this.$gettext('Dieser Block wird bereits bearbeitet.') });
} else {
console.log(error);
}
return false;
}
if (!this.preview) { if (!this.preview) {
this.showContent = false; this.showContent = false;
} }
this['show' + element] = true; this['show' + element] = true;
this.showFeatures = true; this.showFeatures = true;
} else { } else {
if (this.userId === this.blockerId) { if (this.blockedByThisUser) {
if (!this.preview) { if (!this.preview) {
this.showContent = false; this.showContent = false;
} }
...@@ -223,25 +243,64 @@ export default { ...@@ -223,25 +243,64 @@ export default {
} }
} }
}, },
prepareStoreEdit() {
// storeEdit is only emitted when the block is not in deleting process.
if (!this.showDeleteDialog) {
this.storeBlock();
}
},
async storeBlock() {
await this.loadBlock({ id: this.block.id, options: { include: 'edit-blocker' } });
if (this.blockedByThisUser) {
this.$emit('storeEdit');
}
if (this.blockedByAnotherUser) {
this.companionWarning({ info: this.$gettextInterpolate('Ihre Änderungen konnten nicht gespeichert werden, da %{blockingUserName} die Bearbeitung übernommen hat.', {blockingUserName: this.blockingUserName}) });
this.displayFeature(false);
this.$emit('closeEdit');
}
if (this.blockerId === null) {
await this.lockObject({ id: this.block.id, type: 'courseware-blocks' });
this.$emit('storeEdit');
}
},
async closeEdit() { async closeEdit() {
await this.loadBlock({ id: this.block.id , options: { include: 'edit-blocker' } }); // has block editor lock changed?
this.displayFeature(false); this.displayFeature(false);
this.$emit('closeEdit'); this.$emit('closeEdit');
if (this.blockedByThisUser) {
await this.unlockObject({ id: this.block.id, type: 'courseware-blocks' }); await this.unlockObject({ id: this.block.id, type: 'courseware-blocks' });
this.loadContainer(this.block.relationships.container.data.id); // to update block editor lock }
this.loadBlock({ id: this.block.id , options: { include: 'edit-blocker' } }); // to update block editor lock
}, },
async displayDeleteDialog() { async displayDeleteDialog() {
await this.loadBlock({ id: this.block.id, options: { include: 'edit-blocker' } });
if (!this.blocked) { if (!this.blocked) {
await this.lockObject({ id: this.block.id, type: 'courseware-blocks' }); await this.lockObject({ id: this.block.id, type: 'courseware-blocks' });
this.showDeleteDialog = true; this.showDeleteDialog = true;
} else { } else {
if (this.userId === this.blockerId) { if (this.blockedByThisUser) {
this.showDeleteDialog = true; this.showDeleteDialog = true;
} else { } else {
this.companionInfo({ info: 'Dieser Block wird bereits bearbeitet.' }); this.companionInfo({ info: this.$gettextInterpolate('Löschen nicht möglich, da %{blockingUserName} den Block bearbeitet.', {blockingUserName: this.blockingUserName}) });
}
} }
},
async closeDeleteDialog() {
await this.loadBlock({ id: this.block.id, options: { include: 'edit-blocker' } });
if (this.blockedByThisUser) {
await this.unlockObject({ id: this.block.id, type: 'courseware-blocks' });
} }
this.showDeleteDialog = false;
}, },
async executeDelete() { async executeDelete() {
await this.loadBlock({ id: this.block.id, options: { include: 'edit-blocker' } });
if (this.blockedByAnotherUser) {
this.companionInfo({ info: this.$gettextInterpolate('Löschen nicht möglich, da %{blockingUserName} die Bearbeitung übernommen hat.', {blockingUserName: this.blockingUserName}) });
return false;
}
const containerId = this.block.relationships.container.data.id; const containerId = this.block.relationships.container.data.id;
await this.loadContainer(containerId); await this.loadContainer(containerId);
let container = this.containerById({id: containerId}); let container = this.containerById({id: containerId});
...@@ -273,13 +332,20 @@ export default { ...@@ -273,13 +332,20 @@ export default {
containerId: containerId, containerId: containerId,
}); });
}, },
displayRemoveLockDialog() {
this.showRemoveLockDialog = true;
},
async executeRemoveLock() {
await this.unlockObject({ id: this.block.id , type: 'courseware-blocks' });
await this.loadBlock({ id: this.block.id });
this.showRemoveLockDialog = false;
}
prepareStoreEdit() { },
// storeEdit is only emitted when the block is not in deleting process. watch: {
if (!this.showDeleteDialog) { showEdit(state) {
this.$emit('storeEdit'); this.$emit('showEdit', state);
} }
} }
},
}; };
</script> </script>
...@@ -5,13 +5,18 @@ ...@@ -5,13 +5,18 @@
> >
<div class="cw-container-content"> <div class="cw-container-content">
<header v-if="showEditMode && canEdit" class="cw-container-header"> <header v-if="showEditMode && canEdit" class="cw-container-header">
<studip-icon v-if="blockedByAnotherUser" shape="lock-locked" />
<span>{{ container.attributes.title }} ({{container.attributes.width}})</span> <span>{{ container.attributes.title }} ({{container.attributes.width}})</span>
<span v-if="blockedByAnotherUser" class="cw-default-container-blocker-warning">
| {{ $gettextInterpolate('wird im Moment von %{ userName } bearbeitet', { userName: this.blockingUserName }) }}
</span>
<courseware-container-actions <courseware-container-actions
:canEdit="canEdit" :canEdit="canEdit"
:container="container" :container="container"
@editContainer="displayEditDialog" @editContainer="displayEditDialog"
@deleteContainer="displayDeleteDialog" @deleteContainer="displayDeleteDialog"
@sortBlocks="sortBlocks" @sortBlocks="sortBlocks"
@removeLock="displayRemoveLockDialog"
/> />
</header> </header>
<div class="cw-block-wrapper" :class="{ 'cw-block-wrapper-active': showEditMode }"> <div class="cw-block-wrapper" :class="{ 'cw-block-wrapper-active': showEditMode }">
...@@ -44,6 +49,17 @@ ...@@ -44,6 +49,17 @@
@confirm="executeDelete" @confirm="executeDelete"
@close="closeDeleteDialog" @close="closeDeleteDialog"
></studip-dialog> ></studip-dialog>
<studip-dialog
v-if="showRemoveLockDialog"
:title="textRemoveLockTitle"
:question="textRemoveLockAlert"
height="200"
width="450"
@confirm="executeRemoveLock"
@close="showRemoveLockDialog = false"
></studip-dialog>
</div> </div>
</div> </div>
</template> </template>
...@@ -69,16 +85,20 @@ export default { ...@@ -69,16 +85,20 @@ export default {
return { return {
showDeleteDialog: false, showDeleteDialog: false,
showEditDialog: false, showEditDialog: false,
showRemoveLockDialog: false,
textEditConfirm: this.$gettext('Speichern'), textEditConfirm: this.$gettext('Speichern'),
textEditClose: this.$gettext('Schließen'), textEditClose: this.$gettext('Schließen'),
textEditTitle: this.$gettext('Abschnitt bearbeiten'), textEditTitle: this.$gettext('Abschnitt bearbeiten'),
textDeleteTitle: this.$gettext('Abschnitt unwiderruflich löschen'), textDeleteTitle: this.$gettext('Abschnitt unwiderruflich löschen'),
textDeleteAlert: this.$gettext('Möchten Sie diesen Abschnitt wirklich löschen?'), textDeleteAlert: this.$gettext('Möchten Sie diesen Abschnitt wirklich löschen?'),
textRemoveLockTitle: this.$gettext('Sperre aufheben'),
textRemoveLockAlert: this.$gettext('Möchten Sie die Sperre dieses Abschnitts wirklich aufheben?'),
}; };
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
userId: 'userId', userId: 'userId',
userById: 'users/byId',
}), }),
showEditMode() { showEditMode() {
return this.$store.getters.viewMode === 'edit'; return this.$store.getters.viewMode === 'edit';
...@@ -87,10 +107,10 @@ export default { ...@@ -87,10 +107,10 @@ export default {
return this.container.attributes.payload.colspan ? this.container.attributes.payload.colspan : 'full'; return this.container.attributes.payload.colspan ? this.container.attributes.payload.colspan : 'full';
}, },
blocked() { blocked() {
return this.container?.relationships['edit-blocker'].data !== null; return this.container?.relationships?.['edit-blocker']?.data !== null;
}, },
blockerId() { blockerId() {
return this.blocked ? this.container?.relationships['edit-blocker'].data?.id : null; return this.blocked ? this.container?.relationships?.['edit-blocker']?.data?.id : null;
}, },
blockedByThisUser() { blockedByThisUser() {
return this.blocked && this.userId === this.blockerId; return this.blocked && this.userId === this.blockerId;
...@@ -98,53 +118,88 @@ export default { ...@@ -98,53 +118,88 @@ export default {
blockedByAnotherUser() { blockedByAnotherUser() {
return this.blocked && this.userId !== this.blockerId; return this.blocked && this.userId !== this.blockerId;
}, },
blockingUser() {
if (this.blockedByAnotherUser) {
return this.userById({id: this.blockerId});
}
return null;
},
blockingUserName() {
return this.blockingUser ? this.blockingUser.attributes['formatted-name'] : '';
},
}, },
methods: { methods: {
...mapActions({ ...mapActions({
companionInfo: 'companionInfo',
companionWarning: 'companionWarning',
loadContainer: 'courseware-containers/loadById',
deleteContainer: 'deleteContainer', deleteContainer: 'deleteContainer',
lockObject: 'lockObject', lockObject: 'lockObject',
unlockObject: 'unlockObject', unlockObject: 'unlockObject',
companionInfo: 'companionInfo', companionInfo: 'companionInfo',
}), }),
async displayEditDialog() { async displayEditDialog() {
await this.loadContainer({ id: this.container.id, options: { include: 'edit-blocker' } });
if (this.blockedByAnotherUser) { if (this.blockedByAnotherUser) {
this.companionInfo({ info: this.$gettext('Dieser Abschnitt wird bereits bearbeitet.') }); this.companionInfo({ info: this.$gettext('Dieser Abschnitt wird bereits bearbeitet.') });
return false; return false;
} }
try {
await this.lockObject({ id: this.container.id, type: 'courseware-containers' });
} catch(error) {
if (error.status === 409) {
this.companionInfo({ info: this.$gettext('Dieser Abschnitt wird bereits bearbeitet.') });
} else {
console.log(error);
}
return false;
}
await this.lockObject({ id: this.container.id, type: 'courseware-containers' });
this.showEditDialog = true; this.showEditDialog = true;
}, },
async closeEdit() { async closeEdit() {
await this.loadContainer({ id: this.container.id });
this.$emit('closeEdit'); this.$emit('closeEdit');
this.showEditDialog = false; this.showEditDialog = false;
if (this.blockedByThisUser) {
await this.unlockObject({ id: this.container.id, type: 'courseware-containers' }); await this.unlockObject({ id: this.container.id, type: 'courseware-containers' });
}
await this.loadContainer({ id: this.container.id, options: { include: 'edit-blocker' } });
}, },
async storeContainer() { async storeContainer() {
await this.loadContainer({ id: this.container.id, options: { include: 'edit-blocker' } });
if (this.blockedByThisUser) {
this.$emit('storeContainer');
}
if (this.blockedByAnotherUser) {
this.companionWarning({ info: this.$gettextInterpolate('Ihre Änderungen konnten nicht gespeichert werden, da %{blockingUserName} die Bearbeitung übernommen hat.', {blockingUserName: this.blockingUserName}) });
this.$emit('closeEdit');
}
if (this.blockerId === null) {
await this.lockObject({ id: this.container.id, type: 'courseware-containers' });
this.$emit('storeContainer'); this.$emit('storeContainer');
}
this.showEditDialog = false; this.showEditDialog = false;
// await this.unlockObject({ id: this.container.id, type: 'courseware-containers' });
}, },
async displayDeleteDialog() { async displayDeleteDialog() {
await this.loadContainer({ id: this.container.id, options: { include: 'edit-blocker' } });
if (!this.blocked) {
await this.lockObject({ id: this.container.id, type: 'courseware-containers' }); await this.lockObject({ id: this.container.id, type: 'courseware-containers' });
this.showDeleteDialog = true; this.showDeleteDialog = true;
} else {
if (this.blockedByThisUser) {
this.showDeleteDialog = true;
} else {
this.companionInfo({ info: this.$gettextInterpolate('Löschen nicht möglich, da %{blockingUserName} den Abschnitt bearbeitet.', {blockingUserName: this.blockingUserName}) });
}
}
}, },
async closeDeleteDialog() { async closeDeleteDialog() {
await this.loadContainer({ id: this.container.id, options: { include: 'edit-blocker' } });
if (this.blockedByThisUser) {
await this.unlockObject({ id: this.container.id, type: 'courseware-containers' }); await this.unlockObject({ id: this.container.id, type: 'courseware-containers' });
}
this.showDeleteDialog = false; this.showDeleteDialog = false;
}, },
async executeDelete() { async executeDelete() {
await this.loadContainer({ id: this.container.id, options: { include: 'edit-blocker' } });
if (this.blockedByAnotherUser) {
this.companionInfo({ info: this.$gettextInterpolate('Löschen nicht möglich, da %{blockingUserName} die Bearbeitung übernommen hat.', {blockingUserName: this.blockingUserName}) });
return false;
}
await this.deleteContainer({ await this.deleteContainer({
containerId: this.container.id, containerId: this.container.id,
structuralElementId: this.container.relationships['structural-element'].data.id, structuralElementId: this.container.relationships['structural-element'].data.id,
...@@ -155,24 +210,31 @@ export default { ...@@ -155,24 +210,31 @@ export default {
this.showDeleteDialog = false; this.showDeleteDialog = false;
}, },
async sortBlocks() { async sortBlocks() {
await this.loadContainer({ id: this.container.id, options: { include: 'edit-blocker' } });
if (this.blockedByAnotherUser) { if (this.blockedByAnotherUser) {
this.companionInfo({ info: this.$gettext('Dieser Abschnitt wird bereits bearbeitet.') }); this.companionInfo({ info: this.$gettext('Dieser Abschnitt wird bereits bearbeitet.') });
return false; return false;
} }
try {
await this.lockObject({ id: this.container.id, type: 'courseware-containers' }); await this.lockObject({ id: this.container.id, type: 'courseware-containers' });
} catch(error) { this.$emit('sortBlocks');
if (error.status === 409) { },
this.companionInfo({ info: this.$gettext('Dieser Abschnitt wird bereits bearbeitet.') }); displayRemoveLockDialog() {
} else { this.showRemoveLockDialog = true;
console.log(error); },
} async executeRemoveLock() {
await this.unlockObject({ id: this.container.id , type: 'courseware-containers' });
await this.loadContainer({ id: this.container.id });
this.showRemoveLockDialog = false;
},
return false; },
watch: {
showEditDialog(state) {
this.$emit('showEdit', state);
} }
this.$emit('sortBlocks');
} }
},
}; };
</script> </script>
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="true" :preview="true"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
...@@ -117,12 +118,13 @@ import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue'; ...@@ -117,12 +118,13 @@ import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue';
import CoursewareFileChooser from './CoursewareFileChooser.vue'; import CoursewareFileChooser from './CoursewareFileChooser.vue';
import CoursewareTabs from './CoursewareTabs.vue'; import CoursewareTabs from './CoursewareTabs.vue';
import CoursewareTab from './CoursewareTab.vue'; import CoursewareTab from './CoursewareTab.vue';
import { blockMixin } from './block-mixin.js';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import StudipIcon from '../StudipIcon.vue'; import StudipIcon from '../StudipIcon.vue';
export default { export default {
name: 'courseware-dialog-cards-block', name: 'courseware-dialog-cards-block',
mixins: [blockMixin],
components: { components: {
CoursewareDefaultBlock, CoursewareDefaultBlock,
CoursewareFileChooser, CoursewareFileChooser,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="false" :preview="false"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
...@@ -69,6 +70,7 @@ ...@@ -69,6 +70,7 @@
<script> <script>
import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue'; import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue';
import CoursewareFileChooser from './CoursewareFileChooser.vue'; import CoursewareFileChooser from './CoursewareFileChooser.vue';
import { blockMixin } from './block-mixin.js';
import * as pdfjsLib from 'pdfjs-dist'; import * as pdfjsLib from 'pdfjs-dist';
import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry'; import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry';
...@@ -76,6 +78,7 @@ import { mapActions } from 'vuex'; ...@@ -76,6 +78,7 @@ import { mapActions } from 'vuex';
export default { export default {
name: 'courseware-document-block', name: 'courseware-document-block',
mixins: [blockMixin],
components: { components: {
CoursewareDefaultBlock, CoursewareDefaultBlock,
CoursewareFileChooser, CoursewareFileChooser,
...@@ -256,7 +259,6 @@ export default { ...@@ -256,7 +259,6 @@ export default {
containerId: this.block.relationships.container.data.id, containerId: this.block.relationships.container.data.id,
}); });
} }
}, },
}, },
}; };
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="true" :preview="true"
:defaultGrade="false" :defaultGrade="false"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
...@@ -77,11 +78,12 @@ ...@@ -77,11 +78,12 @@
<script> <script>
import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue'; import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue';
import CoursewareFileChooser from './CoursewareFileChooser.vue'; import CoursewareFileChooser from './CoursewareFileChooser.vue';
import { blockMixin } from './block-mixin.js';
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
export default { export default {
name: 'courseware-download-block', name: 'courseware-download-block',
mixins: [blockMixin],
components: { components: {
CoursewareDefaultBlock, CoursewareDefaultBlock,
CoursewareFileChooser, CoursewareFileChooser,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="false" :preview="false"
@showEdit="initCurrentData"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
...@@ -87,11 +88,12 @@ ...@@ -87,11 +88,12 @@
<script> <script>
import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue'; import CoursewareDefaultBlock from './CoursewareDefaultBlock.vue';
import { blockMixin } from './block-mixin.js';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
export default { export default {
name: 'courseware-embed-block', name: 'courseware-embed-block',
mixins: [blockMixin],
components: { components: {
CoursewareDefaultBlock, CoursewareDefaultBlock,
}, },
...@@ -245,5 +247,6 @@ export default { ...@@ -245,5 +247,6 @@ export default {
}); });
}, },
}, },
}; };
</script> </script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment