UI: Fixed persistent page link not correct init in pageMode disable

This commit is contained in:
Vladyslav_Prykhodko 2022-01-17 14:09:21 +02:00
parent 480612a1ac
commit 0437be70f6

View File

@ -217,10 +217,17 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
const routerQueryParams: PageQueryParam = this.route.snapshot.queryParams; const routerQueryParams: PageQueryParam = this.route.snapshot.queryParams;
let sortOrder: SortOrder = null; let sortOrder: SortOrder = null;
if (this.entitiesTableConfig.defaultSortOrder || routerQueryParams.hasOwnProperty('direction') || routerQueryParams.hasOwnProperty('property')) { if (this.pageMode) {
if (this.entitiesTableConfig.defaultSortOrder || routerQueryParams.hasOwnProperty('direction') || routerQueryParams.hasOwnProperty('property')) {
sortOrder = {
property: routerQueryParams?.property || this.entitiesTableConfig.defaultSortOrder.property,
direction: routerQueryParams?.direction || this.entitiesTableConfig.defaultSortOrder.direction
};
}
} else if (this.entitiesTableConfig.defaultSortOrder){
sortOrder = { sortOrder = {
property: routerQueryParams?.property || this.entitiesTableConfig.defaultSortOrder.property, property: this.entitiesTableConfig.defaultSortOrder.property,
direction: routerQueryParams?.direction || this.entitiesTableConfig.defaultSortOrder.direction direction: this.entitiesTableConfig.defaultSortOrder.direction
}; };
} }
@ -238,15 +245,17 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
this.pageLink = new PageLink(10, 0, null, sortOrder); this.pageLink = new PageLink(10, 0, null, sortOrder);
} }
this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : MAX_SAFE_PAGE_SIZE; this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : MAX_SAFE_PAGE_SIZE;
if (routerQueryParams.hasOwnProperty('page')) { if (this.pageMode) {
this.pageLink.page = Number(routerQueryParams.page); if (routerQueryParams.hasOwnProperty('page')) {
} this.pageLink.page = Number(routerQueryParams.page);
if (routerQueryParams.hasOwnProperty('pageSize')) { }
this.pageLink.pageSize = Number(routerQueryParams.pageSize); if (routerQueryParams.hasOwnProperty('pageSize')) {
} this.pageLink.pageSize = Number(routerQueryParams.pageSize);
if (routerQueryParams.hasOwnProperty('textSearch') && !isEmptyStr(routerQueryParams.textSearch)) { }
this.textSearchMode = true; if (routerQueryParams.hasOwnProperty('textSearch') && !isEmptyStr(routerQueryParams.textSearch)) {
this.pageLink.textSearch = decodeURI(routerQueryParams.textSearch); this.textSearchMode = true;
this.pageLink.textSearch = decodeURI(routerQueryParams.textSearch);
}
} }
this.dataSource = this.entitiesTableConfig.dataSource(this.dataLoaded.bind(this)); this.dataSource = this.entitiesTableConfig.dataSource(this.dataLoaded.bind(this));
if (this.entitiesTableConfig.onLoadAction) { if (this.entitiesTableConfig.onLoadAction) {