2019-02-01 13:56:08 +01:00
|
|
|
import { AgendaInformation } from 'app/site/base/agenda-information';
|
|
|
|
import { BaseProjectableViewModel } from './base-projectable-view-model';
|
2019-01-19 21:55:06 +01:00
|
|
|
import { SearchRepresentation } from 'app/core/ui-services/search.service';
|
2019-02-01 13:56:08 +01:00
|
|
|
import { ViewItem } from '../agenda/models/view-item';
|
2018-09-13 09:23:57 +02:00
|
|
|
|
2019-02-08 16:02:46 +01:00
|
|
|
export function isAgendaBaseModel(obj: object): obj is BaseAgendaViewModel {
|
|
|
|
const agendaViewModel = <BaseAgendaViewModel>obj;
|
|
|
|
return (
|
|
|
|
agendaViewModel.getAgendaTitle !== undefined &&
|
|
|
|
agendaViewModel.getAgendaTitleWithType !== undefined &&
|
|
|
|
agendaViewModel.getCSVExportText !== undefined &&
|
|
|
|
agendaViewModel.getAgendaItem !== undefined &&
|
|
|
|
agendaViewModel.getDetailStateURL !== undefined
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-09-13 09:23:57 +02:00
|
|
|
/**
|
2019-02-01 13:56:08 +01:00
|
|
|
* Base view class for projectable models.
|
2018-09-13 09:23:57 +02:00
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
export abstract class BaseAgendaViewModel extends BaseProjectableViewModel implements AgendaInformation {
|
2019-02-08 16:02:46 +01:00
|
|
|
/**
|
|
|
|
* @returns the contained agenda item
|
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
public abstract getAgendaItem(): ViewItem;
|
2018-09-13 09:23:57 +02:00
|
|
|
|
2018-11-07 08:43:48 +01:00
|
|
|
/**
|
|
|
|
* @returns the agenda title
|
|
|
|
*/
|
2019-02-08 16:02:46 +01:00
|
|
|
public getAgendaTitle = () => {
|
2018-09-13 09:23:57 +02:00
|
|
|
return this.getTitle();
|
2019-02-08 16:02:46 +01:00
|
|
|
};
|
2018-09-13 09:23:57 +02:00
|
|
|
|
2018-11-07 08:43:48 +01:00
|
|
|
/**
|
|
|
|
* @return the agenda title with the verbose name of the content object
|
|
|
|
*/
|
2019-02-08 16:02:46 +01:00
|
|
|
public getAgendaTitleWithType = () => {
|
2018-09-13 09:23:57 +02:00
|
|
|
// Return the agenda title with the model's verbose name appended
|
2018-11-07 08:43:48 +01:00
|
|
|
return this.getAgendaTitle() + ' (' + this.getVerboseName() + ')';
|
2019-02-08 16:02:46 +01:00
|
|
|
};
|
2018-09-13 09:23:57 +02:00
|
|
|
|
2018-12-11 17:20:32 +01:00
|
|
|
/**
|
|
|
|
* @returns the (optional) descriptive text to be exported in the CSV.
|
|
|
|
* May be overridden by inheriting classes
|
|
|
|
*/
|
|
|
|
public getCSVExportText(): string {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public abstract getDetailStateURL(): string;
|
|
|
|
|
2018-11-07 08:43:48 +01:00
|
|
|
/**
|
|
|
|
* Should return a string representation of the object, so there can be searched for.
|
|
|
|
*/
|
|
|
|
public abstract formatForSearch(): SearchRepresentation;
|
2018-09-13 09:23:57 +02:00
|
|
|
}
|