From 2c5d8ea29ef9a37761f24815bed043782942db9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Sch=C3=BCtze?= Date: Sat, 19 Jan 2019 18:50:05 +0100 Subject: [PATCH] Improved history table. --- client/src/app/core/marked-translations.ts | 12 +++++++++ .../history-list/history-list.component.html | 26 +++++++++---------- .../history-list/history-list.component.ts | 18 ++++++++++++- .../app/site/history/models/view-history.ts | 2 +- openslides/core/serializers.py | 2 ++ 5 files changed, 44 insertions(+), 16 deletions(-) diff --git a/client/src/app/core/marked-translations.ts b/client/src/app/core/marked-translations.ts index 2e9e15bdd..527a27179 100644 --- a/client/src/app/core/marked-translations.ts +++ b/client/src/app/core/marked-translations.ts @@ -333,3 +333,15 @@ _('Admin'); _('Delegates'); _('Staff'); _('Committees'); + +// history strings +_('Motion deleted'); +_('Motion updated'); +_('Submitters changed'); +_('Supporters changed'); +_('State set to {arg1}'); +_('Recommendation set to {arg1}'); +_('Vote created'); +_('Vote updated'); +_('Vote deleted'); +_('Number set'); diff --git a/client/src/app/site/history/components/history-list/history-list.component.html b/client/src/app/site/history/components/history-list/history-list.component.html index 8a31e3617..c6236fa77 100644 --- a/client/src/app/site/history/components/history-list/history-list.component.html +++ b/client/src/app/site/history/components/history-list/history-list.component.html @@ -8,24 +8,16 @@ - + - Time - {{ history.getLocaleString('DE-de') }} - - - - - Info - {{ history.information }} + Timestamp + {{ history.getLocaleString('DE-de') }} - Element - - + Element
{{ getElementInfo(history) | translate }}
+ + + Comment + {{ parseInformation(history.information) }} + + - User - {{ history.user }} + Changed by + {{ history.user }} diff --git a/client/src/app/site/history/components/history-list/history-list.component.ts b/client/src/app/site/history/components/history-list/history-list.component.ts index 5ecd21bba..b4c2b80a2 100644 --- a/client/src/app/site/history/components/history-list/history-list.component.ts +++ b/client/src/app/site/history/components/history-list/history-list.component.ts @@ -60,7 +60,7 @@ export class HistoryListComponent extends ListViewBaseComponent imp * @param unsortedHistoryList */ private sortAndPublish(unsortedHistoryList: ViewHistory[]): void { - const sortedList = unsortedHistoryList.map(history => history); + const sortedList = unsortedHistoryList.map(history => history).filter(item => item.information.length > 0); sortedList.sort((a, b) => b.history.unixtime - a.history.unixtime); this.dataSource.data = sortedList; } @@ -109,4 +109,20 @@ export class HistoryListComponent extends ListViewBaseComponent imp public onDeleteAllButton(): void { this.repo.delete(); } + + /** + * Returns a translated history information string which contains optional (translated) arguments. + * + * @param information history information string + */ + public parseInformation(information: string): void { + if (information.length) { + const base_string = this.translate.instant(information[0]); + let argument_string; + if (information.length > 1) { + argument_string = this.translate.instant(information[1]); + } + return base_string.replace(/{arg1}/g, argument_string); + } + } } diff --git a/client/src/app/site/history/models/view-history.ts b/client/src/app/site/history/models/view-history.ts index b53a6b910..846710b4b 100644 --- a/client/src/app/site/history/models/view-history.ts +++ b/client/src/app/site/history/models/view-history.ts @@ -43,7 +43,7 @@ export class ViewHistory extends BaseViewModel { } /** - * Get the elementIs of the history object + * Get the elementIDs of the history object * * @returns the element ID as String */ diff --git a/openslides/core/serializers.py b/openslides/core/serializers.py index c95e69cc8..2ce26973f 100644 --- a/openslides/core/serializers.py +++ b/openslides/core/serializers.py @@ -167,6 +167,8 @@ class HistorySerializer(ModelSerializer): Does not contain full data of history object. """ + information = JSONSerializerField() + class Meta: model = History fields = ("id", "element_id", "now", "information", "restricted", "user")