Move class selection to sidebar, refactor it in the process
This commit is contained in:
parent
950faf1c9c
commit
4f7a2cdc2f
|
|
@ -5,7 +5,8 @@
|
||||||
<logo></logo>
|
<logo></logo>
|
||||||
</router-link>
|
</router-link>
|
||||||
<div class="user-header">
|
<div class="user-header">
|
||||||
<class-selection-widget />
|
<a class="user-header__sidebar-link" @click="openSidebar()"><current-class class="user-header__current-class"/></a>
|
||||||
|
|
||||||
<user-widget v-bind="me"></user-widget>
|
<user-widget v-bind="me"></user-widget>
|
||||||
</div>
|
</div>
|
||||||
<book-navigation v-if="showSubnavigation">
|
<book-navigation v-if="showSubnavigation">
|
||||||
|
|
@ -19,18 +20,22 @@
|
||||||
import UserWidget from '@/components/UserWidget.vue';
|
import UserWidget from '@/components/UserWidget.vue';
|
||||||
import LogoutWidget from '@/components/LogoutWidget.vue';
|
import LogoutWidget from '@/components/LogoutWidget.vue';
|
||||||
import Logo from '@/components/icons/Logo';
|
import Logo from '@/components/icons/Logo';
|
||||||
import ClassSelectionWidget from '@/components/ClassSelectionWidget';
|
import CurrentClass from '@/components/school-class/CurrentClass';
|
||||||
|
|
||||||
|
import openSidebar from '@/mixins/open-sidebar';
|
||||||
|
|
||||||
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
mixins: [openSidebar],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
ContentNavigation,
|
ContentNavigation,
|
||||||
UserWidget,
|
UserWidget,
|
||||||
LogoutWidget,
|
LogoutWidget,
|
||||||
BookNavigation,
|
BookNavigation,
|
||||||
Logo,
|
Logo,
|
||||||
ClassSelectionWidget
|
CurrentClass
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -39,6 +44,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
me: {}
|
me: {}
|
||||||
|
|
@ -127,5 +133,13 @@
|
||||||
|
|
||||||
.user-header {
|
.user-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
|
&__current-class {
|
||||||
|
margin-right: $large-spacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__sidebar-link {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TOGGLE_SIDEBAR from '@/graphql/gql/local/mutations/toggleSidebar.gql';
|
|
||||||
import Avatar from '@/components/profile/Avatar';
|
import Avatar from '@/components/profile/Avatar';
|
||||||
|
import openSidebar from '@/mixins/open-sidebar';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// todo: clean up unneeded props
|
// todo: clean up unneeded props
|
||||||
|
|
@ -32,16 +32,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
mixins: [openSidebar],
|
||||||
openSidebar() {
|
|
||||||
this.$apollo.mutate({
|
|
||||||
mutation: TOGGLE_SIDEBAR,
|
|
||||||
variables: {
|
|
||||||
open: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
Avatar
|
Avatar
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
import UserWidget from '@/components/UserWidget';
|
import UserWidget from '@/components/UserWidget';
|
||||||
import LogoutWidget from '@/components/LogoutWidget';
|
import LogoutWidget from '@/components/LogoutWidget';
|
||||||
import ContentNavigation from '@/components/ContentNavigation';
|
import ContentNavigation from '@/components/ContentNavigation';
|
||||||
import ClassSelectionWidget from '@/components/ClassSelectionWidget';
|
import ClassSelectionWidget from '@/components/school-class/ClassSelectionWidget';
|
||||||
|
|
||||||
import {meQuery} from '@/graphql/queries';
|
import {meQuery} from '@/graphql/queries';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
<div class="profile-sidebar__item" @click="closeSidebar">
|
<div class="profile-sidebar__item" @click="closeSidebar">
|
||||||
<router-link to="/me/activity" class="profile-sidebar__link">Meine Aktivitäten</router-link>
|
<router-link to="/me/activity" class="profile-sidebar__link">Meine Aktivitäten</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div class="profile-sidebar__item" @click="closeSidebar">
|
<div class="profile-sidebar__item">
|
||||||
|
<h3 class="profile-sidebar__subtitle">Klasse</h3>
|
||||||
|
<class-selection-widget></class-selection-widget>
|
||||||
<router-link :to="{name: 'my-classes'}" class="profile-sidebar__link">Klassenliste</router-link>
|
<router-link :to="{name: 'my-classes'}" class="profile-sidebar__link">Klassenliste</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div class="profile-sidebar__item" @click="closeSidebar">
|
<div class="profile-sidebar__item" @click="closeSidebar">
|
||||||
|
|
@ -26,9 +28,11 @@
|
||||||
import SIDEBAR from '@/graphql/gql/local/sidebar.gql';
|
import SIDEBAR from '@/graphql/gql/local/sidebar.gql';
|
||||||
import TOGGLE_SIDEBAR from '@/graphql/gql/local/mutations/toggleSidebar.gql';
|
import TOGGLE_SIDEBAR from '@/graphql/gql/local/mutations/toggleSidebar.gql';
|
||||||
import LOGOUT_MUTATION from '@/graphql/gql/mutations/logoutUser.gql';
|
import LOGOUT_MUTATION from '@/graphql/gql/mutations/logoutUser.gql';
|
||||||
|
import ClassSelectionWidget from '@/components/school-class/ClassSelectionWidget';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
ClassSelectionWidget,
|
||||||
ProfileWidget,
|
ProfileWidget,
|
||||||
Cross
|
Cross
|
||||||
},
|
},
|
||||||
|
|
@ -88,12 +92,18 @@
|
||||||
|
|
||||||
&__item {
|
&__item {
|
||||||
border-bottom: 1px solid $color-silver-light;
|
border-bottom: 1px solid $color-silver-light;
|
||||||
|
padding: $large-spacing $medium-spacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__subtitle {
|
||||||
|
@include small-text;
|
||||||
|
margin: 0;
|
||||||
|
margin-bottom: $small-spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__link {
|
&__link {
|
||||||
@include default-link;
|
@include default-link;
|
||||||
displaY: block;
|
display: block;
|
||||||
padding: $large-spacing $medium-spacing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__close-link {
|
&__close-link {
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,14 @@
|
||||||
<div class="class-selection" v-if="currentClassSelection">
|
<div class="class-selection" v-if="currentClassSelection">
|
||||||
<div data-cy="class-selection" class="class-selection__selected-class selected-class"
|
<div data-cy="class-selection" class="class-selection__selected-class selected-class"
|
||||||
@click="showPopover = !showPopover">
|
@click="showPopover = !showPopover">
|
||||||
<p class="selected-class__text">Klasse: {{currentClassSelection.name}}</p>
|
<current-class class="selected-class__text"></current-class> <chevron-down class="selected-class__dropdown-icon"></chevron-down>
|
||||||
</div>
|
</div>
|
||||||
<widget-popover v-if="showPopover"
|
<widget-popover v-if="showPopover"
|
||||||
@hide-me="showPopover = false"
|
@hide-me="showPopover = false"
|
||||||
:mobile="mobile"
|
:mobile="mobile"
|
||||||
class="class-selection__popover">
|
class="class-selection__popover">
|
||||||
<li data-cy="class-selection-entry" class="popover-links__link popover-links__link--large"
|
<li data-cy="class-selection-entry" class="popover-links__link popover-links__link--large"
|
||||||
v-for="schoolClass in schoolClasses"
|
v-for="schoolClass in me.schoolClasses"
|
||||||
:key="schoolClass.id"
|
:key="schoolClass.id"
|
||||||
:label="schoolClass.name"
|
:label="schoolClass.name"
|
||||||
:item="schoolClass"
|
:item="schoolClass"
|
||||||
|
|
@ -22,12 +22,16 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import WidgetPopover from '@/components/WidgetPopover';
|
import WidgetPopover from '@/components/WidgetPopover';
|
||||||
|
import ChevronDown from '@/components/icons/ChevronDown';
|
||||||
|
import CurrentClass from '@/components/school-class/CurrentClass';
|
||||||
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
||||||
import UPDATE_USER_SETTING from '@/graphql/gql/mutations/updateUserSetting.gql';
|
import UPDATE_USER_SETTING from '@/graphql/gql/mutations/updateUserSetting.gql';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
WidgetPopover
|
WidgetPopover,
|
||||||
|
ChevronDown,
|
||||||
|
CurrentClass
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -39,7 +43,13 @@
|
||||||
|
|
||||||
apollo: {
|
apollo: {
|
||||||
me: {
|
me: {
|
||||||
query: ME_QUERY
|
query: ME_QUERY,
|
||||||
|
manual: true,
|
||||||
|
result({data, loading, networkStatus}) {
|
||||||
|
if (!loading) {
|
||||||
|
this.me = this.$getRidOfEdges(data).me;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -67,7 +77,7 @@
|
||||||
},
|
},
|
||||||
update(store, data) {
|
update(store, data) {
|
||||||
let meData = store.readQuery({query: ME_QUERY});
|
let meData = store.readQuery({query: ME_QUERY});
|
||||||
meData.me.selectedClass = selectedClass
|
meData.me.selectedClass = selectedClass;
|
||||||
store.writeQuery({query: ME_QUERY, data: meData});
|
store.writeQuery({query: ME_QUERY, data: meData});
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
|
@ -79,13 +89,10 @@
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
currentClassSelection() {
|
currentClassSelection() {
|
||||||
let currentClass = this.schoolClasses.find(schoolClass => {
|
let currentClass = this.me.schoolClasses.find(schoolClass => {
|
||||||
return schoolClass.id === this.me.selectedClass.id
|
return schoolClass.id === this.me.selectedClass.id
|
||||||
});
|
});
|
||||||
return currentClass || this.schoolClasses[0];
|
return currentClass || this.me.schoolClasses[0];
|
||||||
},
|
|
||||||
schoolClasses() {
|
|
||||||
return this.$getRidOfEdges(this.me.schoolClasses);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -97,23 +104,40 @@
|
||||||
@import "@/styles/_mixins.scss";
|
@import "@/styles/_mixins.scss";
|
||||||
|
|
||||||
.class-selection {
|
.class-selection {
|
||||||
|
|
||||||
position: relative;
|
position: relative;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin-right: $large-spacing;
|
margin-bottom: $medium-spacing;
|
||||||
|
border: 1px solid $color-silver;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: $small-spacing $medium-spacing;
|
||||||
|
/*justify-self: space-between;*/
|
||||||
|
|
||||||
&__popover {
|
&__popover {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
top: 40px;
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
transform: translateY($small-spacing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.selected-class {
|
.selected-class {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
&__text {
|
&__text {
|
||||||
line-height: $large-spacing;
|
line-height: $large-spacing;
|
||||||
@include regular-text;
|
@include regular-text;
|
||||||
color: $color-silver-dark;
|
color: $color-silver-dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__dropdown-icon {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
fill: $color-brand;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.popover-links__link {
|
.popover-links__link {
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
<template>
|
||||||
|
<span class="current-class">Klasse: {{currentClassSelection.name}}</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
apollo: {
|
||||||
|
me: {
|
||||||
|
query: ME_QUERY,
|
||||||
|
manual: true,
|
||||||
|
result({data, loading, networkStatus}) {
|
||||||
|
if (!loading) {
|
||||||
|
this.me = this.$getRidOfEdges(data).me;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
me: {
|
||||||
|
selectedClass: {
|
||||||
|
id: ''
|
||||||
|
},
|
||||||
|
permissions: [],
|
||||||
|
schoolClasses: []
|
||||||
|
},
|
||||||
|
showPopover: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
currentClassSelection() {
|
||||||
|
let currentClass = this.me.schoolClasses.find(schoolClass => {
|
||||||
|
return schoolClass.id === this.me.selectedClass.id
|
||||||
|
});
|
||||||
|
return currentClass || this.me.schoolClasses[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
@import "@/styles/_variables.scss";
|
||||||
|
@import "@/styles/_mixins.scss";
|
||||||
|
|
||||||
|
.current-class {
|
||||||
|
line-height: $large-spacing;
|
||||||
|
@include regular-text;
|
||||||
|
color: $color-silver-dark;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import TOGGLE_SIDEBAR from '@/graphql/gql/local/mutations/toggleSidebar.gql';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
openSidebar() {
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: TOGGLE_SIDEBAR,
|
||||||
|
variables: {
|
||||||
|
open: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue