Course: Start restoring Student View button - refs #4678
parent
207f095c67
commit
d728437375
@ -0,0 +1,37 @@ |
|||||||
|
<template> |
||||||
|
<BaseToggleButton |
||||||
|
v-if="isCurrentTeacher && 'true' === platformConfigurationStore.getSetting('course.student_view_enabled')" |
||||||
|
v-model="isStudentView" |
||||||
|
:off-label="t('Switch to student view')" |
||||||
|
:on-label="t('Switch to teacher view')" |
||||||
|
off-icon="eye" |
||||||
|
on-icon="eye" |
||||||
|
/> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script setup> |
||||||
|
import BaseToggleButton from "./basecomponents/BaseToggleButton.vue"; |
||||||
|
import { computed, ref, watch } from "vue"; |
||||||
|
import { useI18n } from "vue-i18n"; |
||||||
|
import { useRoute } from "vue-router"; |
||||||
|
import { useStore } from "vuex"; |
||||||
|
import { usePlatformConfig } from "../store/platformConfig"; |
||||||
|
|
||||||
|
const route = useRoute(); |
||||||
|
const store = useStore(); |
||||||
|
const { t } = useI18n(); |
||||||
|
|
||||||
|
const platformConfigurationStore = usePlatformConfig(); |
||||||
|
|
||||||
|
const isStudentView = ref('studentview' === platformConfigurationStore.studentView); |
||||||
|
|
||||||
|
watch(isStudentView, (newValue) => { |
||||||
|
const params = new URLSearchParams(window.location.search); |
||||||
|
params.delete('isStudentView'); |
||||||
|
params.append('isStudentView', newValue ? 'true' : 'false'); |
||||||
|
|
||||||
|
window.location.href = route.path + '?' + params.toString(); |
||||||
|
}); |
||||||
|
|
||||||
|
const isCurrentTeacher = computed(() => store.getters["security/isCurrentTeacher"]); |
||||||
|
</script> |
@ -0,0 +1,45 @@ |
|||||||
|
<template> |
||||||
|
<ToggleButton |
||||||
|
v-model="primeModelValue" |
||||||
|
:off-icon="chamiloIconToClass[offIcon]" |
||||||
|
:off-label="offLabel" |
||||||
|
:on-icon="chamiloIconToClass[onIcon]" |
||||||
|
:on-label="onLabel" |
||||||
|
@change="$emit('update:modelValue', primeModelValue)" |
||||||
|
/> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script setup> |
||||||
|
import ToggleButton from "primevue/togglebutton"; |
||||||
|
import { ref } from "vue"; |
||||||
|
import { chamiloIconToClass, validator } from "./ChamiloIcons"; |
||||||
|
|
||||||
|
const props = defineProps({ |
||||||
|
modelValue: { |
||||||
|
type: Boolean, |
||||||
|
required: true, |
||||||
|
}, |
||||||
|
onLabel: { |
||||||
|
type: String, |
||||||
|
required: true, |
||||||
|
}, |
||||||
|
onIcon: { |
||||||
|
type: String, |
||||||
|
required: true, |
||||||
|
validator, |
||||||
|
}, |
||||||
|
offLabel: { |
||||||
|
type: String, |
||||||
|
required: true, |
||||||
|
}, |
||||||
|
offIcon: { |
||||||
|
type: String, |
||||||
|
required: true, |
||||||
|
validator, |
||||||
|
}, |
||||||
|
}); |
||||||
|
|
||||||
|
defineEmits(["update:modelValue"]); |
||||||
|
|
||||||
|
const primeModelValue = ref(props.modelValue); |
||||||
|
</script> |
Loading…
Reference in new issue