mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 19:52:53 +00:00
refactor: change meta class structure to include types.
Introduce requiredness of translations via implemented interface.
This commit is contained in:
committed by
Karl-Philipp Wulfert
parent
90e3d22399
commit
62975b9ded
@@ -21,9 +21,10 @@ import {
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from '../base/ThingWithCategories';
|
||||
import {SCThingMeta, SCThingType} from '../Thing';
|
||||
import {SCTranslations} from '../types/i18n';
|
||||
import {SCMetaTranslations, SCTranslations} from '../types/i18n';
|
||||
|
||||
/**
|
||||
* A dish without references
|
||||
@@ -92,34 +93,7 @@ export interface SCDishTranslatableProperties
|
||||
/**
|
||||
* Characteristics of the dish
|
||||
*/
|
||||
characteristics?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Dish meta data
|
||||
*/
|
||||
export class SCDishMeta extends SCThingMeta {
|
||||
static fieldTranslations = {
|
||||
...SCThingMeta.fieldTranslations,
|
||||
de: {
|
||||
categories: 'Kategorien',
|
||||
},
|
||||
};
|
||||
|
||||
static fieldValueTranslations = {
|
||||
...SCThingMeta.fieldValueTranslations,
|
||||
de: {
|
||||
categories: {
|
||||
appetizer: 'Vorspeise',
|
||||
dessert: 'Nachtisch',
|
||||
'main dish': 'Hauptgericht',
|
||||
salad: 'Salat',
|
||||
'side dish': 'Beilage',
|
||||
soup: 'Suppe',
|
||||
},
|
||||
type: 'Essen',
|
||||
},
|
||||
};
|
||||
characteristics?: SCDishCharacteristic[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,3 +163,46 @@ export interface SCNutritionInformation {
|
||||
*/
|
||||
sugarContent?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a dish
|
||||
*/
|
||||
export class SCDishMeta extends SCThingMeta implements SCMetaTranslations<SCDish> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
|
||||
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
|
||||
},
|
||||
en: {
|
||||
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
|
||||
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
|
||||
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
|
||||
categories: {
|
||||
appetizer: 'Vorspeise',
|
||||
dessert: 'Nachtisch',
|
||||
'main dish': 'Hauptgericht',
|
||||
salad: 'Salat',
|
||||
'side dish': 'Beilage',
|
||||
soup: 'Suppe',
|
||||
},
|
||||
type: 'Essen',
|
||||
},
|
||||
en: {
|
||||
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCDishCategories,
|
||||
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.en,
|
||||
type: SCThingType.Dish,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user