2019-01-19 21:55:06 +01:00
|
|
|
import { MotionComment } from 'app/shared/models/motions/motion-comment';
|
|
|
|
import { Motion } from 'app/shared/models/motions/motion';
|
2019-01-17 10:53:16 +01:00
|
|
|
import { PersonalNoteContent } from 'app/shared/models/users/personal-note';
|
|
|
|
import { ViewMotionCommentSection } from './view-motion-comment-section';
|
2019-01-19 21:55:06 +01:00
|
|
|
import { WorkflowState } from 'app/shared/models/motions/workflow-state';
|
2019-01-24 16:25:50 +01:00
|
|
|
import { ProjectorElementBuildDeskriptor } from 'app/site/base/projectable';
|
2019-02-01 13:56:08 +01:00
|
|
|
import { SearchRepresentation } from 'app/core/ui-services/search.service';
|
|
|
|
import { BaseAgendaViewModel } from 'app/site/base/base-agenda-view-model';
|
|
|
|
import { Searchable } from 'app/site/base/searchable';
|
|
|
|
import { ViewUser } from 'app/site/users/models/view-user';
|
|
|
|
import { ViewTag } from 'app/site/tags/models/view-tag';
|
|
|
|
import { ViewMediafile } from 'app/site/mediafiles/models/view-mediafile';
|
|
|
|
import { ViewItem } from 'app/site/agenda/models/view-item';
|
|
|
|
import { ViewWorkflow } from './view-workflow';
|
|
|
|
import { ViewCategory } from './view-category';
|
|
|
|
import { ViewMotionBlock } from './view-motion-block';
|
|
|
|
import { BaseViewModel } from 'app/site/base/base-view-model';
|
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',
|
2018-12-13 16:26:08 +01:00
|
|
|
Final = 'agreed',
|
|
|
|
ModifiedFinal = 'modified_final_version'
|
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-02-01 13:56:08 +01:00
|
|
|
export class ViewMotion extends BaseAgendaViewModel implements Searchable {
|
2018-11-30 09:24:07 +01:00
|
|
|
protected _motion: Motion;
|
2019-02-01 13:56:08 +01:00
|
|
|
protected _category: ViewCategory;
|
|
|
|
protected _submitters: ViewUser[];
|
|
|
|
protected _supporters: ViewUser[];
|
|
|
|
protected _workflow: ViewWorkflow;
|
2018-11-30 09:24:07 +01:00
|
|
|
protected _state: WorkflowState;
|
2019-02-01 13:56:08 +01:00
|
|
|
protected _item: ViewItem;
|
|
|
|
protected _block: ViewMotionBlock;
|
|
|
|
protected _attachments: ViewMediafile[];
|
|
|
|
protected _tags: ViewTag[];
|
|
|
|
protected _parent: ViewMotion;
|
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 {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.id;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get identifier(): string {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.identifier;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get title(): string {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.title;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-11-23 13:42:44 +01:00
|
|
|
public get identifierOrTitle(): string {
|
|
|
|
return this.identifier ? this.identifier : this.title;
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public get text(): string {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.text;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get reason(): string {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.reason;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-12-13 16:26:08 +01:00
|
|
|
public get modified_final_version(): string {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.modified_final_version;
|
2018-12-13 16:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public set modified_final_version(value: string) {
|
|
|
|
if (this.motion) {
|
|
|
|
this.motion.modified_final_version = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-08 17:38:44 +01:00
|
|
|
public get weight(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.weight;
|
2018-11-08 17:38:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public get sort_parent_id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.sort_parent_id;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-10-23 14:20:29 +02:00
|
|
|
public get agenda_item_id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.agenda_item_id;
|
2018-10-23 14:20:29 +02:00
|
|
|
}
|
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
public get category_id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.category_id;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public get category(): ViewCategory {
|
|
|
|
return this._category;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get submitters(): ViewUser[] {
|
2018-09-04 14:55:07 +02:00
|
|
|
return this._submitters;
|
|
|
|
}
|
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
public get submitters_id(): number[] {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.submitterIds;
|
2018-09-20 12:25:37 +02:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public get supporters(): ViewUser[] {
|
2018-09-04 14:55:07 +02:00
|
|
|
return this._supporters;
|
|
|
|
}
|
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
public get supporters_id(): number[] {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.supporters_id;
|
2018-09-20 12:25:37 +02:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public set supporters(users: ViewUser[]) {
|
|
|
|
this._supporters = users;
|
|
|
|
this._motion.supporters_id = users.map(user => user.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public get workflow(): ViewWorkflow {
|
2018-09-04 14:55:07 +02:00
|
|
|
return this._workflow;
|
|
|
|
}
|
|
|
|
|
2018-11-22 12:33:40 +01:00
|
|
|
public get workflow_id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.workflow_id;
|
2018-11-22 12:33:40 +01:00
|
|
|
}
|
|
|
|
|
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 {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.state_id;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
public get recommendation_id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.recommendation_id;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-10-28 11:06:36 +01:00
|
|
|
public get statute_paragraph_id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.statute_paragraph_id;
|
2018-10-28 11:06:36 +01:00
|
|
|
}
|
|
|
|
|
2018-09-04 14:55:07 +02:00
|
|
|
public get recommendation(): WorkflowState {
|
2019-02-01 13:56:08 +01:00
|
|
|
return 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 {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.origin;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get nextStates(): WorkflowState[] {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.state && this.workflow ? this.state.getNextStates(this.workflow.workflow) : [];
|
2018-09-20 12:25:37 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 09:48:58 +01:00
|
|
|
public get previousStates(): WorkflowState[] {
|
|
|
|
return this.state && this.workflow ? this.state.getPreviousStates(this.workflow.workflow) : [];
|
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public get item(): ViewItem {
|
2018-11-12 15:24:23 +01:00
|
|
|
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 {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.motion_block_id;
|
2018-11-23 13:42:44 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public get motion_block(): ViewMotionBlock {
|
2018-11-23 13:42:44 +01:00
|
|
|
return this._block;
|
|
|
|
}
|
|
|
|
|
2018-11-12 15:24:23 +01:00
|
|
|
public get agendaSpeakerAmount(): number {
|
2019-01-24 11:15:52 +01:00
|
|
|
return this.item ? this.item.waitingSpeakerAmount : null;
|
2018-11-12 15:24:23 +01:00
|
|
|
}
|
|
|
|
|
2018-11-04 11:11:48 +01:00
|
|
|
public get parent_id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.parent_id;
|
2018-11-04 11:11:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public get amendment_paragraphs(): string[] {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.amendment_paragraphs ? this.motion.amendment_paragraphs : [];
|
2018-11-04 11:11:48 +01:00
|
|
|
}
|
|
|
|
|
2018-11-27 22:44:37 +01:00
|
|
|
public get tags_id(): number[] {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.tags_id;
|
2018-12-10 17:54:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public get attachments_id(): number[] {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this.motion.attachments_id;
|
2018-12-10 17:54:48 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public get attachments(): ViewMediafile[] {
|
|
|
|
return this._attachments;
|
2018-11-27 22:44:37 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public get tags(): ViewTag[] {
|
|
|
|
return this._tags;
|
2019-02-01 12:31:10 +01:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public get parent(): ViewMotion {
|
2019-02-01 14:27:24 +01:00
|
|
|
return this._parent;
|
|
|
|
}
|
|
|
|
|
2019-01-19 17:06:23 +01:00
|
|
|
/**
|
|
|
|
* @returns the creation date as Date object
|
|
|
|
*/
|
|
|
|
public get creationDate(): Date {
|
2019-02-01 13:56:08 +01:00
|
|
|
if (!this.motion.created) {
|
2019-01-19 17:06:23 +01:00
|
|
|
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 {
|
2019-02-01 13:56:08 +01:00
|
|
|
if (!this.motion.last_modified) {
|
2019-01-19 17:06:23 +01:00
|
|
|
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(
|
2019-02-01 13:56:08 +01:00
|
|
|
motion: Motion,
|
|
|
|
category?: ViewCategory,
|
|
|
|
submitters?: ViewUser[],
|
|
|
|
supporters?: ViewUser[],
|
|
|
|
workflow?: ViewWorkflow,
|
2018-11-12 15:24:23 +01:00
|
|
|
state?: WorkflowState,
|
2019-02-01 13:56:08 +01:00
|
|
|
item?: ViewItem,
|
|
|
|
block?: ViewMotionBlock,
|
|
|
|
attachments?: ViewMediafile[],
|
|
|
|
tags?: ViewTag[],
|
|
|
|
parent?: ViewMotion
|
2018-09-04 14:55:07 +02:00
|
|
|
) {
|
2019-02-01 13:56:08 +01:00
|
|
|
super('Motion');
|
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;
|
2019-02-01 12:31:10 +01:00
|
|
|
this._tags = tags;
|
2019-02-01 14:27:24 +01:00
|
|
|
this._parent = parent;
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
|
2018-10-12 11:05:24 +02:00
|
|
|
public getTitle(): string {
|
2019-02-01 13:56:08 +01:00
|
|
|
if (this.identifier) {
|
|
|
|
return this.identifier + ': ' + this.title;
|
|
|
|
} else {
|
|
|
|
return this.title;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public getAgendaItem(): ViewItem {
|
|
|
|
return this.item;
|
|
|
|
}
|
|
|
|
|
|
|
|
public getAgendaTitle(): string {
|
|
|
|
// if the identifier is set, the title will be 'Motion <identifier>'.
|
|
|
|
if (this.identifier) {
|
|
|
|
return 'Motion ' + this.identifier;
|
|
|
|
} else {
|
|
|
|
return this.getTitle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public getAgendaTitleWithType(): string {
|
|
|
|
// Append the verbose name only, if not the special format 'Motion <identifier>' is used.
|
2018-11-08 17:38:44 +01:00
|
|
|
if (this.identifier) {
|
2019-01-26 20:37:49 +01:00
|
|
|
return 'Motion ' + this.identifier;
|
2019-02-01 13:56:08 +01:00
|
|
|
} else {
|
|
|
|
return this.getTitle() + ' (' + this.getVerboseName() + ')';
|
2018-10-15 11:52:57 +02:00
|
|
|
}
|
2019-02-01 13:56:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Formats the category for search
|
|
|
|
*
|
|
|
|
* TODO!!!!
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
public formatForSearch(): SearchRepresentation {
|
|
|
|
let searchValues = [this.title, this.text, this.reason];
|
|
|
|
if (this.amendment_paragraphs) {
|
|
|
|
searchValues = searchValues.concat(this.amendment_paragraphs.filter(x => !!x));
|
|
|
|
}
|
|
|
|
return searchValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
public getDetailStateURL(): string {
|
|
|
|
return `/motions/${this.id}`;
|
2018-09-10 15:53:11 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateDependencies(update: BaseViewModel): void {
|
|
|
|
if (update instanceof ViewWorkflow) {
|
|
|
|
this.updateWorkflow(update);
|
|
|
|
} else if (update instanceof ViewCategory) {
|
|
|
|
this.updateCategory(update);
|
|
|
|
} else if (update instanceof ViewItem) {
|
|
|
|
this.updateItem(update);
|
|
|
|
} else if (update instanceof ViewMotionBlock) {
|
2018-11-23 13:42:44 +01:00
|
|
|
this.updateMotionBlock(update);
|
2019-02-01 13:56:08 +01:00
|
|
|
} else if (update instanceof ViewUser) {
|
|
|
|
this.updateUser(update);
|
|
|
|
} else if (update instanceof ViewMediafile) {
|
|
|
|
this.updateAttachments(update);
|
|
|
|
} else if (update instanceof ViewTag) {
|
|
|
|
this.updateTags(update);
|
|
|
|
} else if (update instanceof ViewMotion && update.id !== this.id) {
|
|
|
|
this.updateParent(update);
|
2018-09-04 14:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-20 12:25:37 +02:00
|
|
|
/**
|
2019-02-01 13:56:08 +01:00
|
|
|
* Update routine for the workflow
|
2018-12-10 17:54:48 +01:00
|
|
|
*
|
2019-02-01 13:56:08 +01:00
|
|
|
* @param workflow potentially the (changed workflow (state). Needs manual verification
|
2018-09-20 12:25:37 +02:00
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateWorkflow(workflow: ViewWorkflow): void {
|
|
|
|
if (workflow.id === this.motion.workflow_id) {
|
|
|
|
this._workflow = workflow;
|
|
|
|
this._state = workflow.getStateById(this.state_id);
|
2018-09-20 12:25:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-02-01 13:56:08 +01:00
|
|
|
* Update routine for the category
|
2018-12-10 17:54:48 +01:00
|
|
|
*
|
2019-02-01 13:56:08 +01:00
|
|
|
* @param category potentially the changed category. Needs manual verification
|
2018-09-20 12:25:37 +02:00
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateCategory(category: ViewCategory): void {
|
|
|
|
if (this.category_id && 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 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
|
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateItem(item: ViewItem): void {
|
|
|
|
if (item.id === this.motion.agenda_item_id) {
|
2018-11-23 13:42:44 +01:00
|
|
|
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
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateMotionBlock(block: ViewMotionBlock): void {
|
|
|
|
if (this.motion_block_id && block.id === this.motion.motion_block_id) {
|
2018-11-23 13:42:44 +01:00
|
|
|
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
|
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateUser(update: ViewUser): void {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
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;
|
2018-11-23 13:59:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-10 17:54:48 +01:00
|
|
|
/**
|
|
|
|
* Update routine for attachments
|
|
|
|
*
|
2019-02-01 13:56:08 +01:00
|
|
|
* @param mediafile
|
2018-12-10 17:54:48 +01:00
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateAttachments(mediafile: ViewMediafile): void {
|
|
|
|
if (this.attachments_id && this.attachments_id.includes(mediafile.id)) {
|
|
|
|
const attachmentIndex = this.attachments.findIndex(_mediafile => _mediafile.id === mediafile.id);
|
|
|
|
this.attachments[attachmentIndex] = mediafile;
|
2018-12-10 17:54:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateTags(tag: ViewTag): void {
|
|
|
|
if (this.tags_id && this.tags_id.includes(tag.id)) {
|
|
|
|
const tagIndex = this.tags.findIndex(_tag => _tag.id === tag.id);
|
|
|
|
this.tags[tagIndex] = tag;
|
2019-02-01 12:31:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateParent(parent: ViewMotion): void {
|
|
|
|
if (this.parent_id && this.parent_id === parent.id) {
|
|
|
|
this._parent = parent;
|
2019-02-01 14:27:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-02-01 12:31:10 +01:00
|
|
|
public hasTags(): boolean {
|
|
|
|
return !!(this.tags && this.tags.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-24 16:25:50 +01:00
|
|
|
public getSlide(): ProjectorElementBuildDeskriptor {
|
|
|
|
return {
|
|
|
|
getBasicProjectorElement: () => ({
|
|
|
|
name: Motion.COLLECTIONSTRING,
|
|
|
|
id: this.id,
|
|
|
|
getIdentifiers: () => ['name', 'id']
|
|
|
|
}),
|
|
|
|
slideOptions: [
|
|
|
|
{
|
|
|
|
key: 'mode',
|
|
|
|
displayName: 'Mode',
|
|
|
|
default: 'original',
|
|
|
|
choices: [
|
|
|
|
{ value: 'original', displayName: 'Original' },
|
|
|
|
{ value: 'changed', displayName: 'Changed' },
|
|
|
|
{ value: 'diff', displayName: 'Diff' },
|
|
|
|
{ value: 'agreed', displayName: 'Agreed' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
projectionDefaultName: 'motions',
|
2019-01-26 20:37:49 +01:00
|
|
|
getTitle: () => this.identifier
|
2019-01-24 16:25:50 +01:00
|
|
|
};
|
2019-01-10 15:06:10 +01:00
|
|
|
}
|
|
|
|
|
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-02-01 12:31:10 +01:00
|
|
|
this._attachments,
|
2019-02-01 14:27:24 +01:00
|
|
|
this._tags,
|
|
|
|
this._parent
|
2018-09-04 14:55:07 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|