From cc456fdb5a46d15246087ab6577f6cb512a0af35 Mon Sep 17 00:00:00 2001 From: GabrielMeyer Date: Mon, 2 Sep 2019 14:52:08 +0200 Subject: [PATCH] Removes the item-number from items in PDF - ...for exporting the agenda-list. - Fixes #4965 --- .../agenda/item-repository.service.ts | 16 ++++++++++++++++ ...list-of-speakers-content-object-repository.ts | 12 ++++++++++++ ...e-is-agenda-item-content-object-repository.ts | 13 +++++++++++++ .../motions/motion-repository.service.ts | 11 +++++++++++ .../topics/topic-repository.service.ts | 9 +++++++++ .../site/agenda/services/agenda-pdf.service.ts | 2 +- ...odel-with-agenda-item-and-list-of-speakers.ts | 1 + .../base/base-view-model-with-agenda-item.ts | 10 ++++++++++ 8 files changed, 73 insertions(+), 1 deletion(-) diff --git a/client/src/app/core/repositories/agenda/item-repository.service.ts b/client/src/app/core/repositories/agenda/item-repository.service.ts index 5ca35f94e..97f8b69af 100644 --- a/client/src/app/core/repositories/agenda/item-repository.service.ts +++ b/client/src/app/core/repositories/agenda/item-repository.service.ts @@ -91,6 +91,22 @@ export class ItemRepositoryService extends BaseHasContentObjectRepository< } }; + /** + * Overrides the base function. + * + * @returns The title without any prefix like item number. + */ + public getTitleWithoutItemNumber = (titleInformation: ItemTitleInformation) => { + if (titleInformation.contentObject) { + return titleInformation.contentObject.getAgendaListTitleWithoutItemNumber(); + } else { + const repo = this.collectionStringMapperService.getRepository( + titleInformation.contentObjectData.collection + ) as BaseIsAgendaItemContentObjectRepository; + return repo.getAgendaListTitleWithoutItemNumber(titleInformation.title_information); + } + }; + /** * Trigger the automatic numbering sequence on the server */ diff --git a/client/src/app/core/repositories/base-is-agenda-item-and-list-of-speakers-content-object-repository.ts b/client/src/app/core/repositories/base-is-agenda-item-and-list-of-speakers-content-object-repository.ts index e9ea37edc..040084e2e 100644 --- a/client/src/app/core/repositories/base-is-agenda-item-and-list-of-speakers-content-object-repository.ts +++ b/client/src/app/core/repositories/base-is-agenda-item-and-list-of-speakers-content-object-repository.ts @@ -64,6 +64,17 @@ export abstract class BaseIsAgendaItemAndListOfSpeakersContentObjectRepository< return numberPrefix + this.getTitle(titleInformation); } + /** + * Function to get the list-title without the item-number. + * + * @param titleInformation The title-information for an object. + * + * @returns {string} The title without any prefix like item-number. + */ + public getAgendaListTitleWithoutItemNumber(titleInformation: T): string { + return this.getTitle(titleInformation) + ' (' + this.getVerboseName() + ')'; + } + public getListOfSpeakersTitle = (titleInformation: T) => { return this.getAgendaListTitle(titleInformation); }; @@ -75,6 +86,7 @@ export abstract class BaseIsAgendaItemAndListOfSpeakersContentObjectRepository< protected createViewModelWithTitles(model: M, initialLoading: boolean): V { const viewModel = super.createViewModelWithTitles(model, initialLoading); viewModel.getAgendaListTitle = () => this.getAgendaListTitle(viewModel); + viewModel.getAgendaListTitleWithoutItemNumber = () => this.getAgendaListTitleWithoutItemNumber(viewModel); viewModel.getAgendaSlideTitle = () => this.getAgendaSlideTitle(viewModel); viewModel.getListOfSpeakersTitle = () => this.getListOfSpeakersTitle(viewModel); viewModel.getListOfSpeakersSlideTitle = () => this.getListOfSpeakersSlideTitle(viewModel); diff --git a/client/src/app/core/repositories/base-is-agenda-item-content-object-repository.ts b/client/src/app/core/repositories/base-is-agenda-item-content-object-repository.ts index 1953a8215..e82a6aa11 100644 --- a/client/src/app/core/repositories/base-is-agenda-item-content-object-repository.ts +++ b/client/src/app/core/repositories/base-is-agenda-item-content-object-repository.ts @@ -30,6 +30,7 @@ export interface IBaseIsAgendaItemContentObjectRepository< T extends TitleInformationWithAgendaItem > extends BaseRepository { getAgendaListTitle: (titleInformation: T) => string; + getAgendaListTitleWithoutItemNumber: (titleInformation: T) => string; getAgendaSlideTitle: (titleInformation: T) => string; } @@ -83,6 +84,17 @@ export abstract class BaseIsAgendaItemContentObjectRepository< return numberPrefix + this.getTitle(titleInformation) + ' (' + this.getVerboseName() + ')'; } + /** + * Function to return the title without item-number, in example used for pdf-creation. + * + * @param titleInformation The title information. + * + * @returns {string} The title without any prefix like the item-number. + */ + public getAgendaListTitleWithoutItemNumber(titleInformation: T): string { + return this.getTitle(titleInformation) + ' (' + this.getVerboseName() + ')'; + } + /** * @returns the agenda title for the item slides */ @@ -96,6 +108,7 @@ export abstract class BaseIsAgendaItemContentObjectRepository< protected createViewModelWithTitles(model: M, initialLoading: boolean): V { const viewModel = super.createViewModelWithTitles(model, initialLoading); viewModel.getAgendaListTitle = () => this.getAgendaListTitle(viewModel); + viewModel.getAgendaListTitleWithoutItemNumber = () => this.getAgendaListTitleWithoutItemNumber(viewModel); viewModel.getAgendaSlideTitle = () => this.getAgendaSlideTitle(viewModel); return viewModel; } diff --git a/client/src/app/core/repositories/motions/motion-repository.service.ts b/client/src/app/core/repositories/motions/motion-repository.service.ts index 5bd1f0645..63141942d 100644 --- a/client/src/app/core/repositories/motions/motion-repository.service.ts +++ b/client/src/app/core/repositories/motions/motion-repository.service.ts @@ -267,6 +267,17 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo } }; + /** + * @override The base function + */ + public getAgendaListTitleWithoutItemNumber = (titleInformation: MotionTitleInformation) => { + if (titleInformation.identifier) { + return this.translate.instant('Motion') + ' ' + titleInformation.identifier; + } else { + return titleInformation.title + `(${this.getVerboseName()})`; + } + }; + public getVerboseName = (plural: boolean = false) => { return this.translate.instant(plural ? 'Motions' : 'Motion'); }; diff --git a/client/src/app/core/repositories/topics/topic-repository.service.ts b/client/src/app/core/repositories/topics/topic-repository.service.ts index b0668d066..148833c3b 100644 --- a/client/src/app/core/repositories/topics/topic-repository.service.ts +++ b/client/src/app/core/repositories/topics/topic-repository.service.ts @@ -69,6 +69,15 @@ export class TopicRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCon return this.getTitle(titleInformation); }; + /** + * @override The base function. + * + * @returns The plain title. + */ + public getAgendaListTitleWithoutItemNumber = (titleInformation: TopicTitleInformation) => { + return titleInformation.title; + }; + public getVerboseName = (plural: boolean = false) => { return this.translate.instant(plural ? 'Topics' : 'Topic'); }; diff --git a/client/src/app/site/agenda/services/agenda-pdf.service.ts b/client/src/app/site/agenda/services/agenda-pdf.service.ts index 798d81ac9..d6f54c3e7 100644 --- a/client/src/app/site/agenda/services/agenda-pdf.service.ts +++ b/client/src/app/site/agenda/services/agenda-pdf.service.ts @@ -87,7 +87,7 @@ export class AgendaPdfService { text: nodeItem.item.itemNumber }, { - text: nodeItem.item.getTitle() + text: nodeItem.item.contentObject.getAgendaListTitleWithoutItemNumber() } ] }; diff --git a/client/src/app/site/base/base-view-model-with-agenda-item-and-list-of-speakers.ts b/client/src/app/site/base/base-view-model-with-agenda-item-and-list-of-speakers.ts index 6b7c62aa2..655d83cef 100644 --- a/client/src/app/site/base/base-view-model-with-agenda-item-and-list-of-speakers.ts +++ b/client/src/app/site/base/base-view-model-with-agenda-item-and-list-of-speakers.ts @@ -46,6 +46,7 @@ export abstract class BaseViewModelWithAgendaItemAndListOfSpeakers< public getAgendaSlideTitle: () => string; public getAgendaListTitle: () => string; + public getAgendaListTitleWithoutItemNumber: () => string; public getListOfSpeakersTitle: () => string; public getListOfSpeakersSlideTitle: () => string; diff --git a/client/src/app/site/base/base-view-model-with-agenda-item.ts b/client/src/app/site/base/base-view-model-with-agenda-item.ts index 31e796cfd..dc7e3d010 100644 --- a/client/src/app/site/base/base-view-model-with-agenda-item.ts +++ b/client/src/app/site/base/base-view-model-with-agenda-item.ts @@ -46,6 +46,11 @@ export interface IBaseViewModelWithAgendaItem string; + /** + * @return the agenda title with the verbose name of the content object + */ + getAgendaListTitleWithoutItemNumber: () => string; + /** * @returns the (optional) descriptive text to be exported in the CSV. * May be overridden by inheriting classes @@ -85,6 +90,11 @@ export abstract class BaseViewModelWithAgendaItem string; + /** + * @return the agenda title without any item number. + */ + public getAgendaListTitleWithoutItemNumber: () => string; + public constructor(model: M, item?: any) { super(model); this._item = item || null; // Explicit set to null instead of undefined, if not given