mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4947] Array type supported in data table columns (#5165)
* [WIP] [ADF-4947] Array type supported in data table columns * * removed resolver for aria label * * process services feature added * * fixed docs
This commit is contained in:
@@ -45,7 +45,12 @@ export let fakeProcessInstance = {
|
||||
graphicalNotationDefined: true,
|
||||
startFormDefined: false,
|
||||
suspended: false,
|
||||
variables: []
|
||||
variables: [
|
||||
{
|
||||
name: 'initiator',
|
||||
value: 'fake-user-1'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
@@ -70,7 +75,12 @@ export let fakeProcessInstance = {
|
||||
graphicalNotationDefined: true,
|
||||
startFormDefined: false,
|
||||
suspended: false,
|
||||
variables: []
|
||||
variables: [
|
||||
{
|
||||
name: 'initiator',
|
||||
value: 'fake-user-2'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
@@ -6,6 +6,7 @@
|
||||
[loading]="isLoading"
|
||||
[selectionMode]="selectionMode"
|
||||
[multiselect]="multiselect"
|
||||
[resolverFn]="resolverFn"
|
||||
(rowClick)="onRowClick($event)"
|
||||
(row-keyup)="onRowKeyUp($event)">
|
||||
<adf-loading-content-template>
|
||||
|
@@ -22,7 +22,7 @@ import { By } from '@angular/platform-browser';
|
||||
|
||||
import { ProcessInstanceListComponent } from './process-list.component';
|
||||
|
||||
import { AppConfigService, setupTestBed, CoreModule, DataTableModule } from '@alfresco/adf-core';
|
||||
import { AppConfigService, setupTestBed, CoreModule, DataTableModule, DataRow, DataColumn } from '@alfresco/adf-core';
|
||||
import { DataRowEvent, ObjectDataRow, ObjectDataTableAdapter } from '@alfresco/adf-core';
|
||||
|
||||
import { fakeProcessInstance, fakeProcessInstancesWithNoName, fakeProcessInstancesEmpty } from '../../mock';
|
||||
@@ -38,6 +38,13 @@ describe('ProcessInstanceListComponent', () => {
|
||||
let service: ProcessService;
|
||||
let getProcessInstancesSpy: jasmine.Spy;
|
||||
let appConfig: AppConfigService;
|
||||
const resolverfn = (row: DataRow, col: DataColumn) => {
|
||||
const value = row.getValue(col.key);
|
||||
if (col.key === 'variables') {
|
||||
return (value || []).map((processVar) => `${processVar.name} - ${processVar.value}`).toString();
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -271,6 +278,30 @@ describe('ProcessInstanceListComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show custom resolved value in the column', async(() => {
|
||||
appConfig.config['adf-process-list'] = {
|
||||
'presets': {
|
||||
'fakeProcessCustomSchema': [
|
||||
{
|
||||
'key': 'variables',
|
||||
'type': 'text',
|
||||
'title': 'Variables'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
component.presetColumn = 'fakeProcessCustomSchema';
|
||||
component.resolverFn = resolverfn;
|
||||
component.reload();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const customColumn = fixture.debugElement.queryAll(By.css('[title="Variables"] adf-datatable-cell'));
|
||||
expect(customColumn[0].nativeElement.innerText).toEqual('initiator - fake-user-1');
|
||||
expect(customColumn[1].nativeElement.innerText).toEqual('initiator - fake-user-2');
|
||||
});
|
||||
}));
|
||||
|
||||
describe('component changes', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
|
@@ -20,7 +20,9 @@ import {
|
||||
DataRowEvent,
|
||||
DataTableAdapter,
|
||||
CustomEmptyContentTemplateDirective,
|
||||
CustomLoadingContentTemplateDirective
|
||||
CustomLoadingContentTemplateDirective,
|
||||
DataRow,
|
||||
DataColumn
|
||||
} from '@alfresco/adf-core';
|
||||
import {
|
||||
AppConfigService,
|
||||
@@ -112,6 +114,13 @@ export class ProcessInstanceListComponent extends DataTableSchema implements On
|
||||
@Input()
|
||||
selectFirstRow: boolean = true;
|
||||
|
||||
/**
|
||||
* Resolver function is used to show dynamic complex column objects
|
||||
* see the docs to learn how to configure a resolverFn.
|
||||
*/
|
||||
@Input()
|
||||
resolverFn: (row: DataRow, col: DataColumn) => any = null;
|
||||
|
||||
/** Emitted when a row in the process list is clicked. */
|
||||
@Output()
|
||||
rowClick: EventEmitter<string> = new EventEmitter<string>();
|
||||
|
Reference in New Issue
Block a user