Skip to content
Snippets Groups Projects
Commit 6dbd486b authored by Ron Lucke's avatar Ron Lucke
Browse files

Biest #320

parent 44d94f1e
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,7 @@ export default { ...@@ -36,6 +36,7 @@ export default {
...mapGetters({ ...mapGetters({
oerEnabled: 'oerEnabled', oerEnabled: 'oerEnabled',
oerTitle: 'oerTitle', oerTitle: 'oerTitle',
userId: 'userId',
}), }),
isRoot() { isRoot() {
if (!this.structuralElement) { if (!this.structuralElement) {
...@@ -53,6 +54,18 @@ export default { ...@@ -53,6 +54,18 @@ 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;
},
}, },
methods: { methods: {
...mapActions({ ...mapActions({
...@@ -67,7 +80,22 @@ export default { ...@@ -67,7 +80,22 @@ export default {
lockObject: 'lockObject', lockObject: 'lockObject',
}), }),
async editElement() { async editElement() {
await this.lockObject({ id: this.currentId, type: 'courseware-structural-elements' }); 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.showElementEditDialog(true); this.showElementEditDialog(true);
}, },
async deleteElement() { async deleteElement() {
......
...@@ -150,10 +150,10 @@ export default { ...@@ -150,10 +150,10 @@ export default {
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.userId === this.blockerId; return this.blocked && this.userId === this.blockerId;
}, },
blockedByAnotherUser() { blockedByAnotherUser() {
return this.userId !== this.blockerId; return this.blocked && this.userId !== this.blockerId;
}, },
blockTitle() { blockTitle() {
const type = this.block.attributes['block-type']; const type = this.block.attributes['block-type'];
...@@ -181,6 +181,9 @@ export default { ...@@ -181,6 +181,9 @@ export default {
loadContainer: 'loadContainer', loadContainer: 'loadContainer',
}), }),
async displayFeature(element) { async displayFeature(element) {
if (this.showEdit && element === 'Edit') {
return false;
}
this.showFeatures = false; this.showFeatures = false;
this.showFeedback = false; this.showFeedback = false;
this.showComments = false; this.showComments = false;
...@@ -190,8 +193,20 @@ export default { ...@@ -190,8 +193,20 @@ 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);
if (!this.blocked) { if (!this.blocked) {
await this.lockObject({ id: this.block.id, type: 'courseware-blocks' }); try {
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;
} }
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<script> <script>
import CoursewareContainerActions from './CoursewareContainerActions.vue'; import CoursewareContainerActions from './CoursewareContainerActions.vue';
import StudipDialog from '../StudipDialog.vue'; import StudipDialog from '../StudipDialog.vue';
import { mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
export default { export default {
name: 'courseware-default-container', name: 'courseware-default-container',
...@@ -76,12 +76,27 @@ export default { ...@@ -76,12 +76,27 @@ export default {
}; };
}, },
computed: { computed: {
...mapGetters({
userId: 'userId',
}),
showEditMode() { showEditMode() {
return this.$store.getters.viewMode === 'edit'; return this.$store.getters.viewMode === 'edit';
}, },
colSpan() { colSpan() {
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() {
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;
},
}, },
methods: { methods: {
...mapActions({ ...mapActions({
...@@ -90,7 +105,23 @@ export default { ...@@ -90,7 +105,23 @@ export default {
unlockObject: 'unlockObject', unlockObject: 'unlockObject',
}), }),
async displayEditDialog() { async displayEditDialog() {
await this.lockObject({ id: this.container.id, type: 'courseware-containers' }); if (this.blockedByAnotherUser) {
this.companionInfo({ info: this.$gettext('Dieser Abschnitt wird bereits bearbeitet.') });
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;
}
this.showEditDialog = true; this.showEditDialog = true;
}, },
async closeEdit() { async closeEdit() {
......
...@@ -555,6 +555,7 @@ export default { ...@@ -555,6 +555,7 @@ export default {
licenses: 'licenses', licenses: 'licenses',
exportState: 'exportState', exportState: 'exportState',
exportProgress: 'exportProgress', exportProgress: 'exportProgress',
userId: 'userId',
}), }),
currentId() { currentId() {
...@@ -907,6 +908,18 @@ export default { ...@@ -907,6 +908,18 @@ export default {
return ''; return '';
}, },
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;
},
}, },
methods: { methods: {
...@@ -936,7 +949,22 @@ export default { ...@@ -936,7 +949,22 @@ export default {
async menuAction(action) { async menuAction(action) {
switch (action) { switch (action) {
case 'editCurrentElement': case 'editCurrentElement':
await this.lockObject({ id: this.currentId, type: 'courseware-structural-elements' }); 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.showElementEditDialog(true); this.showElementEditDialog(true);
break; break;
case 'addElement': case 'addElement':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment