mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Process list implement pagination interface (#2872)
This commit is contained in:
committed by
Eugenio Romano
parent
105bc80d2c
commit
0f6ac42e4c
@@ -133,11 +133,14 @@
|
|||||||
<div class="adf-grid-item adf-processes-list adf-list" fxFlex.gt-md="335px" [ngClass.gt-md]="{'small-pagination': true}"
|
<div class="adf-grid-item adf-processes-list adf-list" fxFlex.gt-md="335px" [ngClass.gt-md]="{'small-pagination': true}"
|
||||||
*ngIf="processFilter && !isStartProcessMode()">
|
*ngIf="processFilter && !isStartProcessMode()">
|
||||||
<adf-process-instance-list
|
<adf-process-instance-list
|
||||||
|
#processList
|
||||||
*ngIf="processFilter?.filter" [appId]="processFilter?.appId"
|
*ngIf="processFilter?.filter" [appId]="processFilter?.appId"
|
||||||
[processDefinitionKey]="processFilter?.filter?.processDefinitionKey"
|
[processDefinitionKey]="processFilter?.filter?.processDefinitionKey"
|
||||||
[name]="processFilter?.filter?.name"
|
[name]="processFilter?.filter?.name"
|
||||||
[presetColumn]="presetColoum"
|
[presetColumn]="presetColoum"
|
||||||
[state]="processFilter?.filter?.state"
|
[state]="processFilter?.filter?.state"
|
||||||
|
[page]="processPage"
|
||||||
|
[size]="paginationPageSize"
|
||||||
[sort]="processFilter?.filter?.sort"
|
[sort]="processFilter?.filter?.sort"
|
||||||
[data]="dataProcesses"
|
[data]="dataProcesses"
|
||||||
(rowClick)="onProcessRowClick($event)"
|
(rowClick)="onProcessRowClick($event)"
|
||||||
@@ -151,6 +154,16 @@
|
|||||||
</data-columns> -->
|
</data-columns> -->
|
||||||
|
|
||||||
</adf-process-instance-list>
|
</adf-process-instance-list>
|
||||||
|
<adf-pagination
|
||||||
|
*ngIf="processList"
|
||||||
|
[target]="processList"
|
||||||
|
[supportedPageSizes]="supportedPages"
|
||||||
|
(changePageNumber)="onChangePageNumberProcess($event)"
|
||||||
|
(changePageSize)="onChangePageSizeProcess($event)"
|
||||||
|
(nextPage)="onNextPageProcess($event)"
|
||||||
|
(prevPage)="onPrevPageProcess($event)"
|
||||||
|
#processListPagination>
|
||||||
|
</adf-pagination>
|
||||||
</div>
|
</div>
|
||||||
<div class="adf-grid-item adf-processes-details" *ngIf="!isStartProcessMode()" fxFlex.gt-md="1 1 auto">
|
<div class="adf-grid-item adf-processes-details" *ngIf="!isStartProcessMode()" fxFlex.gt-md="1 1 auto">
|
||||||
<adf-process-instance-details
|
<adf-process-instance-details
|
||||||
|
@@ -30,7 +30,7 @@ import { ActivatedRoute, Router } from '@angular/router';
|
|||||||
import { Pagination, ProcessInstanceFilterRepresentation } from 'alfresco-js-api';
|
import { Pagination, ProcessInstanceFilterRepresentation } from 'alfresco-js-api';
|
||||||
import {
|
import {
|
||||||
FORM_FIELD_VALIDATORS, FormEvent, FormFieldEvent, FormRenderingService, FormService,
|
FORM_FIELD_VALIDATORS, FormEvent, FormFieldEvent, FormRenderingService, FormService,
|
||||||
DynamicTableRow, ValidateDynamicTableRowEvent, AppConfigService
|
DynamicTableRow, ValidateDynamicTableRowEvent, AppConfigService, PaginationComponent
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
|
|
||||||
import { AnalyticsReportListComponent } from '@alfresco/adf-insights';
|
import { AnalyticsReportListComponent } from '@alfresco/adf-insights';
|
||||||
@@ -76,6 +76,9 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
@ViewChild(TaskFiltersComponent)
|
@ViewChild(TaskFiltersComponent)
|
||||||
activitifilter: TaskFiltersComponent;
|
activitifilter: TaskFiltersComponent;
|
||||||
|
|
||||||
|
@ViewChild(PaginationComponent)
|
||||||
|
processListPagination: PaginationComponent;
|
||||||
|
|
||||||
@ViewChild(TaskListComponent)
|
@ViewChild(TaskListComponent)
|
||||||
taskList: TaskListComponent;
|
taskList: TaskListComponent;
|
||||||
|
|
||||||
@@ -119,6 +122,8 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
totalItems: 0
|
totalItems: 0
|
||||||
};
|
};
|
||||||
taskPage = 0;
|
taskPage = 0;
|
||||||
|
processPage = 0;
|
||||||
|
paginationPageSize = 0;
|
||||||
processSchemaColumns: any[] = [];
|
processSchemaColumns: any[] = [];
|
||||||
|
|
||||||
supportedPages: number[];
|
supportedPages: number[];
|
||||||
@@ -159,6 +164,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
this.dataTasks.setSorting(new DataSorting('created', 'desc'));
|
this.dataTasks.setSorting(new DataSorting('created', 'desc'));
|
||||||
this.supportedPages = this.preferenceService.getDifferentPageSizes();
|
this.supportedPages = this.preferenceService.getDifferentPageSizes();
|
||||||
this.taskPagination.maxItems = this.preferenceService.paginationSize;
|
this.taskPagination.maxItems = this.preferenceService.paginationSize;
|
||||||
|
this.paginationPageSize = this.preferenceService.paginationSize;
|
||||||
|
|
||||||
this.defaultProcessName = this.appConfig.get<string>('adf-start-process.name');
|
this.defaultProcessName = this.appConfig.get<string>('adf-start-process.name');
|
||||||
this.defaultProcessDefinitionName = this.appConfig.get<string>('adf-start-process.processDefinitionName');
|
this.defaultProcessDefinitionName = this.appConfig.get<string>('adf-start-process.processDefinitionName');
|
||||||
@@ -202,11 +208,26 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
this.taskPage--;
|
this.taskPage--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPrevPageProcess(pagination: Pagination): void {
|
||||||
|
this.processPage = this.processListPagination.current - 1;
|
||||||
|
}
|
||||||
|
|
||||||
onNextPage(pagination: Pagination): void {
|
onNextPage(pagination: Pagination): void {
|
||||||
this.taskPagination.skipCount = pagination.skipCount;
|
this.taskPagination.skipCount = pagination.skipCount;
|
||||||
this.taskPage++;
|
this.taskPage++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onNextPageProcess(pagination: Pagination): void {
|
||||||
|
this.processPage = this.processListPagination.current - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangePageSizeProcess(pagination: Pagination): void {
|
||||||
|
const { maxItems } = pagination;
|
||||||
|
this.preferenceService.paginationSize = maxItems;
|
||||||
|
this.processPage = this.processListPagination.current - 1;
|
||||||
|
this.paginationPageSize = maxItems;
|
||||||
|
}
|
||||||
|
|
||||||
onChangePageSize(pagination: Pagination): void {
|
onChangePageSize(pagination: Pagination): void {
|
||||||
const { skipCount, maxItems } = pagination;
|
const { skipCount, maxItems } = pagination;
|
||||||
this.taskPage = this.currentPage(skipCount, maxItems);
|
this.taskPage = this.currentPage(skipCount, maxItems);
|
||||||
@@ -222,6 +243,10 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
this.taskPagination.skipCount = skipCount;
|
this.taskPagination.skipCount = skipCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChangePageNumberProcess(pagination: Pagination): void {
|
||||||
|
this.processPage = this.processListPagination.current - 1;
|
||||||
|
}
|
||||||
|
|
||||||
currentPage(skipCount: number, maxItems: number): number {
|
currentPage(skipCount: number, maxItems: number): number {
|
||||||
return (skipCount && maxItems) ? Math.floor(skipCount / maxItems) : 0;
|
return (skipCount && maxItems) ? Math.floor(skipCount / maxItems) : 0;
|
||||||
}
|
}
|
||||||
@@ -269,6 +294,12 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
|
|
||||||
onTaskFilterClick(filter: FilterRepresentationModel): void {
|
onTaskFilterClick(filter: FilterRepresentationModel): void {
|
||||||
this.applyTaskFilter(filter);
|
this.applyTaskFilter(filter);
|
||||||
|
this.resetTaskPaginationPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
resetTaskPaginationPage() {
|
||||||
|
this.taskPage = 0;
|
||||||
|
this.taskPagination.skipCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
onReportClick(event: any): void {
|
onReportClick(event: any): void {
|
||||||
@@ -302,6 +333,11 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
|
|
||||||
onProcessFilterClick(event: ProcessInstanceFilterRepresentation): void {
|
onProcessFilterClick(event: ProcessInstanceFilterRepresentation): void {
|
||||||
this.processFilter = event;
|
this.processFilter = event;
|
||||||
|
this.resetProcessPaginationPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
resetProcessPaginationPage() {
|
||||||
|
this.processPage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSuccessProcessFilterList(event: ProcessInstanceFilterRepresentation[]): void {
|
onSuccessProcessFilterList(event: ProcessInstanceFilterRepresentation[]): void {
|
||||||
|
@@ -55,6 +55,8 @@ define custom schema in the app.config.json as shown below json format.
|
|||||||
| presetColumn | string | | The presetColumn of the custom schema to fetch. |
|
| presetColumn | string | | The presetColumn of the custom schema to fetch. |
|
||||||
| state | Define state of the processes. Possible values are `running`, `completed` and `all` | | |
|
| state | Define state of the processes. Possible values are `running`, `completed` and `all` | | |
|
||||||
| sort | Define sort of the processes. Possible values are `created-desc`, `created-asc`, `ended-desc`, `ended-asc` | | |
|
| sort | Define sort of the processes. Possible values are `created-desc`, `created-asc`, `ended-desc`, `ended-asc` | | |
|
||||||
|
| page | number | 0 | The page of the tasks to fetch. |
|
||||||
|
| size | number | 25 | The number of tasks to fetch. |
|
||||||
| schemaColumn | List of columns to display in the process instances datatable (see the [Details](#details) section below) | | |
|
| schemaColumn | List of columns to display in the process instances datatable (see the [Details](#details) section below) | | |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
@@ -134,7 +134,7 @@ You can also use both HTML-based and app.config.json custom schema declaration a
|
|||||||
| processInstanceId | string | | The processInstanceId of the process. |
|
| processInstanceId | string | | The processInstanceId of the process. |
|
||||||
| presetColumn | string | | The presetColumn of the custom schema to fetch. |
|
| presetColumn | string | | The presetColumn of the custom schema to fetch. |
|
||||||
| page | number | 0 | The page of the tasks to fetch. |
|
| page | number | 0 | The page of the tasks to fetch. |
|
||||||
| size | number | 5 | The number of tasks to fetch. |
|
| size | number | 25 | The number of tasks to fetch. |
|
||||||
| assignment | string | | The assignment of the process. <ul>Possible values are: <li>assignee : where the current user is the assignee</li> <li>candidate: where the current user is a task candidate </li><li>group_x: where the task is assigned to a group where the current user is a member of.</li> <li>no value: where the current user is involved</li> </ul> |
|
| assignment | string | | The assignment of the process. <ul>Possible values are: <li>assignee : where the current user is the assignee</li> <li>candidate: where the current user is a task candidate </li><li>group_x: where the task is assigned to a group where the current user is a member of.</li> <li>no value: where the current user is involved</li> </ul> |
|
||||||
| selectionMode | string | 'single' | Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows. |
|
| selectionMode | string | 'single' | Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows. |
|
||||||
| multiselect | boolean | false | Toggles multiple row selection, renders checkboxes at the beginning of each row |
|
| multiselect | boolean | false | Toggles multiple row selection, renders checkboxes at the beginning of each row |
|
||||||
|
@@ -169,35 +169,43 @@ describe('PaginationComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('goes next', () => {
|
it('goes next', () => {
|
||||||
|
expect(component.current).toBe(3);
|
||||||
component.goNext();
|
component.goNext();
|
||||||
|
|
||||||
const { skipCount } = nextPageSpy.calls.mostRecent().args[0];
|
const { skipCount } = nextPageSpy.calls.mostRecent().args[0];
|
||||||
|
|
||||||
expect(skipCount).toBe(75);
|
expect(skipCount).toBe(75);
|
||||||
|
expect(component.current).toBe(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('goes previous', () => {
|
it('goes previous', () => {
|
||||||
|
expect(component.current).toBe(3);
|
||||||
component.goPrevious();
|
component.goPrevious();
|
||||||
|
|
||||||
const { skipCount } = prevPageSpy.calls.mostRecent().args[0];
|
const { skipCount } = prevPageSpy.calls.mostRecent().args[0];
|
||||||
|
|
||||||
expect(skipCount).toBe(25);
|
expect(skipCount).toBe(25);
|
||||||
|
expect(component.current).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('changes page size', () => {
|
it('changes page size', () => {
|
||||||
|
expect(component.current).toBe(3);
|
||||||
component.onChangePageSize(50);
|
component.onChangePageSize(50);
|
||||||
|
|
||||||
const { maxItems } = changePageSizeSpy.calls.mostRecent().args[0];
|
const { maxItems } = changePageSizeSpy.calls.mostRecent().args[0];
|
||||||
|
|
||||||
expect(maxItems).toBe(50);
|
expect(maxItems).toBe(50);
|
||||||
|
expect(component.current).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('changes page number', () => {
|
it('changes page number', () => {
|
||||||
|
expect(component.current).toBe(3);
|
||||||
component.onChangePageNumber(5);
|
component.onChangePageNumber(5);
|
||||||
|
|
||||||
const { skipCount } = changePageNumberSpy.calls.mostRecent().args[0];
|
const { skipCount } = changePageNumberSpy.calls.mostRecent().args[0];
|
||||||
|
|
||||||
expect(skipCount).toBe(100);
|
expect(skipCount).toBe(100);
|
||||||
|
expect(component.current).toBe(5);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -318,10 +326,12 @@ describe('PaginationComponent', () => {
|
|||||||
component.target = customComponent;
|
component.target = customComponent;
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
customComponent.pagination.next(new FakePaginationInput(2, 0, 25));
|
customComponent.pagination.next(new FakePaginationInput(2, 1, 25));
|
||||||
|
expect(component.current).toBe(1);
|
||||||
|
|
||||||
component.goNext();
|
component.goNext();
|
||||||
expect(customComponent.updatePagination).toHaveBeenCalled();
|
expect(customComponent.updatePagination).toHaveBeenCalled();
|
||||||
|
expect(component.current).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -168,6 +168,7 @@ export class PaginationComponent implements OnInit, OnDestroy {
|
|||||||
if (this.hasItems) {
|
if (this.hasItems) {
|
||||||
const maxItems = this.pagination.maxItems;
|
const maxItems = this.pagination.maxItems;
|
||||||
const skipCount = (this.next - 1) * maxItems;
|
const skipCount = (this.next - 1) * maxItems;
|
||||||
|
this.pagination.skipCount = skipCount;
|
||||||
|
|
||||||
this.handlePaginationEvent(PaginationComponent.ACTIONS.NEXT_PAGE, {
|
this.handlePaginationEvent(PaginationComponent.ACTIONS.NEXT_PAGE, {
|
||||||
skipCount,
|
skipCount,
|
||||||
@@ -180,6 +181,7 @@ export class PaginationComponent implements OnInit, OnDestroy {
|
|||||||
if (this.hasItems) {
|
if (this.hasItems) {
|
||||||
const maxItems = this.pagination.maxItems;
|
const maxItems = this.pagination.maxItems;
|
||||||
const skipCount = (this.previous - 1) * maxItems;
|
const skipCount = (this.previous - 1) * maxItems;
|
||||||
|
this.pagination.skipCount = skipCount;
|
||||||
|
|
||||||
this.handlePaginationEvent(PaginationComponent.ACTIONS.PREV_PAGE, {
|
this.handlePaginationEvent(PaginationComponent.ACTIONS.PREV_PAGE, {
|
||||||
skipCount,
|
skipCount,
|
||||||
@@ -192,6 +194,7 @@ export class PaginationComponent implements OnInit, OnDestroy {
|
|||||||
if (this.hasItems) {
|
if (this.hasItems) {
|
||||||
const maxItems = this.pagination.maxItems;
|
const maxItems = this.pagination.maxItems;
|
||||||
const skipCount = (pageNumber - 1) * maxItems;
|
const skipCount = (pageNumber - 1) * maxItems;
|
||||||
|
this.pagination.skipCount = skipCount;
|
||||||
|
|
||||||
this.handlePaginationEvent(PaginationComponent.ACTIONS.CHANGE_PAGE_NUMBER, {
|
this.handlePaginationEvent(PaginationComponent.ACTIONS.CHANGE_PAGE_NUMBER, {
|
||||||
skipCount,
|
skipCount,
|
||||||
@@ -201,6 +204,8 @@ export class PaginationComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onChangePageSize(maxItems: number) {
|
onChangePageSize(maxItems: number) {
|
||||||
|
this.pagination.skipCount = 0;
|
||||||
|
this.pagination.maxItems = maxItems;
|
||||||
this.handlePaginationEvent(PaginationComponent.ACTIONS.CHANGE_PAGE_SIZE, {
|
this.handlePaginationEvent(PaginationComponent.ACTIONS.CHANGE_PAGE_SIZE, {
|
||||||
skipCount: 0,
|
skipCount: 0,
|
||||||
maxItems
|
maxItems
|
||||||
|
@@ -61,48 +61,48 @@ describe('ProcessAttachmentListComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mockAttachment = {
|
mockAttachment = {
|
||||||
'size': 2,
|
size: 2,
|
||||||
'total': 2,
|
total: 2,
|
||||||
'start': 0,
|
start: 0,
|
||||||
'data': [{
|
data: [{
|
||||||
'id': 4001,
|
id: 4001,
|
||||||
'name': 'Invoice01.pdf',
|
name: 'Invoice01.pdf',
|
||||||
'created': '2017-05-12T12:50:05.522+0000',
|
created: '2017-05-12T12:50:05.522+0000',
|
||||||
'createdBy': {
|
createdBy: {
|
||||||
'id': 1,
|
id: 1,
|
||||||
'firstName': 'Apps',
|
firstName: 'Apps',
|
||||||
'lastName': 'Administrator',
|
lastName: 'Administrator',
|
||||||
'email': 'admin@app.activiti.com',
|
email: 'admin@app.activiti.com',
|
||||||
'company': 'Alfresco.com',
|
company: 'Alfresco.com',
|
||||||
'pictureId': 3003
|
pictureId: 3003
|
||||||
},
|
},
|
||||||
'relatedContent': true,
|
relatedContent: true,
|
||||||
'contentAvailable': true,
|
contentAvailable: true,
|
||||||
'link': false,
|
link: false,
|
||||||
'mimeType': 'application/pdf',
|
mimeType: 'application/pdf',
|
||||||
'simpleType': 'pdf',
|
simpleType: 'pdf',
|
||||||
'previewStatus': 'created',
|
previewStatus: 'created',
|
||||||
'thumbnailStatus': 'created'
|
thumbnailStatus: 'created'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 4002,
|
id: 4002,
|
||||||
'name': 'Invoice02.pdf',
|
name: 'Invoice02.pdf',
|
||||||
'created': '2017-05-12T12:50:05.522+0000',
|
created: '2017-05-12T12:50:05.522+0000',
|
||||||
'createdBy': {
|
createdBy: {
|
||||||
'id': 1,
|
id: 1,
|
||||||
'firstName': 'Apps',
|
firstName: 'Apps',
|
||||||
'lastName': 'Administrator',
|
lastName: 'Administrator',
|
||||||
'email': 'admin@app.activiti.com',
|
email: 'admin@app.activiti.com',
|
||||||
'company': 'Alfresco.com',
|
company: 'Alfresco.com',
|
||||||
'pictureId': 3003
|
pictureId: 3003
|
||||||
},
|
},
|
||||||
'relatedContent': true,
|
relatedContent: true,
|
||||||
'contentAvailable': true,
|
contentAvailable: true,
|
||||||
'link': false,
|
link: false,
|
||||||
'mimeType': 'application/pdf',
|
mimeType: 'application/pdf',
|
||||||
'simpleType': 'pdf',
|
simpleType: 'pdf',
|
||||||
'previewStatus': 'created',
|
previewStatus: 'created',
|
||||||
'thumbnailStatus': 'created'
|
thumbnailStatus: 'created'
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -115,6 +115,14 @@ describe('ProcessAttachmentListComponent', () => {
|
|||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
const overlayContainers = <any> window.document.querySelectorAll('.cdk-overlay-container');
|
||||||
|
|
||||||
|
overlayContainers.forEach((overlayContainer) => {
|
||||||
|
overlayContainer.innerHTML = '';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should load attachments when processInstanceId specified', () => {
|
it('should load attachments when processInstanceId specified', () => {
|
||||||
let change = new SimpleChange(null, '123', true);
|
let change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({ 'processInstanceId': change });
|
component.ngOnChanges({ 'processInstanceId': change });
|
||||||
@@ -154,7 +162,7 @@ describe('ProcessAttachmentListComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should display all actions if attachements are not read only', () => {
|
it('should display all actions if attachements are not read only', async(() => {
|
||||||
let change = new SimpleChange(null, '123', true);
|
let change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({ 'processInstanceId': change });
|
component.ngOnChanges({ 'processInstanceId': change });
|
||||||
|
|
||||||
@@ -163,14 +171,15 @@ describe('ProcessAttachmentListComponent', () => {
|
|||||||
actionButton.click();
|
actionButton.click();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let actionMenu = fixture.debugElement.nativeElement.querySelectorAll('button.mat-menu-item').length;
|
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="View"]')).not.toBeNull();
|
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="Remove"]')).not.toBeNull();
|
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).not.toBeNull();
|
||||||
|
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
|
||||||
expect(actionMenu).toBe(3);
|
expect(actionMenu).toBe(3);
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should not display remove action if attachments are read only', () => {
|
it('should not display remove action if attachments are read only', async(() => {
|
||||||
let change = new SimpleChange(null, '123', true);
|
let change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({ 'processInstanceId': change });
|
component.ngOnChanges({ 'processInstanceId': change });
|
||||||
component.disabled = true;
|
component.disabled = true;
|
||||||
@@ -180,12 +189,13 @@ describe('ProcessAttachmentListComponent', () => {
|
|||||||
actionButton.click();
|
actionButton.click();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let actionMenu = fixture.debugElement.nativeElement.querySelectorAll('button.mat-menu-item').length;
|
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="View"]')).not.toBeNull();
|
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="Remove"]')).toBeNull();
|
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
|
||||||
|
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).toBeNull();
|
||||||
expect(actionMenu).toBe(2);
|
expect(actionMenu).toBe(2);
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should show the empty list component when the attachments list is empty', async(() => {
|
it('should show the empty list component when the attachments list is empty', async(() => {
|
||||||
getProcessRelatedContentSpy.and.returnValue(Observable.of({
|
getProcessRelatedContentSpy.and.returnValue(Observable.of({
|
||||||
@@ -325,12 +335,12 @@ describe('Custom CustomEmptyTemplateComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render the custom template', () => {
|
it('should render the custom template', async(() => {
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
|
let title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
|
||||||
expect(title.length).toBe(1);
|
expect(title.length).toBe(1);
|
||||||
expect(title[0].nativeElement.innerText).toBe('Custom header');
|
expect(title[0].nativeElement.innerText).toBe('Custom header');
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
|
@@ -61,7 +61,7 @@ export class ProcessAttachmentListComponent implements OnChanges, AfterContentIn
|
|||||||
hasCustomTemplate: boolean = false;
|
hasCustomTemplate: boolean = false;
|
||||||
|
|
||||||
attachments: any[] = [];
|
attachments: any[] = [];
|
||||||
isLoading: boolean = true;
|
isLoading: boolean = false;
|
||||||
|
|
||||||
constructor(private activitiContentService: ProcessContentService,
|
constructor(private activitiContentService: ProcessContentService,
|
||||||
private contentService: ContentService,
|
private contentService: ContentService,
|
||||||
|
@@ -99,6 +99,13 @@ describe('TaskAttachmentList', () => {
|
|||||||
getFileRawContentSpy = spyOn(service, 'getFileRawContent').and.returnValue(Observable.of(blobObj));
|
getFileRawContentSpy = spyOn(service, 'getFileRawContent').and.returnValue(Observable.of(blobObj));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
const overlayContainers = <any> window.document.querySelectorAll('.cdk-overlay-container');
|
||||||
|
overlayContainers.forEach((overlayContainer) => {
|
||||||
|
overlayContainer.innerHTML = '';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should load attachments when taskId specified', () => {
|
it('should load attachments when taskId specified', () => {
|
||||||
let change = new SimpleChange(null, '123', true);
|
let change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({ 'taskId': change });
|
component.ngOnChanges({ 'taskId': change });
|
||||||
@@ -168,7 +175,7 @@ describe('TaskAttachmentList', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should display all actions if attachments are not read only', () => {
|
it('should display all actions if attachments are not read only', async(() => {
|
||||||
let change = new SimpleChange(null, '123', true);
|
let change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({ 'taskId': change });
|
component.ngOnChanges({ 'taskId': change });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -177,14 +184,15 @@ describe('TaskAttachmentList', () => {
|
|||||||
actionButton.click();
|
actionButton.click();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let actionMenu = fixture.debugElement.nativeElement.querySelectorAll('button.mat-menu-item').length;
|
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="View"]')).not.toBeNull();
|
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="Remove"]')).not.toBeNull();
|
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).not.toBeNull();
|
||||||
|
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
|
||||||
expect(actionMenu).toBe(3);
|
expect(actionMenu).toBe(3);
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should not display remove action if attachments are read only', () => {
|
it('should not display remove action if attachments are read only', async(() => {
|
||||||
let change = new SimpleChange(null, '123', true);
|
let change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({ 'taskId': change });
|
component.ngOnChanges({ 'taskId': change });
|
||||||
component.disabled = true;
|
component.disabled = true;
|
||||||
@@ -194,12 +202,13 @@ describe('TaskAttachmentList', () => {
|
|||||||
actionButton.click();
|
actionButton.click();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let actionMenu = fixture.debugElement.nativeElement.querySelectorAll('button.mat-menu-item').length;
|
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="View"]')).not.toBeNull();
|
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="Remove"]')).toBeNull();
|
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
|
||||||
|
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).toBeNull();
|
||||||
expect(actionMenu).toBe(2);
|
expect(actionMenu).toBe(2);
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should show the empty list component when the attachments list is empty', async(() => {
|
it('should show the empty list component when the attachments list is empty', async(() => {
|
||||||
getTaskRelatedContentSpy.and.returnValue(Observable.of({
|
getTaskRelatedContentSpy.and.returnValue(Observable.of({
|
||||||
@@ -330,12 +339,12 @@ describe('Custom CustomEmptyTemplateComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render the custom template', () => {
|
it('should render the custom template', async(() => {
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
|
let title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
|
||||||
expect(title.length).toBe(1);
|
expect(title.length).toBe(1);
|
||||||
expect(title[0].nativeElement.innerText).toBe('Custom header');
|
expect(title[0].nativeElement.innerText).toBe('Custom header');
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
|
@@ -104,7 +104,7 @@ describe('CommentsComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should display comments count when the task has comments', () => {
|
it('should display comments count when the task has comments', async(() => {
|
||||||
let change = new SimpleChange(null, '123', true);
|
let change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({ 'taskId': change });
|
component.ngOnChanges({ 'taskId': change });
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
@@ -112,7 +112,7 @@ describe('CommentsComponent', () => {
|
|||||||
let element = fixture.nativeElement.querySelector('#comment-header');
|
let element = fixture.nativeElement.querySelector('#comment-header');
|
||||||
expect(element.innerText).toBe('ADF_TASK_LIST.DETAILS.COMMENTS.HEADER');
|
expect(element.innerText).toBe('ADF_TASK_LIST.DETAILS.COMMENTS.HEADER');
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should not display comments when the task has no comments', async(() => {
|
it('should not display comments when the task has no comments', async(() => {
|
||||||
component.taskId = '123';
|
component.taskId = '123';
|
||||||
|
@@ -100,7 +100,7 @@ describe('ActivitiProcessInstanceComments', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should display comments count when the process has comments', () => {
|
it('should display comments count when the process has comments', async(() => {
|
||||||
let change = new SimpleChange(null, '123', true);
|
let change = new SimpleChange(null, '123', true);
|
||||||
component.ngOnChanges({ 'processInstanceId': change });
|
component.ngOnChanges({ 'processInstanceId': change });
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ describe('ActivitiProcessInstanceComments', () => {
|
|||||||
let element = fixture.nativeElement.querySelector('#comment-header');
|
let element = fixture.nativeElement.querySelector('#comment-header');
|
||||||
expect(element.innerText).toBe('ADF_PROCESS_LIST.DETAILS.COMMENTS.HEADER');
|
expect(element.innerText).toBe('ADF_PROCESS_LIST.DETAILS.COMMENTS.HEADER');
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should not display comments when the process has no comments', async(() => {
|
it('should not display comments when the process has no comments', async(() => {
|
||||||
let change = new SimpleChange(null, '123', true);
|
let change = new SimpleChange(null, '123', true);
|
||||||
|
@@ -15,60 +15,75 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ProcessInstance } from '../../process-list/models/process-instance.model';
|
export let fakeProcessInstance = {
|
||||||
|
size: 2, total: 2, start: 0,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: '1', name: 'Process 773443333', businessKey: null,
|
||||||
|
processDefinitionId: 'fakeprocess:5:7507',
|
||||||
|
tenantId: 'tenant_1',
|
||||||
|
started: '2015-11-09T12:36:14.184+0000',
|
||||||
|
ended: null,
|
||||||
|
startedBy: { id: 3, firstName: 'tenant2', lastName: 'tenantLastname', email: 'tenant2@tenant'},
|
||||||
|
processDefinitionName: 'Fake Process Name',
|
||||||
|
processDefinitionDescription: null,
|
||||||
|
processDefinitionKey: 'fakeprocess',
|
||||||
|
processDefinitionCategory: 'http://www.activiti.org/processdef',
|
||||||
|
processDefinitionVersion: 1,
|
||||||
|
processDefinitionDeploymentId: '2540',
|
||||||
|
graphicalNotationDefined: true,
|
||||||
|
startFormDefined: false,
|
||||||
|
suspended: false,
|
||||||
|
variables: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '2', name: 'Process 382927392', businessKey: null,
|
||||||
|
processDefinitionId: 'fakeprocess:5:7507',
|
||||||
|
tenantId: 'tenant_1',
|
||||||
|
started: '2018-01-10T17:02:22.597+0000',
|
||||||
|
ended: null,
|
||||||
|
startedBy: { id: 3, firstName: 'tenant2', lastName: 'tenantLastname', email: 'tenant2@tenant' },
|
||||||
|
processDefinitionName: 'Fake Process Name',
|
||||||
|
processDefinitionDescription: null,
|
||||||
|
processDefinitionKey: 'fakeprocess',
|
||||||
|
processDefinitionCategory: 'http://www.activiti.org/processdef',
|
||||||
|
processDefinitionVersion: 1,
|
||||||
|
processDefinitionDeploymentId: '2540',
|
||||||
|
graphicalNotationDefined: true,
|
||||||
|
startFormDefined: false,
|
||||||
|
suspended: false,
|
||||||
|
variables: []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
export let fakeProcessInstance = [
|
export let fakeProcessInstancesWithNoName = {
|
||||||
new ProcessInstance({
|
size: 2, total: 2, start: 0,
|
||||||
id: 1,
|
data: [
|
||||||
name: 'Process 773443333',
|
{
|
||||||
processDefinitionId: 'fakeprocess:5:7507',
|
id: '1',
|
||||||
processDefinitionKey: 'fakeprocess',
|
name: null,
|
||||||
processDefinitionName: 'Fake Process Name',
|
processDefinitionId: 'fakeprocess:5:7507',
|
||||||
description: null, category: null,
|
processDefinitionKey: 'fakeprocess',
|
||||||
started: '2015-11-09T12:36:14.184+0000',
|
processDefinitionName: 'Fake Process Name',
|
||||||
startedBy: {
|
description: null, category: null,
|
||||||
id: 3, firstName: 'tenant2', lastName: 'tenantLastname', email: 'tenant2@tenant'
|
started: '2017-11-09T12:36:14.184+0000',
|
||||||
|
startedBy: {
|
||||||
|
id: 3, firstName: 'tenant2', lastName: 'tenantLastname', email: 'tenant2@tenant'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: '',
|
||||||
|
processDefinitionId: 'fakeprocess:5:7507',
|
||||||
|
processDefinitionKey: 'fakeprocess',
|
||||||
|
processDefinitionName: 'Fake Process Name',
|
||||||
|
description: null,
|
||||||
|
category: null,
|
||||||
|
started: '2017-11-09T12:37:25.184+0000',
|
||||||
|
startedBy: {
|
||||||
|
id: 3, firstName: 'tenant2', lastName: 'tenantLastname', email: 'tenant2@tenant'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}),
|
]
|
||||||
new ProcessInstance({
|
};
|
||||||
id: 2,
|
|
||||||
name: 'Process 382927392',
|
|
||||||
processDefinitionId: 'fakeprocess:5:7507',
|
|
||||||
processDefinitionKey: 'fakeprocess',
|
|
||||||
processDefinitionName: 'Fake Process Name',
|
|
||||||
description: null,
|
|
||||||
category: null,
|
|
||||||
started: '2017-11-09T12:37:25.184+0000',
|
|
||||||
startedBy: {
|
|
||||||
id: 3, firstName: 'tenant2', lastName: 'tenantLastname', email: 'tenant2@tenant'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
export let fakeProcessInstancesWithNoName = [
|
|
||||||
new ProcessInstance({
|
|
||||||
id: 1,
|
|
||||||
name: null,
|
|
||||||
processDefinitionId: 'fakeprocess:5:7507',
|
|
||||||
processDefinitionKey: 'fakeprocess',
|
|
||||||
processDefinitionName: 'Fake Process Name',
|
|
||||||
description: null, category: null,
|
|
||||||
started: '2017-11-09T12:36:14.184+0000',
|
|
||||||
startedBy: {
|
|
||||||
id: 3, firstName: 'tenant2', lastName: 'tenantLastname', email: 'tenant2@tenant'
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
new ProcessInstance({
|
|
||||||
id: 2,
|
|
||||||
name: '',
|
|
||||||
processDefinitionId: 'fakeprocess:5:7507',
|
|
||||||
processDefinitionKey: 'fakeprocess',
|
|
||||||
processDefinitionName: 'Fake Process Name',
|
|
||||||
description: null,
|
|
||||||
category: null,
|
|
||||||
started: '2017-11-09T12:37:25.184+0000',
|
|
||||||
startedBy: {
|
|
||||||
id: 3, firstName: 'tenant2', lastName: 'tenantLastname', email: 'tenant2@tenant'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
@@ -16,20 +16,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { DataColumn, DataRowEvent, DataSorting, DataTableAdapter, ObjectDataColumn, ObjectDataRow, ObjectDataTableAdapter } from '@alfresco/adf-core';
|
import { DataColumn, DataRowEvent, DataSorting, DataTableAdapter, ObjectDataColumn, ObjectDataRow, ObjectDataTableAdapter } from '@alfresco/adf-core';
|
||||||
import { AppConfigService, DataColumnListComponent } from '@alfresco/adf-core';
|
import { AppConfigService, DataColumnListComponent, PaginatedComponent, PaginationComponent, PaginationQueryParams, UserPreferencesService } from '@alfresco/adf-core';
|
||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { AfterContentInit, Component, ContentChild, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
import { AfterContentInit, Component, ContentChild, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
||||||
import { ProcessFilterParamRepresentationModel } from '../models/filter-process.model';
|
import { ProcessFilterParamRepresentationModel } from '../models/filter-process.model';
|
||||||
import { ProcessInstance } from '../models/process-instance.model';
|
|
||||||
import { processPresetsDefaultModel } from '../models/process-preset.model';
|
import { processPresetsDefaultModel } from '../models/process-preset.model';
|
||||||
import { ProcessService } from '../services/process.service';
|
import { ProcessService } from '../services/process.service';
|
||||||
|
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||||
|
import { Pagination } from 'alfresco-js-api';
|
||||||
|
import { ProcessListModel } from '../models/process-list.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-process-instance-list',
|
selector: 'adf-process-instance-list',
|
||||||
styleUrls: ['./process-list.component.css'],
|
styleUrls: ['./process-list.component.css'],
|
||||||
templateUrl: './process-list.component.html'
|
templateUrl: './process-list.component.html'
|
||||||
})
|
})
|
||||||
export class ProcessInstanceListComponent implements OnChanges, AfterContentInit {
|
export class ProcessInstanceListComponent implements OnChanges, AfterContentInit, PaginatedComponent {
|
||||||
|
|
||||||
@ContentChild(DataColumnListComponent) columnList: DataColumnListComponent;
|
@ContentChild(DataColumnListComponent) columnList: DataColumnListComponent;
|
||||||
|
|
||||||
@@ -56,6 +58,12 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
/** The presetColumn of the custom schema to fetch. */
|
/** The presetColumn of the custom schema to fetch. */
|
||||||
|
@Input()
|
||||||
|
page: number = 0;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
size: number = PaginationComponent.DEFAULT_PAGINATION.maxItems;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
presetColumn: string;
|
presetColumn: string;
|
||||||
|
|
||||||
@@ -71,7 +79,7 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
|
|
||||||
/** Emitted when the list of process instances has been loaded successfully from the server. */
|
/** Emitted when the list of process instances has been loaded successfully from the server. */
|
||||||
@Output()
|
@Output()
|
||||||
success: EventEmitter<ProcessInstance[]> = new EventEmitter<ProcessInstance[]>();
|
success: EventEmitter<ProcessListModel> = new EventEmitter<ProcessListModel>();
|
||||||
|
|
||||||
/** Emitted when an error occurs while loading the list of process instances from the server. */
|
/** Emitted when an error occurs while loading the list of process instances from the server. */
|
||||||
@Output()
|
@Output()
|
||||||
@@ -81,8 +89,18 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
isLoading: boolean = true;
|
isLoading: boolean = true;
|
||||||
layoutPresets = {};
|
layoutPresets = {};
|
||||||
|
|
||||||
|
pagination: BehaviorSubject<Pagination>;
|
||||||
|
|
||||||
constructor(private processService: ProcessService,
|
constructor(private processService: ProcessService,
|
||||||
|
private userPreferences: UserPreferencesService,
|
||||||
private appConfig: AppConfigService) {
|
private appConfig: AppConfigService) {
|
||||||
|
this.size = this.userPreferences.paginationSize;
|
||||||
|
|
||||||
|
this.pagination = new BehaviorSubject<Pagination>(<Pagination> {
|
||||||
|
maxItems: this.size,
|
||||||
|
skipCount: 0,
|
||||||
|
totalItems: 0
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterContentInit() {
|
ngAfterContentInit() {
|
||||||
@@ -130,6 +148,8 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
let state = changes['state'];
|
let state = changes['state'];
|
||||||
let sort = changes['sort'];
|
let sort = changes['sort'];
|
||||||
let name = changes['name'];
|
let name = changes['name'];
|
||||||
|
let page = changes['page'];
|
||||||
|
let size = changes['size'];
|
||||||
|
|
||||||
if (appId && appId.currentValue) {
|
if (appId && appId.currentValue) {
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -141,6 +161,10 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
changed = true;
|
changed = true;
|
||||||
} else if (name && name.currentValue) {
|
} else if (name && name.currentValue) {
|
||||||
changed = true;
|
changed = true;
|
||||||
|
} else if (page && page.currentValue !== page.previousValue) {
|
||||||
|
changed = true;
|
||||||
|
} else if (size && size.currentValue !== size.previousValue) {
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -155,11 +179,17 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
this.processService.getProcessInstances(requestNode, this.processDefinitionKey)
|
this.processService.getProcessInstances(requestNode, this.processDefinitionKey)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
let instancesRow = this.createDataRow(response);
|
let instancesRow = this.createDataRow(response.data);
|
||||||
this.renderInstances(instancesRow);
|
this.renderInstances(instancesRow);
|
||||||
this.selectFirst();
|
this.selectFirst();
|
||||||
this.success.emit(response);
|
this.success.emit(response);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
this.pagination.next({
|
||||||
|
count: response.data.length,
|
||||||
|
maxItems: this.size,
|
||||||
|
skipCount: this.page * this.size,
|
||||||
|
totalItems: response.total
|
||||||
|
});
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
this.error.emit(error);
|
this.error.emit(error);
|
||||||
@@ -297,7 +327,10 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
let requestNode = {
|
let requestNode = {
|
||||||
appDefinitionId: this.appId,
|
appDefinitionId: this.appId,
|
||||||
state: this.state,
|
state: this.state,
|
||||||
sort: this.sort
|
sort: this.sort,
|
||||||
|
page: this.page,
|
||||||
|
size: this.size,
|
||||||
|
start: 0
|
||||||
};
|
};
|
||||||
return new ProcessFilterParamRepresentationModel(requestNode);
|
return new ProcessFilterParamRepresentationModel(requestNode);
|
||||||
}
|
}
|
||||||
@@ -323,4 +356,12 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit
|
|||||||
private getLayoutPreset(name: string = 'default'): DataColumn[] {
|
private getLayoutPreset(name: string = 'default'): DataColumn[] {
|
||||||
return (this.layoutPresets[name] || this.layoutPresets['default']).map(col => new ObjectDataColumn(col));
|
return (this.layoutPresets[name] || this.layoutPresets['default']).map(col => new ObjectDataColumn(col));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePagination(params: PaginationQueryParams) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
get supportedPageSizes(): number[] {
|
||||||
|
return this.userPreferences.getDifferentPageSizes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,27 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2016 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { ProcessInstance } from './process-instance.model';
|
||||||
|
|
||||||
|
export interface ProcessListModel {
|
||||||
|
size: number;
|
||||||
|
total: number;
|
||||||
|
start: number;
|
||||||
|
length: number;
|
||||||
|
data: ProcessInstance [];
|
||||||
|
|
||||||
|
}
|
@@ -64,13 +64,13 @@ describe('ProcessService', () => {
|
|||||||
|
|
||||||
it('should return the correct number of instances', async(() => {
|
it('should return the correct number of instances', async(() => {
|
||||||
service.getProcessInstances(filter).subscribe((instances) => {
|
service.getProcessInstances(filter).subscribe((instances) => {
|
||||||
expect(instances.length).toBe(1);
|
expect(instances.data.length).toBe(1);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return the correct instance data', async(() => {
|
it('should return the correct instance data', async(() => {
|
||||||
service.getProcessInstances(filter).subscribe((instances) => {
|
service.getProcessInstances(filter).subscribe((instances) => {
|
||||||
let instance = instances[0];
|
let instance = instances.data[0];
|
||||||
expect(instance.id).toBe(exampleProcess.id);
|
expect(instance.id).toBe(exampleProcess.id);
|
||||||
expect(instance.name).toBe(exampleProcess.name);
|
expect(instance.name).toBe(exampleProcess.name);
|
||||||
expect(instance.started).toBe(exampleProcess.started);
|
expect(instance.started).toBe(exampleProcess.started);
|
||||||
@@ -81,8 +81,8 @@ describe('ProcessService', () => {
|
|||||||
getProcessInstances = getProcessInstances.and.returnValue(Promise.resolve(fakeProcessInstances));
|
getProcessInstances = getProcessInstances.and.returnValue(Promise.resolve(fakeProcessInstances));
|
||||||
|
|
||||||
service.getProcessInstances(filter, 'fakeProcessDefinitionKey1').subscribe((instances) => {
|
service.getProcessInstances(filter, 'fakeProcessDefinitionKey1').subscribe((instances) => {
|
||||||
expect(instances.length).toBe(1);
|
expect(instances.data.length).toBe(1);
|
||||||
let instance = instances[0];
|
let instance = instances.data[0];
|
||||||
expect(instance.id).toBe('340124');
|
expect(instance.id).toBe('340124');
|
||||||
expect(instance.name).toBe('James Franklin EMEA Onboarding');
|
expect(instance.name).toBe('James Franklin EMEA Onboarding');
|
||||||
expect(instance.started).toEqual(new Date('2017-10-09T12:19:44.560+0000'));
|
expect(instance.started).toEqual(new Date('2017-10-09T12:19:44.560+0000'));
|
||||||
|
@@ -23,6 +23,7 @@ import { ProcessFilterParamRepresentationModel } from '../models/filter-process.
|
|||||||
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
|
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
|
||||||
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
||||||
import { ProcessInstance } from '../models/process-instance.model';
|
import { ProcessInstance } from '../models/process-instance.model';
|
||||||
|
import { ProcessListModel } from '../models/process-list.model';
|
||||||
import 'rxjs/add/observable/throw';
|
import 'rxjs/add/observable/throw';
|
||||||
|
|
||||||
declare let moment: any;
|
declare let moment: any;
|
||||||
@@ -33,13 +34,15 @@ export class ProcessService {
|
|||||||
constructor(private alfrescoApiService: AlfrescoApiService) {
|
constructor(private alfrescoApiService: AlfrescoApiService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getProcessInstances(requestNode: ProcessFilterParamRepresentationModel, processDefinitionKey?: string): Observable<ProcessInstance[]> {
|
getProcessInstances(requestNode: ProcessFilterParamRepresentationModel, processDefinitionKey?: string): Observable<ProcessListModel> {
|
||||||
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstances(requestNode))
|
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstances(requestNode))
|
||||||
.map((res: any) => {
|
.map((res: any) => {
|
||||||
if (processDefinitionKey) {
|
if (processDefinitionKey) {
|
||||||
return res.data.filter(process => process.processDefinitionKey === processDefinitionKey);
|
const filtered = res.data.filter(process => process.processDefinitionKey === processDefinitionKey);
|
||||||
|
res.data = filtered;
|
||||||
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return res.data;
|
return res;
|
||||||
}
|
}
|
||||||
}).catch(err => this.handleProcessError(err));
|
}).catch(err => this.handleProcessError(err));
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { DataColumn, DataRowEvent, DataTableAdapter, ObjectDataColumn, ObjectDataRow, ObjectDataTableAdapter } from '@alfresco/adf-core';
|
import { DataColumn, DataRowEvent, DataTableAdapter, ObjectDataColumn, ObjectDataRow, ObjectDataTableAdapter } from '@alfresco/adf-core';
|
||||||
import { AppConfigService, DataColumnListComponent } from '@alfresco/adf-core';
|
import { AppConfigService, DataColumnListComponent, PaginationComponent } from '@alfresco/adf-core';
|
||||||
import { AfterContentInit, Component, ContentChild, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
import { AfterContentInit, Component, ContentChild, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
||||||
@@ -24,7 +24,6 @@ import { TaskListModel } from '../models/task-list.model';
|
|||||||
import { taskPresetsDefaultModel } from '../models/task-preset.model';
|
import { taskPresetsDefaultModel } from '../models/task-preset.model';
|
||||||
import { TaskListService } from './../services/tasklist.service';
|
import { TaskListService } from './../services/tasklist.service';
|
||||||
|
|
||||||
const DEFAULT_SIZE = 5;
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-tasklist',
|
selector: 'adf-tasklist',
|
||||||
templateUrl: './task-list.component.html',
|
templateUrl: './task-list.component.html',
|
||||||
@@ -120,7 +119,7 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit {
|
|||||||
|
|
||||||
/* The number of tasks to fetch. */
|
/* The number of tasks to fetch. */
|
||||||
@Input()
|
@Input()
|
||||||
size: number = DEFAULT_SIZE;
|
size: number = PaginationComponent.DEFAULT_PAGINATION.maxItems;
|
||||||
|
|
||||||
isLoading: boolean = true;
|
isLoading: boolean = true;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user