Fix some merge issues
This commit is contained in:
parent
973fef379d
commit
6ecf33d12b
|
|
@ -28,7 +28,6 @@ export default {
|
||||||
|
|
||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
|
|
||||||
emits: ['click'],
|
|
||||||
components: {
|
components: {
|
||||||
Avatar,
|
Avatar,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,10 @@
|
||||||
import ALL_TOPICS_QUERY from '@/graphql/gql/queries/allTopicsQuery.gql';
|
import ALL_TOPICS_QUERY from '@/graphql/gql/queries/allTopicsQuery.gql';
|
||||||
import sidebarMixin from '@/mixins/sidebar';
|
import sidebarMixin from '@/mixins/sidebar';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
mobile: {
|
mobile: {
|
||||||
default: false,
|
default: false,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -36,10 +35,9 @@ import sidebarMixin from '@/mixins/sidebar';
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
topicId(id) {
|
topicId(id) {
|
||||||
return atob(id);
|
return atob(id);
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,23 +10,23 @@
|
||||||
<script>
|
<script>
|
||||||
import ContentsForm from '@/components/content-block-form/ContentsForm';
|
import ContentsForm from '@/components/content-block-form/ContentsForm';
|
||||||
|
|
||||||
import {store} from '@/store';
|
import { store } from '@/store';
|
||||||
|
|
||||||
import EDIT_CONTENT_BLOCK_MUTATION from 'gql/mutations/editContentBlock.gql';
|
import EDIT_CONTENT_BLOCK_MUTATION from 'gql/mutations/editContentBlock.gql';
|
||||||
import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
|
import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
|
||||||
import CONTENT_BLOCK_QUERY from '@/graphql/gql/queries/contentBlockQuery.gql';
|
import CONTENT_BLOCK_QUERY from '@/graphql/gql/queries/contentBlockQuery.gql';
|
||||||
import {setUserBlockType} from '@/helpers/content-block';
|
import { setUserBlockType } from '@/helpers/content-block';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ContentsForm,
|
ContentsForm,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
contentBlock: {},
|
contentBlock: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
// debugger;
|
// debugger;
|
||||||
|
|
@ -45,35 +45,36 @@ import ContentsForm from '@/components/content-block-form/ContentsForm';
|
||||||
input: {
|
input: {
|
||||||
contentBlock: {
|
contentBlock: {
|
||||||
title: contentBlock.title,
|
title: contentBlock.title,
|
||||||
contents: contentBlock.contents.filter(value => Object.keys(value).length > 0),
|
contents: contentBlock.contents.filter((value) => Object.keys(value).length > 0),
|
||||||
type: setUserBlockType(contentBlock.isAssignment),
|
type: setUserBlockType(contentBlock.isAssignment),
|
||||||
},
|
},
|
||||||
id: contentBlock.id,
|
id: contentBlock.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
refetchQueries: [{
|
refetchQueries: [
|
||||||
query: MODULE_DETAILS_QUERY,
|
{
|
||||||
variables: {
|
query: MODULE_DETAILS_QUERY,
|
||||||
slug: this.$route.params.slug,
|
variables: {
|
||||||
|
slug: this.$route.params.slug,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}],
|
],
|
||||||
}).then(() => {
|
})
|
||||||
|
.then(() => {
|
||||||
this.hideModal();
|
this.hideModal();
|
||||||
});
|
});
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
apollo: {
|
apollo: {
|
||||||
contentBlock() {
|
contentBlock() {
|
||||||
return {
|
return {
|
||||||
query: CONTENT_BLOCK_QUERY,
|
query: CONTENT_BLOCK_QUERY,
|
||||||
variables: {
|
variables: {
|
||||||
id: store.state.currentNoteBlock,
|
id: store.state.currentNoteBlock,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,8 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -25,18 +25,17 @@
|
||||||
export default {
|
export default {
|
||||||
props: ['metaTitle', 'title', 'teaser', 'id', 'slug', 'heroImage'],
|
props: ['metaTitle', 'title', 'teaser', 'id', 'slug', 'heroImage'],
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
moduleLink() {
|
moduleLink() {
|
||||||
if (this.slug) {
|
if (this.slug) {
|
||||||
return {
|
return {
|
||||||
name: 'module',
|
name: 'module',
|
||||||
params: {
|
params: {
|
||||||
slug: this.slug
|
slug: this.slug,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
class="project__owner"
|
class="project__owner"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<entry-count-widgetclass
|
<entry-count-widget
|
||||||
="project__entry-count"
|
class="project__entry-count"
|
||||||
:verbose="false"
|
:verbose="false"
|
||||||
:entry-count="project.entriesCount"
|
:entry-count="project.entriesCount"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -56,12 +56,14 @@
|
||||||
import WidgetPopover from '@/components/ui/WidgetPopover';
|
import WidgetPopover from '@/components/ui/WidgetPopover';
|
||||||
import CurrentClass from '@/components/school-class/CurrentClass';
|
import CurrentClass from '@/components/school-class/CurrentClass';
|
||||||
|
|
||||||
import updateSelectedClassMixin from '@/mixins/update-selected-class';
|
import updateSelectedClassMixin from '@/mixins/update-selected-class';
|
||||||
import sidebarMixin from '@/mixins/sidebar';
|
import sidebarMixin from '@/mixins/sidebar';
|
||||||
import meMixin from '@/mixins/me';
|
import meMixin from '@/mixins/me';
|
||||||
import {defineAsyncComponent} from 'vue';
|
import { defineAsyncComponent } from 'vue';
|
||||||
const ChevronDown = defineAsyncComponent(() => import(/* webpackChunkName: "icons" */'@/components/icons/ChevronDown'));
|
const ChevronDown = defineAsyncComponent(() =>
|
||||||
const AddIcon = defineAsyncComponent(() => import(/* webpackChunkName: "icons" */'@/components/icons/AddIcon'));
|
import(/* webpackChunkName: "icons" */ '@/components/icons/ChevronDown')
|
||||||
|
);
|
||||||
|
const AddIcon = defineAsyncComponent(() => import(/* webpackChunkName: "icons" */ '@/components/icons/AddIcon'));
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -94,15 +96,14 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
toggle() {
|
toggle() {
|
||||||
this.showPopover = !this.showPopover;
|
this.showPopover = !this.showPopover;
|
||||||
},
|
},
|
||||||
updateSelectedClassAndHidePopover(selectedClass) {
|
updateSelectedClassAndHidePopover(selectedClass) {
|
||||||
this.updateSelectedClass(selectedClass);
|
this.updateSelectedClass(selectedClass);
|
||||||
this.showPopover = false;
|
this.showPopover = false;
|
||||||
this.closeSidebar('profile');
|
this.closeSidebar('profile');
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {defineComponent} from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
import ContentBlockForm from '@/components/content-block-form/ContentBlockForm';
|
import ContentBlockForm from '@/components/content-block-form/ContentBlockForm';
|
||||||
import { setUserBlockType } from '@/helpers/content-block';
|
import { setUserBlockType } from '@/helpers/content-block';
|
||||||
|
|
@ -16,16 +16,15 @@ import NEW_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/addContentBlock.
|
||||||
import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
|
import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
|
||||||
import { cleanUpContents } from '@/components/content-block-form/helpers';
|
import { cleanUpContents } from '@/components/content-block-form/helpers';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
parent: {
|
parent: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: '',
|
||||||
},
|
},
|
||||||
after: {
|
after: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: '',
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,233 +1,228 @@
|
||||||
<template>
|
<template>
|
||||||
<module
|
<module :module="module" @editNote="editNote" @addNote="addNote" @bookmark="bookmark" />
|
||||||
:module="module"
|
|
||||||
@editNote="editNote"
|
|
||||||
@addNote="addNote"
|
|
||||||
@bookmark="bookmark"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Module from '@/components/modules/Module';
|
import Module from '@/components/modules/Module';
|
||||||
import log from 'loglevel';
|
import log from 'loglevel';
|
||||||
|
|
||||||
import UPDATE_LAST_MODULE_MUTATION from '@/graphql/gql/mutations/updateLastModule.gql';
|
import UPDATE_LAST_MODULE_MUTATION from '@/graphql/gql/mutations/updateLastModule.gql';
|
||||||
import UPDATE_MODULE_BOOKMARK_MUTATION from '@/graphql/gql/mutations/updateModuleBookmark.gql';
|
import UPDATE_MODULE_BOOKMARK_MUTATION from '@/graphql/gql/mutations/updateModuleBookmark.gql';
|
||||||
// import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
// import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
||||||
import MODULE_FRAGMENT from '@/graphql/gql/fragments/moduleParts.gql';
|
import MODULE_FRAGMENT from '@/graphql/gql/fragments/moduleParts.gql';
|
||||||
import SCROLL_POSITION from '@/graphql/gql/local/scrollPosition.gql';
|
import SCROLL_POSITION from '@/graphql/gql/local/scrollPosition.gql';
|
||||||
import SCROLL_TO_MUTATION from '@/graphql/gql/local/mutations/scrollTo.gql';
|
import SCROLL_TO_MUTATION from '@/graphql/gql/local/mutations/scrollTo.gql';
|
||||||
|
|
||||||
import meMixin from '@/mixins/me';
|
import meMixin from '@/mixins/me';
|
||||||
import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
|
import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
|
||||||
import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
|
import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
|
||||||
import { setModuleEditMode } from '@/graphql/cache-operations';
|
import {setModuleEditMode} from '@/graphql/cache-operations';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [meMixin],
|
mixins: [meMixin],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
Module,
|
Module,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
|
||||||
module: {},
|
|
||||||
updateSent: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
beforeRouteLeave(to, _, next) {
|
|
||||||
// toggle edit mode if leaving the module subtree
|
|
||||||
if (this.module.inEditMode && to.path.indexOf('/module/') === -1) {
|
|
||||||
setModuleEditMode(this.module.slug, false);
|
|
||||||
}
|
|
||||||
next();
|
|
||||||
},
|
|
||||||
|
|
||||||
apollo: {
|
|
||||||
module() {
|
|
||||||
return {
|
return {
|
||||||
query: MODULE_DETAILS_QUERY,
|
module: {},
|
||||||
variables: {
|
updateSent: false,
|
||||||
slug: this.$route.params.slug,
|
|
||||||
},
|
|
||||||
result({
|
|
||||||
data: {
|
|
||||||
module: { id },
|
|
||||||
},
|
|
||||||
}) {
|
|
||||||
if (!this.updateSent) {
|
|
||||||
log.debug(`=== updating result for module ${id} ===`);
|
|
||||||
this.updateLastVisitedModule(id);
|
|
||||||
this.updateSent = true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fetchPolicy: 'cache-first',
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
scrollPosition: {
|
|
||||||
query: SCROLL_POSITION,
|
beforeRouteLeave(to, _, next) {
|
||||||
|
// toggle edit mode if leaving the module subtree
|
||||||
|
if (this.module.inEditMode && to.path.indexOf('/module/') === -1) {
|
||||||
|
setModuleEditMode(this.module.slug, false);
|
||||||
|
}
|
||||||
|
next();
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
apollo: {
|
||||||
updateLastVisitedModule(moduleId) {
|
module() {
|
||||||
log.debug(`updating last visited module for module ${moduleId}`);
|
return {
|
||||||
if (!moduleId) {
|
query: MODULE_DETAILS_QUERY,
|
||||||
log.warn('no module id');
|
variables: {
|
||||||
return;
|
slug: this.$route.params.slug,
|
||||||
}
|
|
||||||
|
|
||||||
if (this.me.lastModule && this.me.lastModule.id === moduleId) {
|
|
||||||
log.debug('same module already set as last module');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$apollo.mutate({
|
|
||||||
mutation: UPDATE_LAST_MODULE_MUTATION,
|
|
||||||
variables: {
|
|
||||||
input: {
|
|
||||||
id: moduleId,
|
|
||||||
},
|
},
|
||||||
},
|
result({
|
||||||
update: (
|
|
||||||
store,
|
|
||||||
{
|
|
||||||
data: {
|
data: {
|
||||||
updateLastModule: { lastModule },
|
module: {id},
|
||||||
},
|
},
|
||||||
}
|
}) {
|
||||||
) => {
|
if (!this.updateSent) {
|
||||||
const { id, slug } = lastModule;
|
log.debug(`=== updating result for module ${id} ===`);
|
||||||
log.debug('updating last module', id, slug);
|
this.updateLastVisitedModule(id);
|
||||||
const query = ME_QUERY;
|
this.updateSent = true;
|
||||||
let { me } = store.readQuery({
|
}
|
||||||
query,
|
|
||||||
});
|
|
||||||
// me.lastModule = {
|
|
||||||
// id,
|
|
||||||
// slug,
|
|
||||||
// __typename: 'ModuleNode',
|
|
||||||
// };
|
|
||||||
|
|
||||||
let edges = [...me.recentModules.edges];
|
|
||||||
const foundIndex = edges.findIndex((edge) => edge.node.slug === slug);
|
|
||||||
if (foundIndex > -1) {
|
|
||||||
edges = [...edges.slice(0, foundIndex), ...edges.slice(foundIndex + 1, edges.length)];
|
|
||||||
}
|
|
||||||
edges = [
|
|
||||||
{
|
|
||||||
node: lastModule,
|
|
||||||
__typename: 'ModuleNodeEdge',
|
|
||||||
},
|
|
||||||
...edges.slice(0, 2),
|
|
||||||
];
|
|
||||||
const recentModules = {
|
|
||||||
__typename: 'ModuleNodeConnection',
|
|
||||||
edges,
|
|
||||||
};
|
|
||||||
const data = {
|
|
||||||
me: {
|
|
||||||
...me,
|
|
||||||
recentModules,
|
|
||||||
lastModule: {
|
|
||||||
...lastModule,
|
|
||||||
// todo: do we really need this? shouldn't the lastModule property already include this?
|
|
||||||
__typename: 'ModuleNode',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
store.writeQuery({
|
|
||||||
query,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
bookmark(bookmarked) {
|
|
||||||
const slug = this.module.slug;
|
|
||||||
this.$apollo.mutate({
|
|
||||||
mutation: UPDATE_MODULE_BOOKMARK_MUTATION,
|
|
||||||
variables: {
|
|
||||||
input: {
|
|
||||||
module: slug,
|
|
||||||
bookmarked,
|
|
||||||
},
|
},
|
||||||
},
|
fetchPolicy: 'cache-first',
|
||||||
update: (store) => {
|
|
||||||
const fragment = MODULE_FRAGMENT;
|
|
||||||
const id = store.identify({
|
|
||||||
__typename: 'ModuleNode',
|
|
||||||
slug: slug,
|
|
||||||
});
|
|
||||||
|
|
||||||
const module = store.readFragment({
|
|
||||||
fragment,
|
|
||||||
id,
|
|
||||||
});
|
|
||||||
|
|
||||||
let bookmark;
|
|
||||||
|
|
||||||
if (bookmarked) {
|
|
||||||
bookmark = {
|
|
||||||
__typename: 'ModuleBookmarkNode',
|
|
||||||
note: null,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
bookmark = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = {
|
|
||||||
...module,
|
|
||||||
bookmark,
|
|
||||||
};
|
|
||||||
|
|
||||||
store.writeFragment({
|
|
||||||
data,
|
|
||||||
fragment,
|
|
||||||
id,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
optimisticResponse: {
|
|
||||||
__typename: 'Mutation',
|
|
||||||
updateModuleBookmark: {
|
|
||||||
__typename: 'UpdateModuleBookmarkPayload',
|
|
||||||
success: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
addNote(id) {
|
|
||||||
this.$store.dispatch('addNote', {
|
|
||||||
content: id,
|
|
||||||
parent: this.module.slug,
|
|
||||||
type: 'module',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
editNote() {
|
|
||||||
this.$store.dispatch('editNote', this.module.bookmark.note);
|
|
||||||
},
|
|
||||||
scrollTo() {
|
|
||||||
if (this.scrollPosition && this.scrollPosition.scrollTo) {
|
|
||||||
let options = {
|
|
||||||
container: 'body',
|
|
||||||
easing: 'ease',
|
|
||||||
offset: -60,
|
|
||||||
x: false,
|
|
||||||
y: true,
|
|
||||||
};
|
};
|
||||||
setTimeout(() => {
|
},
|
||||||
this.$scrollTo(`[data-scrollto="${this.scrollPosition.scrollTo}"]`, 1000, options);
|
scrollPosition: {
|
||||||
this.$apollo.mutate({
|
query: SCROLL_POSITION,
|
||||||
mutation: SCROLL_TO_MUTATION,
|
},
|
||||||
variables: {
|
|
||||||
scrollTo: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}, 250); // unfortunately this timeout is needed as it is hard to tell when everything is rendered
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
|
||||||
};
|
methods: {
|
||||||
|
updateLastVisitedModule(moduleId) {
|
||||||
|
log.debug(`updating last visited module for module ${moduleId}`);
|
||||||
|
if (!moduleId) {
|
||||||
|
log.warn('no module id');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.me.lastModule && this.me.lastModule.id === moduleId) {
|
||||||
|
log.debug('same module already set as last module');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: UPDATE_LAST_MODULE_MUTATION,
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
id: moduleId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
update: (
|
||||||
|
store,
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
updateLastModule: {lastModule},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
const {id, slug} = lastModule;
|
||||||
|
log.debug('updating last module', id, slug);
|
||||||
|
const query = ME_QUERY;
|
||||||
|
let {me} = store.readQuery({
|
||||||
|
query,
|
||||||
|
});
|
||||||
|
// me.lastModule = {
|
||||||
|
// id,
|
||||||
|
// slug,
|
||||||
|
// __typename: 'ModuleNode',
|
||||||
|
// };
|
||||||
|
|
||||||
|
let edges = [...me.recentModules.edges];
|
||||||
|
const foundIndex = edges.findIndex((edge) => edge.node.slug === slug);
|
||||||
|
if (foundIndex > -1) {
|
||||||
|
edges = [...edges.slice(0, foundIndex), ...edges.slice(foundIndex + 1, edges.length)];
|
||||||
|
}
|
||||||
|
edges = [
|
||||||
|
{
|
||||||
|
node: lastModule,
|
||||||
|
__typename: 'ModuleNodeEdge',
|
||||||
|
},
|
||||||
|
...edges.slice(0, 2),
|
||||||
|
];
|
||||||
|
const recentModules = {
|
||||||
|
__typename: 'ModuleNodeConnection',
|
||||||
|
edges,
|
||||||
|
};
|
||||||
|
const data = {
|
||||||
|
me: {
|
||||||
|
...me,
|
||||||
|
recentModules,
|
||||||
|
lastModule: {
|
||||||
|
...lastModule,
|
||||||
|
// todo: do we really need this? shouldn't the lastModule property already include this?
|
||||||
|
__typename: 'ModuleNode',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
store.writeQuery({
|
||||||
|
query,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
bookmark(bookmarked) {
|
||||||
|
const slug = this.module.slug;
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: UPDATE_MODULE_BOOKMARK_MUTATION,
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
module: slug,
|
||||||
|
bookmarked,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
update: (store) => {
|
||||||
|
const fragment = MODULE_FRAGMENT;
|
||||||
|
const id = store.identify({
|
||||||
|
__typename: 'ModuleNode',
|
||||||
|
slug: slug,
|
||||||
|
});
|
||||||
|
|
||||||
|
const module = store.readFragment({
|
||||||
|
fragment,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
let bookmark;
|
||||||
|
|
||||||
|
if (bookmarked) {
|
||||||
|
bookmark = {
|
||||||
|
__typename: 'ModuleBookmarkNode',
|
||||||
|
note: null,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
bookmark = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
...module,
|
||||||
|
bookmark,
|
||||||
|
};
|
||||||
|
|
||||||
|
store.writeFragment({
|
||||||
|
data,
|
||||||
|
fragment,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
optimisticResponse: {
|
||||||
|
__typename: 'Mutation',
|
||||||
|
updateModuleBookmark: {
|
||||||
|
__typename: 'UpdateModuleBookmarkPayload',
|
||||||
|
success: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addNote(id) {
|
||||||
|
this.$store.dispatch('addNote', {
|
||||||
|
content: id,
|
||||||
|
parent: this.module.slug,
|
||||||
|
type: 'module',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
editNote() {
|
||||||
|
this.$store.dispatch('editNote', this.module.bookmark.note);
|
||||||
|
},
|
||||||
|
scrollTo() {
|
||||||
|
if (this.scrollPosition && this.scrollPosition.scrollTo) {
|
||||||
|
let options = {
|
||||||
|
container: 'body',
|
||||||
|
easing: 'ease',
|
||||||
|
offset: -60,
|
||||||
|
x: false,
|
||||||
|
y: true,
|
||||||
|
};
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$scrollTo(`[data-scrollto="${this.scrollPosition.scrollTo}"]`, 1000, options);
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: SCROLL_TO_MUTATION,
|
||||||
|
variables: {
|
||||||
|
scrollTo: '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, 250); // unfortunately this timeout is needed as it is hard to tell when everything is rendered
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {defineComponent} from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
import ROOM_ENTRY_QUERY from 'gql/queries/roomEntryQuery.gql';
|
import ROOM_ENTRY_QUERY from 'gql/queries/roomEntryQuery.gql';
|
||||||
import ROOM_ENTRY_FRAGMENT from 'gql/fragments/roomEntryParts.gql';
|
import ROOM_ENTRY_FRAGMENT from 'gql/fragments/roomEntryParts.gql';
|
||||||
|
|
@ -19,16 +19,15 @@ import ContentBlockForm from '@/components/content-block-form/ContentBlockForm';
|
||||||
import { ROOMS_FEATURE_SET } from '@/consts/features.consts';
|
import { ROOMS_FEATURE_SET } from '@/consts/features.consts';
|
||||||
import { ROOM_PAGE } from '@/router/room.names';
|
import { ROOM_PAGE } from '@/router/room.names';
|
||||||
|
|
||||||
export default defineComponent( {
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
slug: {
|
slug: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
entrySlug: {
|
entrySlug: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true,
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,10 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import '@/styles/survey.modern.css';
|
import '@/styles/survey.modern.css';
|
||||||
import '@/styles/survey.reset.css';import { css } from '@/survey.config';
|
import '@/styles/survey.reset.css';
|
||||||
|
import { css } from '@/survey.config';
|
||||||
import gql from 'graphql-tag';
|
import gql from 'graphql-tag';
|
||||||
import { Model , StylesManager } from 'survey-knockout';
|
import { Model, StylesManager } from 'survey-knockout';
|
||||||
// we are switching to the knockout version because the Vue version only works with Vue 2 (as of July 2022)
|
// we are switching to the knockout version because the Vue version only works with Vue 2 (as of July 2022)
|
||||||
|
|
||||||
import SURVEY_QUERY from '@/graphql/gql/queries/surveyQuery.gql';
|
import SURVEY_QUERY from '@/graphql/gql/queries/surveyQuery.gql';
|
||||||
|
|
@ -41,8 +42,8 @@ const Solution = defineAsyncComponent(() =>
|
||||||
*/ '@/components/content-blocks/Solution'
|
*/ '@/components/content-blocks/Solution'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
StylesManager.applyTheme('modern')
|
|
||||||
);
|
StylesManager.applyTheme('modern');
|
||||||
|
|
||||||
const MODULE_QUERY = gql`
|
const MODULE_QUERY = gql`
|
||||||
query ModuleSolutions($slug: String) {
|
query ModuleSolutions($slug: String) {
|
||||||
|
|
@ -63,7 +64,8 @@ export default {
|
||||||
return {
|
return {
|
||||||
survey: this.initSurvey(),
|
survey: this.initSurvey(),
|
||||||
currentPage: null,
|
currentPage: null,
|
||||||
surveyData: null,title: '',
|
surveyData: null,
|
||||||
|
title: '',
|
||||||
module: {},
|
module: {},
|
||||||
completed: false,
|
completed: false,
|
||||||
me: {
|
me: {
|
||||||
|
|
@ -121,7 +123,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyed() {},methods: {
|
destroyed() {},
|
||||||
|
methods: {
|
||||||
initSurvey(data, answers) {
|
initSurvey(data, answers) {
|
||||||
let survey = new Model(data);
|
let survey = new Model(data);
|
||||||
const flatAnswers = {};
|
const flatAnswers = {};
|
||||||
|
|
@ -232,7 +235,7 @@ export default {
|
||||||
this.survey.data = data; // reapply it
|
this.survey.data = data; // reapply it
|
||||||
this.saveDisabled = false;
|
this.saveDisabled = false;
|
||||||
},
|
},
|
||||||
loadSurveyFromServer(survey) {
|
loadSurveyFromServer(survey) {
|
||||||
let json = JSON.parse(survey.data);
|
let json = JSON.parse(survey.data);
|
||||||
json.showTitle = false;
|
json.showTitle = false;
|
||||||
json.showProgressBar = 'bottom';
|
json.showProgressBar = 'bottom';
|
||||||
|
|
@ -260,7 +263,7 @@ export default {
|
||||||
result({ data, loading }) {
|
result({ data, loading }) {
|
||||||
if (!loading) {
|
if (!loading) {
|
||||||
this.surveyData = data.survey;
|
this.surveyData = data.survey;
|
||||||
this.loadSurveyFromServer(data.survey);
|
this.loadSurveyFromServer(data.survey);
|
||||||
const module = data.survey.module;
|
const module = data.survey.module;
|
||||||
|
|
||||||
this.$apollo.addSmartQuery('module', {
|
this.$apollo.addSmartQuery('module', {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue