KON-438 total commit without unit tests
Signed-off-by: Peter Buschmann <peter.buschmann@pta.de>
diff --git a/src/app/pages/contacts/contacts-list/contacts-list-column-definition.ts b/src/app/pages/contacts/contacts-list/contacts-list-column-definition.ts
index 8ca0601..940f047 100644
--- a/src/app/pages/contacts/contacts-list/contacts-list-column-definition.ts
+++ b/src/app/pages/contacts/contacts-list/contacts-list-column-definition.ts
@@ -77,6 +77,7 @@
},
{
field: 'tools',
+ colId: 'tools',
headerName: ' ',
pinned: 'right',
maxWidth: 110,
diff --git a/src/app/pages/contacts/contacts-list/contacts-list.component.html b/src/app/pages/contacts/contacts-list/contacts-list.component.html
index badcfa7..6a44871 100644
--- a/src/app/pages/contacts/contacts-list/contacts-list.component.html
+++ b/src/app/pages/contacts/contacts-list/contacts-list.component.html
@@ -23,6 +23,7 @@
id="search-text"
style="position: 0px;font-size: 13px; line-height:21px; color: #495057;"
placeholder="Suche"
+ [ngModel]="modifiedContacts.searchText"
(keyup)="setModifiedContactsSearchText($event.target.value); searchContacts($event)"
/>
@@ -30,6 +31,7 @@
[required]="false"
type="text"
class="form-control item"
+ [ngModel]="modifiedContacts.contactTypeId"
(change)="setModifiedContactsContactTypeId($event.target.value); searchContacts($event)"
>
<option value="{{ INTERNAL_PERSON }}">{{ 'Contacts.InternalContact' | translate }}</option>
@@ -44,7 +46,7 @@
type="button"
style="color: #495057;"
class="btn btn-default btn-sm"
- (click)="isDSGVOFilterAdvancedVisible = !isDSGVOFilterAdvancedVisible"
+ (click)="setDSGVOFilterAdvancedVisible()"
title="{{ 'Contacts.DSGVO-advanced-filter' | translate }}"
>
DSGVO
@@ -55,6 +57,7 @@
type="text"
class="form-control"
style="margin-right: 12px;"
+ [ngModel]="moduleDisplayName"
(change)="setModifiedContactsModuleAssignmentFilter($event.target.value); searchContacts($event)"
>
<option *ngFor="let moduleType of userModuleAssignmentSandbox.userModuleTypes$ | async" [value]="moduleType.id">{{ moduleType.id }}</option>
@@ -63,7 +66,13 @@
</select>
<div class="dsgvo-filter-item custom-control custom-switch" title="{{ 'Contacts.DSGVO-advanced-filter-expiring-data-in-past' | translate }}">
- <input type="checkbox" class="custom-control-input" id="expiry-date" (change)="setModifiedContactsExpiryDateFilter(); searchContacts($event)" />
+ <input
+ type="checkbox"
+ class="custom-control-input"
+ id="expiry-date"
+ [ngModel]="modifiedContacts.expiringDataInPast"
+ (change)="setModifiedContactsExpiryDateFilter(); searchContacts($event)"
+ />
<label
class="custom-control-label"
style="position: 0px;font-size: 13px; white-space: nowrap; line-height:21px; color: #495057;"
@@ -82,6 +91,7 @@
type="checkbox"
class="custom-control-input"
id="deletion-lock-until"
+ [ngModel]="modifiedContacts.deletionLockExceeded"
(change)="setModifiedContactsDeletionLockExceedFilter(); searchContacts($event)"
/>
<label
@@ -96,7 +106,13 @@
</div>
<div class="sorting-options diverse-options-item">
- <select [required]="false" type="text" class="form-control item" (change)="setSortingContactType($event.target.value); sortContacts()">
+ <select
+ [required]="false"
+ type="text"
+ class="form-control item"
+ [ngModel]="modifiedContacts.sort ? modifiedContacts.sort.substring(0, modifiedContacts.sort.indexOf(',')) : ''"
+ (change)="setSortingContactType($event.target.value); sortContacts()"
+ >
<option value="name">{{ 'Contacts.Name' | translate }}</option>
<option value="contactType">{{ 'Contacts.ContactType' | translate }}</option>
<option value="note">{{ 'Contacts.Note' | translate }}</option>
@@ -106,7 +122,13 @@
<option value="" selected>{{ 'NoSorting' | translate }}</option>
</select>
- <select [required]="false" type="text" class="form-control item" (change)="setSortingOrder($event.target.value); sortContacts()">
+ <select
+ [required]="false"
+ type="text"
+ class="form-control item"
+ [ngModel]="modifiedContacts.sort ? modifiedContacts.sort.substring(modifiedContacts.sort.indexOf(',') + 1) : 'asc'"
+ (change)="setSortingOrder($event.target.value); sortContacts()"
+ >
<option value="asc" selected>{{ 'AscendingSorting' | translate }}</option>
<option value="desc">{{ 'DescendingSorting' | translate }}</option>
</select>
@@ -123,6 +145,7 @@
</div>
<ag-grid-angular
+ (currentPageNumber)="contactsSandbox.setCurrentPageNumber($event)"
[serverside]="contactsSandbox.serversideModel"
[queryParameter]="modifiedContacts"
autoResizeColumns
diff --git a/src/app/pages/contacts/contacts-list/contacts-list.component.ts b/src/app/pages/contacts/contacts-list/contacts-list.component.ts
index 8576d49..daefb2f 100644
--- a/src/app/pages/contacts/contacts-list/contacts-list.component.ts
+++ b/src/app/pages/contacts/contacts-list/contacts-list.component.ts
@@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
-import { Component } from '@angular/core';
+import { Component, OnInit, OnDestroy } from '@angular/core';
import { ContactsSandbox } from '@pages/contacts/contacts.sandbox';
import { CONTACTS_COLDEF } from '@pages/contacts/contacts-list/contacts-list-column-definition';
import { BaseList } from '@shared/components/base-components/base.list';
@@ -18,13 +18,15 @@
import { Globals } from '@shared/constants/globals';
import { ModifiedContacts } from '@shared/models/modifiedContacts.model';
import { UserModuleAssignmentSandBox } from '@shared/components/list-details-view/user-module-assignment/user-module-assignment.sandbox';
+import { ColumnMovedEvent, GridReadyEvent } from 'ag-grid-community';
+import { Subscription } from 'rxjs';
@Component({
selector: 'app-contacts-list',
templateUrl: './contacts-list.component.html',
styleUrls: ['./contacts-list.component.scss'],
})
-export class ContactsListComponent extends BaseList {
+export class ContactsListComponent extends BaseList implements OnInit, OnDestroy {
public readonly NEW_EXTERNAL_PERSON_PATH = `/${Globals.PATH.PERSONS}/${Globals.PATH.EXTERNAL}/${Globals.PATH.NEW}`;
public readonly NEW_INTERNAL_PERSON_PATH = `/${Globals.PATH.PERSONS}/${Globals.PATH.INTERNAL}/${Globals.PATH.NEW}`;
public readonly NEW_COMPANY_PATH = `/${Globals.PATH.COMPANY}/${Globals.PATH.NEW}`;
@@ -37,11 +39,13 @@
public columnDefinition: any = CONTACTS_COLDEF;
public modifiedContacts: ModifiedContacts = new ModifiedContacts();
public isDSGVOFilterAdvancedVisible = false;
+ public moduleDisplayName: string = '';
private _sortingOrder: string = 'asc';
private _sortingContactType: string = '';
private _expiringDataInPast = false;
private _deletionLockExceeded = false;
+ private _subscription: Subscription;
constructor(public contactsSandbox: ContactsSandbox, public userModuleAssignmentSandbox: UserModuleAssignmentSandBox, private router: Router) {
super();
@@ -52,11 +56,42 @@
...this.gridOptions,
localeText: Globals.LOCALE_TEXT,
};
+ // save / retrieve column positions
+ this.gridOptions.onColumnMoved = this._saveColumnPositions.bind(this);
+ this.gridOptions.onGridReady = this._restoreColumnPositions.bind(this);
+ // context
this.gridOptions.context = {
...this.gridOptions.context,
icons: { edit: true, delete: false },
};
- this.gridOptions.context.eventSubject.subscribe(this._handleBusEvents.bind(this));
+ // handling icon events
+ this._subscription = this.gridOptions.context.eventSubject.subscribe(this._handleBusEvents.bind(this));
+ // save filter / search config
+ if (JSON.parse(sessionStorage.getItem(Globals.SESSSION_STORAGE_KEYS.contactListSearchFilterKey))) {
+ this.modifiedContacts = JSON.parse(sessionStorage.getItem(Globals.SESSSION_STORAGE_KEYS.contactListSearchFilterKey));
+ if (this.modifiedContacts.sort) {
+ //sonst wird bei rückkehr aus navigation die sort property null gesetzt (via _setModifiedContactsSort)
+ this._sortingContactType = this.modifiedContacts.sort.substring(0, this.modifiedContacts.sort.indexOf(','));
+ this._sortingOrder = this.modifiedContacts.sort.substring(this.modifiedContacts.sort.indexOf(',') + 1);
+ }
+ this.isDSGVOFilterAdvancedVisible = this.modifiedContacts.isDSGVOFilterAdvancedVisible;
+ this._expiringDataInPast = this.modifiedContacts.expiringDataInPast;
+ this._deletionLockExceeded = this.modifiedContacts.deletionLockExceeded;
+ // modifiedContacts modulWerte zurueckuebersetzen in Display modulWerte
+ this.setModifiedContactsModuleAssignmentFilterDisplayValues(this.modifiedContacts.moduleName, this.modifiedContacts.withoutAssignedModule);
+ }
+ }
+
+ private _saveColumnPositions(event: ColumnMovedEvent) {
+ let columnState = JSON.stringify(event.columnApi.getColumnState());
+ sessionStorage.setItem(Globals.SESSSION_STORAGE_KEYS.contactListColumnStateKey, columnState);
+ }
+
+ private _restoreColumnPositions(event: GridReadyEvent) {
+ let columnState = JSON.parse(sessionStorage.getItem(Globals.SESSSION_STORAGE_KEYS.contactListColumnStateKey));
+ if (columnState) {
+ event.columnApi.setColumnState(columnState);
+ }
}
private _handleBusEvents(event: any): any {
@@ -66,9 +101,6 @@
case 'edit':
this._navigateToDetails(event);
break;
- case 'delete':
- // this._openDialog(event);
- break;
default:
break;
}
@@ -125,6 +157,19 @@
}
}
+ public setModifiedContactsModuleAssignmentFilterDisplayValues(moduleName: string, withoutAssignedModule: boolean) {
+ if (!moduleName && withoutAssignedModule) {
+ //show contacts without module assignments
+ this.moduleDisplayName = '-1';
+ } else if (!moduleName && !withoutAssignedModule) {
+ //show contacts with all module assignments
+ this.moduleDisplayName = '';
+ } else {
+ //show contacts with specific module assignments
+ this.moduleDisplayName = moduleName;
+ }
+ }
+
public setModifiedContactsExpiryDateFilter() {
this._expiringDataInPast = !this._expiringDataInPast;
this.modifiedContacts.expiringDataInPast = this._expiringDataInPast;
@@ -146,24 +191,38 @@
public searchContacts(event) {
if (event.type == 'click' || event.type == 'change' || (event.type == 'keyup' && event.key == 'Enter')) {
this.modifiedContacts = { ...this.modifiedContacts };
- } else {
setTimeout(() => {
this.modifiedContacts = { ...this.modifiedContacts };
}, 1000);
+ sessionStorage.setItem(Globals.SESSSION_STORAGE_KEYS.contactListSearchFilterKey, JSON.stringify(this.modifiedContacts));
}
}
public sortContacts() {
this._setModifiedContactsSort();
this.modifiedContacts = { ...this.modifiedContacts };
+ console.log(this.modifiedContacts);
+ sessionStorage.setItem(Globals.SESSSION_STORAGE_KEYS.contactListSearchFilterKey, JSON.stringify(this.modifiedContacts));
}
private _setModifiedContactsSort() {
if (this._sortingOrder && this._sortingContactType) {
const sort = this._sortingContactType + ',' + this._sortingOrder;
this.modifiedContacts.sort = sort;
+ sessionStorage.setItem(Globals.SESSSION_STORAGE_KEYS.contactListSearchFilterKey, JSON.stringify(this.modifiedContacts));
} else {
this.modifiedContacts.sort = null;
+ sessionStorage.setItem(Globals.SESSSION_STORAGE_KEYS.contactListSearchFilterKey, JSON.stringify(this.modifiedContacts));
}
}
+
+ public setDSGVOFilterAdvancedVisible() {
+ this.isDSGVOFilterAdvancedVisible = !this.isDSGVOFilterAdvancedVisible;
+ this.modifiedContacts.isDSGVOFilterAdvancedVisible = this.isDSGVOFilterAdvancedVisible;
+ sessionStorage.setItem(Globals.SESSSION_STORAGE_KEYS.contactListSearchFilterKey, JSON.stringify(this.modifiedContacts));
+ }
+
+ ngOnDestroy() {
+ this._subscription.unsubscribe();
+ }
}
diff --git a/src/app/pages/contacts/contacts.sandbox.spec.ts b/src/app/pages/contacts/contacts.sandbox.spec.ts
index 0151399..d799383 100644
--- a/src/app/pages/contacts/contacts.sandbox.spec.ts
+++ b/src/app/pages/contacts/contacts.sandbox.spec.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -11,7 +11,7 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { ContactsSandbox } from '@pages/contacts/contacts.sandbox';
-import { Store, ActionsSubject} from '@ngrx/store';
+import { Store, ActionsSubject } from '@ngrx/store';
import { State } from '@shared/store';
import { UtilService } from '@shared/utility/utility.service';
import { of } from 'rxjs';
@@ -22,7 +22,7 @@
let appState: Store<State>;
beforeEach(() => {
- appState = { dispatch:()=> {}, pipe: () => of(true), select:()=> of(true) } as any;
+ appState = { dispatch: () => {}, pipe: () => of(true), select: () => of(true) } as any;
service = new ContactsSandbox(appState);
});
@@ -31,5 +31,4 @@
expect(service).toBeTruthy();
expect(service).toBeDefined();
});
-
});
diff --git a/src/app/pages/contacts/contacts.sandbox.ts b/src/app/pages/contacts/contacts.sandbox.ts
index 4bce18f..85763d4 100644
--- a/src/app/pages/contacts/contacts.sandbox.ts
+++ b/src/app/pages/contacts/contacts.sandbox.ts
@@ -1,15 +1,15 @@
/********************************************************************************
-* Copyright (c) 2020 Contributors to the Eclipse Foundation
-*
-* See the NOTICE file(s) distributed with this work for additional
-* information regarding copyright ownership.
-*
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v. 2.0 which is available at
-* http://www.eclipse.org/legal/epl-2.0.
-*
-* SPDX-License-Identifier: EPL-2.0
-********************************************************************************/
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
import { BaseListSandbox } from '@shared/sandbox/base-list.sandbox';
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
@@ -20,8 +20,6 @@
@Injectable()
export class ContactsSandbox extends BaseListSandbox {
-
- public serversideModel: ServerSideModel;
public contactListLoading$: Observable<boolean> = this.appState$.select(store.getContactsPageLoading);
/**
@@ -37,10 +35,12 @@
constructor(protected appState$: Store<store.State>) {
super(appState$);
this.serversideModel = {
- loadAction: contactsActions.loadContactsPage,
- successAction: contactsActions.loadContactsPageSuccess,
- pageSize: this.pageSize,
+ ...this.serversideModel,
+ ...{
+ loadAction: contactsActions.loadContactsPage,
+ successAction: contactsActions.loadContactsPageSuccess,
+ pageSize: this.pageSize,
+ },
};
}
-
}
diff --git a/src/app/shared/components/anonymizer/anonymizer.component.ts b/src/app/shared/components/anonymizer/anonymizer.component.ts
index 7dc2348..4b55552 100644
--- a/src/app/shared/components/anonymizer/anonymizer.component.ts
+++ b/src/app/shared/components/anonymizer/anonymizer.component.ts
@@ -26,9 +26,11 @@
public anonymizeContact(): void {
this._sandbox.anonymizeContact(this.contactId);
}
+
ngOnInit() {
this._sandbox.init();
}
+
ngOnDestroy() {
this._sandbox.endSubscriptions();
this.contactId = null;
diff --git a/src/app/shared/components/anonymizer/anonymizer.sandbox.ts b/src/app/shared/components/anonymizer/anonymizer.sandbox.ts
index f6898bd..83302b7 100644
--- a/src/app/shared/components/anonymizer/anonymizer.sandbox.ts
+++ b/src/app/shared/components/anonymizer/anonymizer.sandbox.ts
@@ -26,6 +26,7 @@
constructor(protected appState$: Store<store.State>, protected actionsSubject: ActionsSubject, protected router: Router, protected modalService: NgbModal) {
super(appState$);
}
+
public init() {
this.actionsSubject.pipe(ofType(contactsActions.anonymizeContactSuccess), takeUntil(this._endSubscriptions$)).subscribe(() => {
this.router.navigateByUrl(`/overview`);
diff --git a/src/app/shared/components/header/header.component.spec.ts b/src/app/shared/components/header/header.component.spec.ts
index 4e4a858..5ad067a 100644
--- a/src/app/shared/components/header/header.component.spec.ts
+++ b/src/app/shared/components/header/header.component.spec.ts
@@ -15,10 +15,14 @@
describe('HeaderComponent', () => {
let component: HeaderComponent;
let router: any;
+ let sessionStorage: any;
+ let window: any;
beforeEach(() => {
router = { navigateByUrl() {} } as any;
component = new HeaderComponent(router);
+ window = { location: { reload() {} } } as any;
+ sessionStorage = { clear() {} } as any;
});
it('should create', () => {
@@ -26,8 +30,10 @@
});
it('should navigate to overview after call navigateToOverview', () => {
- const spy = spyOn(router, 'navigateByUrl');
+ const spy1 = spyOn<any>(component, '_winLocReload').and.callFake(function() {});
+ const spy2 = spyOn(router, 'navigateByUrl');
component.navigateToOverview();
- expect(spy).toHaveBeenCalledWith('/overview');
+ expect(spy1).toHaveBeenCalled();
+ expect(spy2).toHaveBeenCalled();
});
});
diff --git a/src/app/shared/components/header/header.component.ts b/src/app/shared/components/header/header.component.ts
index a7b2832..9063608 100644
--- a/src/app/shared/components/header/header.component.ts
+++ b/src/app/shared/components/header/header.component.ts
@@ -31,6 +31,13 @@
constructor(public router: Router) {}
public navigateToOverview(): void {
+ // reset contacts state
+ sessionStorage.clear();
+ this._winLocReload();
navigateToOverview(this.router);
}
+
+ private _winLocReload(): void {
+ window.location.reload();
+ }
}
diff --git a/src/app/shared/components/list-details-view/user-module-assignment/user-module-assignment.sandbox.ts b/src/app/shared/components/list-details-view/user-module-assignment/user-module-assignment.sandbox.ts
index 915fe65..674220c 100644
--- a/src/app/shared/components/list-details-view/user-module-assignment/user-module-assignment.sandbox.ts
+++ b/src/app/shared/components/list-details-view/user-module-assignment/user-module-assignment.sandbox.ts
@@ -53,6 +53,7 @@
protected modalService: NgbModal
) {
super(appState$);
+ this.loadFilteredUserModuleTypes();
}
public dateValueConverter: NgrxValueConverter<Date | null | Moment, string | null> = dateValueConverter;
diff --git a/src/app/shared/components/paginator/paginator.component.spec.ts b/src/app/shared/components/paginator/paginator.component.spec.ts
index 626b959..7251421 100644
--- a/src/app/shared/components/paginator/paginator.component.spec.ts
+++ b/src/app/shared/components/paginator/paginator.component.spec.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -16,105 +16,95 @@
describe('PaginatorComponent', () => {
let component: PaginatorComponent;
- beforeEach(async(() => {
- }));
+ beforeEach(async(() => {}));
beforeEach(() => {
component = new PaginatorComponent();
});
- it('should create', () => {
+ it('should create', () => {
expect(component).toBeTruthy();
expect(component).toBeDefined();
});
- it('checks if setter and getter visibleItemsAmount is called and works', () => {
+ it('checks if setter and getter visibleItemsAmount is called and works', () => {
component.visibleItemsAmount = 10;
expect(component.visibleItemsAmount).toBe(10);
});
- it('checks if setter and getter totalPages is called and works', () => {
+ it('checks if setter and getter totalPages is called and works', () => {
component.totalPages = 15;
expect(component.totalPages).toBe(15);
});
- it('return totalPages if totalPages are lesser then visibleItemsAmount', () => {
+ it('return totalPages if totalPages are lesser then visibleItemsAmount', () => {
component.visibleItemsAmount = 15;
- component.totalPages = 10;
+ component.totalPages = 10;
expect(component.visibleItemsAmount).toBe(10);
});
- it('check if isPagingActive works', () => {
- component.totalPages = 1;
+ it('check if isPagingActive works', () => {
+ component.totalPages = 1;
expect(component.isPagingActive).toBeFalsy();
- component.totalPages = 2;
- expect(component.isPagingActive).toBeTruthy();
+ component.totalPages = 2;
+ expect(component.isPagingActive).toBeTruthy();
});
- it('check if setNextPage works', () => {
- component.totalPages = 5;
- expect(component.pageEventItems[component.currentPageIndex].pageIndex).toBe(1);
- component.setNextPage();
- expect(component.pageEventItems[component.currentPageIndex].pageIndex).toBe(2);
+ it('check if setNextPage works', () => {
+ component.totalPages = 5;
+ expect(component.pageEventItems[component.currentPageIndex].pageIndex).toBe(1);
+ component.setNextPage();
+ expect(component.pageEventItems[component.currentPageIndex].pageIndex).toBe(2);
});
- it('check if setPreviousPage works', () => {
- component.totalPages = 5;
- component.setNextPage();
- component.setPreviousPage();
+ it('check if setPreviousPage works', () => {
+ component.totalPages = 5;
+ component.setNextPage();
+ component.setPreviousPage();
expect(component.pageEventItems[component.currentPageIndex].pageIndex).toBe(1);
});
- it('check if setPreviousPage works on page 1', () => {
- component.totalPages = 5;
+ it('check if setPreviousPage works on page 1', () => {
+ component.totalPages = 5;
expect(component.pageEventItems[component.currentPageIndex].pageIndex).toBe(1);
- component.setPreviousPage();
+ component.setPreviousPage();
expect(component.pageEventItems[component.currentPageIndex].pageIndex).toBe(1);
});
- xit('check if setLastPage works', () => {
- component.totalPages = 10;
- component.setLastPage();
- // console.log(component.currentPageIndex);
- // console.log(component.pageEventItems[0]);
- // console.log(component.pageEventItems[component.currentPageIndex].pageIndex);
+ xit('check if setLastPage works', () => {
+ component.totalPages = 10;
+ component.setLastPage();
+ // console.log(component.currentPageIndex);
+ // console.log(component.pageEventItems[0]);
+ // console.log(component.pageEventItems[component.currentPageIndex].pageIndex);
expect(component.currentPageIndex).toBe(5);
});
- it('check if setFirstPage works on first page', () => {
- component.totalPages = 10;
- component.setFirstPage();
+ it('check if setFirstPage works on first page', () => {
+ component.totalPages = 10;
+ component.setFirstPage();
expect(component.pageEventItems[component.currentPageIndex].pageIndex).toBe(1);
});
- it('check if setFirstPage works on <> first page', () => {
- component.totalPages = 10;
- component.setNextPage();
- component.setFirstPage();
- expect(component.pageEventItems[component.currentPageIndex].pageIndex).toBe(1);
- });
-
- it('check if isLastPageLastIcon works', () => {
- component.totalPages = 2;
+ it('check if setFirstPage works on <> first page', () => {
+ component.totalPages = 10;
component.setNextPage();
- let isLastPageLastIcon = component.isLastPageLastIcon();
+ component.setFirstPage();
+ expect(component.pageEventItems[component.currentPageIndex].pageIndex).toBe(1);
+ });
+
+ it('check if isLastPageLastIcon works', () => {
+ component.totalPages = 2;
+ component.setNextPage();
+ let isLastPageLastIcon = component.isLastPageLastIcon();
expect(isLastPageLastIcon).toBeTruthy();
});
- xit('check if isLastPageLastIcon works', () => {
- component.totalPages = 6;
+ xit('check if isLastPageLastIcon works', () => {
+ component.totalPages = 6;
component.setNextPage();
- let isLastPageLastIcon = component.isLastPageLastIcon();
- // console.log(component.pageEventItems[component.currentPageIndex].pageIndex);
+ let isLastPageLastIcon = component.isLastPageLastIcon();
+ // console.log(component.pageEventItems[component.currentPageIndex].pageIndex);
expect(isLastPageLastIcon).toBeFalsy();
});
-
-
-
-
-
-
-
-
-
});
diff --git a/src/app/shared/components/paginator/paginator.component.ts b/src/app/shared/components/paginator/paginator.component.ts
index a110106..12f00b4 100644
--- a/src/app/shared/components/paginator/paginator.component.ts
+++ b/src/app/shared/components/paginator/paginator.component.ts
@@ -29,6 +29,11 @@
pageSize: number;
@Input()
+ public set currrentPageNumber(pageNumber: number) {
+ this._setActivePage({ pageIndex: pageNumber });
+ }
+
+ @Input()
public set visibleItemsAmount(visibleItemsAmount: number) {
this._visibleItemsAmount = visibleItemsAmount;
}
diff --git a/src/app/shared/constants/globals.ts b/src/app/shared/constants/globals.ts
index a412170..8cd5656 100644
--- a/src/app/shared/constants/globals.ts
+++ b/src/app/shared/constants/globals.ts
@@ -47,5 +47,10 @@
notEqual: 'ist nicht gleich',
};
+ static SESSSION_STORAGE_KEYS = {
+ contactListSearchFilterKey: 'contactListSearchFilter',
+ contactListColumnStateKey: 'contactListColumnState',
+ };
+
public static HELP_URL: string = 'http://www.google.de';
}
diff --git a/src/app/shared/directives/agGrid/server-side.directive.spec.ts b/src/app/shared/directives/agGrid/server-side.directive.spec.ts
index 279af24..80ec6da 100644
--- a/src/app/shared/directives/agGrid/server-side.directive.spec.ts
+++ b/src/app/shared/directives/agGrid/server-side.directive.spec.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -10,11 +10,11 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
-import { ServerSideDirective } from './server-side.directive'
+import { ServerSideDirective } from './server-side.directive';
describe('ServerSideDirective', () => {
- it('should create an instance', () => {
- const directive = new ServerSideDirective(null,null,null,null,null);
- expect(directive).toBeTruthy()
- })
-})
+ it('should create an instance', () => {
+ const directive = new ServerSideDirective(null, null, null, null, null);
+ expect(directive).toBeTruthy();
+ });
+});
diff --git a/src/app/shared/directives/agGrid/server-side.directive.ts b/src/app/shared/directives/agGrid/server-side.directive.ts
index 9087173..b8da780 100644
--- a/src/app/shared/directives/agGrid/server-side.directive.ts
+++ b/src/app/shared/directives/agGrid/server-side.directive.ts
@@ -1,3 +1,4 @@
+import { EventEmitter } from '@angular/core';
/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
@@ -16,7 +17,7 @@
import { AgGridAngular } from 'ag-grid-angular';
import { take, map } from 'rxjs/operators';
import { ServerSideModel } from '@shared/models/server-side.model';
-import { Directive, Input, AfterViewInit, ComponentFactoryResolver, ViewContainerRef, ComponentFactory, OnInit } from '@angular/core';
+import { Directive, Input, AfterViewInit, ComponentFactoryResolver, ViewContainerRef, ComponentFactory, OnInit, Output } from '@angular/core';
import { Store, ActionsSubject } from '@ngrx/store';
import * as store from '@shared/store';
@@ -39,6 +40,10 @@
private _queryParameter: any;
private _matPaginator: PaginatorComponent;
+
+ @Output()
+ public currentPageNumber: EventEmitter<number> = new EventEmitter();
+
@Input()
public serverside: ServerSideModel;
@@ -50,6 +55,7 @@
payload: {
queryParameter: query,
pageSize: this.serverside.pageSize,
+ pageNumber: this.serverside.pageNumber,
} as PageRequestInterface,
})
);
@@ -88,20 +94,18 @@
if (!this._matPaginator) {
const paginator: ComponentFactory<PaginatorComponent> = this._resolver.resolveComponentFactory(PaginatorComponent);
this._matPaginator = this._viewContainerRef.createComponent(paginator).instance;
-
}
- if( this._matPaginator.totalPages !== pagedItem.totalPages){
+ if (this._matPaginator.totalPages !== pagedItem.totalPages) {
this._matPaginator.totalPages = pagedItem.totalPages;
}
this._matPaginator.length = pagedItem.totalElements;
this._matPaginator.pageSize = pagedItem.pageable.pageSize || 1;
this._matPaginator.hidePageSize = false;
-
this._matPaginator.page.subscribe((selectedpage: PageEvent) => {
this._retrievePage(selectedpage);
});
-
+ this._matPaginator.currrentPageNumber = this.serverside.pageNumber;
if (!!this._agGrid.api) {
this._agGrid.api.setRowData(pagedItem.content);
} else {
@@ -109,7 +113,7 @@
}
});
- this._retrievePage();
+ this._retrievePage({ pageIndex: this.serverside.pageNumber });
}
/**
@@ -119,6 +123,7 @@
* @memberof ServerSideDirective
*/
private _retrievePage(event?: PageEvent) {
+ this.currentPageNumber.emit(event.pageIndex);
this.appState$.dispatch(
this.serverside.loadAction({
payload: {
diff --git a/src/app/shared/models/modifiedContacts.model.ts b/src/app/shared/models/modifiedContacts.model.ts
index e7817a9..ab6c092 100644
--- a/src/app/shared/models/modifiedContacts.model.ts
+++ b/src/app/shared/models/modifiedContacts.model.ts
@@ -1,9 +1,20 @@
-import { Contact } from '@shared/models';
-
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
export class ModifiedContacts {
public searchText: string = null;
public contactTypeId: string = '';
public sort: string = null;
+ public isDSGVOFilterAdvancedVisible: boolean = null;
public moduleName: string = null;
public withoutAssignedModule: boolean = null;
public expiringDataInPast: boolean = null;
diff --git a/src/app/shared/models/server-side.model.ts b/src/app/shared/models/server-side.model.ts
index 4085140..66e3250 100644
--- a/src/app/shared/models/server-side.model.ts
+++ b/src/app/shared/models/server-side.model.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -13,10 +13,11 @@
import { Action } from '@ngrx/store';
export class ServerSideModel {
- loadAction: any;
+ loadAction?: any;
successAction?: any;
pageSize?: number;
- filter?:any;
+ filter?: any;
+ pageNumber?: number = 1;
constructor() {}
}
diff --git a/src/app/shared/sandbox/base-list.sandbox.ts b/src/app/shared/sandbox/base-list.sandbox.ts
index 0dc7a08..bc4440a 100644
--- a/src/app/shared/sandbox/base-list.sandbox.ts
+++ b/src/app/shared/sandbox/base-list.sandbox.ts
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -11,8 +11,13 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { BaseSandbox } from '@shared/sandbox/base.sandbox';
+import { ServerSideModel } from '@shared/models/server-side.model';
-export abstract class BaseListSandbox extends BaseSandbox
-{
- protected pageSize: number = 10;
+export abstract class BaseListSandbox extends BaseSandbox {
+ protected pageSize: number = 10;
+ public serversideModel: ServerSideModel = new ServerSideModel();
+
+ public setCurrentPageNumber(pageNumber: number): void {
+ this.serversideModel = { ...this.serversideModel, pageNumber: pageNumber };
+ }
}