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

fix #1610

Closes #1610

Merge request studip/studip!1101
parent e625dd14
No related branches found
No related tags found
No related merge requests found
......@@ -356,7 +356,7 @@
<label>
<translate>Position der neuen Seite</translate>
<select v-model="newChapterParent">
<option v-if="!isRoot" value="sibling">
<option v-if="!isRoot && canEditParent" value="sibling">
<translate>Neben der aktuellen Seite</translate>
</option>
<option value="descendant"><translate>Unterhalb der aktuellen Seite</translate></option>
......@@ -941,6 +941,16 @@ export default {
return this.structuralElement.attributes['can-edit'];
},
canEditParent() {
if (this.isRoot) {
return false;
}
const parentId = this.structuralElement.relationships.parent.data.id;
const parent = this.structuralElementById({ id: parentId });
return parent.attributes['can-edit'];
},
isRoot() {
return this.structuralElement.relationships.parent.data === null;
},
......@@ -1591,7 +1601,7 @@ export default {
console.debug(error);
});
},
async createElement() {
createElement() {
let title = this.newChapterName; // this is the title of the new element
let parent_id = this.currentId; // new page is descandant as default
let writeApproval = this.currentElement.attributes['write-approval'];
......@@ -1607,7 +1617,7 @@ export default {
readApproval = [];
}
this.showElementAddDialog(false);
await this.createStructuralElement({
this.createStructuralElement({
attributes: {
title: title,
'write-approval': writeApproval,
......@@ -1615,14 +1625,26 @@ export default {
},
parentId: parent_id,
currentId: this.currentId,
});
})
.then(() => {
let newElement = this.$store.getters['courseware-structural-elements/lastCreated'];
this.companionSuccess({
info: this.$gettextInterpolate(
info:
this.$gettextInterpolate(
this.$gettext('Die Seite %{ pageTitle } wurde erfolgreich angelegt.'),
{ pageTitle: newElement.attributes.title }
)
});
})
.catch(e => {
let errorMessage = this.$gettext('Es ist ein Fehler aufgetreten. Die Seite konnte nicht erstellt werden.');
if (e.status === 403) {
errorMessage = this.$gettext('Die Seite konnte nicht erstellt werden. Sie haben nicht die notwendigen Schreibrechte.');
}
this.companionError({ info: errorMessage });
});
this.newChapterName = '';
},
containerComponent(container) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment