From c56a2880a47c9307a2c761e20dff8e084888cbc1 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Mon, 17 Dec 2018 12:54:42 +0100 Subject: [PATCH] simpler csv export option for agenda type --- client/src/app/shared/models/agenda/item.ts | 18 +++++++++++++++--- client/src/app/site/agenda/models/view-item.ts | 7 +++++++ .../services/agenda-csv-export.service.ts | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/client/src/app/shared/models/agenda/item.ts b/client/src/app/shared/models/agenda/item.ts index e08e46081..1b64cf690 100644 --- a/client/src/app/shared/models/agenda/item.ts +++ b/client/src/app/shared/models/agenda/item.ts @@ -15,9 +15,9 @@ interface ContentObject { * Coming from "OpenSlidesConfigVariables" property "agenda_hide_internal_items_on_projector" */ export const itemVisibilityChoices = [ - { key: 1, name: 'Public item' }, - { key: 2, name: 'Internal item' }, - { key: 3, name: 'Hidden item' } + { key: 1, name: 'Public item', csvName: '' }, + { key: 2, name: 'Internal item', csvName: 'internal' }, + { key: 3, name: 'Hidden item', csvName: 'hidden' } ]; /** @@ -73,6 +73,18 @@ export class Item extends ProjectableBaseModel { return type ? type.name : ''; } + /** + * Gets a shortened string for CSV export + * @returns empty string if it is a public item, 'internal' or 'hidden' otherwise + */ + public get verboseCsvType(): string { + if (!this.type) { + return ''; + } + const type = itemVisibilityChoices.find(choice => choice.key === this.type); + return type ? type.csvName : ''; + } + public getTitle(): string { return this.title; } diff --git a/client/src/app/site/agenda/models/view-item.ts b/client/src/app/site/agenda/models/view-item.ts index 3c4be1932..8b20723a8 100644 --- a/client/src/app/site/agenda/models/view-item.ts +++ b/client/src/app/site/agenda/models/view-item.ts @@ -51,6 +51,13 @@ export class ViewItem extends BaseViewModel { return ''; } + public get verboseCsvType() : string { + if (this.item) { + return this.item.verboseCsvType; + } + return ''; + } + public constructor(item: Item, contentObject: AgendaBaseModel) { super(); this._item = item; diff --git a/client/src/app/site/agenda/services/agenda-csv-export.service.ts b/client/src/app/site/agenda/services/agenda-csv-export.service.ts index cbf9aaec7..8b4695fb8 100644 --- a/client/src/app/site/agenda/services/agenda-csv-export.service.ts +++ b/client/src/app/site/agenda/services/agenda-csv-export.service.ts @@ -33,7 +33,7 @@ export class AgendaCsvExportService { { label: 'Text', map: viewItem => viewItem.contentObject ? viewItem.contentObject.getCSVExportText() : '' }, { label: 'Duration', property: 'duration' }, { label: 'Comment', property: 'comment' }, - { label: 'Item type', property: 'verboseType' } + { label: 'Item type', property: 'verboseCsvType' } ], this.translate.instant('Agenda') + '.csv' );