Add back-to-module link

This commit is contained in:
Ramon Wenger 2021-03-17 18:07:58 +01:00
parent bc53343f55
commit 81e5704fbe
6 changed files with 218 additions and 50 deletions

View File

@ -0,0 +1,55 @@
<template>
<router-link
:to="to"
class="sub-navigation-item back-link">
<chevron-left class="back-link__icon sub-navigation-item__icon"/>
{{ fullTitle }}
</router-link>
</template>
<script>
import ChevronLeft from '@/components/icons/ChevronLeft';
import {MODULE_PAGE} from '@/router/module.names';
export default {
props: {
title: {
type: String,
default: '',
},
type: {
type: String,
default: 'topic',
},
slug: {
type: String,
default: '',
},
},
components: {
ChevronLeft,
},
computed: {
to() {
if (this.type === 'topic') {
return {name: 'topic', params: {topicSlug: this.slug}};
} else {
return {name: MODULE_PAGE};
}
},
fullTitle() {
return this.type === 'topic' ? `Thema: ${this.title}` : `Modul: ${this.title}`;
}
},
};
</script>
<style scoped lang="scss">
@import '~styles/helpers';
.back-link {
@include regular-text;
}
</style>

View File

@ -1,12 +1,11 @@
<template> <template>
<nav <nav
class="module-navigation sub-navigation"> class="module-navigation sub-navigation">
<router-link <back-link
:to="{name: 'topic', params: {topicSlug: module.topic.slug}}" :title="module.topic.title"
class="sub-navigation-item module-navigation__topic-link"> :slug="module.topic.slug"
<chevron-left class="sub-navigation-item__icon" /> class="module-navigation__topic-link"
Thema: {{ module.topic.title }} type="topic"/>
</router-link>
<div <div
class="module-navigation__module-content" class="module-navigation__module-content"
v-if="false"> <!-- Do not display this for now, might be used later again though --> v-if="false"> <!-- Do not display this for now, might be used later again though -->
@ -52,7 +51,8 @@
<router-link <router-link
:to="{name: 'module-settings'}" :to="{name: 'module-settings'}"
class="module-navigation__actions" class="module-navigation__actions"
data-cy="module-settings-button">Einstellungen</router-link> data-cy="module-settings-button">Einstellungen
</router-link>
<toggle-editing v-if="onModulePage"/> <toggle-editing v-if="onModulePage"/>
</div> </div>
</nav> </nav>
@ -60,12 +60,11 @@
</template> </template>
<script> <script>
import BackLink from '@/components/BackLink';
import {moduleQuery} from '@/graphql/queries'; import {moduleQuery} from '@/graphql/queries';
import SubNavigationItem from '@/components/book-navigation/SubNavigationItem'; import SubNavigationItem from '@/components/book-navigation/SubNavigationItem';
import ToggleSolutionsForModule from '@/components/toggle-menu/ToggleSolutionsForModule';
import ToggleEditing from '@/components/toggle-menu/ToggleEditing'; import ToggleEditing from '@/components/toggle-menu/ToggleEditing';
import ChevronLeft from '@/components/icons/ChevronLeft';
import me from '@/mixins/me'; import me from '@/mixins/me';
export default { export default {
@ -76,17 +75,16 @@
mixins: [me], mixins: [me],
components: { components: {
BackLink,
SubNavigationItem, SubNavigationItem,
ToggleSolutionsForModule,
ToggleEditing, ToggleEditing,
ChevronLeft
}, },
data() { data() {
return { return {
module: { module: {
assignments: [], assignments: [],
topic: {} topic: {},
}, },
}; };
}, },
@ -106,7 +104,7 @@
return []; return [];
} }
return this.extractAssignmentsFromChapters(this.module.chapters, []); return this.extractAssignmentsFromChapters(this.module.chapters, []);
} },
}, },
methods: { methods: {
@ -155,8 +153,8 @@
flattenArray(arrayToFlatten) { flattenArray(arrayToFlatten) {
// https://stackoverflow.com/questions/10865025/merge-flatten-an-array-of-arrays // https://stackoverflow.com/questions/10865025/merge-flatten-an-array-of-arrays
return [].concat.apply([], arrayToFlatten); return [].concat.apply([], arrayToFlatten);
} },
} },
}; };
</script> </script>

View File

@ -0,0 +1,103 @@
<template>
<nav
class="module-sub-navigation sub-navigation">
<back-link
:title="module.title"
type="module"/>
</nav>
</template>
<script>
import BackLink from '@/components/BackLink';
import {moduleQuery} from '@/graphql/queries';
import me from '@/mixins/me';
export default {
apollo: {
module: moduleQuery,
},
mixins: [me],
components: {
BackLink,
},
data() {
return {
module: {},
};
},
};
</script>
<style scoped lang="scss">
@import "~styles/helpers";
@mixin module-navigation-typography {
font-family: $sans-serif-font-family;
color: $color-silver-dark;
font-weight: $font-weight-regular;
}
.module-sub-navigation {
display: none;
width: 100%;
box-sizing: border-box;
z-index: 11;
background-color: $color-white;
border-top: 1px solid $color-silver;
&__topic-link {
@include regular-text;
}
@include desktop {
display: flex;
}
&__module-content {
margin-bottom: 18px;
}
&__heading {
@include module-navigation-typography;
margin: 0;
font-size: 1.0625rem;
cursor: pointer;
}
&__anchors {
display: flex;
flex-direction: column;
padding: 16px 24px 0;
}
&__anchor {
@include module-navigation-typography;
font-size: 0.875rem;
line-height: 1.2rem;
margin-bottom: .6875rem;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
&--active {
color: $color-brand;
}
}
&__toggle-menu {
margin-left: auto;
display: flex;
align-items: center;
}
&__actions {
@include regular-text;
margin-right: $medium-spacing;
}
}
</style>

View File

@ -1,21 +1,27 @@
<template> <template>
<div class="module-page"> <div class="module-page">
<module-navigation v-if="showNavigation" /> <module-navigation v-if="showNavigation" />
<module-sub-navigation v-if="showSubNavigation" />
<router-view/> <router-view/>
</div> </div>
</template> </template>
<script> <script>
import ModuleNavigation from '@/components/modules/ModuleNavigation.vue'; import ModuleNavigation from '@/components/modules/ModuleNavigation.vue';
import ModuleSubNavigation from '@/components/modules/ModuleSubNavigation.vue';
export default { export default {
components: { components: {
ModuleNavigation ModuleNavigation,
ModuleSubNavigation
}, },
computed: { computed: {
showNavigation() { showNavigation() {
return !this.$route.meta.hideNavigation; return !this.$route.meta.hideNavigation && !this.$route.meta.showSubNavigation;
},
showSubNavigation() {
return !!this.$route.meta.showSubNavigation;
} }
} }
}; };

View File

@ -35,7 +35,7 @@
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import 'styles/_helpers'; @import '~styles/_helpers';
.module-settings { .module-settings {
@include settings-page; @include settings-page;

View File

@ -6,36 +6,42 @@ import {MODULE_PAGE, MODULE_SETTINGS_PAGE, SUBMISSIONS_PAGE, VISIBILITY_PAGE} fr
import settingsPage from '@/pages/module/moduleSettings'; import settingsPage from '@/pages/module/moduleSettings';
export default [ export default [
{ {
path: '/module/:slug', path: '/module/:slug',
component: moduleBase, component: moduleBase,
children: [ children: [
{ {
path: '', path: '',
name: MODULE_PAGE, name: MODULE_PAGE,
component: module, component: module,
meta: {filter: true}, meta: {filter: true},
}, },
{ {
path: 'submissions/:id', path: 'submissions/:id',
name: SUBMISSIONS_PAGE, name: SUBMISSIONS_PAGE,
component: submissions, component: submissions,
meta: {filter: true}, meta: {
}, filter: true,
{ showSubNavigation: true,
path: 'settings', },
name: MODULE_SETTINGS_PAGE, },
component: settingsPage, {
}, path: 'settings',
{ name: MODULE_SETTINGS_PAGE,
path: 'visibility', component: settingsPage,
name: VISIBILITY_PAGE, meta: {
component: moduleVisibility, showSubNavigation: true,
meta: { },
layout: 'simple', },
hideNavigation: true, {
}, path: 'visibility',
}, name: VISIBILITY_PAGE,
], component: moduleVisibility,
}, meta: {
layout: 'simple',
hideNavigation: true,
},
},
],
},
]; ];