refactor: every indexable thing can be a favorite

This commit is contained in:
Jovan Krunić
2021-07-27 11:11:45 +02:00
committed by Rainer Killinger
parent 2cf1027796
commit 4ab8770fbc
7 changed files with 72 additions and 47 deletions

View File

@@ -72,7 +72,7 @@ export const SCClasses: { [K in SCThingType]: object } = {
'video': SCVideoMeta,
};
export type SCThingsWithoutDiff =
export type SCIndexableThings =
SCAcademicEvent
| SCArticle
| SCBook
@@ -82,7 +82,6 @@ export type SCThingsWithoutDiff =
| SCCourseOfStudies
| SCDateSeries
| SCDish
| SCFavorite
| SCFloor
| SCMessage
| SCOrganization
@@ -90,7 +89,6 @@ export type SCThingsWithoutDiff =
| SCPointOfInterest
| SCRoom
| SCSemester
| SCSetting
| SCSportCourse
| SCStudyModule
| SCTicket
@@ -102,8 +100,8 @@ export type SCThingsWithoutDiff =
* An object that exists in the StAppsCore
*/
export type SCThings =
SCThingsWithoutDiff
| SCDiff;
SCIndexableThings
| SCDiff | SCFavorite | SCSetting;
/**
* A field of a thing

View File

@@ -12,6 +12,7 @@
* 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 {SCIndexableThings} from '../../meta';
import {SCThing, SCThingUserOrigin, SCThingWithoutReferences} from './thing';
/**
@@ -19,18 +20,17 @@ import {SCThing, SCThingUserOrigin, SCThingWithoutReferences} from './thing';
*/
export interface SCSaveableThingWithoutReferences
extends SCThingWithoutReferences {
// noop
}
/**
* An encapsulation of the data (e.g. a thing) that is saved, which provides additional information.
*/
export interface SCSaveableThing<T extends SCThingWithoutReferences>
export interface SCSaveableThing
extends SCSaveableThingWithoutReferences, SCThing {
/**
* The contained data
*/
data: T;
data: SCIndexableThings;
/**
* Type of the origin
*/

View File

@@ -15,7 +15,7 @@
import * as jsonpatch from 'json-patch';
import {SCMetaTranslations} from '../general/i18n';
import {SCISO8601Date} from '../general/time';
import {SCThingsWithoutDiff} from '../meta';
import {SCIndexableThings} from '../meta';
import {SCThing, SCThingMeta, SCThingType, SCThingWithoutReferences} from './abstract/thing';
/**
@@ -48,14 +48,13 @@ export interface SCDiffWithoutReferences
* A diff
*
* @validatable
* @indexable
*/
export interface SCDiff
extends SCDiffWithoutReferences, SCThing {
/**
* Original object the diff was generated on
*/
object: SCThingsWithoutDiff;
object: SCIndexableThings;
/**
* Type of a diff

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 StApps
* Copyright (C) 2019-2021 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.
@@ -14,45 +14,24 @@
*/
import {SCSaveableThing, SCSaveableThingWithoutReferences} from './abstract/saveable-thing';
import {SCThingMeta, SCThingType} from './abstract/thing';
import {SCAcademicEventWithoutReferences} from './academic-event';
import {SCArticleWithoutReferences} from './article';
import {SCBookWithoutReferences} from './book';
import {SCBuildingWithoutReferences} from './building';
import {SCPersonWithoutReferences} from './person';
import {SCPointOfInterestWithoutReferences} from './point-of-interest';
import {SCRoomWithoutReferences} from './room';
import {SCSportCourseWithoutReferences} from './sport-course';
import {SCToDoWithoutReferences} from './todo';
/**
* Types that can be made a favorite (added as a favorite)
*/
export type SCFavoriteDataTypes = SCAcademicEventWithoutReferences
| SCArticleWithoutReferences
| SCBookWithoutReferences
| SCBuildingWithoutReferences
| SCPersonWithoutReferences
| SCPointOfInterestWithoutReferences
| SCRoomWithoutReferences
| SCSportCourseWithoutReferences
| SCToDoWithoutReferences;
/**
* A favorite without references
*/
export interface SCFavoriteWithoutReferences
extends SCSaveableThingWithoutReferences {
// noop
/**
* Type of a favorite
*/
type: SCThingType.Favorite;
}
/**
* A favorite
*
* @validatable
* @indexable
*/
export interface SCFavorite
extends SCSaveableThing<SCFavoriteDataTypes>, SCFavoriteWithoutReferences {
export interface SCFavorite extends SCSaveableThing {
/**
* Type of a favorite
*/

View File

@@ -84,7 +84,6 @@ export enum SCSettingInputType {
* A setting with references
*
* @validatable
* @indexable
*/
export interface SCSetting
extends SCSettingWithoutReferences, SCThing,