Refactor some code
This commit is contained in:
parent
d97ad231cc
commit
16baba9423
|
|
@ -60,11 +60,11 @@
|
||||||
import CHAPTER_QUERY from '@/graphql/gql/chapterQuery.gql';
|
import CHAPTER_QUERY from '@/graphql/gql/chapterQuery.gql';
|
||||||
import DELETE_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/deleteContentBlock.gql';
|
import DELETE_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/deleteContentBlock.gql';
|
||||||
|
|
||||||
import {meQuery} from '@/graphql/queries';
|
|
||||||
|
|
||||||
import {mapState} from 'vuex';
|
import {mapState} from 'vuex';
|
||||||
|
|
||||||
import {isHidden} from '@/helpers/content-block';
|
import me from '@/mixins/me';
|
||||||
|
import {hidden} from '@/helpers/visibility';
|
||||||
|
import {CONTENT_TYPE} from '@/consts/types';
|
||||||
|
|
||||||
const instruments = {
|
const instruments = {
|
||||||
base_communication: 'Sprache & Kommunikation',
|
base_communication: 'Sprache & Kommunikation',
|
||||||
|
|
@ -77,6 +77,8 @@
|
||||||
name: 'ContentBlock',
|
name: 'ContentBlock',
|
||||||
props: ['contentBlock', 'parent'],
|
props: ['contentBlock', 'parent'],
|
||||||
|
|
||||||
|
mixins: [me],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
ContentComponent,
|
ContentComponent,
|
||||||
AddContentButton,
|
AddContentButton,
|
||||||
|
|
@ -85,13 +87,6 @@
|
||||||
UserWidget
|
UserWidget
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
showVisibility: false,
|
|
||||||
me: {}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['editModule']),
|
...mapState(['editModule']),
|
||||||
canEditModule() {
|
canEditModule() {
|
||||||
|
|
@ -164,11 +159,12 @@
|
||||||
contents: this.removeSingleContentListItem(newContent, startingIndex)
|
contents: this.removeSingleContentListItem(newContent, startingIndex)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
schoolClass() {
|
|
||||||
return this.me.selectedClass;
|
|
||||||
},
|
|
||||||
hidden() {
|
hidden() {
|
||||||
return isHidden(this.contentBlock, this.schoolClass);
|
return hidden({
|
||||||
|
block: this.contentBlock,
|
||||||
|
schoolClass: this.schoolClass,
|
||||||
|
type: CONTENT_TYPE
|
||||||
|
});
|
||||||
},
|
},
|
||||||
root() {
|
root() {
|
||||||
// we need the root content block id, not the generated content block if inside a content list block
|
// we need the root content block id, not the generated content block if inside a content list block
|
||||||
|
|
@ -235,10 +231,6 @@
|
||||||
}
|
}
|
||||||
return [...content.slice(0, listIndex), ...content[listIndex].contents[0].value, ...content.slice(listIndex + 1)];
|
return [...content.slice(0, listIndex), ...content[listIndex].contents[0].value, ...content.slice(listIndex + 1)];
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
apollo: {
|
|
||||||
me: meQuery
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -59,21 +59,20 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {moduleQuery} from '@/graphql/queries';
|
import {moduleQuery} from '@/graphql/queries';
|
||||||
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
|
||||||
|
|
||||||
import SubNavigationItem from '@/components/book-navigation/SubNavigationItem';
|
import SubNavigationItem from '@/components/book-navigation/SubNavigationItem';
|
||||||
import ToggleSolutionsForModule from '@/components/toggle-menu/ToggleSolutionsForModule';
|
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 ChevronLeft from '@/components/icons/ChevronLeft';
|
||||||
|
import me from '@/mixins/me';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
apollo: {
|
apollo: {
|
||||||
module: moduleQuery,
|
module: moduleQuery,
|
||||||
me: {
|
|
||||||
query: ME_QUERY
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mixins: [me],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
SubNavigationItem,
|
SubNavigationItem,
|
||||||
ToggleSolutionsForModule,
|
ToggleSolutionsForModule,
|
||||||
|
|
@ -87,9 +86,6 @@
|
||||||
assignments: [],
|
assignments: [],
|
||||||
topic: {}
|
topic: {}
|
||||||
},
|
},
|
||||||
me: {
|
|
||||||
permissions: []
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -103,9 +99,6 @@
|
||||||
showResults() {
|
showResults() {
|
||||||
return this.me.permissions.includes('users.can_manage_school_class_content');
|
return this.me.permissions.includes('users.can_manage_school_class_content');
|
||||||
},
|
},
|
||||||
canManageContent() {
|
|
||||||
return this.me.permissions.includes('users.can_manage_school_class_content');
|
|
||||||
},
|
|
||||||
assignments() {
|
assignments() {
|
||||||
if (!this.module.chapters) {
|
if (!this.module.chapters) {
|
||||||
return [];
|
return [];
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,11 @@
|
||||||
import MoreOptionsWidget from '@/components/MoreOptionsWidget';
|
import MoreOptionsWidget from '@/components/MoreOptionsWidget';
|
||||||
|
|
||||||
import {mapState} from 'vuex';
|
import {mapState} from 'vuex';
|
||||||
import {isHidden} from '@/helpers/content-block';
|
|
||||||
import {meQuery} from '@/graphql/queries';
|
import {meQuery} from '@/graphql/queries';
|
||||||
import DELETE_OBJECTIVE_MUTATION from '@/graphql/gql/mutations/deleteObjective.gql';
|
import DELETE_OBJECTIVE_MUTATION from '@/graphql/gql/mutations/deleteObjective.gql';
|
||||||
import MODULE_DETAILS_QUERY from '@/graphql/gql/moduleDetailsQuery.gql';
|
import MODULE_DETAILS_QUERY from '@/graphql/gql/moduleDetailsQuery.gql';
|
||||||
|
import {hidden} from '@/helpers/visibility';
|
||||||
|
import {OBJECTIVE_TYPE} from '@/consts/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['objective', 'schoolClass'],
|
props: ['objective', 'schoolClass'],
|
||||||
|
|
@ -52,7 +53,11 @@
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['editModule']),
|
...mapState(['editModule']),
|
||||||
hidden() {
|
hidden() {
|
||||||
return isHidden(this.objective, this.schoolClass);
|
return hidden({
|
||||||
|
block: this.objective,
|
||||||
|
schoolClass: this.schoolClass,
|
||||||
|
type: OBJECTIVE_TYPE
|
||||||
|
});
|
||||||
},
|
},
|
||||||
canEdit() {
|
canEdit() {
|
||||||
return this.objective.mine;
|
return this.objective.mine;
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,12 @@
|
||||||
<script>
|
<script>
|
||||||
import Objective from '@/components/objective-groups/Objective';
|
import Objective from '@/components/objective-groups/Objective';
|
||||||
|
|
||||||
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
|
||||||
import AddContentButton from '@/components/AddContentButton';
|
import AddContentButton from '@/components/AddContentButton';
|
||||||
|
|
||||||
import {mapState} from 'vuex';
|
import {mapState} from 'vuex';
|
||||||
|
|
||||||
|
import me from '@/mixins/me';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
group: {
|
group: {
|
||||||
|
|
@ -34,22 +35,15 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mixins: [me],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
AddContentButton,
|
AddContentButton,
|
||||||
Objective
|
Objective
|
||||||
},
|
},
|
||||||
|
|
||||||
apollo: {
|
|
||||||
me: {
|
|
||||||
query: ME_QUERY,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['editModule']),
|
...mapState(['editModule']),
|
||||||
canManageContent() {
|
|
||||||
return this.me.permissions.includes('users.can_manage_school_class_content');
|
|
||||||
},
|
|
||||||
currentFilter() {
|
currentFilter() {
|
||||||
return this.me.selectedClass;
|
return this.me.selectedClass;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Checkbox from '@/components/Checkbox';
|
import Checkbox from '@/components/Checkbox';
|
||||||
import {mapGetters, mapActions} from 'vuex';
|
import {mapState, mapActions} from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapState({
|
||||||
checked: 'editModule',
|
checked: 'editModule',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,3 @@
|
||||||
export function setUserBlockType(isAssignment) {
|
export function setUserBlockType(isAssignment) {
|
||||||
return isAssignment ? 'TASK' : 'NORMAL';
|
return isAssignment ? 'TASK' : 'NORMAL';
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isHidden = (contentBlock, schoolClass) => {
|
|
||||||
if (!contentBlock.id || !contentBlock.visibleFor || !contentBlock.hiddenFor) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (contentBlock.userCreated) {
|
|
||||||
if (schoolClass.id === '') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !contentBlock.visibleFor.map(entry => entry.id).includes(schoolClass.id);
|
|
||||||
} else {
|
|
||||||
return contentBlock.hiddenFor.map(entry => entry.id).includes(schoolClass.id);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapGetters, mapActions} from 'vuex';
|
import {mapState, mapActions} from 'vuex';
|
||||||
import MODULE_DETAILS_QUERY from '@/graphql/gql/moduleDetailsQuery.gql';
|
import MODULE_DETAILS_QUERY from '@/graphql/gql/moduleDetailsQuery.gql';
|
||||||
|
|
||||||
import SCROLL_POSITION from '@/graphql/gql/local/scrollPosition.gql';
|
import SCROLL_POSITION from '@/graphql/gql/local/scrollPosition.gql';
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapState({
|
||||||
editModule: 'editModule'
|
editModule: 'editModule'
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue