Merge pull request #4147 from emanuelschuetze/history-table
Improved history table.
This commit is contained in:
commit
251cc4acc1
@ -333,3 +333,15 @@ _('Admin');
|
|||||||
_('Delegates');
|
_('Delegates');
|
||||||
_('Staff');
|
_('Staff');
|
||||||
_('Committees');
|
_('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');
|
||||||
|
@ -8,24 +8,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</os-head-bar>
|
</os-head-bar>
|
||||||
|
|
||||||
<mat-table class="os-listview-table on-transition-fade" [dataSource]="dataSource" matSort>
|
<mat-table class="os-header-listview-table on-transition-fade" [dataSource]="dataSource" matSort>
|
||||||
<!-- Timestamp -->
|
<!-- Timestamp -->
|
||||||
<ng-container matColumnDef="time">
|
<ng-container matColumnDef="time">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Time</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef translate>Timestamp</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let history"> {{ history.getLocaleString('DE-de') }} </mat-cell>
|
<mat-cell *matCellDef="let history">{{ history.getLocaleString('DE-de') }}</mat-cell>
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<!-- Info -->
|
|
||||||
<ng-container matColumnDef="info">
|
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Info</mat-header-cell>
|
|
||||||
<mat-cell *matCellDef="let history"> {{ history.information }} </mat-cell>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- Element -->
|
<!-- Element -->
|
||||||
<ng-container matColumnDef="element">
|
<ng-container matColumnDef="element">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Element</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef translate>Element</mat-header-cell>
|
||||||
|
|
||||||
<!-- <mat-cell *matCellDef="let history"> {{ history.element_id }} </mat-cell> -->
|
|
||||||
<mat-cell *matCellDef="let history">
|
<mat-cell *matCellDef="let history">
|
||||||
<div *ngIf="getElementInfo(history)">{{ getElementInfo(history) | translate }}</div>
|
<div *ngIf="getElementInfo(history)">{{ getElementInfo(history) | translate }}</div>
|
||||||
<div
|
<div
|
||||||
@ -38,10 +30,16 @@
|
|||||||
</mat-cell>
|
</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- Info -->
|
||||||
|
<ng-container matColumnDef="info">
|
||||||
|
<mat-header-cell *matHeaderCellDef translate>Comment</mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let history">{{ parseInformation(history.information) }}</mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<!-- User -->
|
<!-- User -->
|
||||||
<ng-container matColumnDef="user">
|
<ng-container matColumnDef="user">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header>User</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef translate>Changed by</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let history"> {{ history.user }} </mat-cell>
|
<mat-cell *matCellDef="let history">{{ history.user }}</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<mat-header-row *matHeaderRowDef="getRowDef()"></mat-header-row>
|
<mat-header-row *matHeaderRowDef="getRowDef()"></mat-header-row>
|
||||||
|
@ -60,7 +60,7 @@ export class HistoryListComponent extends ListViewBaseComponent<ViewHistory> imp
|
|||||||
* @param unsortedHistoryList
|
* @param unsortedHistoryList
|
||||||
*/
|
*/
|
||||||
private sortAndPublish(unsortedHistoryList: ViewHistory[]): void {
|
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);
|
sortedList.sort((a, b) => b.history.unixtime - a.history.unixtime);
|
||||||
this.dataSource.data = sortedList;
|
this.dataSource.data = sortedList;
|
||||||
}
|
}
|
||||||
@ -109,4 +109,20 @@ export class HistoryListComponent extends ListViewBaseComponent<ViewHistory> imp
|
|||||||
public onDeleteAllButton(): void {
|
public onDeleteAllButton(): void {
|
||||||
this.repo.delete();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
* @returns the element ID as String
|
||||||
*/
|
*/
|
||||||
|
@ -167,6 +167,8 @@ class HistorySerializer(ModelSerializer):
|
|||||||
Does not contain full data of history object.
|
Does not contain full data of history object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
information = JSONSerializerField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = History
|
model = History
|
||||||
fields = ("id", "element_id", "now", "information", "restricted", "user")
|
fields = ("id", "element_id", "now", "information", "restricted", "user")
|
||||||
|
Loading…
Reference in New Issue
Block a user