Add PDF for paragraph based amendments
Also add some more pdf fixes
This commit is contained in:
parent
a5eee7c99c
commit
d22ec6f34d
@ -75,7 +75,8 @@ export class HtmlToPdfService {
|
|||||||
*/
|
*/
|
||||||
private classStyles = {
|
private classStyles = {
|
||||||
delete: ['color:red', 'text-decoration:line-through'],
|
delete: ['color:red', 'text-decoration:line-through'],
|
||||||
insert: ['color:green', 'text-decoration:underline']
|
insert: ['color:green', 'text-decoration:underline'],
|
||||||
|
paragraphcontext: ['color:grey']
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +126,6 @@ export class HtmlToPdfService {
|
|||||||
const parsedElement = this.parseElement(child);
|
const parsedElement = this.parseElement(child);
|
||||||
docDef.push(parsedElement);
|
docDef.push(parsedElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
return docDef;
|
return docDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,11 @@ export class HtmlToPdfService {
|
|||||||
const children = this.parseChildren(element, styles);
|
const children = this.parseChildren(element, styles);
|
||||||
|
|
||||||
// this introduces a bug with rendering sub-lists in PDF
|
// this introduces a bug with rendering sub-lists in PDF
|
||||||
if (this.lineNumberingMode === LineNumberingMode.Outside && !this.isInsideAList(element)) {
|
if (
|
||||||
|
this.lineNumberingMode === LineNumberingMode.Outside &&
|
||||||
|
!this.isInsideAList(element) &&
|
||||||
|
!classes.includes('insert')
|
||||||
|
) {
|
||||||
newParagraph = this.create('stack');
|
newParagraph = this.create('stack');
|
||||||
newParagraph.stack = children;
|
newParagraph.stack = children;
|
||||||
} else {
|
} else {
|
||||||
@ -193,20 +197,28 @@ export class HtmlToPdfService {
|
|||||||
newParagraph.text = children;
|
newParagraph.text = children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newParagraph.margin = [0, 0, 0, 0];
|
||||||
|
if (this.lineNumberingMode === LineNumberingMode.Outside) {
|
||||||
|
// that is usually the case for inserted change which should appear
|
||||||
|
// under a set of line numbers with correct alignment
|
||||||
|
if (classes.includes('insert')) {
|
||||||
|
newParagraph.margin[0] = 20;
|
||||||
|
newParagraph.margin[1] = this.P_MARGIN_BOTTOM;
|
||||||
|
newParagraph.margin[3] = this.P_MARGIN_BOTTOM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (classes.includes('os-split-before')) {
|
if (classes.includes('os-split-before')) {
|
||||||
newParagraph.listType = 'none';
|
newParagraph.listType = 'none';
|
||||||
} else {
|
} else if (this.isInsideAList(element)) {
|
||||||
newParagraph.marginBottom = this.getMarginBottom(nodeName);
|
newParagraph.margin[3] = this.getMarginBottom(nodeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
newParagraph.lineHeight = this.LINE_HEIGHT;
|
newParagraph.lineHeight = this.LINE_HEIGHT;
|
||||||
|
|
||||||
const implicitStyles = this.computeStyle(this.elementStyles[nodeName]);
|
|
||||||
|
|
||||||
newParagraph = {
|
newParagraph = {
|
||||||
...newParagraph,
|
...newParagraph,
|
||||||
...this.computeStyle(styles),
|
...this.computeStyle(styles),
|
||||||
...implicitStyles
|
...this.computeStyle(this.elementStyles[nodeName])
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -477,7 +489,7 @@ export class HtmlToPdfService {
|
|||||||
* Recursive helper function to determine if the element is inside a list
|
* Recursive helper function to determine if the element is inside a list
|
||||||
*
|
*
|
||||||
* @param element the current html node
|
* @param element the current html node
|
||||||
* @returns wheater the element is inside a list or not
|
* @returns wether the element is inside a list or not
|
||||||
*/
|
*/
|
||||||
private isInsideAList(element: Element): boolean {
|
private isInsideAList(element: Element): boolean {
|
||||||
let parent = element.parentNode;
|
let parent = element.parentNode;
|
||||||
|
@ -765,6 +765,7 @@
|
|||||||
[class.line-numbers-outside]="isLineNumberingOutside()"
|
[class.line-numbers-outside]="isLineNumberingOutside()"
|
||||||
[class.amendment-context]="showAmendmentContext"
|
[class.amendment-context]="showAmendmentContext"
|
||||||
>
|
>
|
||||||
|
<!-- TODO: everything here is required for PDF as well. Should be in a service -->
|
||||||
<div class="amendment-context" *ngIf="showAmendmentContext">
|
<div class="amendment-context" *ngIf="showAmendmentContext">
|
||||||
<div [innerHTML]="getParentMotionRange(1, paragraph.paragraphLineFrom)" class="context"></div>
|
<div [innerHTML]="getParentMotionRange(1, paragraph.paragraphLineFrom)" class="context"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -782,9 +783,9 @@
|
|||||||
<span translate>Line</span> {{ paragraph.diffLineFrom }} - {{ paragraph.diffLineTo - 1 }}:
|
<span translate>Line</span> {{ paragraph.diffLineFrom }} - {{ paragraph.diffLineTo - 1 }}:
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div class="paragraph-context" [innerHtml]="sanitizedText(paragraph.textPre)"></div>
|
<div class="paragraphcontext" [innerHtml]="sanitizedText(paragraph.textPre)"></div>
|
||||||
<div [innerHtml]="sanitizedText(paragraph.text)"></div>
|
<div [innerHtml]="sanitizedText(paragraph.text)"></div>
|
||||||
<div class="paragraph-context" [innerHtml]="sanitizedText(paragraph.textPost)"></div>
|
<div class="paragraphcontext" [innerHtml]="sanitizedText(paragraph.textPost)"></div>
|
||||||
|
|
||||||
<div class="amendment-context" *ngIf="showAmendmentContext">
|
<div class="amendment-context" *ngIf="showAmendmentContext">
|
||||||
<div [innerHtml]="getParentMotionRange(paragraph.paragraphLineTo, null)"></div>
|
<div [innerHtml]="getParentMotionRange(paragraph.paragraphLineTo, null)"></div>
|
||||||
|
@ -274,10 +274,10 @@ span {
|
|||||||
.os-split-before {
|
.os-split-before {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
.paragraph-context {
|
.paragraphcontext {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
&.amendment-context .paragraph-context {
|
&.amendment-context .paragraphcontext {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,6 +476,10 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* Merges amendments and change recommendations and sorts them by the line numbers.
|
* Merges amendments and change recommendations and sorts them by the line numbers.
|
||||||
* Called each time one of these arrays changes.
|
* Called each time one of these arrays changes.
|
||||||
|
*
|
||||||
|
* TODO: 1. Having logic in a service is bad practice
|
||||||
|
* 2. Manipulating class parameters without an subscription should
|
||||||
|
* be avoided. It's safer and simpler to return values than to manipulate the scope
|
||||||
*/
|
*/
|
||||||
private recalcUnifiedChanges(): void {
|
private recalcUnifiedChanges(): void {
|
||||||
this.allChangingObjects = [];
|
this.allChangingObjects = [];
|
||||||
|
@ -455,7 +455,24 @@ export class MotionPdfService {
|
|||||||
const lineLength = this.configService.instant<number>('motions_line_length');
|
const lineLength = this.configService.instant<number>('motions_line_length');
|
||||||
|
|
||||||
if (motion.isParagraphBasedAmendment()) {
|
if (motion.isParagraphBasedAmendment()) {
|
||||||
// TODO: special docs for special amendment
|
motionText = '';
|
||||||
|
// this is logically redundant with the formation of amendments in the motion-detail html.
|
||||||
|
// Should be refactored in a way that a service returns the correct html for both cases
|
||||||
|
for (const paragraph of this.motionRepo.getAmendedParagraphs(motion, lineLength)) {
|
||||||
|
if (paragraph.diffLineTo === paragraph.diffLineFrom + 1) {
|
||||||
|
motionText += `<h3>
|
||||||
|
${this.translate.instant('Line')} ${paragraph.diffLineFrom}:
|
||||||
|
</h3>`;
|
||||||
|
} else {
|
||||||
|
motionText += `<h3>
|
||||||
|
${this.translate.instant('Line')} ${paragraph.diffLineFrom} - ${paragraph.diffLineTo - 1}:
|
||||||
|
</h3>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
motionText += `<div class="paragraphcontext">${paragraph.textPre}</div>`;
|
||||||
|
motionText += paragraph.text;
|
||||||
|
motionText += `<div class="paragraphcontext">${paragraph.textPost}</div>`;
|
||||||
|
}
|
||||||
} else if (motion.isStatuteAmendment()) {
|
} else if (motion.isStatuteAmendment()) {
|
||||||
// statute amendments
|
// statute amendments
|
||||||
const statutes = this.statureRepo.getViewModelList();
|
const statutes = this.statureRepo.getViewModelList();
|
||||||
|
Loading…
Reference in New Issue
Block a user