diff --git a/resources/vue/components/courseware/CoursewareStructuralElement.vue b/resources/vue/components/courseware/CoursewareStructuralElement.vue index 7652a8dc4dbf1287d299bcf66d7f673f72adcff8..436dbac1d3458529d9e590b1668d404e90d69249 100644 --- a/resources/vue/components/courseware/CoursewareStructuralElement.vue +++ b/resources/vue/components/courseware/CoursewareStructuralElement.vue @@ -675,6 +675,7 @@ import { FocusTrap } from 'focus-trap-vue'; import IsoDate from './IsoDate.vue'; import StockImageSelector from '../stock-images/SelectorDialog.vue'; import StudipDialog from '../StudipDialog.vue'; +import StudipProgressIndicator from '../StudipProgressIndicator.vue'; import draggable from 'vuedraggable'; import { mapActions, mapGetters } from 'vuex'; @@ -702,6 +703,7 @@ export default { IsoDate, StockImageSelector, StudipDialog, + StudipProgressIndicator, draggable, }, props: ['canVisit', 'orderedStructuralElements', 'structuralElement'], @@ -767,7 +769,6 @@ export default { 'expire-date': '' }, deletingPreviewImage: false, - processing: false, keyboardSelected: null, assistiveLive: '', uploadImageURL: null, @@ -821,6 +822,8 @@ export default { templates: 'courseware-templates/all', progressData: 'progresses', + + processing: 'processing', }), currentId() { @@ -1280,7 +1283,8 @@ export default { loadStructuralElement: 'loadStructuralElement', createLink: 'createLink', setCurrentElementId: 'coursewareCurrentElement', - loadProgresses: 'loadProgresses' + loadProgresses: 'loadProgresses', + setProcessing: 'setProcessing', }), initCurrent() { @@ -1452,7 +1456,7 @@ export default { }, async storeSort() { - const timeout = setTimeout(() => this.processing = true, 800); + const timeout = setTimeout(() => this.setProcessing(true), 800); if (this.blockedByAnotherUser) { this.companionInfo({ info: this.$gettext('Diese Seite wird bereits bearbeitet.') }); clearTimeout(timeout); @@ -1469,7 +1473,7 @@ export default { } clearTimeout(timeout); - this.processing = false; + this.setProcessing(false); return false; } @@ -1480,7 +1484,7 @@ export default { this.$emit('select', this.currentId); clearTimeout(timeout); - this.processing = false; + this.setProcessing(false); }, async exportCurrentElement(data) { diff --git a/resources/vue/mixins/courseware/container.js b/resources/vue/mixins/courseware/container.js index e4e02ddef53c7fb025ed400ca6bbbb13be0758fb..7022cbd6aacdda8583cfeb15567902da0002b6f1 100644 --- a/resources/vue/mixins/courseware/container.js +++ b/resources/vue/mixins/courseware/container.js @@ -16,8 +16,19 @@ const containerMixin = { updateBlock: 'updateBlock', updateContainer: 'updateContainer', loadContainer: 'courseware-containers/loadById', + loadBlock: 'courseware-blocks/loadById', + loadStructuralElement: 'loadStructuralElement', lockObject: 'lockObject', unlockObject: 'unlockObject', + createBlock: 'createBlockInContainer', + createContainer: 'createContainer', + companionInfo: 'companionInfo', + companionSuccess: 'companionSuccess', + companionWarning: 'companionWarning', + sortContainersInStructualElements: 'sortContainersInStructualElements', + setAdderStorage: 'coursewareBlockAdder', + setProcessing: 'setProcessing', + containerUpdate: 'courseware-containers/update' }), dropBlock(e) { this.isDragging = false; // implemented bei echt container type @@ -39,39 +50,41 @@ const containerMixin = { } }, async storeInAnotherContainer(data) { + this.setProcessing(true); + // update origin container + 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}); + originContainer.attributes.payload.sections[data.originSectionId].blocks = data.originSectionBlockList; + await this.containerUpdate( + originContainer, + ); + await this.unlockObject({ id: data.originContainerId, type: 'courseware-containers' }); + } + // 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}); + targetContainer.attributes.payload.sections[data.targetSectionId].blocks = data.targetSectionBlockList; + await this.containerUpdate( + targetContainer, + ); + await this.unlockObject({ id: data.targetContainerId, type: 'courseware-containers' }); + // update block container id 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.lockObject({ id: block.id, type: 'courseware-blocks' }); await this.updateBlock({ block: block, containerId: data.targetContainerId, }); - await this.unlockObject({ id: data.blockId, type: 'courseware-blocks' }); - - // update origin container - let originContainer = this.containerById({ id: data.originContainerId}); - originContainer.attributes.payload.sections[data.originSectionId].blocks = data.originSectionBlockList; - await this.lockObject({ id: data.originContainerId, type: 'courseware-containers' }); - await this.updateContainer({ - container: originContainer, - structuralElementId: originContainer.relationships['structural-element'].data.id, - }); - await this.unlockObject({ id: data.originContainerId, type: 'courseware-containers' }); - - // update target container - let targetContainer = this.containerById({ id: data.targetContainerId}); - targetContainer.attributes.payload.sections[data.targetSectionId].blocks = data.targetSectionBlockList; - await this.lockObject({ id: data.targetContainerId, type: 'courseware-containers' }); - await this.updateContainer({ - container: targetContainer, - structuralElementId: targetContainer.relationships['structural-element'].data.id, - }); - await this.unlockObject({ id: data.targetContainerId, type: 'courseware-containers' }); - - this.loadContainer({id : data.originContainerId }); - this.loadContainer({id : 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) { return Array.isArray(firstSet) && Array.isArray(secondSet) && diff --git a/resources/vue/store/courseware/courseware.module.js b/resources/vue/store/courseware/courseware.module.js index 0f56e3e7af87e3fa9d52c9c8a113a541f46f260f..e9fde56ad505bce75469fa9b4cfb8ee2fa19f72d 100644 --- a/resources/vue/store/courseware/courseware.module.js +++ b/resources/vue/store/courseware/courseware.module.js @@ -61,7 +61,8 @@ const getDefaultState = () => { searchResults: [], assistiveLiveContents: '', - progresses: null + progresses: null, + processing: false, }; }; @@ -258,7 +259,17 @@ const getters = { }, progresses(state) { return state.progresses; - } + }, + processing(state) { + return state.processing; + }, + + oerCampusEnabled(state, getters, rootState, rootGetters) { + return rootGetters['studip-properties/byId']({ id: 'oer-campus-enabled'}).attributes?.value; + }, + oerEnableSuggestions(state, getters, rootState, rootGetters) { + return getters.oerCampusEnabled && rootGetters['studip-properties/byId']({ id: 'oer-enable-suggestions'}).attributes?.value; + }, }; export const state = { ...initialState }; @@ -1326,6 +1337,10 @@ export const actions = { commit('setBookmarkFilter', course); }, + setProcessing({ commit }, processing) { + commit('setProcessing', processing); + }, + createLink({ dispatch, rootGetters }, { publicLink }) { dispatch('courseware-public-links/create', publicLink, { root: true }); }, @@ -1593,6 +1608,9 @@ export const mutations = { }, setProgresses(state, data) { state.progresses = data; + }, + setProcessing(state, processing) { + state.processing = processing; } };