mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 16:13:06 +00:00
192
src/things/room.ts
Normal file
192
src/things/room.ts
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (C) 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCMap} from '../general/map';
|
||||
import {SCPlace, SCPlaceWithoutReferences, SCPlaceWithoutReferencesMeta} from './abstract/place';
|
||||
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {SCThingInPlace, SCThingInPlaceMeta} from './abstract/thing-in-place';
|
||||
import {
|
||||
SCThingThatAcceptsPayments,
|
||||
SCThingThatAcceptsPaymentsWithoutReferences,
|
||||
SCThingThatAcceptsPaymentsWithoutReferencesMeta,
|
||||
} from './abstract/thing-that-accepts-payments';
|
||||
import {
|
||||
SCThingWithCategories,
|
||||
SCThingWithCategoriesSpecificValues,
|
||||
SCThingWithCategoriesTranslatableProperties,
|
||||
SCThingWithCategoriesWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferencesMeta,
|
||||
} from './abstract/thing-with-categories';
|
||||
|
||||
/**
|
||||
* Categories of a room
|
||||
*/
|
||||
export type SCRoomCategories =
|
||||
'cafe'
|
||||
| 'canteen'
|
||||
| 'computer'
|
||||
| 'education'
|
||||
| 'laboratory'
|
||||
| 'learn'
|
||||
| 'library'
|
||||
| 'lounge'
|
||||
| 'office'
|
||||
| 'restaurant'
|
||||
| 'restroom'
|
||||
| 'student canteen'
|
||||
| 'student union';
|
||||
|
||||
/**
|
||||
* A room without references
|
||||
*/
|
||||
export interface SCRoomWithoutReferences
|
||||
extends SCPlaceWithoutReferences, SCThingThatAcceptsPaymentsWithoutReferences,
|
||||
SCThingWithCategoriesWithoutReferences<SCRoomCategories, SCRoomSpecificValues> {
|
||||
/**
|
||||
* The name of the floor in which the room is in.
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
floorName?: string;
|
||||
|
||||
/**
|
||||
* The inventory of the place/room as a list of items and their quantity.
|
||||
*/
|
||||
inventory?: SCMap<number>;
|
||||
|
||||
/**
|
||||
* Translations of specific values of the object
|
||||
*
|
||||
* Take precedence over "main" value for selected languages.
|
||||
*/
|
||||
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the room
|
||||
*/
|
||||
type: SCThingType.Room;
|
||||
}
|
||||
|
||||
/**
|
||||
* A room
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCRoom
|
||||
extends SCRoomWithoutReferences, SCThingInPlace, SCThingThatAcceptsPayments, SCPlace,
|
||||
SCThingWithCategories<SCRoomCategories, SCRoomSpecificValues> {
|
||||
/**
|
||||
* Translations of specific values of the object
|
||||
*
|
||||
* Take precedence over "main" value for selected languages.
|
||||
*/
|
||||
translations?: SCTranslations<SCThingWithCategoriesTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of the room
|
||||
*/
|
||||
type: SCThingType.Room;
|
||||
}
|
||||
|
||||
/**
|
||||
* Category specific values of a room
|
||||
*/
|
||||
export interface SCRoomSpecificValues
|
||||
extends SCThingWithCategoriesSpecificValues {
|
||||
/**
|
||||
* Category specific opening hours of the room
|
||||
*
|
||||
* @keyword
|
||||
*/
|
||||
openingHours?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about a place
|
||||
*/
|
||||
export class SCRoomMeta
|
||||
extends SCThingMeta
|
||||
implements SCMetaTranslations<SCRoom> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldTranslations.de,
|
||||
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<SCThingThatAcceptsPaymentsWithoutReferencesMeta>()
|
||||
.fieldTranslations.de,
|
||||
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
|
||||
SCRoomSpecificValues>().fieldTranslations.de,
|
||||
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
|
||||
.de,
|
||||
floorName: 'Etagenbezeichnung',
|
||||
inventory: 'Bestand',
|
||||
},
|
||||
en: {
|
||||
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldTranslations.en,
|
||||
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<SCThingThatAcceptsPaymentsWithoutReferencesMeta>()
|
||||
.fieldTranslations.en,
|
||||
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
|
||||
SCRoomSpecificValues>().fieldTranslations.en,
|
||||
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>().fieldTranslations
|
||||
.en,
|
||||
floorName: 'floor name',
|
||||
inventory: 'inventory',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldValueTranslations.de,
|
||||
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<SCThingThatAcceptsPaymentsWithoutReferencesMeta>()
|
||||
.fieldValueTranslations.de,
|
||||
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
|
||||
SCRoomSpecificValues>().fieldValueTranslations.de,
|
||||
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
|
||||
.fieldValueTranslations.de,
|
||||
categories: {
|
||||
'cafe': 'Café',
|
||||
'canteen': 'Kantine',
|
||||
'computer': 'PC-Pool',
|
||||
'education': 'Bildung',
|
||||
'laboratory': 'Labor',
|
||||
'learn': 'Lernen',
|
||||
'library': 'Bibliothek',
|
||||
'lounge': 'Lounge',
|
||||
'office': 'Büro',
|
||||
'restaurant': 'Restaurant',
|
||||
'restroom': 'Toilette',
|
||||
'student canteen': 'Mensa',
|
||||
'student union': 'Studentenvereinigung',
|
||||
},
|
||||
type: 'Raum',
|
||||
},
|
||||
en: {
|
||||
...SCPlaceWithoutReferencesMeta.getInstance<SCPlaceWithoutReferencesMeta>().fieldValueTranslations.en,
|
||||
...SCThingThatAcceptsPaymentsWithoutReferencesMeta.getInstance<SCThingThatAcceptsPaymentsWithoutReferencesMeta>()
|
||||
.fieldValueTranslations.en,
|
||||
...SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCRoomCategories,
|
||||
SCRoomSpecificValues>().fieldValueTranslations.en,
|
||||
...SCThingInPlaceMeta.getInstance<SCThingInPlaceMeta>()
|
||||
.fieldValueTranslations.en,
|
||||
type: SCThingType.Room,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user