OpenSlides/client/src/app/site/base/slide-options.ts
2019-02-15 12:21:23 +01:00

37 lines
1.0 KiB
TypeScript

interface BaseSlideOption {
key: string;
displayName: string;
}
export interface SlideDecisionOption extends BaseSlideOption {
default: boolean;
}
export interface SlideChoiceOption extends BaseSlideOption {
default: string;
choices: { value: string; displayName: string }[];
}
export type SlideOption = SlideDecisionOption | SlideChoiceOption;
export type SlideOptions = SlideOption[];
export function isSlideDecisionOption(object: any): object is SlideDecisionOption {
const option = <SlideDecisionOption>object;
return (
option.key !== undefined &&
option.displayName !== undefined &&
option.default !== undefined &&
(<SlideChoiceOption>object).choices === undefined
);
}
export function isSlideChoiceOption(object: any): object is SlideChoiceOption {
const option = <SlideChoiceOption>object;
return (
option.key !== undefined &&
option.displayName !== undefined &&
option.default !== undefined &&
option.choices !== undefined
);
}