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 @@ ...@@ -356,7 +356,7 @@
<label> <label>
<translate>Position der neuen Seite</translate> <translate>Position der neuen Seite</translate>
<select v-model="newChapterParent"> <select v-model="newChapterParent">
<option v-if="!isRoot" value="sibling"> <option v-if="!isRoot && canEditParent" value="sibling">
<translate>Neben der aktuellen Seite</translate> <translate>Neben der aktuellen Seite</translate>
</option> </option>
<option value="descendant"><translate>Unterhalb der aktuellen Seite</translate></option> <option value="descendant"><translate>Unterhalb der aktuellen Seite</translate></option>
...@@ -941,6 +941,16 @@ export default { ...@@ -941,6 +941,16 @@ export default {
return this.structuralElement.attributes['can-edit']; 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() { isRoot() {
return this.structuralElement.relationships.parent.data === null; return this.structuralElement.relationships.parent.data === null;
}, },
...@@ -1591,7 +1601,7 @@ export default { ...@@ -1591,7 +1601,7 @@ export default {
console.debug(error); console.debug(error);
}); });
}, },
async createElement() { createElement() {
let title = this.newChapterName; // this is the title of the new element let title = this.newChapterName; // this is the title of the new element
let parent_id = this.currentId; // new page is descandant as default let parent_id = this.currentId; // new page is descandant as default
let writeApproval = this.currentElement.attributes['write-approval']; let writeApproval = this.currentElement.attributes['write-approval'];
...@@ -1607,7 +1617,7 @@ export default { ...@@ -1607,7 +1617,7 @@ export default {
readApproval = []; readApproval = [];
} }
this.showElementAddDialog(false); this.showElementAddDialog(false);
await this.createStructuralElement({ this.createStructuralElement({
attributes: { attributes: {
title: title, title: title,
'write-approval': writeApproval, 'write-approval': writeApproval,
...@@ -1615,14 +1625,26 @@ export default { ...@@ -1615,14 +1625,26 @@ export default {
}, },
parentId: parent_id, parentId: parent_id,
currentId: this.currentId, currentId: this.currentId,
})
.then(() => {
let newElement = this.$store.getters['courseware-structural-elements/lastCreated'];
this.companionSuccess({
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 });
}); });
let newElement = this.$store.getters['courseware-structural-elements/lastCreated'];
this.companionSuccess({
info: this.$gettextInterpolate(
this.$gettext('Die Seite %{ pageTitle } wurde erfolgreich angelegt.'),
{pageTitle: newElement.attributes.title}
)
});
this.newChapterName = ''; this.newChapterName = '';
}, },
containerComponent(container) { containerComponent(container) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment