[ADF-2131] Search sorting (#3334)

* sorting configuration

* detect primary sorting and use with document list

* search results sorting

* docs update

* unit tests and code updates

* update code

* update code

* generic sorting picker, test updates

* ability to switch off client side sorting

* update docs for document list
This commit is contained in:
Denys Vuika
2018-05-18 14:33:28 +01:00
committed by Eugenio Romano
parent 73bc62ae8f
commit 07440731fa
29 changed files with 682 additions and 35 deletions

View File

@@ -14,17 +14,26 @@
<adf-search-filter #searchFilter></adf-search-filter>
<div class="adf-search-results__content">
<div class="adf-search-results__sorting">
<adf-search-sorting-picker></adf-search-sorting-picker>
</div>
<app-files-component
[currentFolderId]="null"
[nodeResult]="resultNodePageList"
[disableDragArea]="true"
[pagination]="pagination"
(changedPageSize)="onRefreshPagination($event)"
(changedPageNumber)="onRefreshPagination($event)"
(turnedNextPage)="onRefreshPagination($event)"
(loadNext)="onRefreshPagination($event)"
(turnedPreviousPage)="onRefreshPagination($event)"
(deleteElementSuccess)="onDeleteElementSuccess($event)">
[showHeader]="false"
[sorting]="sorting"
[sortingMode]="'server'"
[showRecentFiles]="false"
[showSitePicker]="false"
[showSettingsPanel]="false"
[currentFolderId]="null"
[nodeResult]="resultNodePageList"
[disableDragArea]="true"
[pagination]="pagination"
(changedPageSize)="onRefreshPagination($event)"
(changedPageNumber)="onRefreshPagination($event)"
(turnedNextPage)="onRefreshPagination($event)"
(loadNext)="onRefreshPagination($event)"
(turnedPreviousPage)="onRefreshPagination($event)"
(deleteElementSuccess)="onDeleteElementSuccess($event)">
</app-files-component>
</div>
</div>

View File

@@ -14,6 +14,10 @@
&__content {
flex: 1;
}
&__sorting {
text-align: right;
}
}
div.search-results-container {

View File

@@ -39,6 +39,8 @@ export class SearchResultComponent implements OnInit {
maxItems: number;
skipCount = 0;
sorting = ['name', 'asc'];
constructor(public router: Router,
private preferences: UserPreferencesService,
private queryBuilder: SearchQueryBuilderService,
@@ -51,6 +53,13 @@ export class SearchResultComponent implements OnInit {
}
ngOnInit() {
this.sorting = this.getSorting();
this.queryBuilder.updated.subscribe(() => {
this.sorting = this.getSorting();
});
if (this.route) {
this.route.params.forEach((params: Params) => {
this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null;
@@ -79,4 +88,14 @@ export class SearchResultComponent implements OnInit {
onDeleteElementSuccess(element: any) {
this.searchResult.reload();
}
private getSorting(): string[] {
const primary = this.queryBuilder.getPrimarySorting();
if (primary) {
return [primary.key, primary.ascending ? 'asc' : 'desc'];
}
return ['name', 'asc'];
}
}