2018-09-13 09:23:57 +02:00
|
|
|
import { BaseModel } from '../../../shared/models/base/base-model';
|
2019-01-10 15:06:10 +01:00
|
|
|
import { BaseProjectableModel } from 'app/site/base/base-projectable-model';
|
2019-01-17 10:53:16 +01:00
|
|
|
import { Category } from '../../../shared/models/motions/category';
|
2019-01-10 15:06:10 +01:00
|
|
|
import { MotionComment } from '../../../shared/models/motions/motion-comment';
|
2018-11-12 15:24:23 +01:00
|
|
|
import { Item } from 'app/shared/models/agenda/item';
|
2018-12-10 17:54:48 +01:00
|
|
|
import { Mediafile } from 'app/shared/models/mediafiles/mediafile';
|
2019-01-17 10:53:16 +01:00
|
|
|
import { Motion } from '../../../shared/models/motions/motion';
|
|
|
|
import { MotionBlock } from 'app/shared/models/motions/motion-block';
|
|
|
|
import { PersonalNoteContent } from 'app/shared/models/users/personal-note';
|
|
|
|
import { User } from '../../../shared/models/users/user';
|
|
|
|
import { ViewMotionCommentSection } from './view-motion-comment-section';
|
|
|
|
import { Workflow } from '../../../shared/models/motions/workflow';
|
|
|
|
import { WorkflowState } from '../../../shared/models/motions/workflow-state';
|
2019-01-10 15:06:10 +01:00
|
|
|
import { ProjectorOptions } from 'app/site/base/projector-options';
|
2018-09-28 15:10:48 +02:00
|
|
|
|
2018-12-22 19:23:13 +01:00
|
|
|
/**
|
|
|
|
* The line numbering mode for the motion detail view.
|
|
|
|
* The constants need to be in sync with the values saved in the config store.
|
|
|
|
*/
|
2018-09-30 18:43:20 +02:00
|
|
|
export enum LineNumberingMode {
|
2018-12-22 19:23:13 +01:00
|
|
|
None = 'none',
|
|
|
|
Inside = 'inline',
|
|
|
|
Outside = 'outside'
|
2018-09-28 15:10:48 +02:00
|
|
|
}
|
|
|
|
|
2018-12-22 19:23:13 +01:00
|
|
|
/**
|
|
|
|
* The change recommendation mode for the motion detail view.
|
|
|
|
*/
|
2018-09-30 18:43:20 +02:00
|
|
|
export enum ChangeRecoMode {
|
2018-12-22 19:23:13 +01:00
|
|
|
Original = 'original',
|
|
|
|
Changed = 'changed',
|
|
|
|
Diff = 'diff',
|
|
|
|
Final = 'agreed'
|
2018-09-28 15:10:48 +02:00
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
/**
|
|
|
|
* Motion class for the View
|
|
|
|
*
|
|
|
|
* Stores a motion including all (implicit) references
|
|
|
|
* Provides "safe" access to variables and functions in {@link Motion}
|
|
|
|
* @ignore
|
|
|
|
*/
|
2019-01-10 15:06:10 +01:00
|
|
|
export class ViewMotion extends BaseProjectableModel {
|
2018-11-30 09:24:07 +01:00
|
|
|
protected _motion: Motion;
|
|
|
|
protected _category: Category;
|
|
|
|
protected _submitters: User[];
|
|
|
|
protected _supporters: User[];
|
|
|
|
protected _workflow: Workflow;
|
|
|
|
protected _state: WorkflowState;
|
|
|
|
protected _item: Item;
|
|
|
|
protected _block: MotionBlock;
|
2018-12-10 17:54:48 +01:00
|
|
|
protected _attachments: Mediafile[];
|
2019-01-17 10:53:16 +01:00
|
|
|
public personalNote: PersonalNoteContent;
|
2018-09-04 14:55:07 +02:00
|
|
|
|
2018-11-22 15:14:01 +01:00
|
|
|
/**
|
|
|
|
* Is set by the repository; this is the order of the flat call list given by
|
|
|
|
* the properties weight and sort_parent_id
|
|
|
|
*/
|
|
|
|
public callListWeight: number;
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public get motion(): Motion {
|
|
|
|
return this._motion;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get id(): number {
|
2018-09-11 16:38:23 +02:00
|
|
|
return this.motion ? this.motion.id : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get identifier(): string {
|
2018-12-10 17:54:48 +01:00
|
|
|
return this.motion && this.motion.identifier ? this.motion.identifier : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get title(): string {
|
2018-09-11 16:38:23 +02:00
|
|
|
return this.motion ? this.motion.title : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-11-23 13:42:44 +01:00
|
|
|
public get identifierOrTitle(): string {
|
|
|
|
if (!this.motion) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return this.identifier ? this.identifier : this.title;
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public get text(): string {
|
2018-09-11 16:38:23 +02:00
|
|
|
return this.motion ? this.motion.text : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get reason(): string {
|
2018-09-11 16:38:23 +02:00
|
|
|
return this.motion ? this.motion.reason : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-11-08 17:38:44 +01:00
|
|
|
public get weight(): number {
|
|
|
|
return this.motion ? this.motion.weight : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get sort_parent_id(): number {
|
|
|
|
return this.motion ? this.motion.sort_parent_id : null;
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public get category(): Category {
|
|
|
|
return this._category;
|
|
|
|
}
|
|
|
|
|
2018-10-23 14:20:29 +02:00
|
|
|
public get agenda_item_id(): number {
|
|
|
|
return this.motion ? this.motion.agenda_item_id : null;
|
|
|
|
}
|
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
public get category_id(): number {
|
2018-09-11 16:38:23 +02:00
|
|
|
return this.motion && this.category ? this.motion.category_id : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get submitters(): User[] {
|
|
|
|
return this._submitters;
|
|
|
|
}
|
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
public get submitters_id(): number[] {
|
2018-11-30 09:24:07 +01:00
|
|
|
return this.motion ? this.motion.submitterIds : null;
|
2018-09-20 12:25:37 +02:00
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public get supporters(): User[] {
|
|
|
|
return this._supporters;
|
|
|
|
}
|
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
public get supporters_id(): number[] {
|
2018-09-20 12:25:37 +02:00
|
|
|
return this.motion ? this.motion.supporters_id : null;
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public get workflow(): Workflow {
|
|
|
|
return this._workflow;
|
|
|
|
}
|
|
|
|
|
2018-11-22 12:33:40 +01:00
|
|
|
public get workflow_id(): number {
|
|
|
|
return this.motion ? this.motion.workflow_id : null;
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public get state(): WorkflowState {
|
|
|
|
return this._state;
|
|
|
|
}
|
|
|
|
|
2019-01-10 14:41:20 +01:00
|
|
|
/**
|
|
|
|
* Checks if the current state of thw workflow is final
|
|
|
|
*
|
|
|
|
* @returns true if it is final
|
|
|
|
*/
|
|
|
|
public get isFinalState(): boolean {
|
|
|
|
return this._state.isFinalState;
|
|
|
|
}
|
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
public get state_id(): number {
|
2018-09-11 16:38:23 +02:00
|
|
|
return this.motion && this.motion.state_id ? this.motion.state_id : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
public get recommendation_id(): number {
|
2018-09-11 16:38:23 +02:00
|
|
|
return this.motion && this.motion.recommendation_id ? this.motion.recommendation_id : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-10-28 11:06:36 +01:00
|
|
|
public get statute_paragraph_id(): number {
|
|
|
|
return this.motion && this.motion.statute_paragraph_id ? this.motion.statute_paragraph_id : null;
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public get recommendation(): WorkflowState {
|
2018-10-05 16:34:08 +02:00
|
|
|
return this.recommendation_id && this.workflow ? this.workflow.getStateById(this.recommendation_id) : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-11-05 17:43:44 +01:00
|
|
|
public get possibleRecommendations(): WorkflowState[] {
|
2018-11-08 17:38:44 +01:00
|
|
|
return this.workflow
|
|
|
|
? this.workflow.states.filter(recommendation => recommendation.recommendation_label !== undefined)
|
|
|
|
: null;
|
2018-11-05 17:43:44 +01:00
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public get origin(): string {
|
2018-09-11 16:38:23 +02:00
|
|
|
return this.motion ? this.motion.origin : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get nextStates(): WorkflowState[] {
|
2018-09-11 16:38:23 +02:00
|
|
|
return this.state && this.workflow ? this.state.getNextStates(this.workflow) : null;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-09-20 12:25:37 +02:00
|
|
|
public set supporters(users: User[]) {
|
|
|
|
this._supporters = users;
|
2018-10-16 12:41:46 +02:00
|
|
|
this._motion.supporters_id = users.map(user => user.id);
|
2018-09-20 12:25:37 +02:00
|
|
|
}
|
|
|
|
|
2018-11-12 15:24:23 +01:00
|
|
|
public get item(): Item {
|
|
|
|
return this._item;
|
|
|
|
}
|
|
|
|
|
2018-12-10 17:54:48 +01:00
|
|
|
public get agenda_type(): number {
|
|
|
|
return this.item ? this.item.type : null;
|
|
|
|
}
|
|
|
|
|
2018-11-23 13:42:44 +01:00
|
|
|
public get motion_block_id(): number {
|
|
|
|
return this.motion ? this.motion.motion_block_id : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get motion_block(): MotionBlock {
|
|
|
|
return this._block;
|
|
|
|
}
|
|
|
|
|
2018-11-12 15:24:23 +01:00
|
|
|
public get agendaSpeakerAmount(): number {
|
2018-11-22 15:14:01 +01:00
|
|
|
return this.item ? this.item.speakerAmount : null;
|
2018-11-12 15:24:23 +01:00
|
|
|
}
|
|
|
|
|
2018-11-04 11:11:48 +01:00
|
|
|
public get parent_id(): number {
|
|
|
|
return this.motion && this.motion.parent_id ? this.motion.parent_id : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get amendment_paragraphs(): string[] {
|
|
|
|
return this.motion && this.motion.amendment_paragraphs ? this.motion.amendment_paragraphs : [];
|
|
|
|
}
|
|
|
|
|
2018-11-27 22:44:37 +01:00
|
|
|
public get tags_id(): number[] {
|
2018-12-10 17:54:48 +01:00
|
|
|
return this.motion ? this.motion.tags_id : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get attachments_id(): number[] {
|
2019-01-10 12:54:48 +01:00
|
|
|
return this.motion ? this.motion.attachments_id : null;
|
2018-12-10 17:54:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public get attachments(): Mediafile[] {
|
|
|
|
return this._attachments ? this._attachments : null;
|
2018-11-27 22:44:37 +01:00
|
|
|
}
|
|
|
|
|
2019-01-19 17:06:23 +01:00
|
|
|
/**
|
|
|
|
* @returns the creation date as Date object
|
|
|
|
*/
|
|
|
|
public get creationDate(): Date {
|
|
|
|
if (!this.motion || !this.motion.created) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return new Date(this.motion.created);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns the date of the last change as Date object, null if empty
|
|
|
|
*/
|
|
|
|
public get lastChangeDate(): Date {
|
|
|
|
if (!this.motion || !this.motion.last_modified) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return new Date(this.motion.last_modified);
|
|
|
|
}
|
|
|
|
|
2019-01-21 16:34:19 +01:00
|
|
|
/**
|
|
|
|
* @returns the current state extension if the workwlof allows for extenstion fields
|
|
|
|
*/
|
|
|
|
public get stateExtension(): string {
|
|
|
|
if (this.state && this.state.show_state_extension_field) {
|
|
|
|
return this.motion.state_extension;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns the current recommendation extension if the workwlof allows for extenstion fields
|
|
|
|
*/
|
|
|
|
public get recommendationExtension(): string {
|
|
|
|
if (this.recommendation && this.recommendation.show_recommendation_extension_field) {
|
|
|
|
return this.motion.recommendation_extension;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-10 14:41:20 +01:00
|
|
|
/**
|
|
|
|
* Gets the comments' section ids of a motion. Used in filter by motionComment
|
|
|
|
*
|
|
|
|
* @returns an array of ids, or an empty array
|
|
|
|
*/
|
|
|
|
public get commentSectionIds(): number[] {
|
|
|
|
if (!this.motion) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
return this.motion.comments.map(comment => comment.section_id);
|
|
|
|
}
|
|
|
|
|
2019-01-17 10:53:16 +01:00
|
|
|
/**
|
|
|
|
* Getter to query the 'favorite'/'star' status of the motions
|
|
|
|
*
|
|
|
|
* @returns the current state
|
|
|
|
*/
|
|
|
|
public get star(): boolean {
|
|
|
|
return this.personalNote && this.personalNote.star ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Queries if any personal comments are rpesent
|
|
|
|
*
|
|
|
|
* @returns true if personalContent is present and has notes
|
|
|
|
*/
|
|
|
|
public get hasNotes(): boolean {
|
|
|
|
return this.personalNote && this.personalNote.note ? true : false;
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public constructor(
|
|
|
|
motion?: Motion,
|
|
|
|
category?: Category,
|
|
|
|
submitters?: User[],
|
|
|
|
supporters?: User[],
|
|
|
|
workflow?: Workflow,
|
2018-11-12 15:24:23 +01:00
|
|
|
state?: WorkflowState,
|
2018-11-23 13:42:44 +01:00
|
|
|
item?: Item,
|
2018-12-10 17:54:48 +01:00
|
|
|
block?: MotionBlock,
|
2019-01-17 17:13:34 +01:00
|
|
|
attachments?: Mediafile[]
|
2018-09-04 14:55:07 +02:00
|
|
|
) {
|
2018-09-10 15:53:11 +02:00
|
|
|
super();
|
2018-09-04 14:55:07 +02:00
|
|
|
this._motion = motion;
|
|
|
|
this._category = category;
|
|
|
|
this._submitters = submitters;
|
|
|
|
this._supporters = supporters;
|
|
|
|
this._workflow = workflow;
|
|
|
|
this._state = state;
|
2018-11-12 15:24:23 +01:00
|
|
|
this._item = item;
|
2018-11-23 13:42:44 +01:00
|
|
|
this._block = block;
|
2018-12-10 17:54:48 +01:00
|
|
|
this._attachments = attachments;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-10-12 11:05:24 +02:00
|
|
|
public getTitle(): string {
|
2018-11-08 17:38:44 +01:00
|
|
|
if (this.identifier) {
|
|
|
|
return this.identifier + ' - ' + this.title;
|
2018-10-15 11:52:57 +02:00
|
|
|
}
|
2018-09-10 15:53:11 +02:00
|
|
|
return this.title;
|
|
|
|
}
|
|
|
|
|
2018-10-16 12:41:46 +02:00
|
|
|
/**
|
|
|
|
* Returns the motion comment for the given section. Null, if no comment exist.
|
2018-12-10 17:54:48 +01:00
|
|
|
*
|
2018-10-16 12:41:46 +02:00
|
|
|
* @param section The section to search the comment for.
|
|
|
|
*/
|
|
|
|
public getCommentForSection(section: ViewMotionCommentSection): MotionComment {
|
|
|
|
if (!this.motion) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return this.motion.comments.find(comment => comment.section_id === section.id);
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
/**
|
|
|
|
* Updates the local objects if required
|
2018-12-10 17:54:48 +01:00
|
|
|
*
|
2018-09-04 14:55:07 +02:00
|
|
|
* @param update
|
|
|
|
*/
|
|
|
|
public updateValues(update: BaseModel): void {
|
|
|
|
if (update instanceof Workflow) {
|
2018-09-20 12:25:37 +02:00
|
|
|
this.updateWorkflow(update as Workflow);
|
2018-09-04 14:55:07 +02:00
|
|
|
} else if (update instanceof Category) {
|
2018-09-20 12:25:37 +02:00
|
|
|
this.updateCategory(update as Category);
|
2018-11-12 15:24:23 +01:00
|
|
|
} else if (update instanceof Item) {
|
|
|
|
this.updateItem(update as Item);
|
2018-11-23 13:42:44 +01:00
|
|
|
} else if (update instanceof MotionBlock) {
|
|
|
|
this.updateMotionBlock(update);
|
2018-11-23 13:59:14 +01:00
|
|
|
} else if (update instanceof User) {
|
|
|
|
this.updateUser(update as User);
|
2018-12-10 17:54:48 +01:00
|
|
|
} else if (update instanceof Mediafile) {
|
|
|
|
this.updateAttachments(update as Mediafile);
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-20 12:25:37 +02:00
|
|
|
/**
|
2018-11-12 15:24:23 +01:00
|
|
|
* Update routine for the category
|
2018-12-10 17:54:48 +01:00
|
|
|
*
|
2018-11-23 13:42:44 +01:00
|
|
|
* @param category potentially the changed category. Needs manual verification
|
2018-09-20 12:25:37 +02:00
|
|
|
*/
|
2018-11-23 13:42:44 +01:00
|
|
|
public updateCategory(category: Category): void {
|
|
|
|
if (this.motion && category.id === this.motion.category_id) {
|
|
|
|
this._category = category;
|
2018-09-20 12:25:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-11-12 15:24:23 +01:00
|
|
|
* Update routine for the workflow
|
2018-12-10 17:54:48 +01:00
|
|
|
*
|
2018-11-23 13:42:44 +01:00
|
|
|
* @param workflow potentially the changed workflow (state). Needs manual verification
|
2018-09-20 12:25:37 +02:00
|
|
|
*/
|
2018-11-23 13:42:44 +01:00
|
|
|
public updateWorkflow(workflow: Workflow): void {
|
|
|
|
if (this.motion && workflow.id === this.motion.workflow_id) {
|
|
|
|
this._workflow = workflow;
|
2018-09-20 12:25:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-12 15:24:23 +01:00
|
|
|
/**
|
|
|
|
* Update routine for the agenda Item
|
2018-12-10 17:54:48 +01:00
|
|
|
*
|
2018-11-23 13:42:44 +01:00
|
|
|
* @param item potentially the changed agenda Item. Needs manual verification
|
|
|
|
*/
|
|
|
|
public updateItem(item: Item): void {
|
|
|
|
if (this.motion && item.id === this.motion.agenda_item_id) {
|
|
|
|
this._item = item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update routine for the motion block
|
2018-12-10 17:54:48 +01:00
|
|
|
*
|
2018-11-23 13:42:44 +01:00
|
|
|
* @param block potentially the changed motion block. Needs manual verification
|
2018-11-12 15:24:23 +01:00
|
|
|
*/
|
2018-11-23 13:42:44 +01:00
|
|
|
public updateMotionBlock(block: MotionBlock): void {
|
|
|
|
if (this.motion && block.id === this.motion.motion_block_id) {
|
|
|
|
this._block = block;
|
2018-11-12 15:24:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-23 13:59:14 +01:00
|
|
|
/**
|
2018-12-10 17:54:48 +01:00
|
|
|
* Update routine for supporters and submitters
|
|
|
|
*
|
2018-11-23 13:59:14 +01:00
|
|
|
* @param update potentially the changed agenda Item. Needs manual verification
|
|
|
|
*/
|
|
|
|
public updateUser(update: User): void {
|
|
|
|
if (this.motion) {
|
|
|
|
if (this.motion.submitters && this.motion.submitters.findIndex(user => user.user_id === update.id)) {
|
|
|
|
const userIndex = this.submitters.findIndex(user => user.id === update.id);
|
|
|
|
this.submitters[userIndex] = update as User;
|
|
|
|
}
|
|
|
|
if (this.motion.supporters_id && this.motion.supporters_id.includes(update.id)) {
|
|
|
|
const userIndex = this.supporters.findIndex(user => user.id === update.id);
|
|
|
|
this.supporters[userIndex] = update as User;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-10 17:54:48 +01:00
|
|
|
/**
|
|
|
|
* Update routine for attachments
|
|
|
|
*
|
|
|
|
* @param update
|
|
|
|
*/
|
|
|
|
public updateAttachments(update: Mediafile): void {
|
|
|
|
if (this.motion) {
|
|
|
|
if (this.attachments_id && this.attachments_id.includes(update.id)) {
|
|
|
|
const attachmentIndex = this.attachments.findIndex(mediafile => mediafile.id === update.id);
|
|
|
|
this.attachments[attachmentIndex] = update as Mediafile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public hasSupporters(): boolean {
|
|
|
|
return !!(this.supporters && this.supporters.length > 0);
|
|
|
|
}
|
|
|
|
|
2018-12-10 17:54:48 +01:00
|
|
|
public hasAttachments(): boolean {
|
|
|
|
return !!(this.attachments && this.attachments.length > 0);
|
|
|
|
}
|
|
|
|
|
2018-10-28 11:06:36 +01:00
|
|
|
public isStatuteAmendment(): boolean {
|
|
|
|
return !!this.statute_paragraph_id;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:28:05 +01:00
|
|
|
/**
|
|
|
|
* Determine if the motion is in its final workflow state
|
|
|
|
*/
|
|
|
|
public isInFinalState(): boolean {
|
|
|
|
return this.nextStates.length === 0;
|
|
|
|
}
|
|
|
|
|
2018-11-04 11:11:48 +01:00
|
|
|
/**
|
|
|
|
* It's a paragraph-based amendments if only one paragraph is to be changed,
|
|
|
|
* specified by amendment_paragraphs-array
|
|
|
|
*/
|
|
|
|
public isParagraphBasedAmendment(): boolean {
|
|
|
|
return this.amendment_paragraphs.length > 0;
|
|
|
|
}
|
|
|
|
|
2019-01-10 15:06:10 +01:00
|
|
|
public getProjectorOptions(): ProjectorOptions {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
key: 'mode',
|
|
|
|
displayName: 'Mode',
|
|
|
|
default: 'original',
|
|
|
|
choices: [
|
|
|
|
{ value: 'original', displayName: 'Original' },
|
|
|
|
{ value: 'changed', displayName: 'Changed' },
|
|
|
|
{ value: 'diff', displayName: 'Diff' },
|
|
|
|
{ value: 'agreed', displayName: 'Agreed' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public getProjectionDefaultName(): string {
|
|
|
|
return 'motions';
|
|
|
|
}
|
|
|
|
|
|
|
|
public getNameForSlide(): string {
|
|
|
|
return Motion.COLLECTIONSTRING;
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
/**
|
|
|
|
* Duplicate this motion into a copy of itself
|
|
|
|
*/
|
|
|
|
public copy(): ViewMotion {
|
|
|
|
return new ViewMotion(
|
|
|
|
this._motion,
|
|
|
|
this._category,
|
|
|
|
this._submitters,
|
|
|
|
this._supporters,
|
|
|
|
this._workflow,
|
2018-12-10 17:54:48 +01:00
|
|
|
this._state,
|
|
|
|
this._item,
|
|
|
|
this._block,
|
2019-01-17 17:13:34 +01:00
|
|
|
this._attachments
|
2018-09-04 14:55:07 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|