2018-12-06 12:28:05 +01:00
|
|
|
import { MotionBlock } from 'app/shared/models/motions/motion-block';
|
2019-02-01 13:56:08 +01:00
|
|
|
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
|
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
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;
|
2019-02-01 13:56:08 +01:00
|
|
|
private _agendaItem: ViewItem;
|
2018-12-06 12:28:05 +01:00
|
|
|
|
|
|
|
public get motionBlock(): MotionBlock {
|
|
|
|
return this._motionBlock;
|
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public get agendaItem(): ViewItem {
|
|
|
|
return this._agendaItem;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:28:05 +01:00
|
|
|
public get id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motionBlock.id;
|
2018-12-06 12:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public get title(): string {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motionBlock.title;
|
2018-12-06 12:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public get agenda_item_id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
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;
|
2019-02-15 12:17:08 +01:00
|
|
|
public getAgendaTitle;
|
|
|
|
public getAgendaTitleWithType;
|
2019-02-08 16:02:46 +01:00
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
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;
|
2019-02-01 13:56:08 +01:00
|
|
|
this._agendaItem = agendaItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Formats the category for search
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
public formatForSearch(): SearchRepresentation {
|
|
|
|
return [this.title];
|
2018-12-06 12:28:05 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +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
|
|
|
};
|
2019-02-01 13:56:08 +01:00
|
|
|
|
|
|
|
public getSlide(): ProjectorElementBuildDeskriptor {
|
|
|
|
throw new Error('todo');
|
|
|
|
}
|
2018-12-06 12:28:05 +01:00
|
|
|
}
|