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> <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> </content-block>
</div> </div>
</template> </template>
@ -19,6 +19,13 @@
components: { components: {
ContentBlock, ContentBlock,
AddContentBlockButton AddContentBlockButton
},
methods: {
shouldBeVisible(contentBlock, userGroup) {
const userGroups = contentBlock.hiddenFor.map(entry => entry.id)
return !userGroups.includes(userGroup)
}
} }
} }
</script> </script>

View File

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