diff --git a/demo-shell/src/app/components/datatable/datatable.component.ts b/demo-shell/src/app/components/datatable/datatable.component.ts index f92350a493..b57448cb98 100644 --- a/demo-shell/src/app/components/datatable/datatable.component.ts +++ b/demo-shell/src/app/components/datatable/datatable.component.ts @@ -227,13 +227,13 @@ export class DataTableComponent { ], [ { type: 'image', key: 'icon', title: '', srTitle: 'Thumbnail' }, - { type: 'text', key: 'id', title: 'Id', sortable: true , cssClass: '' }, - { type: 'date', key: 'createdOn', title: 'Created On', sortable: true, cssClass: 'adf-ellipsis-cell adf-expand-cell-2' }, - { type: 'text', key: 'name', title: 'Name', cssClass: 'adf-ellipsis-cell', sortable: true }, - { type: 'text', key: 'createdBy.name', title: 'Created By', sortable: true, cssClass: ''}, - { type: 'json', key: 'json', title: 'Json', cssClass: 'adf-expand-cell-2'}, - { type: 'text', key: 'users', title: 'Users', cssClass: 'adf-expand-cell-2'}, - { type: 'json', key: 'status', title: 'Status', cssClass: 'adf-expand-cell-2'} + { type: 'text', key: 'id', title: 'Id', sortable: true , cssClass: '', draggable: true}, + { type: 'date', key: 'createdOn', title: 'Created On', sortable: true, cssClass: 'adf-ellipsis-cell adf-expand-cell-2', draggable: true }, + { type: 'text', key: 'name', title: 'Name', cssClass: 'adf-ellipsis-cell', sortable: true, draggable: true }, + { type: 'text', key: 'createdBy.name', title: 'Created By', sortable: true, cssClass: '', draggable: true}, + { type: 'json', key: 'json', title: 'Json', cssClass: 'adf-expand-cell-2', draggable: true}, + { type: 'text', key: 'users', title: 'Users', cssClass: 'adf-expand-cell-2', draggable: true}, + { type: 'json', key: 'status', title: 'Status', cssClass: 'adf-expand-cell-2', draggable: true} ] ); diff --git a/docs/core/components/data-column.component.md b/docs/core/components/data-column.component.md index 785ecb7c61..b0259688b0 100644 --- a/docs/core/components/data-column.component.md +++ b/docs/core/components/data-column.component.md @@ -43,6 +43,7 @@ Defines column properties for DataTable, Tasklist, Document List and other compo | Name | Type | Default value | Description | | ---- | ---- | ------------- | ----------- | +| id | `string` | '' | Column identifier. | | copyContent | `boolean` | | Enables/disables a [Clipboard directive](../../core/directives/clipboard.directive.md) to allow copying of cell contents. | | cssClass | `string` | | Additional CSS class to be applied to column (header and cells). | | editable | `boolean` | false | Toggles the editing support of the column data. | @@ -51,6 +52,7 @@ Defines column properties for DataTable, Tasklist, Document List and other compo | formatTooltip | `Function` | | Custom tooltip formatter function. | | key | `string` | | Data source key. Can be either a column/property key like `title` or a property path like `createdBy.name`. | | sortable | `boolean` | true | Toggles ability to sort by this column, for example by clicking the column header. | +| draggable | `boolean` | false | Toggles drag and drop for header column. | | sortingKey | `string` | | When using server side sorting the column used by the api call where the sorting will be performed | | srTitle | `string` | | Title to be used for screen readers. | | title | `string` | "" | Display title of the column, typically used for column headers. You can use the i18n resource key to get it translated automatically. | diff --git a/e2e/core/pages/content-services.page.ts b/e2e/core/pages/content-services.page.ts index dd6eb68047..c9fd712605 100644 --- a/e2e/core/pages/content-services.page.ts +++ b/e2e/core/pages/content-services.page.ts @@ -63,10 +63,10 @@ export class ContentServicesPage { errorSnackBar = $('simple-snack-bar[class*="mat-simple-snackbar"]'); emptyPagination = $('adf-pagination[class*="adf-pagination__empty"]'); dragAndDrop = $$('adf-upload-drag-area div').first(); - nameHeader = $$('div[data-automation-id="auto_id_name"] > span').first(); - sizeHeader = $$('div[data-automation-id="auto_id_content.sizeInBytes"] > span').first(); - createdByHeader = $$('div[data-automation-id="auto_id_createdByUser.displayName"] > span').first(); - createdHeader = $$('div[data-automation-id="auto_id_createdAt"] > span').first(); + nameHeader = $$('div[data-automation-id="auto_header_content_id_name"] > span').first(); + sizeHeader = $$('div[data-automation-id="auto_header_content_id_content.sizeInBytes"] > span').first(); + createdByHeader = $$('div[data-automation-id="auto_header_content_id_createdByUser.displayName"] > span').first(); + createdHeader = $$('div[data-automation-id="auto_header_content_id_createdAt"] > span').first(); recentFiles = $('.app-container-recent'); recentFilesExpanded = $('.app-container-recent mat-expansion-panel-header.mat-expanded'); recentFilesClosed = $('.app-container-recent mat-expansion-panel-header'); 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 dfc25ddbf9..a7fb1b0982 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 @@ -59,6 +59,8 @@ import { DocumentListModule } from '../document-list.module'; import { TranslateModule } from '@ngx-translate/core'; import { ShareDataRow } from '../data/share-data-row.model'; import { DocumentLoaderNode } from '../models/document-folder.model'; +import { matIconRegistryMock } from '../../testing/mat-icon-registry-mock'; +import { domSanitizerMock } from '../../testing/dom-sanitizer-mock'; describe('DocumentList', () => { @@ -1139,7 +1141,7 @@ describe('DocumentList', () => { it('should display [empty folder] template ', () => { fixture.detectChanges(); - documentList.dataTable = new DataTableComponent(null, null); + documentList.dataTable = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock); expect(documentList.dataTable).toBeDefined(); expect(fixture.debugElement.query(By.css('adf-empty-list'))).not.toBeNull(); }); @@ -1157,7 +1159,7 @@ describe('DocumentList', () => { }); it('should empty folder NOT show the pagination', () => { - documentList.dataTable = new DataTableComponent(null, null); + documentList.dataTable = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock); expect(documentList.isEmpty()).toBeTruthy(); expect(element.querySelector('alfresco-pagination')).toBe(null); diff --git a/lib/content-services/src/lib/testing/dom-sanitizer-mock.ts b/lib/content-services/src/lib/testing/dom-sanitizer-mock.ts new file mode 100644 index 0000000000..382b5322f0 --- /dev/null +++ b/lib/content-services/src/lib/testing/dom-sanitizer-mock.ts @@ -0,0 +1,5 @@ +import { DomSanitizer } from '@angular/platform-browser'; + +export const domSanitizerMock = { + bypassSecurityTrustResourceUrl: () => {} +} as any as DomSanitizer; diff --git a/lib/content-services/src/lib/testing/mat-icon-registry-mock.ts b/lib/content-services/src/lib/testing/mat-icon-registry-mock.ts new file mode 100644 index 0000000000..edd316b98b --- /dev/null +++ b/lib/content-services/src/lib/testing/mat-icon-registry-mock.ts @@ -0,0 +1,5 @@ +import { MatIconRegistry } from '@angular/material/icon'; + +export const matIconRegistryMock = { + addSvgIconInNamespace: () => {} +} as any as MatIconRegistry; diff --git a/lib/core/assets/images/drag_indicator_24px.svg b/lib/core/assets/images/drag_indicator_24px.svg new file mode 100644 index 0000000000..b159244a60 --- /dev/null +++ b/lib/core/assets/images/drag_indicator_24px.svg @@ -0,0 +1 @@ + diff --git a/lib/core/data-column/data-column.component.ts b/lib/core/data-column/data-column.component.ts index 3b764815f3..4c9d4c3c26 100644 --- a/lib/core/data-column/data-column.component.ts +++ b/lib/core/data-column/data-column.component.ts @@ -25,6 +25,9 @@ import { Component, ContentChild, Input, OnInit, TemplateRef } from '@angular/co }) export class DataColumnComponent implements OnInit { + @Input() + id: string = ''; + /** Data source key. Can be either a column/property key like `title` * or a property path like `createdBy.name`. */ @@ -45,6 +48,10 @@ export class DataColumnComponent implements OnInit { @Input() sortable: boolean = true; + /* Enable drag and drop for header column */ + @Input() + draggable: boolean = false; + /** Display title of the column, typically used for column headers. You can use the * i18n resource key to get it translated automatically. */ diff --git a/lib/core/datatable/components/datatable/datatable.component.html b/lib/core/datatable/components/datatable/datatable.component.html index fd1d45e650..0e3a02a443 100644 --- a/lib/core/datatable/components/datatable/datatable.component.html +++ b/lib/core/datatable/components/datatable/datatable.component.html @@ -8,21 +8,26 @@ [class.adf-datatable--empty--header-visible]="isEmpty() && isHeaderVisible()">