Clean up code

This commit is contained in:
Ramon Wenger 2022-01-26 20:49:31 +01:00
parent 7da98d9ae7
commit 457c59cbc4
35 changed files with 40 additions and 40 deletions

View File

@ -1,4 +1,5 @@
<template> <template>
<!-- eslint-disable vue/no-v-html -->
<div class="assignment-with-submissions"> <div class="assignment-with-submissions">
<p class="assignment-with-submissions__text"> <p class="assignment-with-submissions__text">
{{ assignment.assignment }} {{ assignment.assignment }}

View File

@ -25,7 +25,7 @@
const Tick = () => import(/* webpackChunkName: "icons" */'@/components/icons/Tick'); const Tick = () => import(/* webpackChunkName: "icons" */'@/components/icons/Tick');
export default { export default {
props: ['selected-color'], props: ['selectedColor'],
components: { components: {
Tick Tick

View File

@ -35,7 +35,6 @@
import openSidebar from '@/mixins/open-sidebar'; import openSidebar from '@/mixins/open-sidebar';
import me from '@/mixins/me'; import me from '@/mixins/me';
const Logo = () => import(/* webpackChunkName: "icons" */'@/components/icons/Logo');
const Hamburger = () => import(/* webpackChunkName: "icons" */'@/components/icons/Hamburger'); const Hamburger = () => import(/* webpackChunkName: "icons" */'@/components/icons/Hamburger');
export default { export default {
@ -44,7 +43,6 @@
components: { components: {
ContentNavigation, ContentNavigation,
UserWidget, UserWidget,
Logo,
CurrentClass, CurrentClass,
Hamburger, Hamburger,
}, },

View File

@ -41,7 +41,7 @@
<script> <script>
export default { export default {
props: ['title', 'subtitle', 'route', 'link-text'], props: ['title', 'subtitle', 'route', 'linkText'],
methods: { methods: {
navigate() { navigate() {
if (this.route) { if (this.route) {

View File

@ -45,7 +45,7 @@
topics: { topics: {
query: ALL_TOPICS_QUERY, query: ALL_TOPICS_QUERY,
manual: true, manual: true,
result({data, loading, networkStatus}) { result({data, loading}) {
if (!loading) { if (!loading) {
this.topics = this.$getRidOfEdges(data).topics; this.topics = this.$getRidOfEdges(data).topics;
} }

View File

@ -40,7 +40,7 @@
}, },
watch: { watch: {
$route(to, from) { $route() {
this.show = false; this.show = false;
} }
}, },

View File

@ -120,7 +120,7 @@
}, },
methods: { methods: {
setContentBlockType(checked, localContentBlock) { setContentBlockType(checked) {
this.localContentBlock.isAssignment = checked; this.localContentBlock.isAssignment = checked;
}, },
update(index, element) { update(index, element) {

View File

@ -93,13 +93,12 @@ export default {
methods: { methods: {
addNote(id) { addNote(id) {
if (!this.parent.hasOwnProperty('__typename')) { const type = Object.prototype.hasOwnProperty.call(this.parent, '__typename')
this.parent.__typename = 'ContentBlockNode'; ? this.parent.__typename : 'ContentBlockNode';
}
this.$store.dispatch('addNote', { this.$store.dispatch('addNote', {
content: id, content: id,
type: this.parent.__typename, type,
block: this.root block: this.root
}); });
}, },

View File

@ -1,4 +1,5 @@
<template> <template>
<!-- eslint-disable vue/no-v-html -->
<div class="instrument-widget"> <div class="instrument-widget">
<div <div
class="instrument-widget__description" class="instrument-widget__description"

View File

@ -18,7 +18,7 @@
export default { export default {
props: { props: {
value: Object, value: Object,
'no-margin': { noMargin: {
default: false default: false
} }
}, },

View File

@ -1,4 +1,5 @@
<template> <template>
<!-- eslint-disable vue/no-v-html -->
<h4 <h4
class="section-title" class="section-title"
v-html="value.text" v-html="value.text"

View File

@ -6,6 +6,7 @@
</template> </template>
<script> <script>
//todo: esacpe value.text
export default { export default {
props: ['value'] props: ['value']
}; };

View File

@ -1,4 +1,5 @@
<template> <template>
<!-- eslint-disable vue/no-v-html -->
<div class="task"> <div class="task">
<div <div
class="task__text" class="task__text"

View File

@ -6,6 +6,7 @@
</template> </template>
<script> <script>
// todo: escape text maybe
export default { export default {
props: ['value'] props: ['value']
}; };

View File

@ -112,6 +112,7 @@
return this.assignment.id ? this.assignment.id.replace(/=/g, '') : ''; return this.assignment.id ? this.assignment.id.replace(/=/g, '') : '';
}, },
feedbackText() { feedbackText() {
// todo: should we maybe clean up this feedback text?
let feedback = this.assignment.submission.submissionFeedback; let feedback = this.assignment.submission.submissionFeedback;
return `<span class="inline-title">Feedback von ${feedback.teacher.firstName} ${feedback.teacher.lastName}:</span> ${feedback.text}`; return `<span class="inline-title">Feedback von ${feedback.teacher.firstName} ${feedback.teacher.lastName}:</span> ${feedback.text}`;
}, },

View File

@ -1,4 +1,5 @@
<template> <template>
<!-- eslint-disable vue/no-v-html -->
<p <p
class="spellcheck" class="spellcheck"
v-if="corrections" v-if="corrections"

View File

@ -52,7 +52,6 @@
const FinalSubmission = () => import('@/components/content-blocks/assignment/FinalSubmission'); const FinalSubmission = () => import('@/components/content-blocks/assignment/FinalSubmission');
const FileUpload = () => import('@/components/ui/file-upload/FileUpload'); const FileUpload = () => import('@/components/ui/file-upload/FileUpload');
const DocumentBlock = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/DocumentBlock');
export default { export default {
props: { props: {
@ -81,7 +80,6 @@
FileUpload, FileUpload,
SubmissionInput, SubmissionInput,
FinalSubmission, FinalSubmission,
DocumentBlock,
}, },
computed: { computed: {

View File

@ -48,7 +48,7 @@
this.mountUploadcare(); this.mountUploadcare();
}, },
methods: { methods: {
error(e) { error() {
this.hadError = true; this.hadError = true;
delete this.value.url; delete this.value.url;
@ -84,8 +84,7 @@
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "@/styles/_variables.scss"; @import "~styles/helpers";
@import "@/styles/_mixins.scss";
.image-form { .image-form {
&__error { &__error {

View File

@ -17,7 +17,7 @@
type: Object, type: Object,
default: null, default: null,
validator(value) { validator(value) {
return value.hasOwnProperty('text'); return Object.prototype.hasOwnProperty.call(value, 'text');
} }
}, },
index: { index: {

View File

@ -31,7 +31,6 @@
<script> <script>
import {INTERDISCIPLINARY, LANGUAGE_COMMUNICATION, SOCIETY} from '@/consts/instrument.consts'; import {INTERDISCIPLINARY, LANGUAGE_COMMUNICATION, SOCIETY} from '@/consts/instrument.consts';
import Checkbox from '@/components/ui/Checkbox';
import FilterGroup from '@/components/instruments/FilterGroup'; import FilterGroup from '@/components/instruments/FilterGroup';
import INSTRUMENT_TYPES_QUERY from 'gql/queries/instrumentTypesQuery'; import INSTRUMENT_TYPES_QUERY from 'gql/queries/instrumentTypesQuery';
@ -40,7 +39,6 @@
components: { components: {
FilterGroup, FilterGroup,
Checkbox,
}, },
data() { data() {
return { return {

View File

@ -1,4 +1,5 @@
<template> <template>
<!-- eslint-disable vue/no-v-html -->
<div <div
class="module" class="module"
v-if="module.id" v-if="module.id"

View File

@ -73,7 +73,6 @@
import BackLink from '@/components/BackLink'; import BackLink from '@/components/BackLink';
import {moduleQuery} from '@/graphql/queries'; import {moduleQuery} from '@/graphql/queries';
import SubNavigationItem from '@/components/book-navigation/SubNavigationItem';
import ToggleEditing from '@/components/toggle-menu/ToggleEditing'; import ToggleEditing from '@/components/toggle-menu/ToggleEditing';
import me from '@/mixins/me'; import me from '@/mixins/me';
import SnapshotMenu from '@/components/modules/SnapshotMenu'; import SnapshotMenu from '@/components/modules/SnapshotMenu';
@ -88,7 +87,6 @@
components: { components: {
SnapshotMenu, SnapshotMenu,
BackLink, BackLink,
SubNavigationItem,
ToggleEditing, ToggleEditing,
}, },

View File

@ -1,4 +1,5 @@
<template> <template>
<!-- eslint-disable vue/no-v-html -->
<div class="snapshot-list-item"> <div class="snapshot-list-item">
<router-link <router-link
:to="snapshotRoute" :to="snapshotRoute"

View File

@ -2,8 +2,7 @@
<div class="objective-groups"> <div class="objective-groups">
<objective-group <objective-group
:group="group" :group="group"
v-for="group in objectiveGroups" v-for="group in filteredObjectiveGroups"
v-if="!group.hidden"
:key="group.id" :key="group.id"
/> />
</div> </div>
@ -39,6 +38,9 @@
}, },
computed: { computed: {
filteredObjectiveGroups() {
return this.objectiveGroups.filter(g => !g.hidden);
},
objectiveGroups() { objectiveGroups() {
/* /*
a teacher should get multiple blocks, so he can manage the visibility for his students. a teacher should get multiple blocks, so he can manage the visibility for his students.

View File

@ -14,7 +14,6 @@
<script> <script>
const SimpleFileUploadHiddenInput = () => import('@/components/ui/file-upload/SimpleFileUploadHiddenInput'); const SimpleFileUploadHiddenInput = () => import('@/components/ui/file-upload/SimpleFileUploadHiddenInput');
const ButtonWithIconAndText = () => import('@/components/ui/ButtonWithIconAndText'); const ButtonWithIconAndText = () => import('@/components/ui/ButtonWithIconAndText');
const DocumentIcon = () => import(/* webpackChunkName: "icons" */'@/components/icons/DocumentIcon');
export default { export default {
props: ['value'], props: ['value'],
@ -22,7 +21,6 @@
components: { components: {
ButtonWithIconAndText, ButtonWithIconAndText,
SimpleFileUploadHiddenInput, SimpleFileUploadHiddenInput,
DocumentIcon,
}, },
methods: { methods: {

View File

@ -1,5 +1,5 @@
import dayjs from 'dayjs'; import dayjs from 'dayjs';
require('dayjs/locale/de'); import 'dayjs/locale/de';
dayjs.locale('de'); dayjs.locale('de');

View File

@ -1 +1 @@
export const withoutOwnerFirst = (a, b) => a.owner ? 1 : -1; export const withoutOwnerFirst = (a) => a.owner ? 1 : -1;

View File

@ -2,6 +2,7 @@ export default (contents) => {
if (contents && contents.length) { if (contents && contents.length) {
let first = contents.find(content => content.type !== 'image_url_block'); let first = contents.find(content => content.type !== 'image_url_block');
if (first && first.type) { if (first && first.type) {
let parts;
switch (first.type) { switch (first.type) {
case 'text_block': case 'text_block':
return first.value.text.replace(/<p>/g, '').replace(/<\/p>/g, '<br>').slice(0, 75) + '...'; return first.value.text.replace(/<p>/g, '').replace(/<\/p>/g, '<br>').slice(0, 75) + '...';
@ -9,7 +10,7 @@ export default (contents) => {
case 'link_block': case 'link_block':
return first.value.url; return first.value.url;
case 'document_block': case 'document_block':
const parts = first.value.url.split('/'); parts = first.value.url.split('/');
return parts[parts.length - 1]; return parts[parts.length - 1];
default: default:
return ''; return '';

View File

@ -67,7 +67,7 @@ export const constructContentComponentBookmarkMutation = (uuid, bookmarked, pare
bookmarked bookmarked
} }
}, },
update: (store, response) => { update: (store) => {
const query = CONTENT_BLOCK_QUERY; const query = CONTENT_BLOCK_QUERY;
const variables = {id: root}; const variables = {id: root};
const data = store.readQuery({ const data = store.readQuery({

View File

@ -68,14 +68,14 @@ function getCookieValue(cookieName) {
function loginRequired(to) { function loginRequired(to) {
// public pages have the meta.public property set to true // public pages have the meta.public property set to true
return !to.hasOwnProperty('meta') || !to.meta.hasOwnProperty('public') || !to.meta.public; return !Object.prototype.hasOwnProperty.call(to, 'meta') || !Object.prototype.hasOwnProperty.call(to.meta ,'public') || !to.meta.public;
} }
function unauthorizedAccess(to) { function unauthorizedAccess(to) {
return loginRequired(to) && getCookieValue('loginStatus') !== 'true'; return loginRequired(to) && getCookieValue('loginStatus') !== 'true';
} }
function redirectUsersWithoutValidLicense(to) { function redirectUsersWithoutValidLicense() {
return privateApolloClient.query({ return privateApolloClient.query({
query: ME_QUERY, query: ME_QUERY,
}).then(({data}) => data.me.expiryDate == null); }).then(({data}) => data.me.expiryDate == null);
@ -87,7 +87,7 @@ function redirectStudentsWithoutClass() {
}).then(({data}) => data.me.schoolClasses.edges.length === 0 && !data.me.isTeacher); }).then(({data}) => data.me.schoolClasses.edges.length === 0 && !data.me.isTeacher);
} }
function redirectUsersToOnboarding(to) { function redirectUsersToOnboarding() {
return privateApolloClient.query({ return privateApolloClient.query({
query: ME_QUERY, query: ME_QUERY,
}).then(({data}) => !data.me.onboardingVisited); }).then(({data}) => !data.me.onboardingVisited);

View File

@ -15,7 +15,7 @@ export default {
id: selectedClass.id id: selectedClass.id
} }
}, },
update(store, data) { update(store) {
let meData = store.readQuery({query: ME_QUERY}); let meData = store.readQuery({query: ME_QUERY});
meData.me.selectedClass = selectedClass; meData.me.selectedClass = selectedClass;

View File

@ -92,7 +92,6 @@
import NEW_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/addContentBlock.gql'; import NEW_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/addContentBlock.gql';
import {setUserBlockType} from '@/helpers/content-block'; import {setUserBlockType} from '@/helpers/content-block';
import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql'; import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
import {MODULE_PAGE} from '@/router/module.names';
export default Vue.extend({ export default Vue.extend({
props: { props: {

View File

@ -41,7 +41,7 @@
query: ALL_MODULES, query: ALL_MODULES,
// prefetch: true, // prefetch: true,
manual: true, manual: true,
result({data, loading, networkStatus}) { result({data, loading}) {
if (!loading) { if (!loading) {
this.modules = this.$getRidOfEdges(data).modules; this.modules = this.$getRidOfEdges(data).modules;
} }

View File

@ -2,7 +2,7 @@ const getRidOfEdges = (collection) => {
if (typeof collection === 'object' && collection && !Array.isArray(collection)) { if (typeof collection === 'object' && collection && !Array.isArray(collection)) {
let newObj = {}; let newObj = {};
for (const k in collection) { for (const k in collection) {
if (collection.hasOwnProperty(k)) { if (Object.prototype.hasOwnProperty.call(collection, k)) {
if (k === 'edges') { if (k === 'edges') {
return collection.edges.map(edge => getRidOfEdges(edge.node)); return collection.edges.map(edge => getRidOfEdges(edge.node));
} else { } else {
@ -20,7 +20,7 @@ const getRidOfEdges = (collection) => {
}; };
const EdgesPlugin = { const EdgesPlugin = {
install(Vue, options) { install(Vue) {
Vue.prototype.$getRidOfEdges = getRidOfEdges; Vue.prototype.$getRidOfEdges = getRidOfEdges;
} }
}; };

View File

@ -3,7 +3,7 @@
import Vue from 'vue'; import Vue from 'vue';
class ModalStore { class ModalStore {
constructor(data = {}) { constructor() {
this.vm = new Vue({ this.vm = new Vue({
data: () => ({ data: () => ({
component: '', component: '',
@ -18,7 +18,7 @@ class ModalStore {
} }
const ModalPlugin = { const ModalPlugin = {
install(Vue, options) { install(Vue) {
const store = new ModalStore({}); const store = new ModalStore({});
const reset = () => { const reset = () => {