Add correct component for solution toggle

This commit is contained in:
Ramon Wenger 2021-03-15 23:07:40 +01:00
parent 273d0dc74c
commit bcff36b49f
3 changed files with 13 additions and 9 deletions

View File

@ -1,6 +1,6 @@
<template>
<checkbox
:checked="enabled"
:checked="module.solutionsEnabled"
label="Lösungen für Lernende anzeigen"
v-if="canToggleSolutions"
@input="toggleSolutions"/>
@ -11,17 +11,16 @@
import UPDATE_SOLUTION_VISIBILITY_MUTATION from '@/graphql/gql/mutations/updateSolutionVisibility.gql';
import MODULE_FRAGMENT from '@/graphql/gql/fragments/moduleParts.gql';
import {meQuery} from '@/graphql/queries';
import {meQuery, moduleQuery} from '@/graphql/queries';
export default {
props: ['slug', 'enabled'],
components: {
Checkbox
},
apollo: {
me: meQuery
me: meQuery,
module: moduleQuery
},
data() {
@ -29,12 +28,16 @@
me: {
permissions: []
},
module: {}
};
},
computed: {
canToggleSolutions() {
return this.me.permissions.includes('users.can_manage_school_class_content');
},
slug() {
return this.$route.params.slug;
}
},

View File

@ -7,8 +7,8 @@ export function moduleQuery() {
variables: {
slug: this.$route.params.slug
},
update(data) {
return this.$getRidOfEdges(data).module || {};
update({module}) {
return this.$getRidOfEdges(module) || {};
}
};
}

View File

@ -4,7 +4,7 @@
<section class="module-settings__section">
<h2 class="module-settings__heading">Lösungen</h2>
<p class="module-settings__paragraph">Wollen Sie die Lösungen in diesem Modul für Lernende anzeigen?</p>
<checkbox label="Lösungen anzeigen"/>
<toggle-solutions-for-module />
</section>
<section class="module-settings__section">
<h2 class="module-settings__heading">Sichtbarkeit</h2>
@ -24,9 +24,11 @@
<script>
import Checkbox from '@/components/ui/Checkbox';
import ToggleSolutionsForModule from '@/components/toggle-menu/ToggleSolutionsForModule';
export default {
components: {
ToggleSolutionsForModule,
Checkbox
}
};
@ -37,6 +39,5 @@
.module-settings {
@include settings-page;
}
</style>