mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
fix thumbnail task process list (#1951)
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
(showRowActionsMenu)="onShowRowActionsMenu($event)"
|
||||
(executeRowAction)="onExecuteRowAction($event)">
|
||||
<data-columns>
|
||||
<data-column key="icon" type="image" class="icon-cell" srTitle="Thumbnail" [sortable]="false"></data-column>
|
||||
<data-column key="icon" type="icon" srTitle="Thumbnail" [sortable]="false"></data-column>
|
||||
<data-column key="name" type="text" title="Name" class="full-width ellipsis-cell" [sortable]="true"></data-column>
|
||||
<data-column key="created" type="date" format="shortDate" title="Created On"></data-column>
|
||||
</data-columns>
|
||||
</alfresco-datatable>
|
||||
</alfresco-datatable>
|
||||
|
@@ -36,6 +36,7 @@ describe('Activiti Process Instance Attachment List', () => {
|
||||
let getProcessRelatedContentSpy: jasmine.Spy;
|
||||
let deleteContentSpy: jasmine.Spy;
|
||||
let getFileRawContentSpy: jasmine.Spy;
|
||||
let mockAttachment: any;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -59,31 +60,30 @@ describe('Activiti Process Instance Attachment List', () => {
|
||||
component = fixture.componentInstance;
|
||||
service = fixture.debugElement.injector.get(ActivitiContentService);
|
||||
|
||||
getProcessRelatedContentSpy = spyOn(service, 'getProcessRelatedContent').and.returnValue(Observable.of(
|
||||
{
|
||||
'size': 2,
|
||||
'total': 2,
|
||||
'start': 0,
|
||||
'data': [{
|
||||
'id': 4001,
|
||||
'name': 'Invoice01.pdf',
|
||||
'created': '2017-05-12T12:50:05.522+0000',
|
||||
'createdBy': {
|
||||
'id': 1,
|
||||
'firstName': 'Apps',
|
||||
'lastName': 'Administrator',
|
||||
'email': 'admin@app.activiti.com',
|
||||
'company': 'Alfresco.com',
|
||||
'pictureId': 3003
|
||||
},
|
||||
'relatedContent': true,
|
||||
'contentAvailable': true,
|
||||
'link': false,
|
||||
'mimeType': 'application/pdf',
|
||||
'simpleType': 'pdf',
|
||||
'previewStatus': 'created',
|
||||
'thumbnailStatus': 'created'
|
||||
mockAttachment = {
|
||||
'size': 2,
|
||||
'total': 2,
|
||||
'start': 0,
|
||||
'data': [{
|
||||
'id': 4001,
|
||||
'name': 'Invoice01.pdf',
|
||||
'created': '2017-05-12T12:50:05.522+0000',
|
||||
'createdBy': {
|
||||
'id': 1,
|
||||
'firstName': 'Apps',
|
||||
'lastName': 'Administrator',
|
||||
'email': 'admin@app.activiti.com',
|
||||
'company': 'Alfresco.com',
|
||||
'pictureId': 3003
|
||||
},
|
||||
'relatedContent': true,
|
||||
'contentAvailable': true,
|
||||
'link': false,
|
||||
'mimeType': 'application/pdf',
|
||||
'simpleType': 'pdf',
|
||||
'previewStatus': 'created',
|
||||
'thumbnailStatus': 'created'
|
||||
},
|
||||
{
|
||||
'id': 4002,
|
||||
'name': 'Invoice02.pdf',
|
||||
@@ -104,7 +104,9 @@ describe('Activiti Process Instance Attachment List', () => {
|
||||
'previewStatus': 'created',
|
||||
'thumbnailStatus': 'created'
|
||||
}]
|
||||
}));
|
||||
};
|
||||
|
||||
getProcessRelatedContentSpy = spyOn(service, 'getProcessRelatedContent').and.returnValue(Observable.of(mockAttachment));
|
||||
|
||||
deleteContentSpy = spyOn(service, 'deleteRelatedContent').and.returnValue(Observable.of({successCode: true}));
|
||||
|
||||
@@ -134,6 +136,16 @@ describe('Activiti Process Instance Attachment List', () => {
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit a success event when the attachments are loaded', () => {
|
||||
let change = new SimpleChange(null, '123', true);
|
||||
component.success.subscribe((attachments) => {
|
||||
expect(attachments[0].name).toEqual(mockAttachment.data[0].name);
|
||||
expect(attachments[0].id).toEqual(mockAttachment.data[0].id);
|
||||
});
|
||||
|
||||
component.ngOnChanges({'taskId': change});
|
||||
});
|
||||
|
||||
it('should not attach when no processInstanceId is specified', () => {
|
||||
fixture.detectChanges();
|
||||
expect(getProcessRelatedContentSpy).not.toHaveBeenCalled();
|
||||
|
@@ -32,6 +32,9 @@ export class ActivitiProcessAttachmentListComponent implements OnChanges {
|
||||
@Output()
|
||||
attachmentClick = new EventEmitter();
|
||||
|
||||
@Output()
|
||||
success = new EventEmitter();
|
||||
|
||||
@Output()
|
||||
error: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
@@ -42,14 +45,13 @@ export class ActivitiProcessAttachmentListComponent implements OnChanges {
|
||||
private contentService: ContentService) {
|
||||
|
||||
if (translateService) {
|
||||
translateService.addTranslationFolder('ng2-activiti-processlist', 'node_modules/ng2-activiti-processlist/src');
|
||||
translateService.addTranslationFolder('ng2-activiti-processlist', 'assets/ng2-activiti-processlist');
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes['processInstanceId'] && changes['processInstanceId'].currentValue) {
|
||||
this.processInstanceId = changes['processInstanceId'].currentValue;
|
||||
this.loadAttachmentsByProcessInstanceId(this.processInstanceId);
|
||||
this.loadAttachmentsByProcessInstanceId(changes['processInstanceId'].currentValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +73,7 @@ export class ActivitiProcessAttachmentListComponent implements OnChanges {
|
||||
icon: this.activitiContentService.getMimeTypeIcon(content.mimeType)
|
||||
});
|
||||
});
|
||||
|
||||
this.success.emit(this.attachments);
|
||||
},
|
||||
(err) => {
|
||||
this.error.emit(err);
|
||||
@@ -149,9 +151,6 @@ export class ActivitiProcessAttachmentListComponent implements OnChanges {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke content download.
|
||||
*/
|
||||
downloadContent(content: any): void {
|
||||
this.activitiContentService.getFileRawContent(content.id).subscribe(
|
||||
(blob: Blob) => this.contentService.downloadBlob(blob, content.name),
|
||||
|
Reference in New Issue
Block a user