Fix instrument label bug

This commit is contained in:
Ramon Wenger 2022-05-24 12:43:40 +02:00
parent 7a090cfced
commit 328a34d6d0
3 changed files with 24 additions and 19 deletions

View File

@ -91,12 +91,6 @@
const ContentComponent = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/ContentComponent'); const ContentComponent = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/ContentComponent');
const instruments = {
base_communication: 'Sprache & Kommunikation',
base_society: 'Gesellschaft',
base_interdisciplinary: 'Überfachliches Instrument',
};
export default { export default {
name: 'ContentBlock', name: 'ContentBlock',
@ -135,10 +129,7 @@
}, },
instrumentLabel() { instrumentLabel() {
const contentType = this.contentBlock.type.toLowerCase(); const contentType = this.contentBlock.type.toLowerCase();
if (!(contentType in instruments)) { return instrumentCategory(contentType);
return '';
}
return instrumentCategory(this.instrument);
}, },
canEditContentBlock() { canEditContentBlock() {
return this.contentBlock.mine && !this.contentBlock.indent; return this.contentBlock.mine && !this.contentBlock.indent;

View File

@ -1,3 +1,18 @@
export const LANGUAGE_COMMUNICATION = 'LANGUAGE_COMMUNICATION'; export const LANGUAGE_COMMUNICATION = 'LANGUAGE_COMMUNICATION';
export const LANGUAGE_COMMUNICATION_BASE = 'base_communication';
export const LANGUAGE_COMMUNICATION_VALUE = 'Sprache & Kommunikation';
export const SOCIETY = 'SOCIETY'; export const SOCIETY = 'SOCIETY';
export const SOCIETY_BASE = 'base_society';
export const SOCIETY_VALUE = 'Gesellschaft';
export const INTERDISCIPLINARY = 'INTERDISCIPLINARY'; export const INTERDISCIPLINARY = 'INTERDISCIPLINARY';
export const INTERDISCIPLINARY_BASE = 'base_interdisciplinary';
export const INTERDISCIPLINARY_VALUE = 'Überfachliches Instrument';
export const typeDictionary = {
[LANGUAGE_COMMUNICATION]: LANGUAGE_COMMUNICATION_VALUE,
[LANGUAGE_COMMUNICATION_BASE]: LANGUAGE_COMMUNICATION_VALUE,
[SOCIETY]: SOCIETY_VALUE,
[SOCIETY_BASE]: SOCIETY_VALUE,
[INTERDISCIPLINARY]: INTERDISCIPLINARY_VALUE,
[INTERDISCIPLINARY_BASE]: INTERDISCIPLINARY_VALUE,
};

View File

@ -1,23 +1,22 @@
import {LANGUAGE_COMMUNICATION, SOCIETY} from '@/consts/instrument.consts'; import {typeDictionary} from '@/consts/instrument.consts';
import flavor from '@/helpers/app-flavor'; import flavor from '@/helpers/app-flavor';
const instrumentType = ({type: {category}}) => { const instrumentType = (instrument) => {
if (category === LANGUAGE_COMMUNICATION) { let category;
return 'Sprache & Kommunikation'; if (typeof instrument === 'string') {
} else if (category === SOCIETY) { category = instrument;
return 'Gesellschaft';
} else { } else {
return 'Überfachliches Instrument'; category = instrument.type.category;
} }
return typeDictionary[category] || '';
}; };
const instrumentCategory = (instrument) => { const instrumentCategory = (instrument) => {
if (flavor.appFlavor === 'my-kv') { if (flavor.appFlavor === 'my-kv') {
return flavor.textInstruments; return flavor.textInstruments;
} else { } else {
return instrumentType(instrument); return `${flavor.textInstruments} - ${instrumentType(instrument)}`;
} }
}; };
export default instrumentType; export default instrumentType;