mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
44024: fixed issue with other query parameters on search page
This commit is contained in:
@@ -27,7 +27,6 @@ export class SearchPageComponent implements OnInit, OnDestroy {
|
|||||||
query: string;
|
query: string;
|
||||||
private scope: string;
|
private scope: string;
|
||||||
scopeObject: RemoteData<DSpaceObject>;
|
scopeObject: RemoteData<DSpaceObject>;
|
||||||
private page: number;
|
|
||||||
results: RemoteData<Array<SearchResult<DSpaceObject>>>;
|
results: RemoteData<Array<SearchResult<DSpaceObject>>>;
|
||||||
currentParams = {};
|
currentParams = {};
|
||||||
searchOptions: SearchOptions;
|
searchOptions: SearchOptions;
|
||||||
@@ -56,7 +55,7 @@ export class SearchPageComponent implements OnInit, OnDestroy {
|
|||||||
this.scope = params.scope;
|
this.scope = params.scope;
|
||||||
const page = +params.page || this.searchOptions.pagination.currentPage;
|
const page = +params.page || this.searchOptions.pagination.currentPage;
|
||||||
const pageSize = +params.pageSize || this.searchOptions.pagination.pageSize;
|
const pageSize = +params.pageSize || this.searchOptions.pagination.pageSize;
|
||||||
const sortDirection = +params.page || this.searchOptions.sort.direction;
|
const sortDirection = +params.sortDirection || this.searchOptions.sort.direction;
|
||||||
const pagination = Object.assign({},
|
const pagination = Object.assign({},
|
||||||
this.searchOptions.pagination,
|
this.searchOptions.pagination,
|
||||||
{ currentPage: page, pageSize: pageSize }
|
{ currentPage: page, pageSize: pageSize }
|
||||||
|
@@ -7,7 +7,6 @@ import { TranslateModule } from '@ngx-translate/core';
|
|||||||
import { SharedModule } from '../shared/shared.module';
|
import { SharedModule } from '../shared/shared.module';
|
||||||
import { SearchPageRoutingModule } from './search-page-routing.module';
|
import { SearchPageRoutingModule } from './search-page-routing.module';
|
||||||
import { SearchPageComponent } from './search-page.component';
|
import { SearchPageComponent } from './search-page.component';
|
||||||
import { SearchFormComponent } from '../shared/search-form/search-form.component';
|
|
||||||
import { SearchResultsComponent } from './search-results/search-results.compontent';
|
import { SearchResultsComponent } from './search-results/search-results.compontent';
|
||||||
import { SearchModule } from '../search/search.module';
|
import { SearchModule } from '../search/search.module';
|
||||||
import { ItemSearchResultListElementComponent } from '../object-list/search-result-list-element/item-search-result/item-search-result-list-element.component';
|
import { ItemSearchResultListElementComponent } from '../object-list/search-result-list-element/item-search-result/item-search-result-list-element.component';
|
||||||
|
@@ -10,13 +10,12 @@
|
|||||||
<button class="btn btn-outline-primary" id="paginationControls" ngbDropdownToggle><i class="fa fa-cog" aria-hidden="true"></i></button>
|
<button class="btn btn-outline-primary" id="paginationControls" ngbDropdownToggle><i class="fa fa-cog" aria-hidden="true"></i></button>
|
||||||
<div class="dropdown-menu dropdown-menu-right" id="paginationControlsDropdownMenu" aria-labelledby="paginationControls" ngbDropdownMenu>
|
<div class="dropdown-menu dropdown-menu-right" id="paginationControlsDropdownMenu" aria-labelledby="paginationControls" ngbDropdownMenu>
|
||||||
<h6 class="dropdown-header">{{ 'pagination.results-per-page' | translate}}</h6>
|
<h6 class="dropdown-header">{{ 'pagination.results-per-page' | translate}}</h6>
|
||||||
<button class="dropdown-item" *ngFor="let item of pageSizeOptions" (click)="doPageSizeChange(item)"><i class="fa fa-check {{(item != pageSize) ? 'invisible' : ''}}" aria-hidden="true"></i> {{item}} </button>
|
<button class="dropdown-item" *ngFor="let item of pageSizeOptions" (click)="doPageSizeChange(item)"><i [ngClass]="{'invisible': item != pageSize}" class="fa fa-check" aria-hidden="true"></i> {{item}} </button>
|
||||||
<h6 class="dropdown-header">{{ 'pagination.sort-direction' | translate}}</h6>
|
<h6 class="dropdown-header">{{ 'pagination.sort-direction' | translate}}</h6>
|
||||||
<button class="dropdown-item" *ngFor="let direction of (sortDirections | dsKeys)" (click)="doSortDirectionChange(direction.key)"><i class="fa fa-check {{(direction.key != sortDirection) ? 'invisible' : ''}}" aria-hidden="true"></i> {{direction.value}} </button>
|
<button class="dropdown-item" *ngFor="let direction of (sortDirections | dsKeys)" (click)="doSortDirectionChange(direction.key)"><i [ngClass]="{'invisible': direction.key != sortDirection}" class="fa fa-check" aria-hidden="true"></i> {{direction.value}} </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
|
@@ -35,7 +35,6 @@ import { PageInfo } from '../../core/shared/page-info.model';
|
|||||||
encapsulation: ViewEncapsulation.Emulated
|
encapsulation: ViewEncapsulation.Emulated
|
||||||
})
|
})
|
||||||
export class PaginationComponent implements OnDestroy, OnInit {
|
export class PaginationComponent implements OnDestroy, OnInit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of items in collection.
|
* Number of items in collection.
|
||||||
*/
|
*/
|
||||||
@@ -185,7 +184,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
|||||||
// Listen to changes
|
// Listen to changes
|
||||||
this.subs.push(this.route.queryParams
|
this.subs.push(this.route.queryParams
|
||||||
.subscribe((queryParams) => {
|
.subscribe((queryParams) => {
|
||||||
if (isEmpty(queryParams)) {
|
if (this.isEmptyPaginationParams(queryParams)) {
|
||||||
this.initializeConfig();
|
this.initializeConfig();
|
||||||
} else {
|
} else {
|
||||||
this.currentQueryParams = queryParams;
|
this.currentQueryParams = queryParams;
|
||||||
@@ -470,7 +469,22 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to check whether the current pagination object has multiple pages
|
* Method to check if none of the query params necessary for pagination are filled out.
|
||||||
|
*
|
||||||
|
* @param paginateOptions
|
||||||
|
* The paginate options object.
|
||||||
|
*/
|
||||||
|
private isEmptyPaginationParams(paginateOptions): boolean {
|
||||||
|
const properties = ['id', 'currentPage', 'pageSize', 'pageSizeOptions'];
|
||||||
|
const missing = properties.filter((prop) => {
|
||||||
|
return !(prop in paginateOptions);
|
||||||
|
});
|
||||||
|
|
||||||
|
return properties.length === missing.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property to check whether the current pagination object has multiple pages
|
||||||
* @returns true if there are multiple pages, else returns false
|
* @returns true if there are multiple pages, else returns false
|
||||||
*/
|
*/
|
||||||
get hasMultiplePages(): boolean {
|
get hasMultiplePages(): boolean {
|
||||||
@@ -478,7 +492,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to check whether the current pagination should show a bottom pages
|
* Property to check whether the current pagination should show a bottom pages
|
||||||
* @returns true if a bottom pages should be shown, else returns false
|
* @returns true if a bottom pages should be shown, else returns false
|
||||||
*/
|
*/
|
||||||
get shouldShowBottomPager(): boolean {
|
get shouldShowBottomPager(): boolean {
|
||||||
|
@@ -56,8 +56,7 @@ export class SearchFormComponent implements OnInit, OnDestroy {
|
|||||||
queryParams: Object.assign({}, this.currentParams,
|
queryParams: Object.assign({}, this.currentParams,
|
||||||
{
|
{
|
||||||
query: data.query,
|
query: data.query,
|
||||||
scope: data.scope || undefined,
|
scope: data.scope || undefined
|
||||||
page: data.page || 1
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user