Skip to content
Snippets Groups Projects
Commit 108f0ee8 authored by Farbod Zamani's avatar Farbod Zamani Committed by Ron Lucke
Browse files

CW: Add terms of use to export

Closes #1738 and #921

Merge request studip/studip!1169
parent b1df2e8c
No related branches found
No related tags found
No related merge requests found
...@@ -239,7 +239,7 @@ export default { ...@@ -239,7 +239,7 @@ export default {
if (fileId) { if (fileId) {
await this.$store.dispatch('file-refs/loadById', {id: fileId}); await this.$store.dispatch('file-refs/loadById', {id: fileId});
let fileRef = this.$store.getters['file-refs/byId']({id: fileId}); let fileRef = this.$store.getters['file-refs/byId']({id: fileId});
let fileRefData = {}; let fileRefData = {};
fileRefData.id = fileRef.id; fileRefData.id = fileRef.id;
fileRefData.attributes = fileRef.attributes; fileRefData.attributes = fileRef.attributes;
...@@ -310,6 +310,19 @@ export default { ...@@ -310,6 +310,19 @@ export default {
fileref.related_block_id = block_id; fileref.related_block_id = block_id;
fileref.id = refs[ref_id].id; fileref.id = refs[ref_id].id;
// Create an empty relationships object to pick and hold selected relationships of the fileref. Because not all of
// them are necessary.
let relationships = {};
// Get terms-of-use id from relationships.
if (refs[ref_id].relationships?.['terms-of-use']?.data?.id) {
let terms = {'data' : refs[ref_id].relationships['terms-of-use'].data};
relationships['terms-of-use'] = terms;
}
// Add relationships to the fileref object if it has some values.
if (Object.keys(relationships).length > 0) {
fileref.relationships = relationships;
}
try { try {
await this.loadFolder(folderId); await this.loadFolder(folderId);
folder = this.folderById({id: folderId}); folder = this.folderById({id: folderId});
......
...@@ -314,7 +314,7 @@ export const actions = { ...@@ -314,7 +314,7 @@ export const actions = {
}, },
async createFile(context, { file, filedata, folder }) { async createFile(context, { file, filedata, folder }) {
const termId = file?.relationships['terms-of-use']?.data?.id ?? null; const termId = file?.relationships?.['terms-of-use']?.data?.id ?? null;
const formData = new FormData(); const formData = new FormData();
formData.append('file', filedata, file.attributes.name); formData.append('file', filedata, file.attributes.name);
if (termId) { if (termId) {
......
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