From 623ed613a9405b53a86a33c13d48bc49d48de1ce Mon Sep 17 00:00:00 2001 From: Karl-Philipp Wulfert Date: Wed, 3 Apr 2019 11:19:24 +0200 Subject: [PATCH] fix: resolve issues with things that can be offered Fixes #41 --- src/core/base/ThingThatCanBeOffered.ts | 21 ++++++----- src/core/things/CourseOfStudies.ts | 50 +++++++++++++++----------- src/core/things/DateSeries.ts | 20 ++++++----- src/core/things/Dish.ts | 32 ++++++++--------- 4 files changed, 68 insertions(+), 55 deletions(-) diff --git a/src/core/base/ThingThatCanBeOffered.ts b/src/core/base/ThingThatCanBeOffered.ts index 56ccb111..cec374ca 100644 --- a/src/core/base/ThingThatCanBeOffered.ts +++ b/src/core/base/ThingThatCanBeOffered.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2018, 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -16,8 +16,8 @@ import {SCThing, SCThingTranslatableProperties} from '../Thing'; import {SCOrganizationWithoutReferences} from '../things/Organization'; import {SCPersonWithoutReferences} from '../things/Person'; import {SCTranslations} from '../types/i18n'; +import {SCInPlace} from '../types/Places'; import {SCISO8601Date} from '../types/Time'; -import {SCInPlace} from './../types/Places'; /** * Default price without distinction @@ -50,7 +50,17 @@ export interface SCAcademicPriceGroup extends SCPriceGroup { } /** - * A thing without references that has a price tag + * A thing without references that can be offered + */ +export interface SCThingThatCanBeOfferedWithoutReferences extends SCThing { + /** + * Translations of a thing that can be offered + */ + translations?: SCTranslations; +} + +/** + * A thing that can be offered */ export interface SCThingThatCanBeOffered extends SCThing { @@ -58,11 +68,6 @@ export interface SCThingThatCanBeOffered * List of offers for that thing */ offers?: Array>; - - /** - * Translations of a thing that can be offered - */ - translations?: SCTranslations; } /** diff --git a/src/core/things/CourseOfStudies.ts b/src/core/things/CourseOfStudies.ts index 0ff536c6..d84c5ad4 100644 --- a/src/core/things/CourseOfStudies.ts +++ b/src/core/things/CourseOfStudies.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 StApps + * Copyright (C) 2018, 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,9 +13,12 @@ * this program. If not, see . */ import {SCAcademicDegree, SCAcademicDegreeMeta} from '../base/AcademicDegree'; -import {SCAcademicPriceGroup, - SCThingThatCanBeOffered, - SCThingThatCanBeOfferedTranslatableProperties} from '../base/ThingThatCanBeOffered'; +import { + SCAcademicPriceGroup, + SCThingThatCanBeOffered, + SCThingThatCanBeOfferedTranslatableProperties, + SCThingThatCanBeOfferedWithoutReferences, +} from '../base/ThingThatCanBeOffered'; import {SCThingMeta, SCThingType} from '../Thing'; import {SCLanguage, SCMetaTranslations, SCTranslations} from '../types/i18n'; import {SCDateSeriesWithoutReferences} from './DateSeries'; @@ -24,9 +27,8 @@ import {SCOrganization} from './Organization'; /** * A course of studies without references */ -export interface SCCourseOfStudiesWithoutReferences extends - SCAcademicDegree, - SCThingThatCanBeOffered { +export interface SCCourseOfStudiesWithoutReferences extends SCAcademicDegree, + SCThingThatCanBeOfferedWithoutReferences { /** * The main language in which the course of studies * is beeing offered @@ -64,14 +66,15 @@ export interface SCCourseOfStudiesWithoutReferences extends * * @validatable */ -export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences { +export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences, + SCThingThatCanBeOffered { /** * The department that manages the course of studies */ department: SCOrganization; /** - * The secretary that administers requests and + * The secretary that administers requests and * questions concerning the course of studies */ secretary: SCOrganization; @@ -81,6 +84,11 @@ export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences { */ startDates?: SCDateSeriesWithoutReferences[]; + /** + * Translated fields of a dish + */ + translations?: SCTranslations; + /** * Type of the course of studies */ @@ -88,7 +96,7 @@ export interface SCCourseOfStudies extends SCCourseOfStudiesWithoutReferences { } export interface SCCourseOfStudiesTranslatableProperties - extends SCThingThatCanBeOfferedTranslatableProperties { + extends SCThingThatCanBeOfferedTranslatableProperties { } /** @@ -100,19 +108,19 @@ export class SCCourseOfStudiesMeta extends SCThingMeta implements SCMetaTranslat */ fieldTranslations = { de: { - ... SCAcademicDegreeMeta.getInstance().fieldTranslations.de, + ...SCAcademicDegreeMeta.getInstance().fieldTranslations.de, }, en: { - ... SCAcademicDegreeMeta.getInstance().fieldTranslations.en, + ...SCAcademicDegreeMeta.getInstance().fieldTranslations.en, }, }; /** * Translations of values of fields */ - fieldValueTranslations = { + fieldValueTranslations = { de: { - ... SCAcademicDegreeMeta.getInstance().fieldValueTranslations.de, + ...SCAcademicDegreeMeta.getInstance().fieldValueTranslations.de, modes: { combination: 'Kombinationsstudiengang', dual: 'Dualer Studiengang', @@ -122,7 +130,7 @@ export class SCCourseOfStudiesMeta extends SCThingMeta implements SCMetaTranslat type: 'Studiengang', }, en: { - ... SCAcademicDegreeMeta.getInstance().fieldValueTranslations.en, + ...SCAcademicDegreeMeta.getInstance().fieldValueTranslations.en, academicDegree: 'Hochschulabschluss', department: 'Fachbereich', major: 'Studienfach', @@ -136,13 +144,13 @@ export class SCCourseOfStudiesMeta extends SCThingMeta implements SCMetaTranslat /** * Types of (german) course of studies modes */ -export type SCCourseOfStudiesMode = 'combination' | - 'dual' | - 'double-degree' | - 'standard' ; +export type SCCourseOfStudiesMode = 'combination' + | 'dual' + | 'double-degree' + | 'standard' ; /** * Types of (german) course of studies time modes */ -export type SCCourseOfStudiesTimeMode = 'fulltime' | - 'parttime' ; +export type SCCourseOfStudiesTimeMode = 'fulltime' + | 'parttime' ; diff --git a/src/core/things/DateSeries.ts b/src/core/things/DateSeries.ts index 1f3832f5..5dba61ed 100644 --- a/src/core/things/DateSeries.ts +++ b/src/core/things/DateSeries.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 StApps + * Copyright (C) 2018, 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -17,6 +17,7 @@ import { SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingThatCanBeOfferedTranslatableProperties, + SCThingThatCanBeOfferedWithoutReferences, } from '../base/ThingThatCanBeOffered'; import {SCThingMeta, SCThingType} from '../Thing'; import {SCMetaTranslations, SCTranslations} from '../types/i18n'; @@ -38,8 +39,7 @@ export interface SCSportCoursePriceGroup extends SCAcademicPriceGroup { /** * A date without references */ -export interface SCDateSeriesWithoutReferences - extends SCThingThatCanBeOffered { +export interface SCDateSeriesWithoutReferences extends SCThingThatCanBeOfferedWithoutReferences { /** * Dates of the date series that are initially planned to be held */ @@ -76,7 +76,9 @@ export interface SCDateSeriesWithoutReferences * * @validatable */ -export interface SCDateSeries extends SCDateSeriesWithoutReferences, SCThingInPlace { +export interface SCDateSeries extends SCDateSeriesWithoutReferences, + SCThingInPlace, + SCThingThatCanBeOffered { /** * Event to which the date series belongs */ @@ -108,26 +110,26 @@ export class SCDateSeriesMeta extends SCThingMeta implements SCMetaTranslations< */ fieldTranslations = { de: { - ... SCThingInPlaceMeta.getInstance().fieldTranslations.de, + ...SCThingInPlaceMeta.getInstance().fieldTranslations.de, }, en: { - ... SCThingInPlaceMeta.getInstance().fieldTranslations.en, + ...SCThingInPlaceMeta.getInstance().fieldTranslations.en, }, }; /** * Translations of values of fields */ - fieldValueTranslations = { + fieldValueTranslations = { de: { - ... SCThingInPlaceMeta.getInstance().fieldValueTranslations.de, + ...SCThingInPlaceMeta.getInstance().fieldValueTranslations.de, dates: 'Einzeltermine', duration: 'Dauer', frequency: 'Wiederholung', type: 'Wiederholungreihe', }, en: { - ... SCThingInPlaceMeta.getInstance().fieldValueTranslations.en, + ...SCThingInPlaceMeta.getInstance().fieldValueTranslations.en, type: SCThingType.DateSeries, }, }; diff --git a/src/core/things/Dish.ts b/src/core/things/Dish.ts index 2c458faf..05cc2172 100644 --- a/src/core/things/Dish.ts +++ b/src/core/things/Dish.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 StApps + * Copyright (C) 2018, 2019 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -16,6 +16,7 @@ import { SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingThatCanBeOfferedTranslatableProperties, + SCThingThatCanBeOfferedWithoutReferences, } from '../base/ThingThatCanBeOffered'; import { SCThingWithCategoriesSpecificValues, @@ -29,12 +30,8 @@ import {SCMetaTranslations, SCTranslations} from '../types/i18n'; /** * A dish without references */ -export interface SCDishWithoutReferences - extends SCThingWithCategoriesWithoutReferences< - SCDishCategories, - SCThingWithCategoriesSpecificValues - >, - SCThingThatCanBeOffered { +export interface SCDishWithoutReferences extends SCThingThatCanBeOfferedWithoutReferences, + SCThingWithCategoriesWithoutReferences { /** * Additives of the dish */ @@ -71,7 +68,8 @@ export interface SCDishWithoutReferences * * @validatable */ -export interface SCDish extends SCDishWithoutReferences { +export interface SCDish extends SCDishWithoutReferences, + SCThingThatCanBeOffered { /** * Dishes ("Beilagen") that are served with the dish (if only certain supplement dishes can be taken with a dish) */ @@ -173,22 +171,22 @@ export class SCDishMeta extends SCThingMeta implements SCMetaTranslations().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, }, en: { - ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, }, }; /** * Translations of values of fields */ - fieldValueTranslations = { + fieldValueTranslations = { de: { - ... SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, categories: { appetizer: 'Vorspeise', dessert: 'Nachtisch', @@ -200,8 +198,8 @@ export class SCDishMeta extends SCThingMeta implements SCMetaTranslations().fieldValueTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, type: SCThingType.Dish, }, };