Merge pull request #4117 from CatoTH/Issue4108-Unknown-ChangeRecoMode

Move lnMode/crMode/lineLength into components, Bugfix for lineLength …
This commit is contained in:
Emanuel Schütze 2019-01-17 18:04:38 +01:00 committed by GitHub
commit 57202e74ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 131 additions and 128 deletions

View File

@ -5,6 +5,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatSnackBar } from '@angular/material';
import { TranslateService } from '@ngx-translate/core';
import { ConfigService } from '../../../../core/services/config.service';
import { MotionRepositoryService } from '../../services/motion-repository.service';
import { ViewMotion } from '../../models/view-motion';
@ -61,11 +62,17 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
*/
public metaInfoForm: FormGroup;
/**
* Indicates the maximum line length as defined in the configuration.
*/
public lineLength: number;
/**
* Constructs this component.
*
* @param {Title} titleService set the browser title
* @param {TranslateService} translate the translation service
* @param {ConfigService} configService The configuration provider
* @param {FormBuilder} formBuilder Form builder
* @param {MotionRepositoryService} repo Motion Repository
* @param {ActivatedRoute} route The activated route
@ -77,6 +84,7 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
public constructor(
titleService: Title,
translate: TranslateService,
private configService: ConfigService,
private formBuilder: FormBuilder,
private repo: MotionRepositoryService,
private route: ActivatedRoute,
@ -86,8 +94,12 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
matSnackBar: MatSnackBar
) {
super(titleService, translate, matSnackBar);
this.getMotionByUrl();
this.createForm();
this.configService.get('motions_line_length').subscribe(lineLength => {
this.lineLength = lineLength;
this.getMotionByUrl();
});
}
/**
@ -100,7 +112,7 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
this.motion = newViewMotion;
this.paragraphs = this.repo
.getTextParagraphs(this.motion, true)
.getTextParagraphs(this.motion, true, this.lineLength)
.map((paragraph: string, index: number) => {
return {
paragraphNo: index,

View File

@ -13,6 +13,7 @@ import {
} from '../motion-change-recommendation/motion-change-recommendation.component';
import { BaseViewComponent } from '../../../base/base-view';
import { TranslateService } from '@ngx-translate/core';
import { ConfigService } from '../../../../core/services/config.service';
/**
* This component displays the original motion text with the change blocks inside.
@ -49,6 +50,16 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
@Output()
public createChangeRecommendation: EventEmitter<LineRange> = new EventEmitter<LineRange>();
/**
* Indicates the LineNumberingMode Mode.
*/
public lnMode: LineNumberingMode;
/**
* Indicates the maximum line length as defined in the configuration.
*/
public lineLength: number;
/**
* @param title
* @param translate
@ -57,6 +68,7 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
* @param motionRepo
* @param recoRepo
* @param dialogService
* @param configService
* @param el
*/
public constructor(
@ -67,9 +79,13 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
private motionRepo: MotionRepositoryService,
private recoRepo: ChangeRecommendationRepositoryService,
private dialogService: MatDialog,
private configService: ConfigService,
private el: ElementRef
) {
super(title, translate, matSnackBar);
this.configService.get('motions_default_line_numbering').subscribe(mode => (this.lnMode = mode));
this.configService.get('motions_line_length').subscribe(lineLength => (this.lineLength = lineLength));
}
/**
@ -89,7 +105,7 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
return '';
}
return this.motionRepo.extractMotionLineRange(this.motion.id, lineRange, true);
return this.motionRepo.extractMotionLineRange(this.motion.id, lineRange, true, this.lineLength);
}
/**
@ -118,7 +134,7 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
* @param {ViewUnifiedChange} change
*/
public getDiff(change: ViewUnifiedChange): SafeHtml {
const html = this.motionRepo.getChangeDiff(this.motion, change);
const html = this.motionRepo.getChangeDiff(this.motion, change, this.lineLength);
return this.sanitizer.bypassSecurityTrustHtml(html);
}
@ -126,7 +142,10 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
* Returns the remainder text of the motion after the last change
*/
public getTextRemainderAfterLastChange(): string {
return this.motionRepo.getTextRemainderAfterLastChange(this.motion, this.changes);
if (!this.lineLength) {
return ''; // @TODO This happens in the test case when the lineLength-variable is not set
}
return this.motionRepo.getTextRemainderAfterLastChange(this.motion, this.changes, this.lineLength);
}
/**
@ -144,7 +163,7 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
* @returns whether there are line numbers at all
*/
public isLineNumberingNone(): boolean {
return this.motion.lnMode === LineNumberingMode.None;
return this.lnMode === LineNumberingMode.None;
}
/**
@ -153,7 +172,7 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
* @returns whether the line numberings are inside
*/
public isLineNumberingInline(): boolean {
return this.motion.lnMode === LineNumberingMode.Inside;
return this.lnMode === LineNumberingMode.Inside;
}
/**
@ -162,7 +181,7 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
* @returns whether the line numberings are outside
*/
public isLineNumberingOutside(): boolean {
return this.motion.lnMode === LineNumberingMode.Outside;
return this.lnMode === LineNumberingMode.Outside;
}
/**

View File

@ -615,7 +615,7 @@
mat-menu-item
translate
(click)="setLineNumberingMode(LineNumberingMode.None)"
[ngClass]="{ selected: motion.lnMode === LineNumberingMode.None }"
[ngClass]="{ selected: lnMode === LineNumberingMode.None }"
>
none
</button>
@ -623,7 +623,7 @@
mat-menu-item
translate
(click)="setLineNumberingMode(LineNumberingMode.Inside)"
[ngClass]="{ selected: motion.lnMode === LineNumberingMode.Inside }"
[ngClass]="{ selected: lnMode === LineNumberingMode.Inside }"
>
inline
</button>
@ -631,7 +631,7 @@
mat-menu-item
translate
(click)="setLineNumberingMode(LineNumberingMode.Outside)"
[ngClass]="{ selected: motion.lnMode === LineNumberingMode.Outside }"
[ngClass]="{ selected: lnMode === LineNumberingMode.Outside }"
>
outside
</button>
@ -644,7 +644,7 @@
mat-menu-item
translate
(click)="setChangeRecoMode(ChangeRecoMode.Original)"
[ngClass]="{ selected: motion?.crMode === ChangeRecoMode.Original }"
[ngClass]="{ selected: crMode === ChangeRecoMode.Original }"
>
Original version
</button>
@ -652,7 +652,7 @@
mat-menu-item
translate
(click)="setChangeRecoMode(ChangeRecoMode.Changed)"
[ngClass]="{ selected: motion?.crMode === ChangeRecoMode.Changed }"
[ngClass]="{ selected: crMode === ChangeRecoMode.Changed }"
>
Changed version
</button>
@ -660,7 +660,7 @@
mat-menu-item
translate
(click)="setChangeRecoMode(ChangeRecoMode.Diff)"
[ngClass]="{ selected: motion?.crMode === ChangeRecoMode.Diff }"
[ngClass]="{ selected: crMode === ChangeRecoMode.Diff }"
>
Diff version
</button>
@ -668,7 +668,7 @@
mat-menu-item
translate
(click)="setChangeRecoMode(ChangeRecoMode.Final)"
[ngClass]="{ selected: motion?.crMode === ChangeRecoMode.Final }"
[ngClass]="{ selected: crMode === ChangeRecoMode.Final }"
>
Final version
</button>

View File

@ -239,6 +239,26 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
*/
public LineNumberingMode = LineNumberingMode;
/**
* Indicates the LineNumberingMode Mode.
*/
public lnMode: LineNumberingMode;
/**
* Indicates the Change reco Mode.
*/
public crMode: ChangeRecoMode;
/**
* Indicates the maximum line length as defined in the configuration.
*/
public lineLength: number;
/**
* Indicates the currently highlighted line, if any.
*/
public highlightedLine: number;
/**
* Constuct the detail view.
*
@ -314,6 +334,9 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
this.configService.get('motions_min_supporters').subscribe(supporters => (this.minSupporters = supporters));
this.configService.get('motions_preamble').subscribe(preamble => (this.preamble = preamble));
this.configService.get('motions_amendments_enabled').subscribe(enabled => (this.amendmentsEnabled = enabled));
this.configService.get('motions_line_length').subscribe(lineLength => (this.lineLength = lineLength));
this.configService.get('motions_default_line_numbering').subscribe(mode => (this.lnMode = mode));
this.configService.get('motions_recommendation_text_mode').subscribe(mode => (this.crMode = mode));
}
/**
@ -371,7 +394,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
if (this.amendments) {
this.amendments.forEach(
(amendment: ViewMotion): void => {
this.repo.getAmendmentAmendedParagraphs(amendment).forEach(
this.repo.getAmendmentAmendedParagraphs(amendment, this.lineLength).forEach(
(change: ViewUnifiedChange): void => {
this.allChangingObjects.push(change);
}
@ -558,13 +581,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
public getFormattedTextPlain(): string {
// Prevent this.allChangingObjects to be reordered from within formatMotion
const changes: ViewUnifiedChange[] = Object.assign([], this.allChangingObjects);
return this.repo.formatMotion(
this.motion.id,
this.motion.crMode,
changes,
this.motion.lineLength,
this.motion.highlightedLine
);
return this.repo.formatMotion(this.motion.id, this.crMode, changes, this.lineLength, this.highlightedLine);
}
/**
@ -584,7 +601,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
* @returns {DiffLinesInParagraph[]}
*/
public getAmendedParagraphs(): DiffLinesInParagraph[] {
return this.repo.getAmendedParagraphs(this.motion);
return this.repo.getAmendedParagraphs(this.motion, this.lineLength);
}
/**
@ -596,7 +613,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
* @returns safe html strings
*/
public getParentMotionRange(from: number, to: number): SafeHtml {
const str = this.repo.extractMotionLineRange(this.motion.parent_id, { from, to }, true);
const str = this.repo.extractMotionLineRange(this.motion.parent_id, { from, to }, true, this.lineLength);
return this.sanitizer.bypassSecurityTrustHtml(str);
}
@ -606,7 +623,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
* @returns safe html strings
*/
public getFormattedStatuteAmendment(): SafeHtml {
const diffHtml = this.repo.formatStatuteAmendment(this.statuteParagraphs, this.motion, this.motion.lineLength);
const diffHtml = this.repo.formatStatuteAmendment(this.statuteParagraphs, this.motion, this.lineLength);
return this.sanitizer.bypassSecurityTrustHtml(diffHtml);
}
@ -627,7 +644,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
* @param mode Needs to got the enum defined in ViewMotion
*/
public setLineNumberingMode(mode: LineNumberingMode): void {
this.motion.lnMode = mode;
this.lnMode = mode;
}
/**
@ -636,7 +653,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
* @returns whether there are line numbers at all
*/
public isLineNumberingNone(): boolean {
return this.motion.lnMode === LineNumberingMode.None;
return this.lnMode === LineNumberingMode.None;
}
/**
@ -645,7 +662,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
* @returns whether the line numberings are inside
*/
public isLineNumberingInline(): boolean {
return this.motion.lnMode === LineNumberingMode.Inside;
return this.lnMode === LineNumberingMode.Inside;
}
/**
@ -654,7 +671,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
* @returns whether the line numberings are outside
*/
public isLineNumberingOutside(): boolean {
return this.motion.lnMode === LineNumberingMode.Outside;
return this.lnMode === LineNumberingMode.Outside;
}
/**
@ -662,21 +679,21 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
* @param mode Needs to fot to the enum defined in ViewMotion
*/
public setChangeRecoMode(mode: ChangeRecoMode): void {
this.motion.crMode = mode;
this.crMode = mode;
}
/**
* Returns true if the original version (including change recommendation annotation) is to be shown
*/
public isRecoModeOriginal(): boolean {
return this.motion.crMode === ChangeRecoMode.Original || this.allChangingObjects.length === 0;
return this.crMode === ChangeRecoMode.Original || this.allChangingObjects.length === 0;
}
/**
* Returns true if the diff version is to be shown
*/
public isRecoModeDiff(): boolean {
return this.motion.crMode === ChangeRecoMode.Diff && this.allChangingObjects.length > 0;
return this.crMode === ChangeRecoMode.Diff && this.allChangingObjects.length > 0;
}
/**
@ -689,8 +706,14 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
editChangeRecommendation: false,
newChangeRecommendation: true,
lineRange: lineRange,
changeRecommendation: this.repo.createChangeRecommendationTemplate(this.motion.id, lineRange)
changeRecommendation: this.repo.createChangeRecommendationTemplate(
this.motion.id,
lineRange,
this.lineLength
)
};
console.log(this.lineLength);
console.log(data);
this.dialogService.open(MotionChangeRecommendationComponent, {
height: '400px',
width: '600px',

View File

@ -4,7 +4,7 @@ import { Workflow } from '../../../shared/models/motions/workflow';
import { WorkflowState } from '../../../shared/models/motions/workflow-state';
import { Item } from 'app/shared/models/agenda/item';
import { MotionBlock } from 'app/shared/models/motions/motion-block';
import { LineNumberingMode, ViewMotion } from './view-motion';
import { ViewMotion } from './view-motion';
import { CreateMotion } from './create-motion';
/**
@ -43,7 +43,7 @@ export class ViewCreateMotion extends ViewMotion {
item?: Item,
block?: MotionBlock
) {
super(motion, category, submitters, supporters, workflow, state, item, block, null, 80, LineNumberingMode.None);
super(motion, category, submitters, supporters, workflow, state, item, block, null);
}
/**

View File

@ -49,30 +49,6 @@ export class ViewMotion extends BaseViewModel {
protected _block: MotionBlock;
protected _attachments: Mediafile[];
/**
* Indicates the LineNumberingMode Mode.
* Needs to be accessed from outside
*/
public lnMode: LineNumberingMode;
/**
* Indicates the Change reco Mode.
* Needs to be accessed from outside
*/
public crMode: ChangeRecoMode;
/**
* Indicates the maximum line length as defined in the configuration.
* Needs to be accessed from outside
*/
public lineLength: number;
/**
* Indicates the currently highlighted line, if any.
* Needs to be accessed from outside
*/
public highlightedLine: number;
/**
* Is set by the repository; this is the order of the flat call list given by
* the properties weight and sort_parent_id
@ -242,10 +218,7 @@ export class ViewMotion extends BaseViewModel {
state?: WorkflowState,
item?: Item,
block?: MotionBlock,
attachments?: Mediafile[],
lineLength: number = 80,
lineNumberingMode?: LineNumberingMode,
crMode?: ChangeRecoMode
attachments?: Mediafile[]
) {
super();
this._motion = motion;
@ -257,12 +230,6 @@ export class ViewMotion extends BaseViewModel {
this._item = item;
this._block = block;
this._attachments = attachments;
this.lnMode = lineNumberingMode;
this.crMode = crMode;
this.lineLength = lineLength;
this.highlightedLine = null;
}
public getTitle(): string {
@ -421,10 +388,7 @@ export class ViewMotion extends BaseViewModel {
this._state,
this._item,
this._block,
this._attachments,
this.lineLength,
this.lnMode,
this.crMode
this._attachments
);
}
}

View File

@ -9,7 +9,7 @@ import { User } from '../../../shared/models/users/user';
import { Category } from '../../../shared/models/motions/category';
import { Workflow } from '../../../shared/models/motions/workflow';
import { WorkflowState } from '../../../shared/models/motions/workflow-state';
import { ChangeRecoMode, LineNumberingMode, ViewMotion } from '../models/view-motion';
import { ChangeRecoMode, ViewMotion } from '../models/view-motion';
import { BaseRepository } from '../../base/base-repository';
import { DataStoreService } from '../../../core/services/data-store.service';
import { LinenumberingService } from './linenumbering.service';
@ -28,7 +28,6 @@ import { ViewMotionAmendedParagraph } from '../models/view-motion-amended-paragr
import { CreateMotion } from '../models/create-motion';
import { MotionBlock } from 'app/shared/models/motions/motion-block';
import { Mediafile } from 'app/shared/models/mediafiles/mediafile';
import { ConfigService } from '../../../core/services/config.service';
import { MotionPoll } from 'app/shared/models/motions/motion-poll';
/**
@ -45,15 +44,6 @@ import { MotionPoll } from 'app/shared/models/motions/motion-poll';
providedIn: 'root'
})
export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion> {
// The line length; comes from the config variable motions_line_length
private lineLength = 90;
// The default line numbering mode; comes from the config variable motions_default_line_numbering
private defaultLineNumbering = LineNumberingMode.Outside;
// The default line numbering mode; comes from the config variable motions_recommendation_text_mode
private defaultCrMode = ChangeRecoMode.Original;
/**
* Creates a MotionRepository
*
@ -66,7 +56,6 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
* @param httpService OpenSlides own Http service
* @param lineNumbering Line numbering for motion text
* @param diff Display changes in motion text as diff.
* @param configService The configuration provider
*/
public constructor(
DS: DataStoreService,
@ -75,15 +64,9 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
private httpService: HttpService,
private readonly lineNumbering: LinenumberingService,
private readonly diff: DiffService,
private readonly configService: ConfigService,
private treeService: TreeService
) {
super(DS, mapperService, Motion, [Category, User, Workflow, Item, MotionBlock, Mediafile]);
// load config variables
this.configService.get('motions_line_length').subscribe(lineLength => (this.lineLength = lineLength));
this.configService.get('motions_default_line_numbering').subscribe(mode => (this.defaultLineNumbering = mode));
this.configService.get('motions_recommendation_text_mode').subscribe(mode => (this.defaultCrMode = mode));
}
/**
@ -106,20 +89,7 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
if (workflow) {
state = workflow.getStateById(motion.state_id);
}
return new ViewMotion(
motion,
category,
submitters,
supporters,
workflow,
state,
item,
block,
attachments,
this.lineLength,
this.defaultLineNumbering,
this.defaultCrMode
);
return new ViewMotion(motion, category, submitters, supporters, workflow, state, item, block, attachments);
}
/**
@ -329,7 +299,8 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
from: 1,
to: change.getLineFrom()
},
true
true,
lineLength
);
} else if (changes[idx - 1].getLineTo() < change.getLineFrom()) {
text += this.extractMotionLineRange(
@ -338,12 +309,13 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
from: changes[idx - 1].getLineTo(),
to: change.getLineFrom()
},
true
true,
lineLength
);
}
text += this.getChangeDiff(targetMotion, change, highlightLine);
text += this.getChangeDiff(targetMotion, change, lineLength, highlightLine);
});
text += this.getTextRemainderAfterLastChange(targetMotion, changes, highlightLine);
text += this.getTextRemainderAfterLastChange(targetMotion, changes, lineLength, highlightLine);
return text;
case ChangeRecoMode.Final:
const appliedChanges: ViewUnifiedChange[] = changes.filter(change => change.isAccepted());
@ -374,9 +346,10 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
* @param {number} id
* @param {LineRange} lineRange
* @param {boolean} lineNumbers - weather to add line numbers to the returned HTML string
* @param {number} lineLength
*/
public extractMotionLineRange(id: number, lineRange: LineRange, lineNumbers: boolean): string {
const origHtml = this.formatMotion(id, ChangeRecoMode.Original, [], this.lineLength);
public extractMotionLineRange(id: number, lineRange: LineRange, lineNumbers: boolean, lineLength: number): string {
const origHtml = this.formatMotion(id, ChangeRecoMode.Original, [], lineLength);
const extracted = this.diff.extractRangeByLineNumbers(origHtml, lineRange.from, lineRange.to);
let html =
extracted.outerContextStart +
@ -385,7 +358,7 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
extracted.innerContextEnd +
extracted.outerContextEnd;
if (lineNumbers) {
html = this.lineNumbering.insertLineNumbers(html, 80, null, null, lineRange.from);
html = this.lineNumbering.insertLineNumbers(html, lineLength, null, null, lineRange.from);
}
return html;
}
@ -395,12 +368,14 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
*
* @param {ViewMotion} motion
* @param {ViewUnifiedChange[]} changes
* @param {number} lineLength
* @param {number} highlight
* @returns {string}
*/
public getTextRemainderAfterLastChange(
motion: ViewMotion,
changes: ViewUnifiedChange[],
lineLength: number,
highlight?: number
): string {
let maxLine = 1;
@ -410,7 +385,7 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
}
}, 0);
const numberedHtml = this.lineNumbering.insertLineNumbers(motion.text, motion.lineLength);
const numberedHtml = this.lineNumbering.insertLineNumbers(motion.text, lineLength);
if (changes.length === 0) {
return numberedHtml;
}
@ -437,7 +412,7 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
data.html +
data.innerContextEnd +
data.outerContextEnd;
html = this.lineNumbering.insertLineNumbers(html, motion.lineLength, highlight, null, maxLine);
html = this.lineNumbering.insertLineNumbers(html, lineLength, highlight, null, maxLine);
} else {
// Prevents empty lines at the end of the motion
html = '';
@ -451,13 +426,18 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
*
* @param {number} motionId
* @param {LineRange} lineRange
* @param {number} lineLength
*/
public createChangeRecommendationTemplate(motionId: number, lineRange: LineRange): ViewChangeReco {
public createChangeRecommendationTemplate(
motionId: number,
lineRange: LineRange,
lineLength: number
): ViewChangeReco {
const changeReco = new MotionChangeReco();
changeReco.line_from = lineRange.from;
changeReco.line_to = lineRange.to;
changeReco.type = ModificationType.TYPE_REPLACEMENT;
changeReco.text = this.extractMotionLineRange(motionId, lineRange, false);
changeReco.text = this.extractMotionLineRange(motionId, lineRange, false, lineLength);
changeReco.rejected = false;
changeReco.motion_id = motionId;
@ -470,12 +450,17 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
*
* @param {ViewMotion} motion
* @param {ViewUnifiedChange} change
* @param {number} lineLength
* @param {number} highlight
* @returns {string}
*/
public getChangeDiff(motion: ViewMotion, change: ViewUnifiedChange, highlight?: number): string {
const lineLength = motion.lineLength,
html = this.lineNumbering.insertLineNumbers(motion.text, lineLength);
public getChangeDiff(
motion: ViewMotion,
change: ViewUnifiedChange,
lineLength: number,
highlight?: number
): string {
const html = this.lineNumbering.insertLineNumbers(motion.text, lineLength);
let data, oldText;
@ -534,15 +519,15 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
*
* @param {ViewMotion} motion
* @param {boolean} lineBreaks
* @param {number} lineLength
* @returns {string[]}
*/
public getTextParagraphs(motion: ViewMotion, lineBreaks: boolean): string[] {
public getTextParagraphs(motion: ViewMotion, lineBreaks: boolean, lineLength: number): string[] {
if (!motion) {
return [];
}
let html = motion.text;
if (lineBreaks) {
const lineLength = motion.lineLength;
html = this.lineNumbering.insertLineNumbers(html, lineLength);
}
return this.lineNumbering.splitToParagraphs(html);
@ -552,12 +537,12 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
* Returns all paragraphs that are affected by the given amendment in diff-format
*
* @param {ViewMotion} amendment
* @param {number} lineLength
* @returns {DiffLinesInParagraph}
*/
public getAmendedParagraphs(amendment: ViewMotion): DiffLinesInParagraph[] {
public getAmendedParagraphs(amendment: ViewMotion, lineLength: number): DiffLinesInParagraph[] {
const motion = this.getAmendmentBaseMotion(amendment);
const baseParagraphs = this.getTextParagraphs(motion, true);
const lineLength = amendment.lineLength;
const baseParagraphs = this.getTextParagraphs(motion, true, lineLength);
return amendment.amendment_paragraphs
.map(
@ -581,12 +566,12 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
* Returns all paragraphs that are affected by the given amendment as unified change objects.
*
* @param {ViewMotion} amendment
* @param {number} lineLength
* @returns {ViewMotionAmendedParagraph[]}
*/
public getAmendmentAmendedParagraphs(amendment: ViewMotion): ViewMotionAmendedParagraph[] {
public getAmendmentAmendedParagraphs(amendment: ViewMotion, lineLength: number): ViewMotionAmendedParagraph[] {
const motion = this.getAmendmentBaseMotion(amendment);
const baseParagraphs = this.getTextParagraphs(motion, true);
const lineLength = amendment.lineLength;
const baseParagraphs = this.getTextParagraphs(motion, true, lineLength);
return amendment.amendment_paragraphs
.map(