-
Notifications
You must be signed in to change notification settings - Fork 50
Agenda export improved #5894
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
Draft
Borreg0
wants to merge
6
commits into
OpenSlides:main
Choose a base branch
from
Borreg0:5870-AgendaExportRework
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Agenda export improved #5894
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cd0e679
Agenda to PDF export style changed
64a75a3
fixed indentation levels and aligned texts
0615dc4
Increased distance between headings
b7d463c
Merge branch 'main' of https://github.com/OpenSlides/openslides-clien…
5b5edd6
Requested changes done
b69545a
Cleanup
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,11 @@ import { TreeService } from 'src/app/ui/modules/sorting/modules/sorting-tree/ser | |
|
|
||
| import { MeetingPdfExportService } from '../../../../services/export'; | ||
| import { MeetingSettingsService } from '../../../../services/meeting-settings.service'; | ||
| import { ViewMotion } from '../../../motions'; | ||
| import { ViewPoll } from '../../../polls'; | ||
| import { ViewSpeaker } from '../../modules/list-of-speakers/view-models/view-speaker'; | ||
| import { ViewTopic } from '../../modules/topics/view-models'; | ||
| import { InfoToExport } from '../../pages/agenda-item-list/services/agenda-item-export.service/agenda-item-export.service'; | ||
| import { ViewAgendaItem } from '../../view-models'; | ||
| import { AgendaItemCommonServiceModule } from '../agenda-item-common-service.module'; | ||
|
|
||
|
|
@@ -57,7 +59,7 @@ export class AgendaPdfCatalogExportService { | |
| * @param pdfMeta | ||
| * @returns pdfmake doc definition as object | ||
| */ | ||
| public agendaListToDocDef(agendaItems: ViewAgendaItem[], exportInfo: any, pdfMeta: string[]): Content { | ||
| public agendaListToDocDef(agendaItems: ViewAgendaItem[], exportInfo: InfoToExport[], pdfMeta: string[]): Content { | ||
| const addedAgendaItems = this.getMissingAgendaItems(agendaItems); | ||
| this.addedAgendaItemIds = addedAgendaItems.map(item => item.id); | ||
| const tree = this.treeService.makeSortedTree(agendaItems.concat(addedAgendaItems), `weight`, `parent_id`); | ||
|
|
@@ -69,10 +71,18 @@ export class AgendaPdfCatalogExportService { | |
|
|
||
| for (let agendaItemIndex = 0; agendaItemIndex < sortedAgendaItems.length; ++agendaItemIndex) { | ||
| try { | ||
| const agendaItem: string | null = | ||
| agendaItems[agendaItemIndex].content_object?.description ?? | ||
| agendaItems[agendaItemIndex].content_object?.text ?? | ||
| null; | ||
| const agendaDocDef: any = this.agendaItemToDoc(sortedAgendaItems[agendaItemIndex], exportInfo); | ||
| // add id field to the first page of a agenda item to make it findable over TOC | ||
| agendaDocDef[0].id = `${sortedAgendaItems[agendaItemIndex].id}`; | ||
| if (!enforcePageBreaks && agendaItemIndex + 1 < sortedAgendaItems.length) { | ||
| if ( | ||
| !enforcePageBreaks && | ||
| agendaItemIndex + 1 < sortedAgendaItems.length && | ||
| (agendaItem !== '' || agendaItem === null) | ||
| ) { | ||
| if (!sortedAgendaItems[agendaItemIndex + 1].parent) { | ||
| agendaDocDef.push({ | ||
| text: ``, | ||
|
|
@@ -105,7 +115,7 @@ export class AgendaPdfCatalogExportService { | |
| { | ||
| text: this.translate.instant(`Agenda`), | ||
| style: this.getStyle(`header1`), | ||
| margin: this.getStyle(`margin-header1`) | ||
| margin: this.getStyle(`agenda-title`) | ||
| } | ||
| ]); | ||
|
|
||
|
|
@@ -231,7 +241,13 @@ export class AgendaPdfCatalogExportService { | |
| const useTitle: boolean = info.includes(`title`); | ||
| const itemNumber: string = agendaItem.item_number ?? ``; | ||
| const title: string = agendaItem.content_object!.getTitle(); | ||
| const styleName = agendaItem.level ? `header-child` : `header2`; | ||
| let styleName = `header2`; | ||
| let margin: string | number[] = `margin-header1`; | ||
| if (agendaItem.level > 0) { | ||
| styleName = `header-child`; | ||
| const indentationLevel = agendaItem.level * 10 + 10; | ||
| margin = [indentationLevel, 10, 0, 0]; | ||
| } | ||
| let numberOrTitle = ``; | ||
| if (agendaItem.content_object?.collection === `motion`) { | ||
| const motion = agendaItem.content_object; | ||
|
|
@@ -252,6 +268,16 @@ export class AgendaPdfCatalogExportService { | |
| numberOrTitle = `${itemNumber} `; | ||
| } | ||
| numberOrTitle = numberOrTitle.concat(`${this.translate.instant('Motion block')}: ${motionBlock.title}`); | ||
| } else if (agendaItem.content_object?.collection === `assignment`) { | ||
| const election = agendaItem.content_object; | ||
| if (useItemNumber && itemNumber) { | ||
| numberOrTitle = `${itemNumber} `; | ||
| } | ||
| numberOrTitle = numberOrTitle.concat( | ||
| election.number | ||
| ? `${(this.translate.instant('Election'), election.number)}: ${election.title}` | ||
| : `${this.translate.instant('Election')}: ${election.title}` | ||
| ); | ||
| } else { | ||
| if (useItemNumber && itemNumber && useTitle) { | ||
| numberOrTitle = `${itemNumber}: ${title}`; | ||
|
|
@@ -263,17 +289,30 @@ export class AgendaPdfCatalogExportService { | |
| } | ||
| return { | ||
| style: this.getStyle(styleName), | ||
| text: numberOrTitle | ||
| text: numberOrTitle, | ||
| margin: margin === 'margin-header1' ? this.getStyle(margin) : margin | ||
| }; | ||
| } | ||
|
|
||
| private createTextDoc(agendaItem: ViewAgendaItem): Content { | ||
| const style = this.getStyle(`body-text`); | ||
| const margin = this.getMargin(agendaItem); | ||
| const contentObject = agendaItem.content_object; | ||
| const text = contentObject.text ?? contentObject.description; | ||
|
|
||
| if (!this.isTopic(agendaItem.content_object)) { | ||
| return []; | ||
| } | ||
| if (agendaItem.content_object?.getCSVExportText) { | ||
| const entry = this.htmlToPdfService.convertHtml({ htmlText: agendaItem.content_object?.text ?? `` }); | ||
| return entry; | ||
| // If not agenda topic and no motion block, it's motion or assignment | ||
| if (contentObject.collection === 'motion_block') { | ||
| return this.motionBlockEntry(contentObject, margin); | ||
| } else return this.createHtmlEntry(text, contentObject.collection, style, margin); | ||
| } else if (agendaItem.content_object?.getCSVExportText) { | ||
| // AGENDA TOPIC | ||
| const entry = this.htmlToPdfService.convertHtml({ | ||
| htmlText: | ||
| agendaItem.content_object?.text ?? | ||
| this.translate.instant(`EMPTY ${agendaItem.content_object?.collection}`) | ||
| }); | ||
| return { text: [...entry], style: style, margin }; | ||
| } | ||
| return []; | ||
| } | ||
|
|
@@ -286,14 +325,51 @@ export class AgendaPdfCatalogExportService { | |
| const entry = this.htmlToPdfService.convertHtml({ htmlText: moderationNotes }); | ||
| if (moderationNotes) { | ||
| this._addExtraSpace = true; | ||
| return [ | ||
| { | ||
| text: this.translate.instant(`Moderation note`), | ||
| style: this.getStyle(`header3`), | ||
| margin: this.getStyle(`margin-header3`) | ||
| }, | ||
| entry | ||
| const moderationText = { | ||
| text: entry | ||
| }; | ||
| const text = this.translate.instant(`Moderation note`); | ||
| const style = [this.getStyle(`header3`), this.getStyle(`margin-body-text`)]; | ||
| const margin: [ | ||
| [number, number, number, number], | ||
| [number, number, number, number], | ||
| [number, number, number, number], | ||
| [number, number, number, number] | ||
| ] = [ | ||
| [20, 10, 0, 0], | ||
| [20, 10, 0, 0], | ||
| this.getStyle(`margin-header3`), | ||
| this.getStyle(`margin-moderation-note`) | ||
| ]; | ||
| // Indents the moderation note inside a subitem | ||
| if (agendaItem.level > 0) { | ||
| margin[0][0] = margin[0][0] + agendaItem.level * 10; | ||
| return [ | ||
| { | ||
| text: text, | ||
| style: style[0], | ||
| margin: margin[0] | ||
| }, | ||
| { | ||
| text: moderationText, | ||
| style: style[1], | ||
| margin: margin[0] | ||
| } | ||
| ]; | ||
| } else { | ||
| return [ | ||
| { | ||
| text: text, | ||
| style: style[0], | ||
| margin: margin[2] | ||
| }, | ||
| { | ||
| text: moderationText, | ||
| style: style[1], | ||
| margin: margin[3] | ||
| } | ||
| ]; | ||
| } | ||
| } else { | ||
| return []; | ||
| } | ||
|
|
@@ -517,27 +593,38 @@ export class AgendaPdfCatalogExportService { | |
| private getStyle(name: string): any { | ||
| switch (name) { | ||
| case `header1`: | ||
| return { bold: true, fontSize: 24 }; | ||
| case `header2`: | ||
| return { bold: true, fontSize: 20 }; | ||
| case `header2`: | ||
| return { bold: true, fontSize: 16 }; | ||
| case `header3`: | ||
| return { bold: true, fontSize: 14 }; | ||
| return { bold: true, fontSize: 12 }; | ||
| case `header-child`: | ||
| return { bold: true, fontSize: 16 }; | ||
| return { bold: true, fontSize: 14 }; | ||
| case `table-header`: | ||
| return { bold: true, fontSize: 12 }; | ||
| return { bold: true, fontSize: 10 }; | ||
| case `body-text`: | ||
| return { fontSize: 10 }; | ||
| case `grey`: | ||
| return { layout: TABLEROW_GREY }; | ||
| case `italics`: | ||
| return { italics: true }; | ||
| case `margin-header1`: | ||
| // [L,U,R,D] | ||
| case `agenda-title`: | ||
| return [0, 0, 0, 20]; | ||
| case `margin-header1`: | ||
| return [0, 0, 0, 0]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not seem right. Why even create a style when everything is zero? |
||
| case `margin-header3`: | ||
| return [0, 15, 0, 10]; | ||
| return [15, 10, 0, 0]; | ||
| case `margin-header-child`: | ||
| return [15, 0, 0, 0]; | ||
| case `margin-type-text`: | ||
| return [0, 0, 0, 10]; | ||
| return [12, 0, 0, 0]; | ||
| case `margin-body-text`: | ||
| return [0, 10, 0, 5]; | ||
| case `margin-moderation-note`: | ||
| return [15, 10, 0, 5]; | ||
| case `margin-item`: | ||
| return [0, 0, 0, 5]; | ||
| return [0, 0, 0, 0]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All zero too |
||
| case `margin-item-2`: | ||
| return [0, 10, 0, 5]; | ||
| default: | ||
|
|
@@ -593,4 +680,39 @@ export class AgendaPdfCatalogExportService { | |
| const topic = obj as ViewTopic; | ||
| return !!topic && topic.collection !== undefined && topic.collection === ViewTopic.COLLECTION && !!topic.topic; | ||
| } | ||
|
|
||
| public getMargin(agendaItem: ViewAgendaItem): any { | ||
| const indentationLevel = agendaItem.level * 10 + 10; | ||
| return agendaItem.level > 0 ? [indentationLevel, 10, 0, 0] : this.getStyle(`margin-body-text`); | ||
| } | ||
|
|
||
| public createHtmlEntry(text: string | undefined, collection: string, style: any, margin: number[]): any { | ||
| const htmlText = text ?? this.translate.instant('EMPTY') + collection; | ||
| const entry = this.htmlToPdfService.convertHtml({ htmlText }); | ||
| return { text: [...entry], style, margin }; | ||
| } | ||
|
|
||
| public motionBlockEntry(contentObject: any, margin: number[]): any { | ||
| const motions: ViewMotion[] = contentObject?.motions || []; | ||
| const adjustedMargin = [...margin]; | ||
| adjustedMargin[3] -= 5; | ||
|
|
||
| if (!motions.length) { | ||
| return [ | ||
| { | ||
| text: this.translate.instant('EMPTY') + contentObject.collection, | ||
| style: this.getStyle('header3'), | ||
| margin: adjustedMargin | ||
| } | ||
| ]; | ||
| } | ||
|
|
||
| return motions.map(m => ({ | ||
| text: this.htmlToPdfService.convertHtml({ | ||
| htmlText: `${this.translate.instant('Motion')} ${m.number}: ${m.title}` | ||
| }), | ||
| style: this.getStyle('header3'), | ||
| margin: adjustedMargin | ||
| })); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too messy.