diff --git a/resources/vue/components/courseware/containers/CoursewareTabsContainer.vue b/resources/vue/components/courseware/containers/CoursewareTabsContainer.vue index fd7450c7797d11d1533731a6da736d5dd8990332..e9c45ca4fe6c36ee40e696fcab3ce8a004e0727f 100644 --- a/resources/vue/components/courseware/containers/CoursewareTabsContainer.vue +++ b/resources/vue/components/courseware/containers/CoursewareTabsContainer.vue @@ -24,7 +24,7 @@ {{ $gettext('Drücken Sie die Leertaste, um neu anzuordnen.') }} </span> </template> - <courseware-tabs> + <courseware-tabs @selectTab="selectTabHandler"> <courseware-tab v-for="(section, index) in currentSections" :key="index" @@ -205,6 +205,7 @@ export default { loadContainer: 'courseware-containers/loadById', lockObject: 'lockObject', unlockObject: 'unlockObject', + storeContainerRecord: 'courseware-containers/storeRecord' }), initCurrentData() { this.currentContainer = _.cloneDeep(this.container); @@ -402,6 +403,18 @@ export default { , {blockTitle: block.attributes.title, pos: currentIndex + 1, listLength: this.currentSections[sectionIndex].blocks.length} ); this.storeSort(); + }, + selectTabHandler(event) { + const tabIndex = event.index; + let container = _.cloneDeep(this.container); + container.activeSection = tabIndex; + this.storeContainerRecord(container); + if (this.blockAdder.container.id === this.container.id) { + this.setAdderStorage({ + container: this.container, + section: tabIndex + }); + } } }, watch: { diff --git a/resources/vue/mixins/courseware/container.js b/resources/vue/mixins/courseware/container.js index 2eb7549949ec91c36ef93fe4b1e4e4176461eea9..de162f9d8f42f842d0fbe88b9df483ace457581e 100644 --- a/resources/vue/mixins/courseware/container.js +++ b/resources/vue/mixins/courseware/container.js @@ -253,9 +253,11 @@ const containerMixin = { // choose the last container and its last section as the default adder slot // for adding blocks and containers via click if (this.containers) { + const lastContainer = this.containers[this.containers.length - 1]; + const section = lastContainer.activeSection ?? 0; this.setAdderStorage({ - container: this.containers[this.containers.length - 1], - section: this.containers[this.containers.length - 1].attributes.payload.sections.length - 1 + container: lastContainer, + section: section }); } },