OpenSlides/client/src/app/site/motions/models/view-change-recommendation.ts

102 lines
2.8 KiB
TypeScript
Raw Normal View History

2018-09-30 18:43:20 +02:00
import { BaseViewModel } from '../../base/base-view-model';
import { ModificationType } from 'app/core/ui-services/diff.service';
import { MotionChangeRecommendation } from 'app/shared/models/motions/motion-change-reco';
2018-09-30 18:43:20 +02:00
import { ViewUnifiedChange, ViewUnifiedChangeType } from './view-unified-change';
/**
* Change recommendation class for the View
*
* Stores a motion including all (implicit) references
* Provides "safe" access to variables and functions in {@link MotionChangeReco}
* @ignore
*/
export class ViewMotionChangeRecommendation extends BaseViewModel implements ViewUnifiedChange {
private _changeRecommendation: MotionChangeRecommendation;
2018-09-30 18:43:20 +02:00
public get id(): number {
return this._changeRecommendation.id;
2018-09-30 18:43:20 +02:00
}
public get changeRecommendation(): MotionChangeRecommendation {
return this._changeRecommendation;
2018-09-30 18:43:20 +02:00
}
public constructor(changeReco: MotionChangeRecommendation) {
super('Change recommendation');
this._changeRecommendation = changeReco;
2018-09-30 18:43:20 +02:00
}
public getTitle(): string {
return 'Changerecommendation';
2018-09-30 18:43:20 +02:00
}
public updateDependencies(update: BaseViewModel): void {}
2018-09-30 18:43:20 +02:00
public updateChangeReco(type: number, text: string, internal: boolean): void {
2018-09-30 18:43:20 +02:00
// @TODO HTML sanitazion
this._changeRecommendation.type = type;
this._changeRecommendation.text = text;
this._changeRecommendation.internal = internal;
2018-09-30 18:43:20 +02:00
}
public get rejected(): boolean {
return this._changeRecommendation.rejected;
2018-09-30 18:43:20 +02:00
}
public get internal(): boolean {
return this._changeRecommendation.internal;
}
2018-09-30 18:43:20 +02:00
public get type(): number {
return this._changeRecommendation.type || ModificationType.TYPE_REPLACEMENT;
2018-09-30 18:43:20 +02:00
}
public get other_description(): string {
return this._changeRecommendation.other_description;
2018-09-30 18:43:20 +02:00
}
public get line_from(): number {
return this._changeRecommendation.line_from;
2018-09-30 18:43:20 +02:00
}
public get line_to(): number {
return this._changeRecommendation.line_to;
2018-09-30 18:43:20 +02:00
}
public get text(): string {
return this._changeRecommendation.text;
2018-09-30 18:43:20 +02:00
}
public get motion_id(): number {
return this._changeRecommendation.motion_id;
2018-09-30 18:43:20 +02:00
}
public getChangeId(): string {
return 'recommendation-' + this.id.toString(10);
}
public getChangeType(): ViewUnifiedChangeType {
return ViewUnifiedChangeType.TYPE_CHANGE_RECOMMENDATION;
}
public getLineFrom(): number {
return this.line_from;
}
public getLineTo(): number {
return this.line_to;
}
public getChangeNewText(): string {
return this.text;
}
public isAccepted(): boolean {
return !this.rejected;
}
public isRejected(): boolean {
return this.rejected;
}
}