Skip to content
Snippets Groups Projects
Commit 93e959ec authored by Ron Lucke's avatar Ron Lucke Committed by Elmar Ludwig
Browse files

closes #326

parent 2d154927
No related branches found
No related tags found
No related merge requests found
......@@ -16,25 +16,10 @@
},
"endtime": {
"type": "string"
},
"oembed_request": {
"type": "string"
},
"oembed-unauthorized": {
"type": "boolean"
},
"oembed-not-found": {
"type": "boolean"
},
"oembed": {
"type": "object"
},
"request": {
"type": "string"
}
},
"required": [
"url", "source"
],
"additionalProperties": false
"additionalProperties": true
}
......@@ -131,6 +131,10 @@
<translate>Alles importieren</translate>
</button>
<ul v-if="importErrors.length > 0">
<li v-for="error in importErrors"> {{error}} </li>
</ul>
<input ref="importFile" type="file" accept=".zip" @change="setImport" style="visibility: hidden" />
</courseware-tab>
</courseware-tabs>
......@@ -184,6 +188,7 @@ export default {
importFilesProgress: 'importFilesProgress',
importStructuresState: 'importStructuresState',
importStructuresProgress: 'importStructuresProgress',
importErrors: 'importErrors',
exportState: 'exportState',
exportProgress: 'exportProgress'
}),
......
......@@ -7,6 +7,7 @@ export default {
file_mapping: {},
elementCounter: 0,
importElementCounter: 0,
currentImportErrors: [],
};
},
......@@ -27,6 +28,7 @@ export default {
this.elementCounter = await this.countImportElements([element]);
this.setImportStructuresState('');
this.importElementCounter = 0;
this.setImportErrors([]);
await this.importStructuralElement([element], parent_id, files);
......@@ -61,7 +63,6 @@ export default {
async importStructuralElement(element, parent_id, files) {
if (element.length) {
for (var i = 0; i < element.length; i++) {
// TODO: create element on server and fetch new id
this.setImportStructuresState('Lege Seite an: ' + element[i].attributes.title);
await this.createStructuralElement({
attributes: element[i].attributes,
......@@ -93,8 +94,10 @@ export default {
let new_block = null;
for (var k = 0; k < container.blocks.length; k++) {
new_block = await this.importBlock(container.blocks[k], new_container, files);
this.importElementCounter++;
await this.updateContainerPayload(new_container, new_element.id, container.blocks[k].id, new_block.id);
if (new_block !== null) {
this.importElementCounter++;
await this.updateContainerPayload(new_container, new_element.id, container.blocks[k].id, new_block.id);
}
}
}
......@@ -105,12 +108,17 @@ export default {
},
async importBlock(block, block_container, files) {
// TODO: create element
this.setImportStructuresState('Lege neuen Block an: ' + block.attributes.title);
await this.createBlockInContainer({
container: {type: block_container.type, id: block_container.id},
blockType: block.attributes['block-type'],
});
try {
await this.createBlockInContainer({
container: {type: block_container.type, id: block_container.id},
blockType: block.attributes['block-type'],
});
} catch(error) {
this.currentImportErrors.push(this.$gettext('Block konnte nicht erstellt werden') + ': ' + block.attributes.title);
return null;
}
let new_block = this.$store.getters['courseware-blocks/lastCreated'];
......@@ -155,7 +163,6 @@ export default {
await this.unlockObject({ id: container.id, type: 'courseware-containers' });
},
async uploadAllFiles(files) {
// create folder for importing the files into
this.setImportFilesProgress(0);
......@@ -241,6 +248,7 @@ export default {
'setImportFilesProgress',
'setImportStructuresState',
'setImportStructuresProgress',
'setImportErrors',
]),
},
watch: {
......@@ -250,6 +258,11 @@ export default {
} else {
this.setImportStructuresProgress(100);
}
},
currentImportErrors(errors) {
if(errors.length > 0) {
this.setImportErrors(errors);
}
}
},
};
......@@ -37,6 +37,7 @@ const getDefaultState = () => {
importFilesProgress: 0,
importStructuresState: '',
importStructuresProgress: 0,
importErrors: [],
exportState: '',
exportProgress: 0,
......@@ -154,6 +155,9 @@ const getters = {
importStructuresProgress(state) {
return state.importStructuresProgress;
},
importErrors(state) {
return state.importErrors;
},
exportState(state) {
return state.exportState;
},
......@@ -716,6 +720,9 @@ export const actions = {
setImportStructuresProgress({commit}, percent ) {
commit('setImportStructuresProgress', percent)
},
setImportErrors({commit}, errors) {
commit('setImportErrors', errors);
},
setExportState({commit}, state) {
commit('setExportState', state)
......@@ -1074,6 +1081,9 @@ export const mutations = {
setImportFilesProgress(state, importFilesProgress) {
state.importFilesProgress = importFilesProgress;
},
setImportErrors(state, importErrors) {
state.importErrors = importErrors;
},
setImportStructuresState(state, importStructuresState) {
state.importStructuresState = importStructuresState;
......
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