Merge pull request #4238 from MaximilianKrambach/historyNavigate
navigate to detail view after setting the history mode
This commit is contained in:
commit
e281b310a7
@ -7,3 +7,13 @@ export interface DetailNavigable {
|
||||
*/
|
||||
getDetailStateURL(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if a given object implements implements this interface
|
||||
*
|
||||
* @param obj
|
||||
* @returns true if the interface is implemented
|
||||
*/
|
||||
export function isDetailNavigable(obj: object): obj is DetailNavigable {
|
||||
return (<DetailNavigable>obj).getDetailStateURL !== undefined;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Searchable } from '../base/searchable';
|
||||
import { SearchRepresentation } from '../../../core/ui-services/search.service';
|
||||
import { BaseModel } from '../base/base-model';
|
||||
import { DetailNavigable } from '../base/detail-navigable';
|
||||
|
||||
/**
|
||||
* Iterable pre selection of genders (sexes)
|
||||
@ -11,7 +12,7 @@ export const genders = ['Female', 'Male', 'Diverse'];
|
||||
* Representation of a user in contrast to the operator.
|
||||
* @ignore
|
||||
*/
|
||||
export class User extends BaseModel<User> implements Searchable {
|
||||
export class User extends BaseModel<User> implements Searchable, DetailNavigable {
|
||||
public static COLLECTIONSTRING = 'users/user';
|
||||
|
||||
public id: number;
|
||||
|
@ -14,7 +14,7 @@
|
||||
<mat-icon matSuffix>search</mat-icon>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<mat-table class="os-header-listview-table on-transition-fade" [dataSource]="dataSource" matSort>
|
||||
<mat-table class="os-headed-listview-table on-transition-fade" [dataSource]="dataSource" matSort>
|
||||
<!-- Timestamp -->
|
||||
<ng-container matColumnDef="time">
|
||||
<mat-header-cell *matHeaderCellDef translate>Timestamp</mat-header-cell>
|
||||
|
@ -1,12 +1,16 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { MatSnackBar } from '@angular/material';
|
||||
import { Router } from '@angular/router';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { ListViewBaseComponent } from 'app/site/base/list-view-base';
|
||||
import { HistoryRepositoryService } from 'app/core/repositories/history/history-repository.service';
|
||||
import { DataStoreService } from 'app/core/core-services/data-store.service';
|
||||
import { isDetailNavigable } from 'app/shared/models/base/detail-navigable';
|
||||
|
||||
import { ViewHistory } from '../../models/view-history';
|
||||
|
||||
/**
|
||||
@ -37,7 +41,9 @@ export class HistoryListComponent extends ListViewBaseComponent<ViewHistory> imp
|
||||
titleService: Title,
|
||||
translate: TranslateService,
|
||||
matSnackBar: MatSnackBar,
|
||||
private repo: HistoryRepositoryService
|
||||
private repo: HistoryRepositoryService,
|
||||
private DS: DataStoreService,
|
||||
private router: Router
|
||||
) {
|
||||
super(titleService, translate, matSnackBar);
|
||||
}
|
||||
@ -100,7 +106,19 @@ export class HistoryListComponent extends ListViewBaseComponent<ViewHistory> imp
|
||||
*/
|
||||
public onClickRow(history: ViewHistory): void {
|
||||
this.repo.browseHistory(history).then(() => {
|
||||
this.raiseError(`Temporarily reset OpenSlides to the state from ${history.getLocaleString('DE-de')}`);
|
||||
const element = this.DS.get(history.getCollectionString(), history.getModelID());
|
||||
let message = this.translate.instant('Temporarily reset OpenSlides to the state from ');
|
||||
message += history.getLocaleString('DE-de') + '. ';
|
||||
|
||||
if (isDetailNavigable(element)) {
|
||||
message += this.translate.instant(
|
||||
'You will be redirected to the detail state of the last changed item.'
|
||||
);
|
||||
this.raiseError(message);
|
||||
this.router.navigate([element.getDetailStateURL()]);
|
||||
} else {
|
||||
this.raiseError(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user