Skip to content

Commit

Permalink
Add place sensitive classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Elblinator committed Oct 17, 2024
1 parent ddfd731 commit 357d6d7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,21 @@
}

.amendment-nr-n-icon {
display: block;
//display: flex;
//align-items: center;
//justify-content: flex-start;
//border: 1px solid black;
display: flex;
align-items: center;
justify-content: flex-start;
position: relative;
left: -40px;
bottom: 12px;
height: 0;
margin-top: 45px;
height: 1.5em;
margin-top: 25px;
}

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

.os-linebreak {
.os-linebreak {
display: none !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,14 @@ export class MotionFormatService {
);
}
text.push(...this.addAmendmentNr(changesToShow, changesToShow[i]));
if (text[text.length - 3]?.search(`:</span></span>`)) {
text[text.length - 1] = text[text.length - 1].replace(`os-line-number `, ``);
}
text.push(this.diffService.getChangeDiff(motionText, changesToShow[i], lineLength, highlightedLine));
lastLineTo = changesToShow[i].getLineTo();
}

text.push(
this.diffService.getTextRemainderAfterLastChange(motionText, changesToShow, lineLength, highlightedLine)
);
if (text[0].match(`<os-linebreak data-line-number="1" class="os-line-number line-number-1"></os-linebreak>`)) {
text[0] = text[0].replace(`os-line-number `, ``);
}
return text.join(``);
return this.adjustDiffClasses(text).join(``);
};

public hasCollissions(change: ViewUnifiedChange, changes: ViewUnifiedChange[]): boolean {
Expand All @@ -263,14 +257,28 @@ export class MotionFormatService {
private addAmendmentNr(changesToShow: ViewUnifiedChange[], current_text: ViewUnifiedChange): string[] {
const lineNumbering = this.settings.instant(`motions_default_line_numbering`);
const amendmentNr: string[] = [];
amendmentNr.push(`<span class="amendment-nr-n-icon">`);

if (this.hasCollissions(current_text, changesToShow)) {
if (lineNumbering === LineNumberingMode.Outside) {
amendmentNr.push(`<mat-icon class="margin-right-10">warning</mat-icon>`);
amendmentNr.push(
`<span class="amendment-nr-n-icon"><mat-icon class="margin-right-10">warning</mat-icon>`
);
} else if (lineNumbering === LineNumberingMode.Inside) {
amendmentNr.push(`<mat-icon class="margin-left-45">warning</mat-icon>`);
amendmentNr.push(
`<span class="amendment-nr-n-icon"><mat-icon class="margin-left-45">warning</mat-icon>`
);
} else {
amendmentNr.push(`<mat-icon class="margin-left-40">warning</mat-icon>`);
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) {
Expand All @@ -284,4 +292,22 @@ export class MotionFormatService {
}
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) {
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) {
text[i] = text[i].replace(`os-line-number `, ``);
}
}
return text;
}
}

0 comments on commit 357d6d7

Please sign in to comment.