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

107 lines
2.9 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
}
2019-02-08 16:02:46 +01:00
/**
* This is set by the repository
*/
public getVerboseName;
public constructor(changeReco: MotionChangeRecommendation) {
2019-02-08 16:02:46 +01:00
super(MotionChangeRecommendation.COLLECTIONSTRING);
this._changeRecommendation = changeReco;
2018-09-30 18:43:20 +02:00
}
2019-02-08 16:02:46 +01:00
public getTitle = () => {
return 'Changerecommendation';
2019-02-08 16:02:46 +01:00
};
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;
}
}