[ADF-4055] ProcessAttachmentListComponent- add opt parameter on process-instances api call (#4292)

* [ADF-4055] ProcessAttachmentListComponent - add opts parameter on load  attachments api call

* [ADF-4055] fix lint

* [ADF-4055] - fix unit test

* [ADF-4055] - change opt parameter format

* [ADF-4055] remove useless unit test from process-content
This commit is contained in:
Silviu Popa 2019-02-12 07:54:31 +02:00 committed by Eugenio Romano
parent c55cba5514
commit 0683c4d226
4 changed files with 15 additions and 5 deletions

View File

@ -196,5 +196,4 @@ describe('ProcessContentService', () => {
done(); done();
}); });
}); });
}); });

View File

@ -128,10 +128,11 @@ export class ProcessContentService {
/** /**
* Gets related content items for a process instance. * Gets related content items for a process instance.
* @param processId ID of the target process * @param processId ID of the target process
* @param opts Options supported by JS-API
* @returns Metadata for the content * @returns Metadata for the content
*/ */
getProcessRelatedContent(processId: string): Observable<any> { getProcessRelatedContent(processId: string, opts?: any): Observable<any> {
return from(this.contentApi.getRelatedContentForProcessInstance(processId)) return from(this.contentApi.getRelatedContentForProcessInstance(processId, opts))
.pipe(catchError((err) => this.handleError(err))); .pipe(catchError((err) => this.handleError(err)));
} }

View File

@ -240,6 +240,15 @@ describe('ProcessAttachmentListComponent', () => {
}); });
})); }));
it('should call getProcessRelatedContent with opt isRelatedContent=true', () => {
getProcessRelatedContentSpy.and.returnValue(of(mockAttachment));
const change = new SimpleChange(null, '123', true);
const isRelatedContent = 'true';
component.ngOnChanges({'processInstanceId': change});
expect(getProcessRelatedContentSpy).toHaveBeenCalled();
expect(getProcessRelatedContentSpy).toHaveBeenCalledWith('123', isRelatedContent);
});
describe('change detection', () => { describe('change detection', () => {
let change = new SimpleChange('123', '456', true); let change = new SimpleChange('123', '456', true);
@ -254,7 +263,7 @@ describe('ProcessAttachmentListComponent', () => {
it('should fetch new attachments when processInstanceId changed', () => { it('should fetch new attachments when processInstanceId changed', () => {
component.ngOnChanges({ 'processInstanceId': change }); component.ngOnChanges({ 'processInstanceId': change });
expect(getProcessRelatedContentSpy).toHaveBeenCalledWith('456'); expect(getProcessRelatedContentSpy).toHaveBeenCalledWith('456', 'true');
}); });
it('should NOT fetch new attachments when empty changeset made', () => { it('should NOT fetch new attachments when empty changeset made', () => {

View File

@ -111,7 +111,8 @@ export class ProcessAttachmentListComponent implements OnChanges, AfterContentIn
if (processInstanceId) { if (processInstanceId) {
this.reset(); this.reset();
this.isLoading = true; this.isLoading = true;
this.activitiContentService.getProcessRelatedContent(processInstanceId).subscribe( const opts: string = 'true';
this.activitiContentService.getProcessRelatedContent(processInstanceId, opts).subscribe(
(res: any) => { (res: any) => {
res.data.forEach((content) => { res.data.forEach((content) => {
this.attachments.push({ this.attachments.push({