diff --git a/docs/README.md b/docs/README.md index 6cb106f313..48d4d5f9a8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -441,7 +441,6 @@ for more information about installing and using the source code. | Name | Description | Source link | | ---- | ----------- | ----------- | | [Claim Task Directive](process-services/directives/claim-task.directive.md) ![Experimental](docassets/images/ExperimentalIcon.png) | Claims a task | [Source](../lib/process-services/src/lib/task-list/components/task-form/claim-task.directive.ts) | -| [Process Audit Directive](process-services/directives/process-audit.directive.md) | Fetches the Process Audit information in PDF or JSON format. | [Source](../lib/process-services/src/lib/process-list/components/process-audit/process-audit.directive.ts) | | [Unclaim Task Directive](process-services/directives/unclaim-task.directive.md) ![Experimental](docassets/images/ExperimentalIcon.png) | Unclaims a task | [Source](../lib/process-services/src/lib/task-list/components/task-form/unclaim-task.directive.ts) | ### Services diff --git a/docs/docassets/images/adf-process-audit-directive.png b/docs/docassets/images/adf-process-audit-directive.png deleted file mode 100644 index 6f0c918e07..0000000000 Binary files a/docs/docassets/images/adf-process-audit-directive.png and /dev/null differ diff --git a/docs/process-services/directives/process-audit.directive.md b/docs/process-services/directives/process-audit.directive.md deleted file mode 100644 index 006a4fc107..0000000000 --- a/docs/process-services/directives/process-audit.directive.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -Title: Process Audit Directive -Added: v2.0.0 -Status: Active -Last reviewed: 2019-01-14 ---- - -# [Process Audit Directive](../../../lib/process-services/src/lib/process-list/components/process-audit/process-audit.directive.ts "Defined in process-audit.directive.ts") - -Fetches the Process Audit information in PDF or JSON format. - -![adf-process-audit-directive](../../docassets/images/adf-process-audit-directive.png) - -## Basic Usage - -```html - -``` - -## Class members - -### Properties - -| Name | Type | Default value | Description | -| ---- | ---- | ------------- | ----------- | -| download | `boolean` | true | Enables downloading of the audit file on clicking. | -| fileName | `string` | "Audit" | Name of the file to download (for PDF downloads). | -| format | `string` | "pdf" | Format for the audit information (can be "pdf" or "json"). | -| processId | `string` | | ID of the process. | - -### Events - -| Name | Type | Description | -| ---- | ---- | ----------- | -| clicked | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when the decorated element is clicked. | -| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when an error occurs. | diff --git a/lib/process-services/src/lib/process-comments/process-comments.component.ts b/lib/process-services/src/lib/process-comments/process-comments.component.ts index 0d49751e5c..5cf75999d8 100644 --- a/lib/process-services/src/lib/process-comments/process-comments.component.ts +++ b/lib/process-services/src/lib/process-comments/process-comments.component.ts @@ -18,11 +18,10 @@ import { ADF_COMMENTS_SERVICE, CommentsComponent } from '@alfresco/adf-core'; import { CommentProcessService } from './services/comment-process.service'; import { Component, Input, ViewEncapsulation } from '@angular/core'; -import { CommonModule } from '@angular/common'; @Component({ selector: 'adf-process-instance-comments', - imports: [CommonModule, CommentsComponent], + imports: [CommentsComponent], providers: [ { provide: ADF_COMMENTS_SERVICE, diff --git a/lib/process-services/src/lib/process-list/components/process-audit/process-audit.directive.spec.ts b/lib/process-services/src/lib/process-list/components/process-audit/process-audit.directive.spec.ts deleted file mode 100644 index 1a481078de..0000000000 --- a/lib/process-services/src/lib/process-list/components/process-audit/process-audit.directive.spec.ts +++ /dev/null @@ -1,216 +0,0 @@ -/*! - * @license - * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * 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 { Component } from '@angular/core'; -import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing'; -import { of, throwError } from 'rxjs'; -import { ProcessService } from '../../services/process.service'; -import { DownloadService } from '@alfresco/adf-core'; -import { ProcessInstanceAuditInfoRepresentation } from '@alfresco/js-api'; -import { ProcessAuditDirective } from './process-audit.directive'; - -@Component({ - selector: 'adf-basic-button', - imports: [ProcessAuditDirective], - template: ` ` -}) -class BasicButtonComponent { - download: boolean = false; - fileName: string; - format: string; - - onAuditClick(_event: any) { - /* do nothing */ - } - onAuditError(_event: any) { - /* do nothing */ - } -} - -describe('ProcessAuditDirective', () => { - let fixture: ComponentFixture; - let component: BasicButtonComponent; - let service: ProcessService; - - const createFakePdfBlob = (): Blob => { - const pdfData = atob( - 'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' + - 'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' + - 'TWVkaWFCb3ggWyAwIDAgMjAwIDIwMCBdCiAgL0NvdW50IDEKICAvS2lkcyBbIDMgMCBSIF0K' + - 'Pj4KZW5kb2JqCgozIDAgb2JqCjw8CiAgL1R5cGUgL1BhZ2UKICAvUGFyZW50IDIgMCBSCiAg' + - 'L1Jlc291cmNlcyA8PAogICAgL0ZvbnQgPDwKICAgICAgL0YxIDQgMCBSIAogICAgPj4KICA+' + - 'PgogIC9Db250ZW50cyA1IDAgUgo+PgplbmRvYmoKCjQgMCBvYmoKPDwKICAvVHlwZSAvRm9u' + - 'dAogIC9TdWJ0eXBlIC9UeXBlMQogIC9CYXNlRm9udCAvVGltZXMtUm9tYW4KPj4KZW5kb2Jq' + - 'Cgo1IDAgb2JqICAlIHBhZ2UgY29udGVudAo8PAogIC9MZW5ndGggNDQKPj4Kc3RyZWFtCkJU' + - 'CjcwIDUwIFRECi9GMSAxMiBUZgooSGVsbG8sIHdvcmxkISkgVGoKRVQKZW5kc3RyZWFtCmVu' + - 'ZG9iagoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDEwIDAwMDAwIG4g' + - 'CjAwMDAwMDAwNzkgMDAwMDAgbiAKMDAwMDAwMDE3MyAwMDAwMCBuIAowMDAwMDAwMzAxIDAw' + - 'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' + - 'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G' - ); - return new Blob([pdfData], { type: 'application/pdf' }); - }; - - const blob = createFakePdfBlob(); - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [BasicButtonComponent] - }); - fixture = TestBed.createComponent(BasicButtonComponent); - component = fixture.componentInstance; - service = TestBed.inject(ProcessService); - }); - - afterEach(() => fixture.destroy()); - - it('should fetch the pdf Blob when the format is pdf', fakeAsync(() => { - component.fileName = 'FakeAuditName'; - component.format = 'pdf'; - spyOn(service, 'fetchProcessAuditPdfById').and.returnValue(of(blob)); - spyOn(component, 'onAuditClick').and.callThrough(); - - fixture.detectChanges(); - - const button = fixture.nativeElement.querySelector('#auditButton'); - - fixture.whenStable().then(() => { - fixture.detectChanges(); - expect(component.onAuditClick).toHaveBeenCalledWith({ format: 'pdf', value: blob, fileName: 'FakeAuditName' }); - }); - - button.click(); - })); - - it('should download the audit in PDF format (default mode)', fakeAsync(() => { - component.fileName = 'FakeAuditName'; - component.download = true; - const downloadService = TestBed.inject(DownloadService); - spyOn(service, 'fetchProcessAuditPdfById').and.returnValue(of(blob)); - spyOn(downloadService, 'downloadBlob').and.stub(); - - fixture.detectChanges(); - const button = fixture.nativeElement.querySelector('#auditButton'); - - fixture.whenStable().then(() => { - fixture.detectChanges(); - expect(downloadService.downloadBlob).toHaveBeenCalledWith(blob, 'FakeAuditName.pdf'); - }); - - button.click(); - })); - - it('should throw error if download audit failed', fakeAsync(() => { - const expectedError = 'Failed to get audit'; - spyOn(service, 'fetchProcessAuditPdfById').and.returnValue(throwError(expectedError)); - spyOn(component, 'onAuditError').and.stub(); - - fixture.detectChanges(); - const button = fixture.nativeElement.querySelector('#auditButton'); - - fixture.whenStable().then(() => { - fixture.detectChanges(); - expect(component.onAuditError).toHaveBeenCalledWith(expectedError); - }); - - button.click(); - })); - - it('should fetch the json info when the format is json', fakeAsync(() => { - component.fileName = 'FakeAuditName'; - component.format = 'json'; - component.download = true; - const auditJson: ProcessInstanceAuditInfoRepresentation = { - processInstanceId: '42516', - processInstanceName: 'Fake Process - August 3rd 2017', - processDefinitionName: 'Claim Approval Process', - processDefinitionVersion: '1', - processInstanceStartTime: 'Thu Aug 03 15:32:47 UTC 2017', - processInstanceEndTime: null, - // eslint-disable-next-line @cspell/spellchecker - processInstanceDurationInMillis: null, - processInstanceInitiator: 'MyName MyLastname', - entries: [ - { - index: 1, - type: 'startForm', - selectedOutcome: null, - formData: [ - { - fieldName: 'User Name', - fieldId: 'username', - value: 'dsassd' - }, - { fieldName: 'Claim Amount', fieldId: 'claimamount', value: '22' } - ], - taskName: null, - taskAssignee: null, - activityId: null, - // eslint-disable-next-line @cspell/spellchecker - activityName: null, - activityType: null, - startTime: null, - endTime: null, - durationInMillis: null - } - ], - decisionInfo: { calculatedValues: [], appliedRules: [] } - }; - spyOn(service, 'fetchProcessAuditJsonById').and.returnValue(of(auditJson)); - spyOn(component, 'onAuditClick').and.callThrough(); - - fixture.detectChanges(); - - const button = fixture.nativeElement.querySelector('#auditButton'); - - fixture.whenStable().then(() => { - fixture.detectChanges(); - expect(component.onAuditClick).toHaveBeenCalledWith({ format: 'json', value: auditJson, fileName: 'FakeAuditName' }); - }); - - button.click(); - })); - - it('should fetch the pdf Blob as default when the format is UNKNOW', fakeAsync(() => { - component.fileName = 'FakeAuditName'; - component.format = 'fakeFormat'; - spyOn(service, 'fetchProcessAuditPdfById').and.returnValue(of(blob)); - spyOn(component, 'onAuditClick').and.callThrough(); - - fixture.detectChanges(); - - const button = fixture.nativeElement.querySelector('#auditButton'); - - fixture.whenStable().then(() => { - fixture.detectChanges(); - expect(component.onAuditClick).toHaveBeenCalledWith({ format: 'pdf', value: blob, fileName: 'FakeAuditName' }); - }); - - button.click(); - })); -}); diff --git a/lib/process-services/src/lib/process-list/components/process-audit/process-audit.directive.ts b/lib/process-services/src/lib/process-list/components/process-audit/process-audit.directive.ts deleted file mode 100644 index 722fc9b80a..0000000000 --- a/lib/process-services/src/lib/process-list/components/process-audit/process-audit.directive.ts +++ /dev/null @@ -1,109 +0,0 @@ -/*! - * @license - * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * 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. - */ - -/* eslint-disable @angular-eslint/no-input-rename */ - -import { DownloadService } from '@alfresco/adf-core'; -import { Directive, EventEmitter, Input, OnChanges, Output } from '@angular/core'; -import { ProcessService } from '../../services/process.service'; - -const JSON_FORMAT: string = 'json'; -const PDF_FORMAT: string = 'pdf'; - -@Directive({ - // eslint-disable-next-line @angular-eslint/directive-selector - selector: 'button[adf-process-audit]', - host: { - role: 'button', - '(click)': 'onClickAudit()' - } -}) -export class ProcessAuditDirective implements OnChanges { - /** ID of the process. */ - @Input('process-id') - processId: string; - - /** Name of the file to download (for PDF downloads). */ - @Input() - fileName: string = 'Audit'; - - /** Format for the audit information (can be "pdf" or "json"). */ - @Input() - format: string = 'pdf'; - - /** Enables downloading of the audit file on clicking. */ - @Input() - download: boolean = true; - - /** Emitted when the decorated element is clicked. */ - @Output() - clicked: EventEmitter = new EventEmitter(); - - /** Emitted when an error occurs. */ - @Output() - error: EventEmitter = new EventEmitter(); - - constructor(private downloadService: DownloadService, private processListService: ProcessService) {} - - ngOnChanges(): void { - if (!this.isValidType()) { - this.setDefaultFormatType(); - } - } - - isValidType() { - return this.format && (this.isJsonFormat() || this.isPdfFormat()); - } - - setDefaultFormatType(): void { - this.format = PDF_FORMAT; - } - - /** - * fetch the audit information in the requested format - */ - fetchAuditInfo(): void { - if (this.isPdfFormat()) { - this.processListService.fetchProcessAuditPdfById(this.processId).subscribe( - (blob: Blob) => { - if (this.download) { - this.downloadService.downloadBlob(blob, this.fileName + '.pdf'); - } - this.clicked.emit({ format: this.format, value: blob, fileName: this.fileName }); - }, - (err) => this.error.emit(err) - ); - } else { - this.processListService.fetchProcessAuditJsonById(this.processId).subscribe( - (res) => this.clicked.emit({ format: this.format, value: res, fileName: this.fileName }), - (err) => this.error.emit(err) - ); - } - } - - onClickAudit() { - this.fetchAuditInfo(); - } - - isJsonFormat() { - return this.format === JSON_FORMAT; - } - - isPdfFormat() { - return this.format === PDF_FORMAT; - } -} diff --git a/lib/process-services/src/lib/process-list/public-api.ts b/lib/process-services/src/lib/process-list/public-api.ts index 7647d976f8..bb70a384b7 100644 --- a/lib/process-services/src/lib/process-list/public-api.ts +++ b/lib/process-services/src/lib/process-list/public-api.ts @@ -15,29 +15,25 @@ * limitations under the License. */ -// component import { ProcessInstanceListComponent } from './components/process-list/process-list.component'; import { ProcessFiltersComponent } from './components/process-filters/process-filters.component'; import { ProcessInstanceDetailsComponent } from './components/process-instance-details/process-instance-details.component'; import { ProcessInstanceHeaderComponent } from './components/process-instance-header/process-instance-header.component'; import { ProcessInstanceTasksComponent } from './components/process-instance-tasks/process-instance-tasks.component'; import { StartProcessInstanceComponent } from './components/start-process/start-process.component'; -import { ProcessAuditDirective } from './components/process-audit/process-audit.directive'; export * from './components/process-filters/process-filters.component'; export * from './components/process-instance-details/process-instance-details.component'; -export * from './components/process-audit/process-audit.directive'; export * from './components/process-instance-header/process-instance-header.component'; export * from './components/process-instance-tasks/process-instance-tasks.component'; export * from './components/process-list/process-list.component'; export * from './components/start-process/start-process.component'; -// services export * from './services/process.service'; export * from './services/process-filter.service'; +/* @deprecated use individual exports */ export const PROCESS_LIST_DIRECTIVES = [ - ProcessAuditDirective, ProcessInstanceListComponent, ProcessFiltersComponent, ProcessInstanceDetailsComponent, diff --git a/lib/process-services/src/lib/process-list/services/process.service.ts b/lib/process-services/src/lib/process-list/services/process.service.ts index 0ea28f43cd..d59cee6ebb 100644 --- a/lib/process-services/src/lib/process-list/services/process.service.ts +++ b/lib/process-services/src/lib/process-list/services/process.service.ts @@ -106,6 +106,7 @@ export class ProcessService { } /** + * @deprecated This api is no longer used and will be removed in future releases. * Fetches the Process Audit information as a PDF. * * @param processId ID of the target process @@ -116,6 +117,7 @@ export class ProcessService { } /** + * @deprecated This api is no longer used and will be removed in future releases. * Fetches the Process Audit information in a JSON format. * * @param processId ID of the target process