Skip to content
Snippets Groups Projects
Commit 6722029b authored by Ron Lucke's avatar Ron Lucke
Browse files

fix #3151

Closes #3151

Merge request studip/studip!2487
parent 6ad12621
No related branches found
No related tags found
No related merge requests found
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
handle=".cw-sortable-handle" handle=".cw-sortable-handle"
group="blocks" group="blocks"
@start="isDragging = true" @start="isDragging = true"
@end="dropBlock"
:containerId="container.id" :containerId="container.id"
:sectionId="index" :sectionId="index"
> >
......
...@@ -680,6 +680,7 @@ import IsoDate from '../layouts/IsoDate.vue'; ...@@ -680,6 +680,7 @@ import IsoDate from '../layouts/IsoDate.vue';
import FeedbackDialog from '../../feedback/FeedbackDialog.vue' import FeedbackDialog from '../../feedback/FeedbackDialog.vue'
import FeedbackCreateDialog from '../../feedback/FeedbackCreateDialog.vue'; import FeedbackCreateDialog from '../../feedback/FeedbackCreateDialog.vue';
import StudipFiveStars from '../../feedback/StudipFiveStars.vue'; import StudipFiveStars from '../../feedback/StudipFiveStars.vue';
import StudipProgressIndicator from '../../StudipProgressIndicator.vue';
import draggable from 'vuedraggable'; import draggable from 'vuedraggable';
import containerMixin from '@/vue/mixins/courseware/container.js'; import containerMixin from '@/vue/mixins/courseware/container.js';
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
...@@ -712,6 +713,7 @@ export default { ...@@ -712,6 +713,7 @@ export default {
IsoDate, IsoDate,
StockImageSelector, StockImageSelector,
StudipDialog, StudipDialog,
StudipProgressIndicator,
draggable, draggable,
}), }),
props: ['canVisit', 'orderedStructuralElements', 'structuralElement'], props: ['canVisit', 'orderedStructuralElements', 'structuralElement'],
...@@ -770,7 +772,6 @@ export default { ...@@ -770,7 +772,6 @@ export default {
'expire-date': '' 'expire-date': ''
}, },
deletingPreviewImage: false, deletingPreviewImage: false,
processing: false,
keyboardSelected: null, keyboardSelected: null,
assistiveLive: '', assistiveLive: '',
uploadImageURL: null, uploadImageURL: null,
...@@ -845,7 +846,8 @@ export default { ...@@ -845,7 +846,8 @@ export default {
getFeedbackElementById: 'feedback-elements/byId', getFeedbackElementById: 'feedback-elements/byId',
feedbackEntries: 'feedback-entries/all', feedbackEntries: 'feedback-entries/all',
currentUser: 'currentUser' currentUser: 'currentUser',
processing: 'processing',
}), }),
currentId() { currentId() {
...@@ -1446,6 +1448,7 @@ export default { ...@@ -1446,6 +1448,7 @@ export default {
loadRelatedFeedback: 'courseware-structural-element-feedback/loadRelated', loadRelatedFeedback: 'courseware-structural-element-feedback/loadRelated',
createFeedback: 'feedback-elements/create', createFeedback: 'feedback-elements/create',
loadFeedbackElement: 'feedback-elements/loadById', loadFeedbackElement: 'feedback-elements/loadById',
setProcessing: 'setProcessing',
}), }),
initCurrent() { initCurrent() {
...@@ -1624,7 +1627,7 @@ export default { ...@@ -1624,7 +1627,7 @@ export default {
}, },
async storeSort() { async storeSort() {
const timeout = setTimeout(() => this.processing = true, 800); const timeout = setTimeout(() => this.setProcessing(true), 800);
if (this.blockedByAnotherUser) { if (this.blockedByAnotherUser) {
this.companionInfo({ info: this.$gettext('Diese Seite wird bereits bearbeitet.') }); this.companionInfo({ info: this.$gettext('Diese Seite wird bereits bearbeitet.') });
clearTimeout(timeout); clearTimeout(timeout);
...@@ -1641,7 +1644,7 @@ export default { ...@@ -1641,7 +1644,7 @@ export default {
} }
clearTimeout(timeout); clearTimeout(timeout);
this.processing = false; this.setProcessing(false);
return false; return false;
} }
...@@ -1652,7 +1655,7 @@ export default { ...@@ -1652,7 +1655,7 @@ export default {
this.$emit('select', this.currentId); this.$emit('select', this.currentId);
clearTimeout(timeout); clearTimeout(timeout);
this.processing = false; this.setProcessing(false);
}, },
......
...@@ -21,6 +21,7 @@ const containerMixin = { ...@@ -21,6 +21,7 @@ const containerMixin = {
updateBlock: 'updateBlock', updateBlock: 'updateBlock',
updateContainer: 'updateContainer', updateContainer: 'updateContainer',
loadContainer: 'courseware-containers/loadById', loadContainer: 'courseware-containers/loadById',
loadBlock: 'courseware-blocks/loadById',
loadStructuralElement: 'loadStructuralElement', loadStructuralElement: 'loadStructuralElement',
lockObject: 'lockObject', lockObject: 'lockObject',
unlockObject: 'unlockObject', unlockObject: 'unlockObject',
...@@ -31,6 +32,8 @@ const containerMixin = { ...@@ -31,6 +32,8 @@ const containerMixin = {
companionWarning: 'companionWarning', companionWarning: 'companionWarning',
sortContainersInStructualElements: 'sortContainersInStructualElements', sortContainersInStructualElements: 'sortContainersInStructualElements',
setAdderStorage: 'coursewareBlockAdder', setAdderStorage: 'coursewareBlockAdder',
setProcessing: 'setProcessing',
containerUpdate: 'courseware-containers/update'
}), }),
dropBlock(e) { dropBlock(e) {
this.isDragging = false; // implemented bei echt container type this.isDragging = false; // implemented bei echt container type
...@@ -52,41 +55,41 @@ const containerMixin = { ...@@ -52,41 +55,41 @@ const containerMixin = {
} }
}, },
async storeInAnotherContainer(data) { async storeInAnotherContainer(data) {
// update block container id this.setProcessing(true);
let block = this.blockById({id: data.blockId });
block.relationships.container.data.id = data.targetContainerId;
block.attributes.position = data.newPos;
await this.lockObject({ id: data.blockId, type: 'courseware-blocks' });
await this.updateBlock({
block: block,
containerId: data.targetContainerId,
});
await this.unlockObject({ id: data.blockId, type: 'courseware-blocks' });
// update origin container // update origin container
if (data.originContainerId) { if (data.originContainerId) {
await this.lockObject({ id: data.originContainerId, type: 'courseware-containers' });
await this.loadContainer({ id : data.originContainerId });
let originContainer = this.containerById({ id: data.originContainerId}); let originContainer = this.containerById({ id: data.originContainerId});
originContainer.attributes.payload.sections[data.originSectionId].blocks = data.originSectionBlockList; originContainer.attributes.payload.sections[data.originSectionId].blocks = data.originSectionBlockList;
await this.lockObject({ id: data.originContainerId, type: 'courseware-containers' }); await this.containerUpdate(
await this.updateContainer({ originContainer,
container: originContainer, );
structuralElementId: originContainer.relationships['structural-element'].data.id,
});
await this.unlockObject({ id: data.originContainerId, type: 'courseware-containers' }); await this.unlockObject({ id: data.originContainerId, type: 'courseware-containers' });
} }
// update target container // update target container
await this.lockObject({ id: data.targetContainerId, type: 'courseware-containers' });
await this.loadContainer({ id : data.targetContainerId });
let targetContainer = this.containerById({ id: data.targetContainerId}); let targetContainer = this.containerById({ id: data.targetContainerId});
targetContainer.attributes.payload.sections[data.targetSectionId].blocks = data.targetSectionBlockList; targetContainer.attributes.payload.sections[data.targetSectionId].blocks = data.targetSectionBlockList;
await this.lockObject({ id: data.targetContainerId, type: 'courseware-containers' }); await this.containerUpdate(
await this.updateContainer({ targetContainer,
container: targetContainer, );
structuralElementId: targetContainer.relationships['structural-element'].data.id,
});
await this.unlockObject({ id: data.targetContainerId, type: 'courseware-containers' }); await this.unlockObject({ id: data.targetContainerId, type: 'courseware-containers' });
this.loadContainer({id : data.originContainerId }); // update block container id
this.loadContainer({id : data.targetContainerId }); let block = this.blockById({id: data.blockId });
block.relationships.container.data.id = data.targetContainerId;
block.attributes.position = data.newPos;
await this.lockObject({ id: block.id, type: 'courseware-blocks' });
await this.updateBlock({
block: block,
containerId: data.targetContainerId,
});
await this.unlockObject({ id: block.id, type: 'courseware-blocks' });
await this.loadBlock({ id: block.id });
await this.loadContainer({ id : data.originContainerId });
this.setProcessing(false);
}, },
checkSimpleArrayEquality(firstSet, secondSet) { checkSimpleArrayEquality(firstSet, secondSet) {
return Array.isArray(firstSet) && Array.isArray(secondSet) && return Array.isArray(firstSet) && Array.isArray(secondSet) &&
......
...@@ -68,6 +68,7 @@ const getDefaultState = () => { ...@@ -68,6 +68,7 @@ const getDefaultState = () => {
toolbarActive: true, toolbarActive: true,
feedbackSettings: null, feedbackSettings: null,
processing: false,
}; };
}; };
...@@ -287,6 +288,9 @@ const getters = { ...@@ -287,6 +288,9 @@ const getters = {
progresses(state) { progresses(state) {
return state.progresses; return state.progresses;
}, },
processing(state) {
return state.processing;
},
oerCampusEnabled(state, getters, rootState, rootGetters) { oerCampusEnabled(state, getters, rootState, rootGetters) {
return rootGetters['studip-properties/byId']({ id: 'oer-campus-enabled'}).attributes?.value; return rootGetters['studip-properties/byId']({ id: 'oer-campus-enabled'}).attributes?.value;
...@@ -1457,6 +1461,10 @@ export const actions = { ...@@ -1457,6 +1461,10 @@ export const actions = {
commit('setBookmarkFilter', course); commit('setBookmarkFilter', course);
}, },
setProcessing({ commit }, processing) {
commit('setProcessing', processing);
},
createLink({ dispatch, rootGetters }, { publicLink }) { createLink({ dispatch, rootGetters }, { publicLink }) {
dispatch('courseware-public-links/create', publicLink, { root: true }); dispatch('courseware-public-links/create', publicLink, { root: true });
}, },
...@@ -1748,6 +1756,9 @@ export const mutations = { ...@@ -1748,6 +1756,9 @@ export const mutations = {
}, },
setFeedbackSettings(state, feedbackSettings) { setFeedbackSettings(state, feedbackSettings) {
state.feedbackSettings = feedbackSettings; state.feedbackSettings = feedbackSettings;
},
setProcessing(state, processing) {
state.processing = processing;
} }
}; };
......
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