Skip to content
Snippets Groups Projects
Commit a6e116ec authored by Farbod Zamani's avatar Farbod Zamani Committed by Jan-Hendrik Willms
Browse files

CW: Add terms of use to export

Closes #1738 and #921

Merge request studip/studip!1169
parent 34e5c216
No related branches found
No related tags found
No related merge requests found
......@@ -310,6 +310,19 @@ export default {
fileref.related_block_id = block_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 {
await this.loadFolder(folderId);
folder = this.folderById({id: folderId});
......
......@@ -292,7 +292,7 @@ export const actions = {
},
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();
formData.append('file', filedata, file.attributes.name);
if (termId) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment