OpenSlides/client/src/app/site/base/base-view-model-with-list-of-speakers.ts

59 lines
2.0 KiB
TypeScript
Raw Normal View History

import { BaseModelWithListOfSpeakers } from 'app/shared/models/base/base-model-with-list-of-speakers';
import { DetailNavigable, isDetailNavigable } from 'app/shared/models/base/detail-navigable';
import { BaseProjectableViewModel } from './base-projectable-view-model';
export function isBaseViewModelWithListOfSpeakers(obj: any): obj is BaseViewModelWithListOfSpeakers {
const model = <BaseViewModelWithListOfSpeakers>obj;
return (
!!obj &&
isDetailNavigable(model) &&
model.getListOfSpeakersTitle !== undefined &&
model.listOfSpeakers !== undefined &&
model.list_of_speakers_id !== undefined
);
}
/**
* Describes a base view model with a list of speakers.
*/
export interface IBaseViewModelWithListOfSpeakers<M extends BaseModelWithListOfSpeakers = any>
extends BaseProjectableViewModel<M>,
DetailNavigable {
listOfSpeakers: any | null;
list_of_speakers_id: number;
getListOfSpeakersTitle: () => string;
getListOfSpeakersSlideTitle: () => string;
}
/**
* Base view model class for models with a list of speakers.
*
* TODO: Resolve circular dependencies with `ViewListOfSpeakers` to avoid `any`.
*/
export abstract class BaseViewModelWithListOfSpeakers<M extends BaseModelWithListOfSpeakers = any>
extends BaseProjectableViewModel<M>
implements IBaseViewModelWithListOfSpeakers<M> {
2019-07-17 16:13:49 +02:00
protected _list_of_speakers?: any;
public get listOfSpeakers(): any | null {
2019-07-17 16:13:49 +02:00
return this._list_of_speakers;
}
public get list_of_speakers_id(): number {
return this._model.list_of_speakers_id;
}
public getListOfSpeakersTitle: () => string;
public getListOfSpeakersSlideTitle: () => string;
public constructor(collectionString: string, model: M, listOfSpeakers?: any) {
super(collectionString, model);
2019-07-17 16:13:49 +02:00
this._list_of_speakers = listOfSpeakers || null; // Explicit set to null instead of undefined, if not given
}
public abstract getDetailStateURL(): string;
}