153 lines
3.7 KiB
Vue
153 lines
3.7 KiB
Vue
<template>
|
|
<div
|
|
class="class-selection"
|
|
v-if="currentClassSelection"
|
|
>
|
|
<div
|
|
data-cy="class-selection"
|
|
class="class-selection__selected-class selected-class"
|
|
@click.stop="showPopover = !showPopover"
|
|
>
|
|
<current-class class="selected-class__text" />
|
|
<chevron-down class="selected-class__dropdown-icon" />
|
|
</div>
|
|
<widget-popover
|
|
:mobile="mobile"
|
|
class="class-selection__popover"
|
|
v-if="showPopover"
|
|
@hide-me="showPopover = false"
|
|
>
|
|
<li
|
|
:label="schoolClass.name"
|
|
:item="schoolClass"
|
|
data-cy="class-selection-entry"
|
|
class="popover-links__link popover-links__link--large"
|
|
v-for="schoolClass in me.schoolClasses"
|
|
:key="schoolClass.id"
|
|
@click="updateSelectedClassAndHidePopover(schoolClass)"
|
|
>
|
|
{{ schoolClass.name }}
|
|
</li>
|
|
<li
|
|
class="popover-links__link popover-links__link--large popover-links__divider"
|
|
data-cy="create-class-link"
|
|
v-if="me.isTeacher && !me.readOnly"
|
|
@click="closeSidebar"
|
|
>
|
|
<router-link
|
|
:to="{name: 'create-class'}"
|
|
class="popover-links__link-with-icon"
|
|
>
|
|
<add-icon class="popover-links__icon" />
|
|
<span>Klasse erfassen</span>
|
|
</router-link>
|
|
</li>
|
|
<li
|
|
class="popover-links__link popover-links__link--large popover-links__divider"
|
|
@click="closeSidebar"
|
|
>
|
|
<router-link
|
|
:to="{name: 'old-classes'}"
|
|
>
|
|
Alte Klassen anzeigen
|
|
</router-link>
|
|
</li>
|
|
</widget-popover>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import WidgetPopover from '@/components/ui/WidgetPopover';
|
|
import CurrentClass from '@/components/school-class/CurrentClass';
|
|
|
|
import updateSelectedClassMixin from '@/mixins/update-selected-class';
|
|
import sidebarMixin from '@/mixins/sidebar';
|
|
import meMixin from '@/mixins/me';
|
|
import {defineAsyncComponent} from 'vue';
|
|
const ChevronDown = defineAsyncComponent(() => import(/* webpackChunkName: "icons" */'@/components/icons/ChevronDown'));
|
|
const AddIcon = defineAsyncComponent(() => import(/* webpackChunkName: "icons" */'@/components/icons/AddIcon'));
|
|
|
|
export default {
|
|
|
|
props: {
|
|
mobile: {
|
|
type: Boolean,
|
|
default: false
|
|
}
|
|
},
|
|
|
|
mixins: [updateSelectedClassMixin, sidebarMixin, meMixin],
|
|
components: {
|
|
WidgetPopover,
|
|
ChevronDown,
|
|
CurrentClass,
|
|
AddIcon
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
showPopover: false
|
|
};
|
|
},
|
|
|
|
computed: {
|
|
currentClassSelection() {
|
|
let currentClass = this.me.schoolClasses.find(schoolClass => {
|
|
return schoolClass.id === this.me.selectedClass.id;
|
|
});
|
|
return currentClass || this.me.schoolClasses[0];
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
updateSelectedClassAndHidePopover(selectedClass) {
|
|
this.updateSelectedClass(selectedClass);
|
|
this.showPopover = false;
|
|
this.closeSidebar('profile');
|
|
}
|
|
},
|
|
|
|
};
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
@import "~styles/helpers";
|
|
|
|
.class-selection {
|
|
position: relative;
|
|
cursor: pointer;
|
|
margin-bottom: $medium-spacing;
|
|
border-radius: 4px;
|
|
|
|
&__popover {
|
|
white-space: nowrap;
|
|
top: 100%;
|
|
left: 0;
|
|
transform: translateY($small-spacing);
|
|
}
|
|
|
|
}
|
|
|
|
.selected-class {
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
padding: $small-spacing 0;
|
|
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-start;
|
|
|
|
&__text {
|
|
line-height: $large-spacing;
|
|
@include heading-4;
|
|
margin-right: $small-spacing;
|
|
}
|
|
|
|
&__dropdown-icon {
|
|
width: 20px;
|
|
height: 20px;
|
|
fill: $color-charcoal-dark;
|
|
}
|
|
}
|
|
</style>
|