diff --git a/docs/content-services/components/breadcrumb.component.md b/docs/content-services/components/breadcrumb.component.md index 7da0417bd4..4c0e81974d 100644 --- a/docs/content-services/components/breadcrumb.component.md +++ b/docs/content-services/components/breadcrumb.component.md @@ -23,15 +23,16 @@ Indicates the current position within a navigation hierarchy. ### Properties -| Name | Type | Default value | Description | -| ---- | ---- | ------------- | ----------- | -| folderNode | `Node` | null | Active node, builds UI based on folderNode.path.elements collection. | -| maxItems | `number` | | Maximum number of nodes to display before wrapping them with a dropdown element. | -| readOnly | `boolean` | false | If true, prevents the user from navigating away from the active node. | -| root | `string` | null | (optional) Name of the root element of the breadcrumb. You can use this property to rename "Company Home" to "Personal Files" for example. You can use an i18n resource key for the property value. | -| rootId | `string` | null | (optional) The id of the root element. You can use this property to set a custom element the breadcrumb should start with. | -| target | [`DocumentListComponent`](../../content-services/components/document-list.component.md) | | (optional) [Document List component](../../content-services/components/document-list.component.md) to operate with. The list will update when the breadcrumb is clicked. | -| transform | `Function` | | Transformation to be performed on the chosen/folder node before building the breadcrumb UI. Can be useful when custom formatting is needed for the breadcrumb. You can change the path elements from the node that are used to build the breadcrumb using this function. | +| Name | Type | Default value | Description | +|-----------------------|-----------------------------------------------------------------------------------------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| folderNode | `Node` | null | Active node, builds UI based on folderNode.path.elements collection. | +| maxItems | `number` | | Maximum number of nodes to display before wrapping them with a dropdown element. | +| readOnly | `boolean` | false | If true, prevents the user from navigating away from the active node. | +| root | `string` | null | (optional) Name of the root element of the breadcrumb. You can use this property to rename "Company Home" to "Personal Files" for example. You can use an i18n resource key for the property value. | +| rootId | `string` | null | (optional) The id of the root element. You can use this property to set a custom element the breadcrumb should start with. | +| target | [`DocumentListComponent`](../../content-services/components/document-list.component.md) | | (optional) [Document List component](../../content-services/components/document-list.component.md) to operate with. The list will update when the breadcrumb is clicked. | +| transform | `Function` | | Transformation to be performed on the chosen/folder node before building the breadcrumb UI. Can be useful when custom formatting is needed for the breadcrumb. You can change the path elements from the node that are used to build the breadcrumb using this function. | +| selectedRowItemsCount | `number` | 0 | Number of table rows that are currently selected. | ### Events diff --git a/docs/content-services/components/document-list.component.md b/docs/content-services/components/document-list.component.md index f333e847e0..a80659351e 100644 --- a/docs/content-services/components/document-list.component.md +++ b/docs/content-services/components/document-list.component.md @@ -98,19 +98,20 @@ Displays the documents from a repository. ### Events -| Name | Type | Description | -| ---- | ---- | ----------- | -| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when the API fails to get the Document List data | -| filterSelection | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FilterSearch`](../../../lib/content-services/src/lib/search/models/filter-search.interface.ts)`[]>` | Emitted when a filter value is selected | -| folderChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodeEntryEvent`](../../../lib/content-services/src/lib/document-list/components/node.event.ts)`>` | Emitted when the current display folder changes | -| nodeClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodeEntityEvent`](../../../lib/content-services/src/lib/document-list/components/node.event.ts)`>` | Emitted when the user clicks a list node | -| nodeDblClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodeEntityEvent`](../../../lib/content-services/src/lib/document-list/components/node.event.ts)`>` | Emitted when the user double-clicks a list node | -| nodeSelected | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodeEntry`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeEntry.md)`[]>` | Emitted when the node selection change | -| preview | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodeEntityEvent`](../../../lib/content-services/src/lib/document-list/components/node.event.ts)`>` | Emitted when the user acts upon files with either single or double click (depends on `navigation-mode`). Useful for integration with the [Viewer component](../../core/components/viewer.component.md). | -| ready | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/NodePaging.md)`>` | Emitted when the Document List has loaded all items and is ready for use | -| columnsVisibilityChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<{ [columnId: string]: boolean } \| undefined>` | Emitted when columns visibility change | -| columnsWidthChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<{ [columnId: string]: number } \| undefined>` | Emitted when columns width change | -| columnsOrderChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`< string[] \| undefined>` | Emitted when columns order change | +| Name | Type | Description | +|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when the API fails to get the Document List data | +| filterSelection | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FilterSearch`](../../../lib/content-services/src/lib/search/models/filter-search.interface.ts)`[]>` | Emitted when a filter value is selected | +| folderChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodeEntryEvent`](../../../lib/content-services/src/lib/document-list/components/node.event.ts)`>` | Emitted when the current display folder changes | +| nodeClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodeEntityEvent`](../../../lib/content-services/src/lib/document-list/components/node.event.ts)`>` | Emitted when the user clicks a list node | +| nodeDblClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodeEntityEvent`](../../../lib/content-services/src/lib/document-list/components/node.event.ts)`>` | Emitted when the user double-clicks a list node | +| nodeSelected | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodeEntry`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeEntry.md)`[]>` | Emitted when the node selection change | +| preview | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodeEntityEvent`](../../../lib/content-services/src/lib/document-list/components/node.event.ts)`>` | Emitted when the user acts upon files with either single or double click (depends on `navigation-mode`). Useful for integration with the [Viewer component](../../core/components/viewer.component.md). | +| ready | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/NodePaging.md)`>` | Emitted when the Document List has loaded all items and is ready for use | +| columnsVisibilityChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<{ [columnId: string]: boolean } \| undefined>` | Emitted when columns visibility change | +| columnsWidthChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<{ [columnId: string]: number } \| undefined>` | Emitted when columns width change | +| columnsOrderChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`< string[] \| undefined>` | Emitted when columns order change | +| selectedItemsCountChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`< number \| undefined>` | Emitted when items row count change | ## Details diff --git a/docs/core/components/datatable.component.md b/docs/core/components/datatable.component.md index 44e146cfcf..7c6bdb5494 100644 --- a/docs/core/components/datatable.component.md +++ b/docs/core/components/datatable.component.md @@ -448,15 +448,16 @@ Learn more about styling your datatable: [Customizing the component's styles](#c ### Events -| Name | Type | Description | -|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------| -| columnOrderChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataColumn`](../../../lib/core/src/lib/datatable/data/data-column.model.ts)`<>[]>` | Emitted when the column order is changed. | -| columnsWidthChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataColumn`](../../../lib/core/src/lib/datatable/data/data-column.model.ts)`<>[]>` | Emitted when the column width is changed. | -| executeRowAction | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataRowActionEvent`](../../../lib/core/src/lib/datatable/components/data-row-action.event.ts)`>` | Emitted when the user executes a row action. | -| rowClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataRowEvent`](../../../lib/core/src/lib/datatable/data/data-row-event.model.ts)`>` | Emitted when the user clicks a row. | -| rowDblClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataRowEvent`](../../../lib/core/src/lib/datatable/data/data-row-event.model.ts)`>` | Emitted when the user double-clicks a row. | -| showRowActionsMenu | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataCellEvent`](../../../lib/core/src/lib/datatable/components/data-cell.event.ts)`>` | Emitted before the actions menu is displayed for a row. | -| showRowContextMenu | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataCellEvent`](../../../lib/core/src/lib/datatable/components/data-cell.event.ts)`>` | Emitted before the context menu is displayed for a row. | +| Name | Type | Description | +|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------| +| columnOrderChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataColumn`](../../../lib/core/src/lib/datatable/data/data-column.model.ts)`<>[]>` | Emitted when the column order is changed. | +| columnsWidthChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataColumn`](../../../lib/core/src/lib/datatable/data/data-column.model.ts)`<>[]>` | Emitted when the column width is changed. | +| selectedItemsCountChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when the item row count is changed. | +| executeRowAction | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataRowActionEvent`](../../../lib/core/src/lib/datatable/components/data-row-action.event.ts)`>` | Emitted when the user executes a row action. | +| rowClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataRowEvent`](../../../lib/core/src/lib/datatable/data/data-row-event.model.ts)`>` | Emitted when the user clicks a row. | +| rowDblClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataRowEvent`](../../../lib/core/src/lib/datatable/data/data-row-event.model.ts)`>` | Emitted when the user double-clicks a row. | +| showRowActionsMenu | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataCellEvent`](../../../lib/core/src/lib/datatable/components/data-cell.event.ts)`>` | Emitted before the actions menu is displayed for a row. | +| showRowContextMenu | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`DataCellEvent`](../../../lib/core/src/lib/datatable/components/data-cell.event.ts)`>` | Emitted before the context menu is displayed for a row. | ## Details diff --git a/lib/content-services/src/lib/breadcrumb/breadcrumb.component.html b/lib/content-services/src/lib/breadcrumb/breadcrumb.component.html index f6b6ac7247..5b4fabdf08 100644 --- a/lib/content-services/src/lib/breadcrumb/breadcrumb.component.html +++ b/lib/content-services/src/lib/breadcrumb/breadcrumb.component.html @@ -57,7 +57,7 @@
- {{ item.name | translate }} + {{ (selectedRowItemsCount < 1 ? item.name : 'BREADCRUMB.HEADER.SELECTED') | translate: { count: selectedRowItemsCount } }}
diff --git a/lib/content-services/src/lib/breadcrumb/breadcrumb.component.spec.ts b/lib/content-services/src/lib/breadcrumb/breadcrumb.component.spec.ts index 932a028410..9e3c73a6a3 100644 --- a/lib/content-services/src/lib/breadcrumb/breadcrumb.component.spec.ts +++ b/lib/content-services/src/lib/breadcrumb/breadcrumb.component.spec.ts @@ -33,6 +33,9 @@ describe('Breadcrumb', () => { }); let documentListComponent: DocumentListComponent; + const getBreadcrumbActionText = (): string => + fixture.debugElement.nativeElement.querySelector('.adf-breadcrumb-item-current').textContent.trim(); + beforeEach(() => { TestBed.configureTestingModule({ imports: [ContentTestingModule], @@ -300,4 +303,26 @@ describe('Breadcrumb', () => { expect(component.route[3].id).toBe('test-id'); expect(component.route[3].name).toBe('test-name'); }); + + it('should set title based on selectedRowItemsCount', () => { + component.transform = (transformNode) => { + transformNode.id = 'test-id'; + transformNode.name = 'test-name'; + return transformNode; + }; + + component.folderNode = { + path: { elements: [{ id: 'element-1-id', name: 'element-1-name' }] } + } as Node; + + component.ngOnChanges(); + fixture.detectChanges(); + + expect(getBreadcrumbActionText()).toEqual('test-name'); + + component.selectedRowItemsCount = 2; + fixture.detectChanges(); + + expect(getBreadcrumbActionText()).toEqual('BREADCRUMB.HEADER.SELECTED'); + }); }); diff --git a/lib/content-services/src/lib/breadcrumb/breadcrumb.component.ts b/lib/content-services/src/lib/breadcrumb/breadcrumb.component.ts index 95d68baaaa..e35cf036ad 100644 --- a/lib/content-services/src/lib/breadcrumb/breadcrumb.component.ts +++ b/lib/content-services/src/lib/breadcrumb/breadcrumb.component.ts @@ -72,6 +72,10 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy { @Input() maxItems: number; + /** Number of table rows that are currently selected. */ + @Input() + selectedRowItemsCount = 0; + previousNodes: PathElement[]; lastNodes: PathElement[]; diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.html b/lib/content-services/src/lib/document-list/components/document-list.component.html index ddf4c35d29..b6cd66f6d0 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.html +++ b/lib/content-services/src/lib/document-list/components/document-list.component.html @@ -22,6 +22,7 @@ (executeRowAction)="onExecuteRowAction($event)" (columnsWidthChanged)="onColumnsWidthChange($event)" (columnOrderChanged)="onColumnOrderChange($event)" + (selectedItemsCountChanged)="onSelectedItemsCountChanged($event)" (rowClick)="onNodeClick($event.value?.node)" (rowDblClick)="onNodeDblClick($event.value?.node)" (row-select)="onNodeSelect($any($event).detail)" diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts b/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts index 9c9e53e3e8..a0916488f9 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts @@ -1468,6 +1468,12 @@ describe('DocumentList', () => { expect(documentList.reload).not.toHaveBeenCalled(); }); + it('should emit custom date range on date picker closed', () => { + const selectedItemsCountChangedSpy = spyOn(documentList.selectedItemsCountChanged, 'emit'); + documentList.onSelectedItemsCountChanged(1); + expect(selectedItemsCountChangedSpy).toHaveBeenCalledWith(1); + }); + it('should add includeFields in the server request when present', () => { documentList.includeFields = ['test-include']; documentList.currentFolderId = 'fake-id'; diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.ts b/lib/content-services/src/lib/document-list/components/document-list.component.ts index e5ec7a51b6..5624997557 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.ts @@ -388,6 +388,10 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On @Output() columnsOrderChanged = new EventEmitter(); + /** Emitted when the selected row items count in the table changed. */ + @Output() + selectedItemsCountChanged = new EventEmitter(); + @ViewChild('dataTable', { static: true }) dataTable: DataTableComponent; @@ -832,6 +836,10 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On this.columnsWidthChanged.emit(this.columnsWidths); } + onSelectedItemsCountChanged(count: number) { + this.selectedItemsCountChanged.emit(count); + } + onNodeClick(nodeEntry: NodeEntry) { const domEvent = new CustomEvent('node-click', { detail: { diff --git a/lib/content-services/src/lib/i18n/en.json b/lib/content-services/src/lib/i18n/en.json index df03cb26bc..c68da5598b 100644 --- a/lib/content-services/src/lib/i18n/en.json +++ b/lib/content-services/src/lib/i18n/en.json @@ -662,6 +662,9 @@ "ARIA-LABEL": { "BREADCRUMB": "Breadcrumb", "DROPDOWN": "Dropdown" + }, + "HEADER": { + "SELECTED": "Selected ({{ count }})" } }, "NAME_COLUMN_LINK": { diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.html b/lib/core/src/lib/datatable/components/datatable/datatable.component.html index b958ebacd1..bac4b2e1b6 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.html +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.html @@ -21,7 +21,7 @@ -
+
{{ 'ADF-DATATABLE.ACCESSIBILITY.SELECT_ALL' | translate }}
@@ -182,9 +182,10 @@
-