Adjusts pagination to default code style.
This commit is contained in:
parent
279b8b1d25
commit
15ca6cfec7
@ -38,12 +38,12 @@ export abstract class ListViewBaseComponent<V extends BaseViewModel, M extends B
|
|||||||
* Holds the key for the storage.
|
* Holds the key for the storage.
|
||||||
* This is by default the component's name.
|
* This is by default the component's name.
|
||||||
*/
|
*/
|
||||||
private storageKey: string;
|
private paginationStorageKey: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the value from local storage with the 'Paginator' key.
|
* Holds the value from local storage with the 'Paginator' key.
|
||||||
*/
|
*/
|
||||||
private storageObject = {};
|
private paginationStorageObject: { [key: string]: number };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The table itself
|
* The table itself
|
||||||
@ -82,17 +82,17 @@ export abstract class ListViewBaseComponent<V extends BaseViewModel, M extends B
|
|||||||
titleService: Title,
|
titleService: Title,
|
||||||
translate: TranslateService,
|
translate: TranslateService,
|
||||||
matSnackBar: MatSnackBar,
|
matSnackBar: MatSnackBar,
|
||||||
protected route: ActivatedRoute,
|
protected route?: ActivatedRoute,
|
||||||
private storage: StorageService,
|
protected storage?: StorageService,
|
||||||
public filterService?: BaseFilterListService<M, V>,
|
public filterService?: BaseFilterListService<M, V>,
|
||||||
public sortService?: BaseSortListService<V>
|
public sortService?: BaseSortListService<V>
|
||||||
) {
|
) {
|
||||||
super(titleService, translate, matSnackBar);
|
super(titleService, translate, matSnackBar);
|
||||||
this.selectedRows = [];
|
this.selectedRows = [];
|
||||||
try {
|
try {
|
||||||
this.storageKey = (<Type<any>>route.component).name;
|
this.paginationStorageKey = (<Type<any>>route.component).name;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.storageKey = '';
|
this.paginationStorageKey = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ export abstract class ListViewBaseComponent<V extends BaseViewModel, M extends B
|
|||||||
* Calling these three functions in the constructor of this class
|
* Calling these three functions in the constructor of this class
|
||||||
* would be too early, resulting in non-paginated tables
|
* would be too early, resulting in non-paginated tables
|
||||||
*/
|
*/
|
||||||
public async initTable(): Promise<void> {
|
public initTable(): void {
|
||||||
this.dataSource = new MatTableDataSource();
|
this.dataSource = new MatTableDataSource();
|
||||||
this.dataSource.paginator = this.paginator;
|
this.dataSource.paginator = this.paginator;
|
||||||
// Set the initial page settings.
|
// Set the initial page settings.
|
||||||
@ -173,13 +173,13 @@ export abstract class ListViewBaseComponent<V extends BaseViewModel, M extends B
|
|||||||
private async initializePagination(): Promise<void> {
|
private async initializePagination(): Promise<void> {
|
||||||
// If the storage is not available - like in history mode - do nothing.
|
// If the storage is not available - like in history mode - do nothing.
|
||||||
if (this.storage) {
|
if (this.storage) {
|
||||||
this.storageObject = (await this.storage.get('Pagination')) || {};
|
this.paginationStorageObject = (await this.storage.get('Pagination')) || {};
|
||||||
// Set the number of items per page -- by default to 25.
|
// Set the number of items per page -- by default to 25.
|
||||||
this.paginator.pageSize = this.storageObject[this.storageKey] || 25;
|
this.paginator.pageSize = this.paginationStorageObject[this.paginationStorageKey] || 25;
|
||||||
// Subscription to page change events, like size, index.
|
// Subscription to page change events, like size, index.
|
||||||
this.subscriptions.push(
|
this.subscriptions.push(
|
||||||
this.paginator.page.subscribe(async (event: PageEvent) => {
|
this.paginator.page.subscribe((event: PageEvent) => {
|
||||||
await this.setPageSettings(event.pageSize);
|
this.setPageSettings(event.pageSize);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -191,8 +191,10 @@ export abstract class ListViewBaseComponent<V extends BaseViewModel, M extends B
|
|||||||
* @param size is the new page size.
|
* @param size is the new page size.
|
||||||
*/
|
*/
|
||||||
public async setPageSettings(size: number): Promise<void> {
|
public async setPageSettings(size: number): Promise<void> {
|
||||||
this.storageObject[this.storageKey] = size;
|
if (this.paginationStorageObject) {
|
||||||
await this.storage.set('Pagination', this.storageObject);
|
this.paginationStorageObject[this.paginationStorageKey] = size;
|
||||||
|
await this.storage.set('Pagination', this.paginationStorageObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +51,7 @@ export class HistoryListComponent extends ListViewBaseComponent<ViewHistory, His
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private operator: OperatorService
|
private operator: OperatorService
|
||||||
) {
|
) {
|
||||||
super(titleService, translate, matSnackBar, null, null);
|
super(titleService, translate, matSnackBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,11 +88,11 @@ export class MediafileListComponent extends ListViewBaseComponent<ViewMediafile,
|
|||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor(
|
||||||
titleService: Title,
|
titleService: Title,
|
||||||
matSnackBar: MatSnackBar,
|
|
||||||
storage: StorageService,
|
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
|
matSnackBar: MatSnackBar,
|
||||||
|
route: ActivatedRoute,
|
||||||
|
storage: StorageService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
protected route: ActivatedRoute,
|
|
||||||
private repo: MediafileRepositoryService,
|
private repo: MediafileRepositoryService,
|
||||||
private mediaManage: MediaManageService,
|
private mediaManage: MediaManageService,
|
||||||
private promptService: PromptService,
|
private promptService: PromptService,
|
||||||
|
@ -63,10 +63,10 @@ export class MotionBlockDetailComponent extends ListViewBaseComponent<ViewMotion
|
|||||||
titleService: Title,
|
titleService: Title,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
matSnackBar: MatSnackBar,
|
matSnackBar: MatSnackBar,
|
||||||
|
route: ActivatedRoute,
|
||||||
storage: StorageService,
|
storage: StorageService,
|
||||||
private operator: OperatorService,
|
private operator: OperatorService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
protected route: ActivatedRoute,
|
|
||||||
private repo: MotionBlockRepositoryService,
|
private repo: MotionBlockRepositoryService,
|
||||||
private motionRepo: MotionRepositoryService,
|
private motionRepo: MotionRepositoryService,
|
||||||
private promptService: PromptService
|
private promptService: PromptService
|
||||||
|
@ -81,9 +81,9 @@ export class MotionBlockListComponent extends ListViewBaseComponent<ViewMotionBl
|
|||||||
titleService: Title,
|
titleService: Title,
|
||||||
translate: TranslateService,
|
translate: TranslateService,
|
||||||
matSnackBar: MatSnackBar,
|
matSnackBar: MatSnackBar,
|
||||||
|
route: ActivatedRoute,
|
||||||
storage: StorageService,
|
storage: StorageService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
protected route: ActivatedRoute,
|
|
||||||
private repo: MotionBlockRepositoryService,
|
private repo: MotionBlockRepositoryService,
|
||||||
private agendaRepo: ItemRepositoryService,
|
private agendaRepo: ItemRepositoryService,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
|
@ -89,11 +89,11 @@ export class MotionListComponent extends ListViewBaseComponent<ViewMotion, Motio
|
|||||||
titleService: Title,
|
titleService: Title,
|
||||||
protected translate: TranslateService, // protected required for ng-translate-extract
|
protected translate: TranslateService, // protected required for ng-translate-extract
|
||||||
matSnackBar: MatSnackBar,
|
matSnackBar: MatSnackBar,
|
||||||
sortService: MotionSortListService,
|
route: ActivatedRoute,
|
||||||
filterService: MotionFilterListService,
|
|
||||||
storage: StorageService,
|
storage: StorageService,
|
||||||
|
filterService: MotionFilterListService,
|
||||||
|
sortService: MotionSortListService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
protected route: ActivatedRoute,
|
|
||||||
private configService: ConfigService,
|
private configService: ConfigService,
|
||||||
private tagRepo: TagRepositoryService,
|
private tagRepo: TagRepositoryService,
|
||||||
private motionBlockRepo: MotionBlockRepositoryService,
|
private motionBlockRepo: MotionBlockRepositoryService,
|
||||||
|
@ -45,12 +45,12 @@ export class WorkflowListComponent extends ListViewBaseComponent<ViewWorkflow, W
|
|||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor(
|
||||||
titleService: Title,
|
titleService: Title,
|
||||||
matSnackBar: MatSnackBar,
|
|
||||||
storage: StorageService,
|
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
|
matSnackBar: MatSnackBar,
|
||||||
|
route: ActivatedRoute,
|
||||||
|
storage: StorageService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
protected route: ActivatedRoute,
|
|
||||||
private workflowRepo: WorkflowRepositoryService,
|
private workflowRepo: WorkflowRepositoryService,
|
||||||
private promptService: PromptService
|
private promptService: PromptService
|
||||||
) {
|
) {
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
import { Tag } from 'app/shared/models/core/tag';
|
|
||||||
import { ListViewBaseComponent } from '../../../base/list-view-base';
|
|
||||||
import { TagRepositoryService } from 'app/core/repositories/tags/tag-repository.service';
|
|
||||||
import { ViewTag } from '../../models/view-tag';
|
|
||||||
import { FormGroup, FormControl, Validators } from '@angular/forms';
|
import { FormGroup, FormControl, Validators } from '@angular/forms';
|
||||||
import { PromptService } from 'app/core/ui-services/prompt.service';
|
|
||||||
import { MatSnackBar } from '@angular/material';
|
|
||||||
import { StorageService } from 'app/core/core-services/storage.service';
|
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { MatSnackBar } from '@angular/material';
|
||||||
|
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
|
import { Tag } from 'app/shared/models/core/tag';
|
||||||
|
import { TagRepositoryService } from 'app/core/repositories/tags/tag-repository.service';
|
||||||
|
import { PromptService } from 'app/core/ui-services/prompt.service';
|
||||||
|
import { StorageService } from 'app/core/core-services/storage.service';
|
||||||
|
import { ListViewBaseComponent } from '../../../base/list-view-base';
|
||||||
|
import { ViewTag } from '../../models/view-tag';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listview for the complete lsit of available Tags
|
* Listview for the complete lsit of available Tags
|
||||||
@ -43,8 +45,8 @@ export class TagListComponent extends ListViewBaseComponent<ViewTag, Tag> implem
|
|||||||
titleService: Title,
|
titleService: Title,
|
||||||
protected translate: TranslateService, // protected required for ng-translate-extract
|
protected translate: TranslateService, // protected required for ng-translate-extract
|
||||||
matSnackBar: MatSnackBar,
|
matSnackBar: MatSnackBar,
|
||||||
storage: StorageService,
|
|
||||||
route: ActivatedRoute,
|
route: ActivatedRoute,
|
||||||
|
storage: StorageService,
|
||||||
private repo: TagRepositoryService,
|
private repo: TagRepositoryService,
|
||||||
private promptService: PromptService
|
private promptService: PromptService
|
||||||
) {
|
) {
|
||||||
|
@ -134,12 +134,12 @@ export class UserListComponent extends ListViewBaseComponent<ViewUser, User> imp
|
|||||||
titleService: Title,
|
titleService: Title,
|
||||||
protected translate: TranslateService, // protected required for ng-translate-extract
|
protected translate: TranslateService, // protected required for ng-translate-extract
|
||||||
matSnackBar: MatSnackBar,
|
matSnackBar: MatSnackBar,
|
||||||
|
route: ActivatedRoute,
|
||||||
storage: StorageService,
|
storage: StorageService,
|
||||||
private repo: UserRepositoryService,
|
private repo: UserRepositoryService,
|
||||||
private groupRepo: GroupRepositoryService,
|
private groupRepo: GroupRepositoryService,
|
||||||
private choiceService: ChoiceService,
|
private choiceService: ChoiceService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
protected route: ActivatedRoute,
|
|
||||||
private operator: OperatorService,
|
private operator: OperatorService,
|
||||||
private vp: ViewportService,
|
private vp: ViewportService,
|
||||||
protected csvExport: CsvExportService,
|
protected csvExport: CsvExportService,
|
||||||
|
Loading…
Reference in New Issue
Block a user