diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue index 51c27b2ec7..125dcfb452 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue @@ -118,7 +118,7 @@ import uniqWith from 'lodash/uniqWith'; import isEqual from 'lodash/isEqual'; import { enhancedQuizManagementStrings } from 'kolibri-common/strings/enhancedQuizManagementStrings'; - import { toRefs, computed, ref, getCurrentInstance, watch } from 'kolibri.lib.vueCompositionApi'; + import { computed, ref, getCurrentInstance, watch } from 'kolibri.lib.vueCompositionApi'; import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings'; import { ContentNodeResource, ChannelResource } from 'kolibri.resources'; import { ContentNodeKinds } from 'kolibri.coreVue.vuex.constants'; @@ -373,29 +373,22 @@ function handleCancelClose() { showConfirmationModal.value = false; - context.emit('cancelClosePanel'); } function handleConfirmClose() { - handleCancelClose(); context.emit('closePanel'); } - watch(panelClosing, isClosing => { - if (isClosing) { - if ( - workingResourcePool.value.length != activeResourcePool.value.length || - !isEqual(workingResourcePool.value.sort(), activeResourcePool.value.sort()) - ) { - showConfirmationModal.value = true; - } else { - context.emit('cancelClosePanel'); - context.emit('closePanel'); - } - } + const workingPoolHasChanged = computed(() => { + return ( + workingResourcePool.value.length != activeResourcePool.value.length || + !isEqual(workingResourcePool.value.sort(), activeResourcePool.value.sort()) + ); }); return { + prevRoute, + workingPoolHasChanged, handleConfirmClose, handleCancelClose, topic, @@ -548,7 +541,7 @@ //Also reset workingResourcePool this.resetWorkingResourcePool(); - this.$emit('closePanel'); + this.$router.replace(this.prevRoute); }, selectionMetadata(content) { if (content.kind === ContentNodeKinds.TOPIC) { diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue index c8ab33d0bd..4148f156c6 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue @@ -246,7 +246,7 @@ DragContainer, DragHandle, }, - setup(props, context) { + setup(_, context) { const { activeSection, allSections, @@ -255,57 +255,40 @@ deleteSection, } = injectQuizCreation(); - const { panelClosing } = toRefs(props); - const showConfirmationModal = ref(false); function handleCancelClose() { showConfirmationModal.value = false; - context.emit('cancelClosePanel'); } function handleConfirmClose() { - handleCancelClose(); context.emit('closePanel'); } - const selectedQuestionOrder = ref(activeSection.value.learners_see_fixed_order); - const numberOfQuestions = ref(activeSection.value.question_count); - const descriptionText = ref(activeSection.value.description); - const sectionTitle = ref(activeSection.value.section_title); - - const originalFormData = { - selectedQuestionOrder: activeSection.value.learners_see_fixed_order, - numberOfQuestions: activeSection.value.question_count, - descriptionText: activeSection.value.description, - sectionTitle: activeSection.value.section_title, - }; + const learners_see_fixed_order = ref(activeSection.value.learners_see_fixed_order); + const question_count = ref(activeSection.value.question_count); + const description = ref(activeSection.value.description); + const section_title = ref(activeSection.value.section_title); const formDataHasChanged = computed(() => { return !isEqual( { - selectedQuestionOrder: selectedQuestionOrder.value, - numberOfQuestions: numberOfQuestions.value, - descriptionText: descriptionText.value, - sectionTitle: sectionTitle.value, + learners_see_fixed_order: learners_see_fixed_order.value, + question_count: question_count.value, + description: description.value, + section_title: section_title.value, }, - originalFormData + pick(activeSection.value, [ + 'learners_see_fixed_order', + 'question_count', + 'description', + 'section_title', + ]) ); }); const { windowIsLarge, windowIsSmall } = useKResponsiveWindow(); - watch(panelClosing, isClosing => { - if (isClosing) { - if (formDataHasChanged.value) { - showConfirmationModal.value = true; - } else { - context.emit('cancelClosePanel'); - context.emit('closePanel'); - } - } - }); - const { sectionSettings$, sectionTitle$, @@ -326,6 +309,7 @@ } = enhancedQuizManagementStrings; return { + formDataHasChanged, showConfirmationModal, handleCancelClose, handleConfirmClose, @@ -362,14 +346,6 @@ fixedOptionDescription$, }; }, - props: { - // eslint-disable-next-line kolibri/vue-no-unused-properties - panelClosing: { - type: Boolean, - default: false, - required: true, - }, - }, computed: { borderStyle() { return `border: 1px solid ${this.$themeTokens.fineLine}`; @@ -415,7 +391,6 @@ question_count: this.question_count, learners_see_fixed_order: this.learners_see_fixed_order, }); - this.$emit('closePanel'); }, }, }; diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionSidePanel.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionSidePanel.vue index e27fd249e3..0a42fc0a9e 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionSidePanel.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionSidePanel.vue @@ -1,30 +1,21 @@