2018-09-30 18:43:20 +02:00
|
|
|
import { BaseViewModel } from '../../base/base-view-model';
|
2019-01-19 21:55:06 +01:00
|
|
|
import { ModificationType } from 'app/core/ui-services/diff.service';
|
2019-02-01 13:56:08 +01:00
|
|
|
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
|
|
|
|
*/
|
2019-02-01 13:56:08 +01:00
|
|
|
export class ViewMotionChangeRecommendation extends BaseViewModel implements ViewUnifiedChange {
|
|
|
|
private _changeRecommendation: MotionChangeRecommendation;
|
2018-09-30 18:43:20 +02:00
|
|
|
|
|
|
|
public get id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this._changeRecommendation.id;
|
2018-09-30 18:43:20 +02:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:56:08 +01: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;
|
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public constructor(changeReco: MotionChangeRecommendation) {
|
2019-02-08 16:02:46 +01:00
|
|
|
super(MotionChangeRecommendation.COLLECTIONSTRING);
|
2019-02-01 13:56:08 +01:00
|
|
|
this._changeRecommendation = changeReco;
|
2018-09-30 18:43:20 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 16:02:46 +01:00
|
|
|
public getTitle = () => {
|
2019-02-01 13:56:08 +01:00
|
|
|
return 'Changerecommendation';
|
2019-02-08 16:02:46 +01:00
|
|
|
};
|
2018-09-30 18:43:20 +02:00
|
|
|
|
2019-02-01 13:56:08 +01:00
|
|
|
public updateDependencies(update: BaseViewModel): void {}
|
2018-09-30 18:43:20 +02:00
|
|
|
|
2018-10-25 15:11:38 +02:00
|
|
|
public updateChangeReco(type: number, text: string, internal: boolean): void {
|
2018-09-30 18:43:20 +02:00
|
|
|
// @TODO HTML sanitazion
|
2019-02-01 13:56:08 +01:00
|
|
|
this._changeRecommendation.type = type;
|
|
|
|
this._changeRecommendation.text = text;
|
|
|
|
this._changeRecommendation.internal = internal;
|
2018-09-30 18:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get rejected(): boolean {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this._changeRecommendation.rejected;
|
2018-09-30 18:43:20 +02:00
|
|
|
}
|
|
|
|
|
2018-10-25 15:11:38 +02:00
|
|
|
public get internal(): boolean {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this._changeRecommendation.internal;
|
2018-10-25 15:11:38 +02:00
|
|
|
}
|
|
|
|
|
2018-09-30 18:43:20 +02:00
|
|
|
public get type(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this._changeRecommendation.type || ModificationType.TYPE_REPLACEMENT;
|
2018-09-30 18:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get other_description(): string {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this._changeRecommendation.other_description;
|
2018-09-30 18:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get line_from(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this._changeRecommendation.line_from;
|
2018-09-30 18:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get line_to(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this._changeRecommendation.line_to;
|
2018-09-30 18:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get text(): string {
|
2019-02-01 13:56:08 +01:00
|
|
|
return this._changeRecommendation.text;
|
2018-09-30 18:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public get motion_id(): number {
|
2019-02-01 13:56:08 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|