[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:
dhrn
2019-10-18 04:31:52 +05:30
committed by Eugenio Romano
parent 12bbb993bd
commit baa0d6da30
34 changed files with 350 additions and 99 deletions

View File

@@ -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'
}
]
}
]
};

View File

@@ -6,6 +6,7 @@
[loading]="isLoading"
[selectionMode]="selectionMode"
[multiselect]="multiselect"
[resolverFn]="resolverFn"
(rowClick)="onRowClick($event)"
(row-keyup)="onRowKeyUp($event)">
<adf-loading-content-template>

View File

@@ -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(() => {

View File

@@ -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>();