Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motion with amendments add icon and amendment number #4199

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class AmendmentParagraphUnifiedChange implements ViewUnifiedChange {
public type!: number;
public merge_amendment_into_final: MergeAmendment;
public merge_amendment_into_diff: MergeAmendment;
public amend_nr: string;

public constructor(
data: AmendmentData,
Expand All @@ -23,6 +24,7 @@ export class AmendmentParagraphUnifiedChange implements ViewUnifiedChange {
this.id = data.id;
this.merge_amendment_into_final = data.merge_amendment_into_final;
this.merge_amendment_into_diff = data.merge_amendment_into_diff;
this.amend_nr = data.number;
}

public getTitle(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,23 @@
}
}
}

.amendment-nr-n-icon {
display: flex;
align-items: center;
justify-content: flex-start;
position: relative;
left: -40px;
height: 1.5em;
margin-top: 25px;
}

.amendment-nr {
position: relative;
font-style: italic;
background-color: rgb(224, 224, 224);
}

.os-linebreak {
display: none !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class MotionSlideComponent
return html;
}

public getAllTextChangingObjects(): ViewUnifiedChange[] {
private getAllTextChangingObjects(): ViewUnifiedChange[] {
return this.allChangingObjects.filter((obj: ViewUnifiedChange) => !obj.isTitleChange());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Id } from 'src/app/domain/definitions/key-types';
import { MotionFormattingRepresentation } from 'src/app/domain/models/motions/motion';
import { ChangeRecoMode } from 'src/app/domain/models/motions/motions.constants';
import { ChangeRecoMode, LineNumberingMode } from 'src/app/domain/models/motions/motions.constants';
import { MeetingSettingsService } from 'src/app/site/pages/meetings/services/meeting-settings.service';

import { ViewUnifiedChange, ViewUnifiedChangeType } from '../../../modules';
Expand Down Expand Up @@ -215,7 +215,7 @@ export class MotionFormatService {

private getDiffView = (targetMotion: MotionFormattingRepresentation, args: DifferedViewArguments): string => {
const { changes, lineLength, highlightedLine, firstLine }: DifferedViewArguments = args;
const text = [];
const text: string[] = [];
const changesToShow = changes.filter(change => change.showInDiffView());
const motionText = this.lineNumberingService.insertLineNumbers({
html: targetMotion.text,
Expand All @@ -239,14 +239,75 @@ export class MotionFormatService {
)
);
}

text.push(...this.addAmendmentNr(changesToShow, changesToShow[i]));
text.push(this.diffService.getChangeDiff(motionText, changesToShow[i], lineLength, highlightedLine));
lastLineTo = changesToShow[i].getLineTo();
}

text.push(
this.diffService.getTextRemainderAfterLastChange(motionText, changesToShow, lineLength, highlightedLine)
);
return text.join(``);
return this.adjustDiffClasses(text).join(``);
};

public hasCollissions(change: ViewUnifiedChange, changes: ViewUnifiedChange[]): boolean {
return this.diffService.changeHasCollissions(change, changes);
}

Elblinator marked this conversation as resolved.
Show resolved Hide resolved
private addAmendmentNr(changesToShow: ViewUnifiedChange[], current_text: ViewUnifiedChange): string[] {
const lineNumbering = this.settings.instant(`motions_default_line_numbering`);
const amendmentNr: string[] = [];

if (this.hasCollissions(current_text, changesToShow)) {
if (lineNumbering === LineNumberingMode.Outside) {
amendmentNr.push(
`<span class="amendment-nr-n-icon"><mat-icon class="margin-right-10">warning</mat-icon>`
);
} else if (lineNumbering === LineNumberingMode.Inside) {
amendmentNr.push(
`<span class="amendment-nr-n-icon"><mat-icon class="margin-left-45">warning</mat-icon>`
);
} else {
amendmentNr.push(
`<span class="amendment-nr-n-icon"><mat-icon class="margin-left-40">warning</mat-icon>`
);
}
} else {
if (lineNumbering === LineNumberingMode.Outside) {
amendmentNr.push(`<span class="amendment-nr-n-icon">`);
} else if (lineNumbering === LineNumberingMode.Inside) {
amendmentNr.push(`<span class="margin-left-46 amendment-nr-n-icon">`);
} else {
amendmentNr.push(`<span class="margin-left-40 amendment-nr-n-icon">`);
}
}
if (`amend_nr` in current_text) {
if (typeof current_text.amend_nr === `string`) {
amendmentNr.push(`<span class="amendment-nr">`, current_text.amend_nr);
}
if (current_text.amend_nr === ``) {
amendmentNr.push(`Amendment`);
}
amendmentNr.push(`:</span></span>`);
}
bastianjoel marked this conversation as resolved.
Show resolved Hide resolved
return amendmentNr;
}

private adjustDiffClasses(text: string[]): string[] {
for (let i = 0; i < text.length; i++) {
// Removes the unwanted gap between the paragraph and the amendment number
if (text[i]?.search(`amendment-nr-n-icon`) > -1) {
Elblinator marked this conversation as resolved.
Show resolved Hide resolved
text[i + 4] = text[i + 4]?.replace(`os-split-after`, `os-split-after margin-top-0`);
if (i < 4) {
text[i + 3] = text[i + 3]?.replace(`os-split-after`, `os-split-after margin-top-0`);
}
}

// Removes the doubled numbers
if (text[i]?.search(`<os-linebreak`) > -1) {
Elblinator marked this conversation as resolved.
Show resolved Hide resolved
text[i] = text[i].replace(`os-line-number `, ``);
}
}
return text;
}
}