[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

@@ -88,6 +88,7 @@ Displays the documents from a repository.
| skipCount | `number` | 0 | Number of elements to skip over for pagination purposes |
| sorting | `string[]` | | Defines default sorting. The format is an array of 2 strings `[key, direction]` i.e. `['name', 'desc']` or `['name', 'asc']`. Set this value only if you want to override the default sorting detected by the component based on columns. |
| thumbnails | `boolean` | false | Show document thumbnails rather than icons |
| sortingMode | `string` | `client` | Defines sorting mode. Can be either `client` or `server`. |
### Events

View File

@@ -34,6 +34,16 @@ Below is an example configuration:
```json
{
"search": {
"sorting": {
"options": [
{ "key": "name", "label": "Name", "type": "FIELD", "field": "cm:name", "ascending": true },
{ "key": "content.sizeInBytes", "label": "Size", "type": "FIELD", "field": "content.size", "ascending": true },
{ "key": "description", "label": "Description", "type": "FIELD", "field": "cm:description", "ascending": true }
],
"defaults": [
{ "key": "name", "type": "FIELD", "field": "cm:name", "ascending": true }
]
},
"filterQueries": [
{ "query": "TYPE:'cm:folder' OR TYPE:'cm:content'" },
{ "query": "NOT cm:creator:System" }
@@ -107,6 +117,42 @@ In addition, it is also possible to provide a set of queries that are always exe
Note that the entries of the `filterQueries` array are joined using the `AND` operator.
### Sorting
The Sorting configuration section consists of two blocks:
`options` that holds a list of items that users can select from,
and `defaults` that contains predefined sorting to use by default.
```json
{
"search": {
"sorting": {
"options": [
{ "key": "name", "label": "Name", "type": "FIELD", "field": "cm:name", "ascending": true },
{ "key": "content.sizeInBytes", "label": "Size", "type": "FIELD", "field": "content.size", "ascending": true },
{ "key": "description", "label": "Description", "type": "FIELD", "field": "cm:description", "ascending": true }
],
"defaults": [
{ "key": "name", "type": "FIELD", "field": "cm:name", "ascending": true }
]
}
}
}
```
#### Sorting Definition Attributes
| Name | Type | Description |
| --- | --- | --- |
| key | string | Unique key to identify the entry, can also be used to map DataColumn instances. |
| label | string | Display text, can also be an i18n resource key. |
| type | string | This specifies how to order - either by using a field or based on the position of the document in the index, or by score/relevance. |
| field | string | The name of the field. |
| ascending | boolean | The sorting order. |
See also:
* Alfresco Content Services API Reference / Search Api / [Sort](https://docs.alfresco.com/5.2/concepts/search-api-sort.html)
### Categories
The Search Settings component and Query Builder require a `categories` section provided within the configuration.
@@ -647,4 +693,6 @@ and pass custom attributes in case your component supports them:
## See also
- [Search Query Builder service](search-query-builder.service.md)
- [Search Query Builder service](search-query-builder.service.md)
- [Search Chip List Component](search-chip-list.component.md)
- [Search Sorting Picker Component](search-sorting-picker.component.md)

View File

@@ -0,0 +1,13 @@
---
Added: v2.3.0
Status: Active
---
# Search Sorting Picker Component
Provides an ability to select one of the predefined sorting definitions for search results:
```html
<adf-search-sorting-picker></adf-search-sorting-picker>
<adf-search-filter></adf-search-filter>
```

View File

@@ -0,0 +1,43 @@
---
Added: v2.4.0
Status: Active
---
# Sorting Picker Component
Provides an ability to pick one of the predefined sorting definitions and define sorting direction:
```html
<adf-sorting-picker
[options]="options"
[selected]="value"
[ascending]="ascending"
(change)="onChanged($event)">
</adf-sorting-picker>
```
![Sorting Picker](../docassets/images/sorting-picker.png)
## Options format
You can bind a collection of any objects that expose the following properties:
```ts
{
key: string;
label: string;
}
```
## Properties
| Name | Type | Default Value | Description |
| options | `Array<{key: string, label: string}>` | `[]` | Available sorting options. |
| selected | `string` | | Currently selected option key. |
| ascending | `boolean` | true | Current sorting direction. |
## Events
| Name | Type | Description |
| --- | --- | --- |
| change | `EventEmitter<{ key: string, ascending: boolean }>` | Raised each time sorting key or direction gets changed. |

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB