Implement filtering of ContentBlocks

This commit is contained in:
Pawel Kowalski 2018-09-13 12:52:10 +02:00
parent 4a964b3e81
commit 2db6464f8d
2 changed files with 16 additions and 1 deletions

View File

@ -4,7 +4,7 @@
<add-content-block-button :parent="chapter.id"></add-content-block-button>
<content-block :contentBlock="contentBlock" :key="contentBlock.id" v-for="contentBlock in chapter.contentBlocks">
<content-block v-if="shouldBeVisible(contentBlock, 'VXNlckdyb3VwTm9kZTo2')" :contentBlock="contentBlock" :key="contentBlock.id" v-for="contentBlock in chapter.contentBlocks">
</content-block>
</div>
</template>
@ -19,6 +19,13 @@
components: {
ContentBlock,
AddContentBlockButton
},
methods: {
shouldBeVisible(contentBlock, userGroup) {
const userGroups = contentBlock.hiddenFor.map(entry => entry.id)
return !userGroups.includes(userGroup)
}
}
}
</script>

View File

@ -37,6 +37,14 @@ query ModulesQuery($slug: String!) {
title
type
contents
hiddenFor {
edges {
node {
id
name
}
}
}
}
}
}