OpenSlides/client/src/app/site/motions/models/view-motion-block.ts

86 lines
2.2 KiB
TypeScript
Raw Normal View History

2018-12-06 12:28:05 +01:00
import { MotionBlock } from 'app/shared/models/motions/motion-block';
import { BaseAgendaViewModel } from 'app/site/base/base-agenda-view-model';
import { SearchRepresentation } from 'app/core/ui-services/search.service';
import { ProjectorElementBuildDeskriptor } from 'app/site/base/projectable';
import { Searchable } from 'app/site/base/searchable';
import { ViewItem } from 'app/site/agenda/models/view-item';
import { BaseViewModel } from 'app/site/base/base-view-model';
2018-12-06 12:28:05 +01:00
/**
* ViewModel for motion blocks.
* @ignore
*/
export class ViewMotionBlock extends BaseAgendaViewModel implements Searchable {
2019-02-12 09:25:56 +01:00
public static COLLECTIONSTRING = MotionBlock.COLLECTIONSTRING;
2018-12-06 12:28:05 +01:00
private _motionBlock: MotionBlock;
private _agendaItem: ViewItem;
2018-12-06 12:28:05 +01:00
public get motionBlock(): MotionBlock {
return this._motionBlock;
}
public get agendaItem(): ViewItem {
return this._agendaItem;
}
2018-12-06 12:28:05 +01:00
public get id(): number {
return this.motionBlock.id;
2018-12-06 12:28:05 +01:00
}
public get title(): string {
return this.motionBlock.title;
2018-12-06 12:28:05 +01:00
}
public get agenda_item_id(): number {
return this.motionBlock.agenda_item_id;
2018-12-06 12:28:05 +01:00
}
2019-02-08 16:02:46 +01:00
/**
* This is set by the repository
*/
public getVerboseName;
public constructor(motionBlock: MotionBlock, agendaItem?: ViewItem) {
2019-02-08 16:02:46 +01:00
super(MotionBlock.COLLECTIONSTRING);
2018-12-06 12:28:05 +01:00
this._motionBlock = motionBlock;
this._agendaItem = agendaItem;
}
/**
* Formats the category for search
*
* @override
*/
public formatForSearch(): SearchRepresentation {
return [this.title];
2018-12-06 12:28:05 +01:00
}
public getAgendaItem(): ViewItem {
return this.agendaItem;
}
/**
* Get the URL to the motion block
*
* @returns the URL as string
*/
public getDetailStateURL(): string {
return `/motions/blocks/${this.id}`;
}
public updateDependencies(update: BaseViewModel): void {
if (update instanceof ViewItem && this.agenda_item_id === update.id) {
this._agendaItem = update;
}
2018-12-06 12:28:05 +01:00
}
2019-02-08 16:02:46 +01:00
public getTitle = () => {
2019-01-10 12:54:48 +01:00
return this.title;
2019-02-08 16:02:46 +01:00
};
public getSlide(): ProjectorElementBuildDeskriptor {
throw new Error('todo');
}
2018-12-06 12:28:05 +01:00
}