Hide element types depending on feature set

This commit is contained in:
Ramon Wenger 2022-06-22 20:01:54 +02:00
parent 3b3d485c76
commit 0060889a63
3 changed files with 32 additions and 2 deletions

View File

@ -14,6 +14,7 @@
:checked="localContentBlock.isAssignment"
class="content-block-form__task-toggle"
label="Inhaltsblock als Auftrag formatieren"
v-if="hasDefaultFeatures"
@input="localContentBlock.isAssignment=$event"
/>
@ -139,8 +140,12 @@
import {CHOOSER, transformInnerContents} from '@/components/content-block-form/helpers.js';
import ContentElementActions from '@/components/content-block-form/ContentElementActions.vue';
import {ContentBlock, numberOrUndefined} from "@/@types";
import {DEFAULT_FEATURES} from "@/consts/features.consts";
// TODO: refactor this file, it's huuuuuge!
interface ContentBlockFormData {
localContentBlock: any;
}
export default Vue.extend({
props: {
@ -152,6 +157,15 @@
type: Object as PropType<ContentBlock>,
required: true,
},
features: {
type: String,
default: DEFAULT_FEATURES
}
},
provide(): object {
return {
features: this.features
};
},
components: {
ContentElementActions,
@ -161,7 +175,7 @@
ContentFormSection,
Toggle,
},
data() {
data(): ContentBlockFormData {
return {
localContentBlock: Object.assign({}, {
title: this.contentBlock.title,
@ -176,6 +190,9 @@
isValid(): boolean {
return this.localContentBlock.title > '';
},
hasDefaultFeatures(): boolean {
return this.features === DEFAULT_FEATURES;
}
},
methods: {
update(index: number, element: any, parent?: number) {

View File

@ -13,7 +13,7 @@
Neuer Inhalt
</h3>
<template
v-if="includeListOption"
v-if="includeListOption && hasDefaultFeatures"
>
<checkbox
class="content-block-element-chooser-widget__list-toggle"
@ -46,6 +46,8 @@
import formElementIcons from '@/components/ui/form-element-icons';
import CrossIcon from '@/components/icons/CrossIcon';
import ChooserElement from '@/components/content-forms/ChooserElement';
import {DEFAULT_FEATURES} from '@/consts/features.consts';
export default {
props: {
@ -61,6 +63,8 @@
},
},
inject: ['features'],
components: {
ChooserElement,
CrossIcon,
@ -69,6 +73,7 @@
},
data() {
const hasDefaultFeatures = this.features === DEFAULT_FEATURES;
return {
convertToList: false,
chooserTypes: [
@ -77,6 +82,7 @@
block: 'subtitle',
title: 'Untertitel',
icon: 'title-icon',
show: hasDefaultFeatures
},
{
type: 'link',
@ -102,11 +108,13 @@
block: 'assignment',
icon: 'speech-bubble-icon',
title: 'Aufgabe & Ergebnis',
show: !this.hideAssignment && hasDefaultFeatures
},
{
type: 'document',
block: 'document_block',
title: 'Dokument',
show: hasDefaultFeatures
},
@ -118,6 +126,9 @@
filteredChooserTypes() {
return this.chooserTypes.filter(type => !("show" in type) || type.show ); // display element if `show` is not set or if `show` evaluates to true
},
hasDefaultFeatures() {
return this.features === DEFAULT_FEATURES;
}
},
methods: {

View File

@ -0,0 +1,2 @@
export const DEFAULT_FEATURES = 'default';
export const ROOMS_FEATURES = 'rooms';