Hide content blocks for teachers when not in edit mode
This commit is contained in:
parent
4483175dbe
commit
5ae47029a3
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<content-block :contentBlock="contentBlock"
|
<content-block :contentBlock="contentBlock"
|
||||||
:parent="chapter.id"
|
:parent="chapter.id"
|
||||||
:key="contentBlock.id" v-for="contentBlock in chapter.contentBlocks">
|
:key="contentBlock.id" v-for="contentBlock in filteredContentBlocks">
|
||||||
</content-block>
|
</content-block>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
import AddContentBlockButton from '@/components/AddContentBlockButton';
|
import AddContentBlockButton from '@/components/AddContentBlockButton';
|
||||||
|
|
||||||
import {mapGetters} from 'vuex';
|
import {mapGetters} from 'vuex';
|
||||||
|
import {isHidden} from '@/helpers/content-block';
|
||||||
|
import {meQuery} from '@/graphql/queries';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['chapter', 'index'],
|
props: ['chapter', 'index'],
|
||||||
|
|
@ -30,8 +32,30 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['editModule'])
|
...mapGetters(['editModule']),
|
||||||
|
filteredContentBlocks() {
|
||||||
|
if (!(this.chapter && this.chapter.contentBlocks)) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
if (this.editModule) {
|
||||||
|
return this.chapter.contentBlocks;
|
||||||
|
}
|
||||||
|
return this.chapter.contentBlocks.filter(contentBlock => !isHidden(contentBlock, this.schoolClass));
|
||||||
|
},
|
||||||
|
schoolClass() {
|
||||||
|
return this.me.selectedClass;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
me: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
apollo: {
|
||||||
|
me: meQuery
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,8 @@
|
||||||
|
|
||||||
import {mapGetters} from 'vuex';
|
import {mapGetters} from 'vuex';
|
||||||
|
|
||||||
|
import {isHidden} from '@/helpers/content-block';
|
||||||
|
|
||||||
const instruments = {
|
const instruments = {
|
||||||
base_communication: 'Sprache & Kommunikation',
|
base_communication: 'Sprache & Kommunikation',
|
||||||
base_society: 'Gesellschaft'
|
base_society: 'Gesellschaft'
|
||||||
|
|
@ -174,17 +176,7 @@
|
||||||
return this.me.selectedClass;
|
return this.me.selectedClass;
|
||||||
},
|
},
|
||||||
hidden() {
|
hidden() {
|
||||||
if (!this.contentBlock.id || !this.contentBlock.visibleFor || !this.contentBlock.hiddenFor) {
|
return isHidden(this.contentBlock, this.schoolClass);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.contentBlock.userCreated) {
|
|
||||||
if (this.schoolClass.id === '') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !this.contentBlock.visibleFor.map(entry => entry.id).includes(this.schoolClass.id);
|
|
||||||
} else {
|
|
||||||
return this.contentBlock.hiddenFor.map(entry => entry.id).includes(this.schoolClass.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,17 @@
|
||||||
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue