diff --git a/demo-shell/src/app/components/files/files.component.ts b/demo-shell/src/app/components/files/files.component.ts index 63fcc570f3..d21a0585fd 100644 --- a/demo-shell/src/app/components/files/files.component.ts +++ b/demo-shell/src/app/components/files/files.component.ts @@ -386,7 +386,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { return node && node.list && node.list.entries.length === 0; } - onContentActionError(errors) { + onContentActionError(errors: any) { const errorStatusCode = JSON.parse(errors.message).error.statusCode; let translatedErrorMessage: any; @@ -404,24 +404,24 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { this.openSnackMessage(translatedErrorMessage); } - onContentActionSuccess(message) { + onContentActionSuccess(message: string) { const translatedMessage: any = this.translateService.instant(message); this.openSnackMessage(translatedMessage); this.documentList.reload(); } - onDeleteActionSuccess(message) { + onDeleteActionSuccess(message: string) { this.uploadService.fileDeleted.next(message); this.deleteElementSuccess.emit(); this.documentList.reload(); this.openSnackMessage(message); } - onPermissionRequested(node) { + onPermissionRequested(node: any) { this.router.navigate(['/permissions', node.value.entry.id]); } - onManageVersions(event) { + onManageVersions(event: any) { const contentEntry = event.value.entry; const showComments = this.showVersionComments; const allowDownload = this.allowVersionDownload; @@ -438,7 +438,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { } } - onManageMetadata(event) { + onManageMetadata(event: any) { const contentEntry = event.value.entry; if (this.contentService.hasAllowableOperations(contentEntry, 'update')) { @@ -499,7 +499,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { return false; } - startProcessAction($event) { + startProcessAction($event: any) { this.formValues['file'] = $event.value.entry; const dialogRef = this.dialog.open(SelectAppsDialogComponent, { @@ -588,15 +588,15 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { return true; } - runCustomAction(event) { + runCustomAction(event: any) { this.logService.log(event); } - getFileFiltering() { + getFileFiltering(): string { return this.acceptedFilesTypeShow ? this.acceptedFilesType : '*'; } - createLibrary() { + createLibrary(): void { const dialogInstance: any = this.dialog.open(LibraryDialogComponent, { width: '400px' }); @@ -610,5 +610,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { if (search && search.highlight) { return search.highlight.map((currentHighlight) => currentHighlight.snippets).join(', '); } + return ''; } } diff --git a/demo-shell/src/app/components/tree-view/tree-view-sample.component.html b/demo-shell/src/app/components/tree-view/tree-view-sample.component.html index ca75436205..8deb5aa732 100644 --- a/demo-shell/src/app/components/tree-view/tree-view-sample.component.html +++ b/demo-shell/src/app/components/tree-view/tree-view-sample.component.html @@ -8,12 +8,12 @@ CLICKED NODE: {{clickedNodeName}} - - + An Error Occurred {{errorMessage}} diff --git a/demo-shell/src/app/components/tree-view/tree-view-sample.component.ts b/demo-shell/src/app/components/tree-view/tree-view-sample.component.ts index 032bcd06ae..38506a09d0 100644 --- a/demo-shell/src/app/components/tree-view/tree-view-sample.component.ts +++ b/demo-shell/src/app/components/tree-view/tree-view-sample.component.ts @@ -25,7 +25,7 @@ import { Component } from '@angular/core'; export class TreeViewSampleComponent { clickedNodeName: string = ''; - errorMessage = ''; + errorMessage: string = ''; nodeIdSample: string = '-my-'; @@ -38,7 +38,7 @@ export class TreeViewSampleComponent { this.errorMessage = ''; } - onErrorOccurred(error) { + onErrorOccurred(error: string) { this.clickedNodeName = ''; this.errorMessage = error; } diff --git a/demo-shell/tsconfig.json b/demo-shell/tsconfig.json index d2b9f36445..9111b78b73 100644 --- a/demo-shell/tsconfig.json +++ b/demo-shell/tsconfig.json @@ -12,6 +12,7 @@ "skipLibCheck": true, "noUnusedLocals": true, "noUnusedParameters": true, + "noImplicitReturns": true, "target": "es5", "allowSyntheticDefaultImports": true, "typeRoots": [ diff --git a/lib/content-services/content-metadata/services/config/content-metadata-config.factory.ts b/lib/content-services/content-metadata/services/config/content-metadata-config.factory.ts index d4e1fd6cc7..f6d5a74ae7 100644 --- a/lib/content-services/content-metadata/services/config/content-metadata-config.factory.ts +++ b/lib/content-services/content-metadata/services/config/content-metadata-config.factory.ts @@ -38,7 +38,7 @@ export class ContentMetadataConfigFactory { constructor(private appConfigService: AppConfigService, private logService: LogService) {} public get(presetName: string = 'default'): ContentMetadataConfig { - let presetConfig; + let presetConfig: PresetConfig; try { presetConfig = this.appConfigService.config['content-metadata'].presets[presetName]; } catch { @@ -74,7 +74,7 @@ export class ContentMetadataConfigFactory { return Array.isArray(presetConfig); } - private isObject(x) { + private isObject(x: any): boolean { return x != null && typeof x === 'object'; } } diff --git a/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts b/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts index 3e2174456f..603461c4fa 100644 --- a/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts +++ b/lib/content-services/content-node-selector/content-node-selector-panel.component.spec.ts @@ -608,11 +608,8 @@ describe('ContentNodeSelectorComponent', () => { }); it('should pass through the rowFilter to the documentList', () => { - const filter = (shareDataRow: ShareDataRow) => { - if (shareDataRow.node.entry.name === 'impossible-name') { - return true; - } - }; + const filter = (shareDataRow: ShareDataRow) => + shareDataRow.node.entry.name === 'impossible-name'; component.rowFilter = filter; diff --git a/lib/content-services/content-node-selector/content-node-selector.component.spec.ts b/lib/content-services/content-node-selector/content-node-selector.component.spec.ts index 260d2a3edf..cf5c29f0a4 100644 --- a/lib/content-services/content-node-selector/content-node-selector.component.spec.ts +++ b/lib/content-services/content-node-selector/content-node-selector.component.spec.ts @@ -37,11 +37,7 @@ describe('ContentNodeSelectorDialogComponent', () => { title: 'Move along citizen...', actionName: 'move', select: new EventEmitter(), - rowFilter: (shareDataRow: ShareDataRow) => { - if (shareDataRow.node.entry.name === 'impossible-name') { - return true; - } - }, + rowFilter: (shareDataRow: ShareDataRow) => shareDataRow.node.entry.name === 'impossible-name', imageResolver: () => 'piccolo', currentFolderId: 'cat-girl-nuku-nuku' }; diff --git a/lib/content-services/content-node-selector/name-location-cell/name-location-cell.component.spec.ts b/lib/content-services/content-node-selector/name-location-cell/name-location-cell.component.spec.ts index da0ac61d83..ca9a0749d3 100644 --- a/lib/content-services/content-node-selector/name-location-cell/name-location-cell.component.spec.ts +++ b/lib/content-services/content-node-selector/name-location-cell/name-location-cell.component.spec.ts @@ -37,12 +37,13 @@ describe('NameLocationCellComponent', () => { component = fixture.componentInstance; rowData = { - getValue(key) { + getValue(key): any { if (key === 'name') { return 'file-name'; } else if (key === 'path') { return { name: '/path/to/location' }; } + return undefined; } }; component.row = rowData; diff --git a/lib/content-services/dialogs/confirm.dialog.ts b/lib/content-services/dialogs/confirm.dialog.ts index 5e385abac5..88c9a2784b 100644 --- a/lib/content-services/dialogs/confirm.dialog.ts +++ b/lib/content-services/dialogs/confirm.dialog.ts @@ -19,6 +19,15 @@ import { Component, Inject, ViewEncapsulation, SecurityContext } from '@angular/ import { MAT_DIALOG_DATA } from '@angular/material'; import { DomSanitizer } from '@angular/platform-browser'; +export interface ConfirmDialogComponentProps { + title?: string; + message?: string; + yesLabel?: string; + thirdOptionLabel?: string; + noLabel?: string; + htmlContent?: string; +} + @Component({ selector: 'adf-confirm-dialog', templateUrl: './confirm.dialog.html', @@ -35,7 +44,7 @@ export class ConfirmDialogComponent { thirdOptionLabel: string; htmlContent: string; - constructor(@Inject(MAT_DIALOG_DATA) data, private sanitizer: DomSanitizer) { + constructor(@Inject(MAT_DIALOG_DATA) data: ConfirmDialogComponentProps, private sanitizer: DomSanitizer) { data = data || {}; this.title = data.title || 'ADF_CONFIRM_DIALOG.CONFIRM'; this.message = data.message || 'ADF_CONFIRM_DIALOG.MESSAGE'; @@ -45,7 +54,7 @@ export class ConfirmDialogComponent { this.htmlContent = data.htmlContent; } - public sanitizedHtmlContent() { + sanitizedHtmlContent(): string { return this.sanitizer.sanitize(SecurityContext.HTML, this.htmlContent); } diff --git a/lib/content-services/document-list/services/document-actions.service.ts b/lib/content-services/document-list/services/document-actions.service.ts index 0a4985dd97..9d7633b4a3 100644 --- a/lib/content-services/document-list/services/document-actions.service.ts +++ b/lib/content-services/document-list/services/document-actions.service.ts @@ -18,7 +18,7 @@ import { ContentService, TranslationService } from '@alfresco/adf-core'; import { Injectable } from '@angular/core'; import { NodeEntry } from '@alfresco/js-api'; -import { Observable, Subject, throwError } from 'rxjs'; +import { Observable, Subject, throwError, of } from 'rxjs'; import { ContentActionHandler } from '../models/content-action.model'; import { PermissionModel } from '../models/permissions.model'; import { DocumentListService } from './document-list.service'; @@ -119,11 +119,9 @@ export class DocumentActionsService { } private deleteNode(node: NodeEntry, _target?: any, permission?: string): Observable { - let handlerObservable; - if (this.canExecuteAction(node)) { if (this.contentService.hasAllowableOperations(node.entry, permission)) { - handlerObservable = this.documentListService.deleteNode(node.entry.id); + const handlerObservable = this.documentListService.deleteNode(node.entry.id); handlerObservable.subscribe(() => { const message = this.translation.instant('CORE.DELETE_NODE.SINGULAR', { name: node.entry.name }); this.success.next(message); @@ -141,5 +139,7 @@ export class DocumentActionsService { return throwError(new Error('No permission to delete')); } } + + return of(); } } diff --git a/lib/content-services/document-list/services/folder-actions.service.ts b/lib/content-services/document-list/services/folder-actions.service.ts index 6b895ef963..14f16b2595 100644 --- a/lib/content-services/document-list/services/folder-actions.service.ts +++ b/lib/content-services/document-list/services/folder-actions.service.ts @@ -18,7 +18,7 @@ import { ContentService, TranslationService } from '@alfresco/adf-core'; import { Injectable } from '@angular/core'; import { NodeEntry } from '@alfresco/js-api'; -import { Observable, Subject, throwError } from 'rxjs'; +import { Observable, Subject, throwError, of } from 'rxjs'; import { ContentActionHandler } from '../models/content-action.model'; import { PermissionModel } from '../models/permissions.model'; import { DocumentListService } from './document-list.service'; @@ -102,7 +102,7 @@ export class FolderActionsService { return actionObservable; } - private prepareHandlers(actionObservable, target?: any): void { + private prepareHandlers(actionObservable: Observable, target?: any): void { actionObservable.subscribe( (fileOperationMessage) => { if (target && typeof target.reload === 'function') { @@ -115,11 +115,9 @@ export class FolderActionsService { } private deleteNode(node: NodeEntry, target?: any, permission?: string): Observable { - let handlerObservable: Observable; - if (this.canExecuteAction(node)) { if (this.contentService.hasAllowableOperations(node.entry, permission)) { - handlerObservable = this.documentListService.deleteNode(node.entry.id); + const handlerObservable = this.documentListService.deleteNode(node.entry.id); handlerObservable.subscribe(() => { if (target && typeof target.reload === 'function') { target.reload(); @@ -138,5 +136,7 @@ export class FolderActionsService { return throwError(new Error('No permission to delete')); } } + + return of(); } } diff --git a/lib/content-services/permission-manager/services/node-permission.service.ts b/lib/content-services/permission-manager/services/node-permission.service.ts index 683377bd2c..d50c870c1d 100644 --- a/lib/content-services/permission-manager/services/node-permission.service.ts +++ b/lib/content-services/permission-manager/services/node-permission.service.ts @@ -148,10 +148,13 @@ export class NodePermissionService { removePermission(node: Node, permissionToRemove: PermissionElement): Observable { const permissionBody = { permissions: { locallySet: [] } }; const index = node.permissions.locallySet.map((permission) => permission.authorityId).indexOf(permissionToRemove.authorityId); + if (index !== -1) { node.permissions.locallySet.splice(index, 1); permissionBody.permissions.locallySet = node.permissions.locallySet; return this.nodeService.updateNode(node.id, permissionBody); + } else { + return of(node); } } diff --git a/lib/content-services/upload/components/file-uploading-list.component.ts b/lib/content-services/upload/components/file-uploading-list.component.ts index 721db2ec22..f2dc751e26 100644 --- a/lib/content-services/upload/components/file-uploading-list.component.ts +++ b/lib/content-services/upload/components/file-uploading-list.component.ts @@ -49,7 +49,7 @@ export class FileUploadingListComponent { /** Emitted when a file in the list has an error. */ @Output() - error: EventEmitter = new EventEmitter(); + error = new EventEmitter(); constructor( private uploadService: UploadService, @@ -161,7 +161,7 @@ export class FileUploadingListComponent { ); } - private cancelNodeVersionInstances(file) { + private cancelNodeVersionInstances(file: FileModel) { this.files .filter( (item) => @@ -192,15 +192,12 @@ export class FileUploadingListComponent { this.error.emit(messageError); } - private getUploadingFiles() { - return this.files.filter((item) => { - if ( + private getUploadingFiles(): FileModel[] { + return this.files.filter( + item => item.status === FileUploadStatus.Pending || item.status === FileUploadStatus.Progress || item.status === FileUploadStatus.Starting - ) { - return item; - } - }); + ); } } diff --git a/lib/core/datatable/components/datatable/datatable.component.ts b/lib/core/datatable/components/datatable/datatable.component.ts index 6d9dac1ab9..d863dea578 100644 --- a/lib/core/datatable/components/datatable/datatable.component.ts +++ b/lib/core/datatable/components/datatable/datatable.component.ts @@ -260,10 +260,11 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck, return rows.map((row) => new ObjectDataRow(row, row.isSelected)); } - convertToDataSorting(sorting: any[]): DataSorting { + convertToDataSorting(sorting: any[]): DataSorting | null { if (sorting && sorting.length > 0) { return new DataSorting(sorting[0], sorting[1]); } + return null; } private initAndSubscribeClickStream() { @@ -362,7 +363,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck, } } - private setTableSorting(sorting) { + private setTableSorting(sorting: any[]) { if (this.data) { this.data.setSorting(this.convertToDataSorting(sorting)); } @@ -610,10 +611,12 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck, return `${row.cssClass} ${this.rowStyleClass}`; } - getSortingKey(): string { + getSortingKey(): string | null { if (this.data.getSorting()) { return this.data.getSorting().key; } + + return null; } selectRow(row: DataRow, value: boolean) { diff --git a/lib/core/directives/node-delete.directive.spec.ts b/lib/core/directives/node-delete.directive.spec.ts index 17471be7e8..10805546d6 100644 --- a/lib/core/directives/node-delete.directive.spec.ts +++ b/lib/core/directives/node-delete.directive.spec.ts @@ -258,13 +258,7 @@ describe('NodeDeleteDirective', () => { return Promise.reject(null); } - if (id === '2') { - return Promise.resolve(); - } - - if (id === '3') { - return Promise.resolve(); - } + return Promise.resolve(); }); component.selection = [ diff --git a/lib/core/directives/node-delete.directive.ts b/lib/core/directives/node-delete.directive.ts index b9b7147152..beb5e10a0b 100644 --- a/lib/core/directives/node-delete.directive.ts +++ b/lib/core/directives/node-delete.directive.ts @@ -96,7 +96,9 @@ export class NodeDeleteDirective implements OnChanges { const processedItems: ProcessStatus = this.processStatus(data); const message = this.getMessage(processedItems); - this.delete.emit(message); + if (message) { + this.delete.emit(message); + } }); } } @@ -108,7 +110,7 @@ export class NodeDeleteDirective implements OnChanges { private deleteNode(node: NodeEntry | DeletedNodeEntity): Observable { const id = ( node.entry).nodeId || node.entry.id; - let promise; + let promise: Promise; if (node.entry.hasOwnProperty('archivedAt') && node.entry['archivedAt']) { promise = this.alfrescoApiService.nodesApi.purgeDeletedNode(id); @@ -166,7 +168,7 @@ export class NodeDeleteDirective implements OnChanges { ); } - private getMessage(status): string { + private getMessage(status: ProcessStatus): string | null { if (status.allFailed && !status.oneFailed) { return this.translation.instant( 'CORE.DELETE_NODE.ERROR_PLURAL', @@ -214,5 +216,7 @@ export class NodeDeleteDirective implements OnChanges { { name: status.success[0].entry.name } ); } + + return null; } } diff --git a/lib/core/directives/node-restore.directive.spec.ts b/lib/core/directives/node-restore.directive.spec.ts index 74442853c1..1883f42b42 100644 --- a/lib/core/directives/node-restore.directive.spec.ts +++ b/lib/core/directives/node-restore.directive.spec.ts @@ -160,23 +160,17 @@ describe('NodeRestoreDirective', () => { it('should notify on multiple fails', (done) => { const error = { message: '{ "error": {} }' }; - directiveInstance.restore.subscribe((event) => { + directiveInstance.restore.subscribe((event: any) => { expect(event.message).toEqual('CORE.RESTORE_NODE.PARTIAL_PLURAL'); done(); }); - restoreNodeSpy.and.callFake((id) => { + restoreNodeSpy.and.callFake((id: string) => { if (id === '1') { return Promise.resolve(); } - if (id === '2') { - return Promise.reject(error); - } - - if (id === '3') { - return Promise.reject(error); - } + return Promise.reject(error); }); component.selection = [ @@ -232,7 +226,7 @@ describe('NodeRestoreDirective', () => { restoreNodeSpy.and.returnValue(Promise.reject(error)); - directiveInstance.restore.subscribe((event) => { + directiveInstance.restore.subscribe((event: any) => { expect(event.message).toEqual('CORE.RESTORE_NODE.LOCATION_MISSING'); done(); }); @@ -247,20 +241,14 @@ describe('NodeRestoreDirective', () => { it('should notify success when restore multiple nodes', (done) => { - directiveInstance.restore.subscribe((event) => { + directiveInstance.restore.subscribe((event: any) => { expect(event.message).toEqual('CORE.RESTORE_NODE.PLURAL'); done(); }); - restoreNodeSpy.and.callFake((id) => { - if (id === '1') { - return Promise.resolve(); - } - - if (id === '2') { - return Promise.resolve(); - } + restoreNodeSpy.and.callFake(() => { + return Promise.resolve(); }); component.selection = [ diff --git a/lib/core/directives/node-restore.directive.ts b/lib/core/directives/node-restore.directive.ts index 55cef30615..bacd19b5db 100644 --- a/lib/core/directives/node-restore.directive.ts +++ b/lib/core/directives/node-restore.directive.ts @@ -182,7 +182,7 @@ export class NodeRestoreDirective { ); } - private getRestoreMessage(): string { + private getRestoreMessage(): string | null { const { restoreProcessStatus: status } = this; if (status.someFailed && !status.oneFailed) { @@ -233,6 +233,8 @@ export class NodeRestoreDirective { } ); } + + return null; } private notification(): void { diff --git a/lib/core/form/components/widgets/people/people.widget.ts b/lib/core/form/components/widgets/people/people.widget.ts index 6fe42de6ae..6a7f9c9cbe 100644 --- a/lib/core/form/components/widgets/people/people.widget.ts +++ b/lib/core/form/components/widgets/people/people.widget.ts @@ -98,7 +98,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { } } - checkUserAndValidateForm(list, value) { + checkUserAndValidateForm(list: UserProcessModel[], value: string): void { const isValidUser = this.isValidUser(list, value); if (isValidUser || value === '') { this.field.validationSummary.message = ''; @@ -111,7 +111,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { } } - isValidUser(users: UserProcessModel[], name: string) { + isValidUser(users: UserProcessModel[], name: string): boolean { if (users) { return users.find((user) => { const selectedUser = this.getDisplayName(user).toLocaleLowerCase() === name.toLocaleLowerCase(); @@ -119,8 +119,9 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { this.peopleSelected.emit(user && user.id || undefined); } return selectedUser; - }); + }) ? true : false; } + return false; } getDisplayName(model: UserProcessModel) { diff --git a/lib/core/form/components/widgets/upload/upload.widget.spec.ts b/lib/core/form/components/widgets/upload/upload.widget.spec.ts index 15e45da58b..a872a90679 100644 --- a/lib/core/form/components/widgets/upload/upload.widget.spec.ts +++ b/lib/core/form/components/widgets/upload/upload.widget.spec.ts @@ -202,7 +202,7 @@ describe('UploadWidgetComponent', () => { })); it('should update the form after deleted a file', async(() => { - spyOn(contentService, 'createTemporaryRawRelatedContent').and.callFake((file) => { + spyOn(contentService, 'createTemporaryRawRelatedContent').and.callFake((file: any) => { if (file.name === 'file-fake.png') { return of(fakePngAnswer); } @@ -210,6 +210,8 @@ describe('UploadWidgetComponent', () => { if (file.name === 'file-fake.jpg') { return of(fakeJpgAnswer); } + + return of(); }); uploadWidgetComponent.field.params.multiple = true; @@ -230,7 +232,7 @@ describe('UploadWidgetComponent', () => { })); it('should set has field value all the files uploaded', async(() => { - spyOn(contentService, 'createTemporaryRawRelatedContent').and.callFake((file) => { + spyOn(contentService, 'createTemporaryRawRelatedContent').and.callFake((file: any) => { if (file.name === 'file-fake.png') { return of(fakePngAnswer); } @@ -238,6 +240,8 @@ describe('UploadWidgetComponent', () => { if (file.name === 'file-fake.jpg') { return of(fakeJpgAnswer); } + + return of(); }); uploadWidgetComponent.field.params.multiple = true; diff --git a/lib/core/form/models/widget-visibility.model.ts b/lib/core/form/models/widget-visibility.model.ts index 626b52cc20..2612fa5ea9 100644 --- a/lib/core/form/models/widget-visibility.model.ts +++ b/lib/core/form/models/widget-visibility.model.ts @@ -16,90 +16,92 @@ */ export class WidgetVisibilityModel { - rightRestResponseId?: string; - rightFormFieldId?: string; - leftRestResponseId?: string; - leftFormFieldId?: string; - operator: string; - nextCondition: WidgetVisibilityModel; - nextConditionOperator: string; + rightRestResponseId?: string; + rightFormFieldId?: string; + leftRestResponseId?: string; + leftFormFieldId?: string; + operator: string; + nextCondition: WidgetVisibilityModel; + nextConditionOperator: string; - constructor(private json?: any) { - if (json) { - this.operator = json.operator; - this.nextCondition = new WidgetVisibilityModel(json.nextCondition); - this.nextConditionOperator = json.nextConditionOperator; - this.rightRestResponseId = json.rightRestResponseId; - this.rightFormFieldId = json.rightFormFieldId; - this.leftFormFieldId = json.leftFormFieldId; - this.leftRestResponseId = json.leftRestResponseId; - } else { - this.json = {}; - } + constructor(private json?: any) { + if (json) { + this.operator = json.operator; + this.nextCondition = new WidgetVisibilityModel(json.nextCondition); + this.nextConditionOperator = json.nextConditionOperator; + this.rightRestResponseId = json.rightRestResponseId; + this.rightFormFieldId = json.rightFormFieldId; + this.leftFormFieldId = json.leftFormFieldId; + this.leftRestResponseId = json.leftRestResponseId; + } else { + this.json = {}; + } + } + + get leftType(): string { + if (this.leftFormFieldId) { + return WidgetTypeEnum.field; + } else if (this.leftRestResponseId) { + return WidgetTypeEnum.variable; + } else if (!!this.json.leftType) { + return this.json.leftType; + } + return null; + } + + set leftType(leftType: string) { + this.json.leftType = leftType; + } + + get leftValue(): any { + if (this.json.leftValue) { + return this.json.leftValue; + } else if (this.leftFormFieldId) { + return this.leftFormFieldId; + } else { + return this.leftRestResponseId; + } + } + + set leftValue(leftValue: any) { + this.json.leftValue = leftValue; + } + + get rightType(): string { + if (!!this.json.rightType) { + return this.json.rightType; + } else if (this.json.rightValue) { + return WidgetTypeEnum.value; + } else if (this.rightRestResponseId) { + return WidgetTypeEnum.variable; + } else if (this.rightFormFieldId) { + return WidgetTypeEnum.field; } - set leftType(leftType: string) { - this.json.leftType = leftType; - } + return null; + } - set rightType(rightType: string) { - this.json.rightType = rightType; - } + set rightType(rightType: string) { + this.json.rightType = rightType; + } - set leftValue(leftValue: string) { - this.json.leftValue = leftValue; - } - - set rightValue(rightValue: string) { - this.json.rightValue = rightValue; - } - - get leftType() { - if (this.leftFormFieldId) { - return WidgetTypeEnum.field; - } else if (this.leftRestResponseId) { - return WidgetTypeEnum.variable; - } else if ( !!this.json.leftType) { - return this.json.leftType; - } - } - - get leftValue() { - if ( this.json.leftValue ) { - return this.json.leftValue; - } else if (this.leftFormFieldId) { - return this.leftFormFieldId; - } else { - return this.leftRestResponseId; - } - } - - get rightType() { - if ( !!this.json.rightType ) { - return this.json.rightType; - } else if (this.json.rightValue) { - return WidgetTypeEnum.value; - } else if (this.rightRestResponseId) { - return WidgetTypeEnum.variable; - } else if (this.rightFormFieldId) { - return WidgetTypeEnum.field; - } - } - - get rightValue() { - if (this.json.rightValue) { - return this.json.rightValue; - } else if (this.rightFormFieldId) { - return this.rightFormFieldId; - } else { - return this.rightRestResponseId; - } + get rightValue(): any { + if (this.json.rightValue) { + return this.json.rightValue; + } else if (this.rightFormFieldId) { + return this.rightFormFieldId; + } else { + return this.rightRestResponseId; } + } + set rightValue(rightValue: any) { + this.json.rightValue = rightValue; + } } export enum WidgetTypeEnum { - field = 'field', - variable = 'variable', - value = 'value' + field = 'field', + variable = 'variable', + value = 'value' } diff --git a/lib/core/form/services/widget-visibility.service.ts b/lib/core/form/services/widget-visibility.service.ts index 9ce3af9331..37d9b961b1 100644 --- a/lib/core/form/services/widget-visibility.service.ts +++ b/lib/core/form/services/widget-visibility.service.ts @@ -249,7 +249,7 @@ export class WidgetVisibilityService { return undefined; } - evaluateLogicalOperation(logicOp, previousValue, newValue): boolean { + evaluateLogicalOperation(logicOp: string, previousValue: any, newValue: any): boolean | undefined { switch (logicOp) { case 'and': return previousValue && newValue; @@ -260,12 +260,12 @@ export class WidgetVisibilityService { case 'or-not': return previousValue || !newValue; default: - this.logService.error('NO valid operation! wrong op request : ' + logicOp); - break; + this.logService.error(`Invalid operator: ${logicOp}`); + return undefined; } } - evaluateCondition(leftValue, rightValue, operator): boolean { + evaluateCondition(leftValue: any, rightValue: any, operator: string): boolean | undefined { switch (operator) { case '==': return leftValue + '' === rightValue + ''; @@ -284,10 +284,9 @@ export class WidgetVisibilityService { case '!empty': return leftValue ? leftValue !== '' : false; default: - this.logService.error('NO valid operation!'); - break; + this.logService.error(`Invalid operator: ${operator}`); + return undefined; } - return; } cleanProcessVariable() { diff --git a/lib/core/layout/components/layout-container/layout-container.component.ts b/lib/core/layout/components/layout-container/layout-container.component.ts index cd5acbf578..87ff19a6e5 100644 --- a/lib/core/layout/components/layout-container/layout-container.component.ts +++ b/lib/core/layout/components/layout-container/layout-container.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, Input, ViewChild, OnInit, OnDestroy, ViewEncapsulation, OnChanges } from '@angular/core'; +import { Component, Input, ViewChild, OnInit, OnDestroy, ViewEncapsulation, OnChanges, SimpleChanges } from '@angular/core'; import { MatSidenav } from '@angular/material'; import { sidenavAnimation, contentAnimation } from '../../helpers/animations'; import { Direction } from '@angular/cdk/bidi'; @@ -80,7 +80,7 @@ export class LayoutContainerComponent implements OnInit, OnDestroy, OnChanges { this.mediaQueryList.removeListener(this.onMediaQueryChange); } - ngOnChanges(changes) { + ngOnChanges(changes: SimpleChanges) { if (changes && changes.direction) { this.contentAnimationState = this.toggledContentAnimation; } @@ -99,17 +99,17 @@ export class LayoutContainerComponent implements OnInit, OnDestroy, OnChanges { return this.mediaQueryList.matches; } - getContentAnimationState() { + getContentAnimationState(): any { return this.contentAnimationState; } - private get toggledSidenavAnimation() { + private get toggledSidenavAnimation(): any { return this.sidenavAnimationState === this.SIDENAV_STATES.EXPANDED ? this.SIDENAV_STATES.COMPACT : this.SIDENAV_STATES.EXPANDED; } - private get toggledContentAnimation() { + private get toggledContentAnimation(): any { if (this.isMobileScreenSize) { return this.CONTENT_STATES.MOBILE; } @@ -150,7 +150,7 @@ export class LayoutContainerComponent implements OnInit, OnDestroy, OnChanges { } } - private onMediaQueryChange() { + private onMediaQueryChange(): void { this.sidenavAnimationState = this.SIDENAV_STATES.EXPANDED; this.contentAnimationState = this.toggledContentAnimation; } diff --git a/lib/core/login/components/login.component.ts b/lib/core/login/components/login.component.ts index 698dfb1e63..201612dc59 100644 --- a/lib/core/login/components/login.component.ts +++ b/lib/core/login/components/login.component.ts @@ -197,7 +197,7 @@ export class LoginComponent implements OnInit, OnDestroy { * @param values * @param event */ - onSubmit(values: any) { + onSubmit(values: any): void { this.disableError(); if (this.authService.isOauth() && !this.authService.isSSODiscoveryConfigured()) { @@ -209,9 +209,7 @@ export class LoginComponent implements OnInit, OnDestroy { }); this.executeSubmit.emit(args); - if (args.defaultPrevented) { - return false; - } else { + if (!args.defaultPrevented) { this.performLogin(values); } } diff --git a/lib/core/mock/form/demo-form.mock.ts b/lib/core/mock/form/demo-form.mock.ts index 38481487ca..86c77e7506 100644 --- a/lib/core/mock/form/demo-form.mock.ts +++ b/lib/core/mock/form/demo-form.mock.ts @@ -17,7 +17,7 @@ export class DemoForm { - easyForm = { + easyForm: any = { 'id': 1001, 'name': 'ISSUE_FORM', 'tabs': [], @@ -365,7 +365,7 @@ export class DemoForm { 'globalDateFormat': 'D-M-YYYY' }; - formDefinition = { + formDefinition: any = { 'id': 3003, 'name': 'demo-01', 'taskId': '7501', @@ -1482,7 +1482,7 @@ export class DemoForm { 'globalDateFormat': 'D-M-YYYY' }; - simpleFormDefinition = { + simpleFormDefinition: any = { 'id': 1001, 'name': 'SIMPLE_FORM_EXAMPLE', 'description': '', @@ -1765,7 +1765,7 @@ export class DemoForm { } }; - cloudFormDefinition = { + cloudFormDefinition: any = { 'formRepresentation': { 'id': 'text-form', 'name': 'test-start-form', diff --git a/lib/core/mock/form/form.component.mock.ts b/lib/core/mock/form/form.component.mock.ts index 50c407f71c..86906022ff 100644 --- a/lib/core/mock/form/form.component.mock.ts +++ b/lib/core/mock/form/form.component.mock.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let fakeForm = { +export const fakeForm: any = { id: 1001, name: 'ISSUE_FORM', processDefinitionId: 'ISSUE_APP:1:2504', diff --git a/lib/core/mock/form/form.service.mock.ts b/lib/core/mock/form/form.service.mock.ts index 9ea6275087..48bf954b2a 100644 --- a/lib/core/mock/form/form.service.mock.ts +++ b/lib/core/mock/form/form.service.mock.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let formModelTabs = { +export const formModelTabs: any = { id: 16, name: 'start event', description: '', diff --git a/lib/core/mock/form/formDefinition.mock.ts b/lib/core/mock/form/formDefinition.mock.ts index 9ea3659f7d..dc0ca93c55 100644 --- a/lib/core/mock/form/formDefinition.mock.ts +++ b/lib/core/mock/form/formDefinition.mock.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let formDefinitionTwoTextFields = { +export const formDefinitionTwoTextFields: any = { id: 20, name: 'formTextDefinition', processDefinitionId: 'textDefinition:1:153', @@ -160,7 +160,7 @@ export let formDefinitionTwoTextFields = { globalDateFormat: 'D-M-YYYY' }; -export let formDefinitionDropdownField = { +export const formDefinitionDropdownField: any = { id: 21, name: 'dropdownDefinition', processDefinitionId: 'textDefinition:2:163', @@ -282,7 +282,7 @@ export let formDefinitionDropdownField = { globalDateFormat: 'D-M-YYYY' }; -export let formDefinitionRequiredField = { +export const formDefinitionRequiredField: any = { id: 21, name: 'dropdownDefinition', processDefinitionId: 'textDefinition:2:163', diff --git a/lib/core/mock/form/formDefinitionReadonly.mock.ts b/lib/core/mock/form/formDefinitionReadonly.mock.ts index bee470a159..b1b5a4eb5e 100644 --- a/lib/core/mock/form/formDefinitionReadonly.mock.ts +++ b/lib/core/mock/form/formDefinitionReadonly.mock.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let formReadonlyTwoTextFields = { +export const formReadonlyTwoTextFields: any = { id: 22, name: 'formTextDefinition', processDefinitionId: 'textDefinition:3:182', diff --git a/lib/core/mock/form/formDefinitionVisibility.mock.ts b/lib/core/mock/form/formDefinitionVisibility.mock.ts index 90c89e18cc..221cef9311 100644 --- a/lib/core/mock/form/formDefinitionVisibility.mock.ts +++ b/lib/core/mock/form/formDefinitionVisibility.mock.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let formDefVisibilitiFieldDependsOnNextOne = { +export const formDefVisibilitiFieldDependsOnNextOne: any = { id: 19, processDefinitionId: 'visibility:1:148', processDefinitionName: 'visibility', @@ -181,7 +181,7 @@ export let formDefVisibilitiFieldDependsOnNextOne = { globalDateFormat: 'D-M-YYYY' }; -export let formDefVisibilitiFieldDependsOnPreviousOne = { +export const formDefVisibilitiFieldDependsOnPreviousOne: any = { id: 19, processDefinitionId: 'visibility:1:148', processDefinitionName: 'visibility', diff --git a/lib/core/mock/form/start-form.component.mock.ts b/lib/core/mock/form/start-form.component.mock.ts index d8ae040059..8d1d7fa83d 100644 --- a/lib/core/mock/form/start-form.component.mock.ts +++ b/lib/core/mock/form/start-form.component.mock.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let startFormDateWidgetMock = { +export const startFormDateWidgetMock: any = { id: 4, name: 'Claim Review Process', processDefinitionId: 'ClaimReviewProcess:2: 93', @@ -38,7 +38,7 @@ export let startFormDateWidgetMock = { }] }; -export let startFormNumberWidgetMock = { +export const startFormNumberWidgetMock: any = { id: 4, name: 'Claim Review Process', processDefinitionId: 'ClaimReviewProcess:2: 93', @@ -61,7 +61,7 @@ export let startFormNumberWidgetMock = { }] }; -export let startFormAmountWidgetMock = { +export const startFormAmountWidgetMock: any = { id: 4, name: 'Claim Review Process', processDefinitionId: 'ClaimReviewProcess:2: 93', @@ -84,7 +84,7 @@ export let startFormAmountWidgetMock = { }] }; -export let startFormRadioButtonWidgetMock = { +export const startFormRadioButtonWidgetMock: any = { id: 4, name: 'Claim Review Process', processDefinitionId: 'ClaimReviewProcess:2: 93', @@ -107,7 +107,7 @@ export let startFormRadioButtonWidgetMock = { }] }; -export let startFormTextDefinitionMock = { +export const startFormTextDefinitionMock: any = { id: 4, name: 'Claim Review Process', processDefinitionId: 'ClaimReviewProcess:2: 93', @@ -130,7 +130,7 @@ export let startFormTextDefinitionMock = { }] }; -export let startFormDropdownDefinitionMock = { +export const startFormDropdownDefinitionMock: any = { id: 4, name: 'Claim Review Process', processDefinitionId: 'ClaimReviewProcess:2: 93', @@ -179,7 +179,7 @@ export let startFormDropdownDefinitionMock = { }] }; -export let startMockForm = { +export const startMockForm: any = { id: 4, name: 'Claim Review Process', processDefinitionId: 'ClaimReviewProcess:2: 93', @@ -593,7 +593,7 @@ export let startMockForm = { globalDateFormat: 'D - M - YYYY' }; -export let startMockFormWithTab = { +export const startMockFormWithTab: any = { id: 4, taskName: 'Mock Title', processDefinitionId: 'ClaimReviewProcess:2: 93', diff --git a/lib/core/mock/form/widget-visibility-cloud.service.mock.ts b/lib/core/mock/form/widget-visibility-cloud.service.mock.ts index f8a6d3cde2..eeec4d72d6 100644 --- a/lib/core/mock/form/widget-visibility-cloud.service.mock.ts +++ b/lib/core/mock/form/widget-visibility-cloud.service.mock.ts @@ -19,13 +19,13 @@ import { FormModel, FormValues } from '../../form/components/widgets/core/index' export let formTest = new FormModel({}); -export let fakeTaskProcessVariableModels = [ +export const fakeTaskProcessVariableModels = [ { id: 'TEST_VAR_1', type: 'string', value: 'test_value_1' }, { id: 'TEST_VAR_2', type: 'string', value: 'test_value_2' }, { id: 'TEST_VAR_3', type: 'string', value: 'test_value_3' } ]; -export let formValues: FormValues = { +export const formValues: FormValues = { 'test_1': 'value_1', 'test_2': 'value_2', 'test_3': 'value_1', @@ -34,7 +34,7 @@ export let formValues: FormValues = { 'dropdown': { 'id': 'dropdown_id', 'name': 'dropdown_label' } }; -export let fakeFormJson = { +export const fakeFormJson: any = { id: '9999', name: 'FORM_VISIBILITY', processDefinitionId: 'PROCESS_TEST:9:9999', @@ -116,7 +116,7 @@ export let fakeFormJson = { ] }; -export let complexVisibilityJsonVisible = { +export const complexVisibilityJsonVisible: any = { 'id': 47591, 'name': 'Test-visibility', 'description': '', @@ -481,7 +481,7 @@ export let complexVisibilityJsonVisible = { 'gridsterForm': false } }; -export let complexVisibilityJsonNotVisible = { +export const complexVisibilityJsonNotVisible: any = { 'id': 47591, 'name': 'Test-visibility', 'description': '', @@ -847,7 +847,7 @@ export let complexVisibilityJsonNotVisible = { } }; -export let nextConditionForm = { +export const nextConditionForm: any = { id: '9999', name: 'FORM_PROCESS_VARIABLE_VISIBILITY', processDefinitionId: 'PROCESS_TEST:9:9999', @@ -955,7 +955,7 @@ export let nextConditionForm = { ] }; -export let headerVisibilityCond = { +export const headerVisibilityCond: any = { 'id': 'form-f0823c05-51eb-4703-8634-75a6d5e15df5', 'name': 'text_form', 'description': '', diff --git a/lib/core/mock/form/widget-visibility.service.mock.ts b/lib/core/mock/form/widget-visibility.service.mock.ts index 7cade1694e..833e2f9837 100644 --- a/lib/core/mock/form/widget-visibility.service.mock.ts +++ b/lib/core/mock/form/widget-visibility.service.mock.ts @@ -19,13 +19,13 @@ import { FormModel, FormValues } from '../../form/components/widgets/core/index' export let formTest = new FormModel({}); -export let fakeTaskProcessVariableModels = [ +export const fakeTaskProcessVariableModels = [ { id: 'TEST_VAR_1', type: 'string', value: 'test_value_1' }, { id: 'TEST_VAR_2', type: 'string', value: 'test_value_2' }, { id: 'TEST_VAR_3', type: 'string', value: 'test_value_3' } ]; -export let formValues: FormValues = { +export const formValues: FormValues = { 'test_1': 'value_1', 'test_2': 'value_2', 'test_3': 'value_1', @@ -34,7 +34,7 @@ export let formValues: FormValues = { 'dropdown': { 'id': 'dropdown_id', 'name': 'dropdown_label' } }; -export let fakeFormJson = { +export const fakeFormJson: any = { id: '9999', name: 'FORM_VISIBILITY', processDefinitionId: 'PROCESS_TEST: 9: 9999', @@ -116,7 +116,7 @@ export let fakeFormJson = { ] }; -export let complexVisibilityJsonVisible = { +export const complexVisibilityJsonVisible: any = { 'id': 47591, 'name': 'Test-visibility', 'description': '', @@ -489,7 +489,8 @@ export let complexVisibilityJsonVisible = { 'gridsterForm': false } }; -export let complexVisibilityJsonNotVisible = { + +export const complexVisibilityJsonNotVisible: any = { 'id': 47591, 'name': 'Test-visibility', 'description': '', @@ -859,7 +860,7 @@ export let complexVisibilityJsonNotVisible = { } }; -export let tabVisibilityJsonMock = { +export const tabVisibilityJsonMock: any = { 'id': 45231, 'name': 'visibility-form', 'description': '', @@ -1000,7 +1001,7 @@ export let tabVisibilityJsonMock = { } }; -export const tabInvalidFormVisibility = { +export const tabInvalidFormVisibility: any = { 'id': 'form-0668939d-34b2-440c-ab4d-01ab8b05a881', 'name': 'tab-visibility', 'description': '', diff --git a/lib/core/services/authentication.service.ts b/lib/core/services/authentication.service.ts index 162fc2cfea..d49616da15 100644 --- a/lib/core/services/authentication.service.ts +++ b/lib/core/services/authentication.service.ts @@ -163,6 +163,7 @@ export class AuthenticationService { if (this.alfrescoApi.getInstance()) { return this.alfrescoApi.getInstance().logout(); } + return Promise.resolve(); } /** diff --git a/lib/core/services/identity-role.service.ts b/lib/core/services/identity-role.service.ts index 0ad79fb45c..f56d57547f 100644 --- a/lib/core/services/identity-role.service.ts +++ b/lib/core/services/identity-role.service.ts @@ -17,7 +17,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { throwError as observableThrowError, Observable } from 'rxjs'; +import { throwError as observableThrowError, Observable, of } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { Pagination } from '@alfresco/js-api'; import { IdentityRoleModel } from '../models/identity-role.model'; @@ -90,6 +90,7 @@ export class IdentityRoleService { .post(`${this.identityHost}/roles`, request) .pipe(catchError(error => this.handleError(error))); } + return of(); } /** @@ -119,6 +120,7 @@ export class IdentityRoleService { .put(`${this.identityHost}/roles-by-id/${roleId}`, request) .pipe(catchError(error => this.handleError(error))); } + return of(); } private handleError(error: any) { diff --git a/lib/core/services/lock.service.ts b/lib/core/services/lock.service.ts index 6e40769998..ac5c7a9fb3 100644 --- a/lib/core/services/lock.service.ts +++ b/lib/core/services/lock.service.ts @@ -59,14 +59,18 @@ export class LockService { return node.properties['cm:lockType'] === 'WRITE_LOCK' && node.properties['cm:lockLifetime'] === 'PERSISTENT'; } - private getLockExpiryTime(node: Node): Moment { + private getLockExpiryTime(node: Node): Moment | undefined { if (node.properties['cm:expiryDate']) { return moment(node.properties['cm:expiryDate'], 'yyyy-MM-ddThh:mm:ssZ'); } + return undefined; } private isLockExpired(node: Node): boolean { const expiryLockTime = this.getLockExpiryTime(node); - return moment().isAfter(expiryLockTime); + if (expiryLockTime) { + return moment().isAfter(expiryLockTime); + } + return false; } } diff --git a/lib/core/services/user-preferences.service.ts b/lib/core/services/user-preferences.service.ts index 78ab7f7e81..9a73dbe75e 100644 --- a/lib/core/services/user-preferences.service.ts +++ b/lib/core/services/user-preferences.service.ts @@ -139,9 +139,9 @@ export class UserPreferencesService { * @param property Name of the property * @returns True if the item is present, false otherwise */ - hasItem(property: string) { + hasItem(property: string): boolean { if (!property) { - return; + return false; } return this.storage.hasItem( this.getPropertyKey(property) diff --git a/lib/core/utils/momentDateAdapter.ts b/lib/core/utils/momentDateAdapter.ts index a640ec593e..bd4066265d 100644 --- a/lib/core/utils/momentDateAdapter.ts +++ b/lib/core/utils/momentDateAdapter.ts @@ -50,7 +50,7 @@ export class MomentDateAdapter extends DateAdapter { case 'narrow': return this.localeData.monthsShort().map((month) => month[0]); default : - return; + return []; } } @@ -72,7 +72,7 @@ export class MomentDateAdapter extends DateAdapter { case 'narrow': return this.localeData.weekdaysShort(); default : - return; + return []; } } diff --git a/lib/core/viewer/components/pdfViewer.component.spec.ts b/lib/core/viewer/components/pdfViewer.component.spec.ts index c78fb67fdd..1f01da9e4f 100644 --- a/lib/core/viewer/components/pdfViewer.component.spec.ts +++ b/lib/core/viewer/components/pdfViewer.component.spec.ts @@ -336,7 +336,7 @@ describe('Test PdfViewer component', () => { fixtureUrlTestPasswordComponent = TestBed.createComponent(UrlTestPasswordComponent); componentUrlTestPasswordComponent = fixtureUrlTestPasswordComponent.componentInstance; - spyOn(dialog, 'open').and.callFake((_, context) => { + spyOn(dialog, 'open').and.callFake((_: any, context: any) => { if (context.data.reason === pdfjsLib.PasswordResponses.NEED_PASSWORD) { return { afterClosed: () => of('wrong_password') @@ -348,6 +348,8 @@ describe('Test PdfViewer component', () => { afterClosed: () => of('password') }; } + + return undefined; }); fixtureUrlTestPasswordComponent.detectChanges(); diff --git a/lib/core/viewer/components/txtViewer.component.ts b/lib/core/viewer/components/txtViewer.component.ts index 86e3be70e6..2d8ef66558 100644 --- a/lib/core/viewer/components/txtViewer.component.ts +++ b/lib/core/viewer/components/txtViewer.component.ts @@ -55,6 +55,8 @@ export class TxtViewerComponent implements OnChanges { if (!this.urlFile && !this.blobFile) { throw new Error('Attribute urlFile or blobFile is required'); } + + return Promise.resolve(); } private getUrlContent(url: string): Promise { diff --git a/lib/core/viewer/services/view-util.service.ts b/lib/core/viewer/services/view-util.service.ts index d2ecc3e393..ffaf1b0b72 100644 --- a/lib/core/viewer/services/view-util.service.ts +++ b/lib/core/viewer/services/view-util.service.ts @@ -126,6 +126,8 @@ export class ViewUtilService { return await this.waitRendition(nodeId, renditionId, retries); } } + + return Promise.resolve(null); } getViewerTypeByMimeType(mimeType: string): string { diff --git a/lib/extensions/src/lib/config/extension-utils.ts b/lib/extensions/src/lib/config/extension-utils.ts index ddf3f0146a..a8a120418e 100644 --- a/lib/extensions/src/lib/config/extension-utils.ts +++ b/lib/extensions/src/lib/config/extension-utils.ts @@ -102,7 +102,7 @@ export function reduceEmptyMenus( return acc.concat(el); } -export function mergeObjects(...objects): any { +export function mergeObjects(...objects: object[]): any { const result = {}; objects.forEach((source) => { diff --git a/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts b/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts index 79a3676efe..dd66cd7411 100644 --- a/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts +++ b/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts @@ -62,8 +62,6 @@ export class ContentCloudNodeSelectorService { } private isNodeFile(entry: Node): boolean { - if (entry) { - return entry.isFile; - } + return entry && entry.isFile; } } diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts index ed58d84025..7d9770c4d0 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts @@ -221,17 +221,16 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes return this.filterProperties.indexOf(EditProcessFilterCloudComponent.LAST_MODIFIED) >= 0; } - removeOrderProperty(filteredProperties: ProcessFilterProperties[]) { + removeOrderProperty(filteredProperties: ProcessFilterProperties[]): ProcessFilterProperties[] { if (filteredProperties && filteredProperties.length > 0) { - const propertiesWithOutOrderProperty = filteredProperties.filter( - (property: ProcessFilterProperties) => { - return property.key !== EditProcessFilterCloudComponent.ORDER; - }); - return propertiesWithOutOrderProperty; + return filteredProperties.filter( + property => property.key !== EditProcessFilterCloudComponent.ORDER + ); } + return []; } - get createSortProperties(): any { + get createSortProperties(): ProcessFilterOptions[] { this.checkMandatorySortProperties(); const sortProperties = this.sortProperties.map((property: string) => { return { label: property.charAt(0).toUpperCase() + property.slice(1), value: property }; @@ -425,6 +424,8 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes if (action.actionType === EditProcessFilterCloudComponent.ACTION_DELETE) { return false; } + + return false; } private setLastModifiedToFilter(formValues: ProcessFilterCloudModel) { diff --git a/lib/process-services-cloud/src/lib/process/process-filters/services/process-filter-cloud.service.ts b/lib/process-services-cloud/src/lib/process/process-filters/services/process-filter-cloud.service.ts index 2dc5f98412..c020851539 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/services/process-filter-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/services/process-filter-cloud.service.ts @@ -152,11 +152,14 @@ export class ProcessFilterCloudService { */ deleteFilter(deletedFilter: ProcessFilterCloudModel): Observable { const key = this.prepareKey(deletedFilter.appName); + return this.getProcessFiltersByKey(deletedFilter.appName, key).pipe( - switchMap((filters: any) => { + switchMap(filters => { if (filters && filters.length > 0) { - filters = filters.filter((filter: ProcessFilterCloudModel) => filter.id !== deletedFilter.id); + filters = filters.filter(filter => filter.id !== deletedFilter.id); return this.updateProcessFilters(deletedFilter.appName, key, filters); + } else { + return []; } }), map((filters: ProcessFilterCloudModel[]) => { diff --git a/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts b/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts index dd0311e897..8532f12959 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts @@ -57,16 +57,17 @@ export class ProcessListCloudService extends BaseCloudService { return throwError('Appname not configured'); } } - private buildQueryUrl(requestNode: ProcessQueryCloudRequestModel) { + + private buildQueryUrl(requestNode: ProcessQueryCloudRequestModel): string { this.contextRoot = this.appConfigService.get('bpmHost', ''); return `${this.getBasePath(requestNode.appName)}/query/v1/process-instances`; } - private isPropertyValueValid(requestNode, property) { + private isPropertyValueValid(requestNode: any, property: string) { return requestNode[property] !== '' && requestNode[property] !== null && requestNode[property] !== undefined; } - private buildQueryParams(requestNode: ProcessQueryCloudRequestModel) { + private buildQueryParams(requestNode: ProcessQueryCloudRequestModel): Object { const queryParam = {}; for (const property in requestNode) { if (requestNode.hasOwnProperty(property) && @@ -78,7 +79,7 @@ export class ProcessListCloudService extends BaseCloudService { return queryParam; } - private isExcludedField(property) { + private isExcludedField(property: string): boolean { return property === 'appName' || property === 'sorting'; } diff --git a/lib/process-services-cloud/src/lib/services/local-preference-cloud.service.ts b/lib/process-services-cloud/src/lib/services/local-preference-cloud.service.ts index a1ff947522..592bb203ce 100644 --- a/lib/process-services-cloud/src/lib/services/local-preference-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/services/local-preference-cloud.service.ts @@ -34,6 +34,13 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf if (key || key === '') { return of(this.prepareLocalPreferenceResponse(key)); } + return of( + { + 'list': { + 'entries': [] + } + } + ); } /** @@ -70,8 +77,8 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf updatePreference(_: string, key: string, updatedPreference: any): Observable { if (key) { this.storage.setItem(key, JSON.stringify(updatedPreference)); - return of(updatedPreference); } + return of(updatedPreference); } /** @@ -84,8 +91,8 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf deletePreference(key: string, preferences: any): Observable { if (key) { this.storage.setItem(key, JSON.stringify(preferences)); - return of(preferences); } + return of(preferences); } prepareLocalPreferenceResponse(key: string): any { diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts index c2141c6192..1af2d88679 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filter-cloud.component.ts @@ -242,11 +242,11 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro return this.filterProperties.indexOf(EditTaskFilterCloudComponent.SORT) >= 0; } - removeOrderProperty(filteredProperties: TaskFilterProperties[]) { + removeOrderProperty(filteredProperties: TaskFilterProperties[]): TaskFilterProperties[] { if (filteredProperties && filteredProperties.length > 0) { - const propertiesWithOutOrderProperty = filteredProperties.filter((property: TaskFilterProperties) => { return property.key !== EditTaskFilterCloudComponent.ORDER; }); - return propertiesWithOutOrderProperty; + return filteredProperties.filter(property => property.key !== EditTaskFilterCloudComponent.ORDER); } + return []; } hasLastModifiedProperty(): boolean { @@ -261,19 +261,19 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro return sortProperties; } - checkMandatorySortProperties() { + checkMandatorySortProperties(): void { if (this.sortProperties === undefined || this.sortProperties.length === 0) { this.sortProperties = EditTaskFilterCloudComponent.DEFAULT_SORT_PROPERTIES; } } - createAndFilterActions() { + createAndFilterActions(): TaskFilterAction[] { this.checkMandatoryActions(); - const allActions = this.createFilterActions(); - return allActions.filter((action: TaskFilterAction) => this.isValidAction(this.actions, action)); + return this.createFilterActions() + .filter(action => this.isValidAction(this.actions, action)); } - checkMandatoryActions() { + checkMandatoryActions(): void { if (this.actions === undefined || this.actions.length === 0) { this.actions = EditTaskFilterCloudComponent.DEFAULT_ACTIONS; } @@ -316,9 +316,11 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro return JSON.stringify(editedQuery).toLowerCase() === JSON.stringify(currentQuery).toLowerCase(); } - getRunningApplications() { - this.appsProcessCloudService.getDeployedApplicationsByStatus(EditTaskFilterCloudComponent.APP_RUNNING_STATUS) - .pipe(takeUntil(this.onDestroy$)).subscribe((applications: ApplicationInstanceModel[]) => { + getRunningApplications(): void { + this.appsProcessCloudService + .getDeployedApplicationsByStatus(EditTaskFilterCloudComponent.APP_RUNNING_STATUS) + .pipe(takeUntil(this.onDestroy$)) + .subscribe((applications: ApplicationInstanceModel[]) => { if (applications && applications.length > 0) { applications.map((application) => { this.applicationNames.push({ label: application.name, value: application.name }); @@ -337,24 +339,28 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro } } - save(saveAction: TaskFilterAction) { - this.taskFilterCloudService.updateFilter(this.changedTaskFilter) - .pipe(takeUntil(this.onDestroy$)).subscribe(() => { - saveAction.filter = this.changedTaskFilter; - this.action.emit(saveAction); - this.formHasBeenChanged = this.compareFilters(this.changedTaskFilter, this.taskFilter); - }); + save(saveAction: TaskFilterAction): void { + this.taskFilterCloudService + .updateFilter(this.changedTaskFilter) + .pipe(takeUntil(this.onDestroy$)) + .subscribe(() => { + saveAction.filter = this.changedTaskFilter; + this.action.emit(saveAction); + this.formHasBeenChanged = this.compareFilters(this.changedTaskFilter, this.taskFilter); + }); } - delete(deleteAction: TaskFilterAction) { - this.taskFilterCloudService.deleteFilter(this.taskFilter) - .pipe(takeUntil(this.onDestroy$)).subscribe(() => { - deleteAction.filter = this.taskFilter; - this.action.emit(deleteAction); - }); + delete(deleteAction: TaskFilterAction): void { + this.taskFilterCloudService + .deleteFilter(this.taskFilter) + .pipe(takeUntil(this.onDestroy$)) + .subscribe(() => { + deleteAction.filter = this.taskFilter; + this.action.emit(deleteAction); + }); } - saveAs(saveAsAction: TaskFilterAction) { + saveAs(saveAsAction: TaskFilterAction): void { const dialogRef = this.dialog.open(TaskFilterDialogCloudComponent, { data: { name: this.translateService.instant(this.taskFilter.name) @@ -404,11 +410,11 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro return this.showFilterActions; } - onExpand() { + onExpand(): void { this.toggleFilterActions = true; } - onClose() { + onClose(): void { this.toggleFilterActions = false; } @@ -438,6 +444,8 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro if (action.actionType === EditTaskFilterCloudComponent.ACTION_DELETE) { return false; } + + return false; } createFilterActions(): TaskFilterAction[] { diff --git a/lib/process-services-cloud/src/lib/task/task-filters/services/task-filter-cloud.service.ts b/lib/process-services-cloud/src/lib/task/task-filters/services/task-filter-cloud.service.ts index 8d00ea7661..bbb00e1986 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/services/task-filter-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/services/task-filter-cloud.service.ts @@ -201,13 +201,14 @@ export class TaskFilterCloudService { deleteFilter(deletedFilter: TaskFilterCloudModel): Observable { const key = this.prepareKey(deletedFilter.appName); return this.getTaskFiltersByKey(deletedFilter.appName, key).pipe( - switchMap((filters: any) => { + switchMap(filters => { if (filters && filters.length > 0) { - filters = filters.filter((filter: TaskFilterCloudModel) => filter.id !== deletedFilter.id); + filters = filters.filter(filter => filter.id !== deletedFilter.id); return this.updateTaskFilters(deletedFilter.appName, key, filters); } + return []; }), - map((filters: TaskFilterCloudModel[]) => { + map(filters => { this.addFiltersToStream(filters); return filters; }), diff --git a/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.ts b/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.ts index 1c53233056..2c5129d590 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.ts @@ -65,8 +65,8 @@ export class TaskListCloudService extends BaseCloudService { return `${this.getBasePath(requestNode.appName)}/query/v1/tasks`; } - private buildQueryParams(requestNode: TaskQueryCloudRequestModel) { - const queryParam = {}; + private buildQueryParams(requestNode: TaskQueryCloudRequestModel): Object { + const queryParam: Object = {}; for (const property in requestNode) { if (requestNode.hasOwnProperty(property) && !this.isExcludedField(property) && @@ -77,11 +77,11 @@ export class TaskListCloudService extends BaseCloudService { return queryParam; } - private isExcludedField(property) { + private isExcludedField(property: string): boolean { return property === 'appName' || property === 'sorting'; } - private isPropertyValueValid(requestNode, property) { + private isPropertyValueValid(requestNode: any, property: string): boolean { return requestNode[property] !== '' && requestNode[property] !== null && requestNode[property] !== undefined; } diff --git a/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts b/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts index b481c21f99..5c08b60c61 100644 --- a/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts +++ b/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts @@ -231,7 +231,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements }); } - private getDomainHost(urlToCheck) { + private getDomainHost(urlToCheck: string): string { const result = urlToCheck.match('^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/?\n]+)'); return result[1]; } diff --git a/lib/process-services/src/lib/people/components/people-search/people-search.component.ts b/lib/process-services/src/lib/people/components/people-search/people-search.component.ts index 7581ee4f72..1e6f9a9af6 100644 --- a/lib/process-services/src/lib/people/components/people-search/people-search.component.ts +++ b/lib/process-services/src/lib/people/components/people-search/people-search.component.ts @@ -65,7 +65,7 @@ export class PeopleSearchComponent implements OnInit { this.performSearch = this.performSearchCallback.bind(this); } - private performSearchCallback(event): Observable { + private performSearchCallback(event: any): Observable { this.searchPeople.emit(event); return this.filteredResults$; } diff --git a/lib/process-services/src/lib/process-list/components/process-filters.component.ts b/lib/process-services/src/lib/process-list/components/process-filters.component.ts index 7039e9b7bb..b2976a4aed 100644 --- a/lib/process-services/src/lib/process-list/components/process-filters.component.ts +++ b/lib/process-services/src/lib/process-list/components/process-filters.component.ts @@ -145,7 +145,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges { * Pass the selected filter as next * @param filter */ - public selectFilter(filter: ProcessInstanceFilterRepresentation) { + selectFilter(filter: ProcessInstanceFilterRepresentation) { this.currentFilter = filter; this.filterClick.emit(filter); } @@ -153,7 +153,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges { /** * Select the first filter of a list if present */ - public selectProcessFilter(filterParam: FilterProcessRepresentationModel) { + selectProcessFilter(filterParam: FilterProcessRepresentationModel) { if (filterParam) { this.filters.filter((processFilter: UserProcessInstanceFilterRepresentation, index) => { if (filterParam.name && filterParam.name.toLowerCase() === processFilter.name.toLowerCase() || @@ -172,14 +172,14 @@ export class ProcessFiltersComponent implements OnInit, OnChanges { /** * Select the Running filter */ - public selectRunningFilter() { + selectRunningFilter() { this.selectProcessFilter(this.processFilterService.getRunningFilterInstance(null)); } /** * Select as default task filter the first in the list */ - public selectDefaultTaskFilter() { + selectDefaultTaskFilter() { if (!this.isFilterListEmpty()) { this.currentFilter = this.filters[0]; this.filterSelected.emit(this.filters[0]); @@ -215,7 +215,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges { /** * Return current filter icon */ - getFilterIcon(icon): string { + getFilterIcon(icon: string): string { return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(icon); } } diff --git a/lib/process-services/src/lib/process-list/components/process-instance-details.component.ts b/lib/process-services/src/lib/process-list/components/process-instance-details.component.ts index ce95b55a4f..a6c86ac5fb 100644 --- a/lib/process-services/src/lib/process-list/components/process-instance-details.component.ts +++ b/lib/process-services/src/lib/process-list/components/process-instance-details.component.ts @@ -52,21 +52,21 @@ export class ProcessInstanceDetailsComponent implements OnChanges { /** Emitted when the current process is cancelled by the user from within the component. */ @Output() - processCancelled: EventEmitter = new EventEmitter(); + processCancelled = new EventEmitter(); /** Emitted when an error occurs. */ @Output() - error: EventEmitter = new EventEmitter(); + error = new EventEmitter(); /** Emitted when a task is clicked. */ @Output() - taskClick: EventEmitter = new EventEmitter(); + taskClick = new EventEmitter(); processInstanceDetails: ProcessInstance; /** Emitted when the "show diagram" button is clicked. */ @Output() - showProcessDiagram: EventEmitter = new EventEmitter(); + showProcessDiagram = new EventEmitter(); /** * Constructor @@ -124,7 +124,7 @@ export class ProcessInstanceDetailsComponent implements OnChanges { this.taskClick.emit(event); } - getProcessNameOrDescription(dateFormat): string { + getProcessNameOrDescription(dateFormat: string): string { let name = ''; if (this.processInstanceDetails) { name = this.processInstanceDetails.name || @@ -133,7 +133,7 @@ export class ProcessInstanceDetailsComponent implements OnChanges { return name; } - getFormatDate(value, format: string) { + getFormatDate(value: any, format: string): any { const datePipe = new DatePipe('en-US'); try { return datePipe.transform(value, format); diff --git a/lib/process-services/src/lib/process-list/components/process-instance-header.component.ts b/lib/process-services/src/lib/process-list/components/process-instance-header.component.ts index feb639bb8e..5b87d68220 100644 --- a/lib/process-services/src/lib/process-list/components/process-instance-header.component.ts +++ b/lib/process-services/src/lib/process-list/components/process-instance-header.component.ts @@ -120,6 +120,7 @@ export class ProcessInstanceHeaderComponent implements OnChanges { if (this.processInstance) { return this.isRunning() ? 'Running' : 'Completed'; } + return 'Unknown'; } getStartedByFullName(): string { diff --git a/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.ts b/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.ts index 699c817c82..a29a42ef6b 100644 --- a/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.ts +++ b/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.ts @@ -144,7 +144,7 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr return this.processInstanceDetails && this.processInstanceDetails.startFormDefined === true; } - getUserFullName(user: any) { + getUserFullName(user: any): string { if (user) { return (user.firstName && user.firstName !== 'null' ? user.firstName + ' ' : '') + @@ -153,12 +153,13 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr return 'Nobody'; } - getFormatDate(value, format: string) { + getFormatDate(value: any, format: string): any { const datePipe = new DatePipe('en-US'); try { return datePipe.transform(value, format); } catch (err) { this.logService.error(`ProcessListInstanceTask: error parsing date ${value} to format ${format}`); + return value; } } diff --git a/lib/process-services/src/lib/process-list/components/process-list.component.ts b/lib/process-services/src/lib/process-list/components/process-list.component.ts index 80e61efda9..fc5b1ccb6d 100644 --- a/lib/process-services/src/lib/process-list/components/process-list.component.ts +++ b/lib/process-services/src/lib/process-list/components/process-list.component.ts @@ -292,7 +292,7 @@ export class ProcessInstanceListComponent extends DataTableSchema implements On return instances; } - getProcessNameOrDescription(processInstance, dateFormat): string { + getProcessNameOrDescription(processInstance, dateFormat: string): string { let name = ''; if (processInstance) { name = processInstance.name || @@ -301,7 +301,7 @@ export class ProcessInstanceListComponent extends DataTableSchema implements On return name; } - getFormatDate(value, format: string) { + getFormatDate(value: any, format: string) { const datePipe = new DatePipe('en-US'); try { return datePipe.transform(value, format); @@ -310,7 +310,7 @@ export class ProcessInstanceListComponent extends DataTableSchema implements On } } - private createRequestNode() { + private createRequestNode(): ProcessFilterParamRepresentationModel { const requestNode = { appDefinitionId: this.appId, processDefinitionId: this.processDefinitionId, diff --git a/lib/process-services/src/lib/process-list/components/start-process.component.ts b/lib/process-services/src/lib/process-list/components/start-process.component.ts index 6f867872c4..60581f10d2 100644 --- a/lib/process-services/src/lib/process-list/components/start-process.component.ts +++ b/lib/process-services/src/lib/process-list/components/start-process.component.ts @@ -152,9 +152,11 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr } return filteredProcess; } + + return []; } - getSelectedProcess(selectedProcess) { + getSelectedProcess(selectedProcess: string): ProcessDefinitionRepresentation { let processSelected = this.processDefinitions.find((process) => process.name.toLowerCase() === selectedProcess); if (!processSelected) { @@ -163,7 +165,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr return processSelected; } - public loadStartProcess() { + loadStartProcess(): void { this.resetSelectedProcessDefinition(); this.resetErrorMessage(); @@ -206,7 +208,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr return alfrescoRepositoryName + 'Alfresco'; } - moveNodeFromCStoPS() { + moveNodeFromCStoPS(): void { const accountIdentifier = this.getAlfrescoRepositoryName(); for (const key in this.values) { @@ -222,7 +224,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr } } - public startProcess(outcome?: string) { + startProcess(outcome?: string) { if (this.selectedProcessDef && this.selectedProcessDef.id && this.name) { this.resetErrorMessage(); const formValues = this.startForm ? this.startForm.form.values : undefined; @@ -239,7 +241,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr } } - public cancelStartProcess() { + cancelStartProcess(): void { this.cancel.emit(); } @@ -247,8 +249,9 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr return this.selectedProcessDef && this.selectedProcessDef.hasStartForm; } - isProcessDefinitionEmpty() { - return this.processDefinitions ? (this.processDefinitions.length > 0 || this.errorMessageId) : this.errorMessageId; + isProcessDefinitionEmpty(): boolean { + const hasErrorMessage = this.errorMessageId ? true : false; + return this.processDefinitions ? (this.processDefinitions.length > 0 || hasErrorMessage) : hasErrorMessage; } isStartFormMissingOrValid(): boolean { @@ -279,7 +282,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr this.startProcess(outcome); } - public reset() { + reset(): void { this.resetSelectedProcessDefinition(); this.name = ''; if (this.startForm) { @@ -292,7 +295,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr return this.name ? true : false; } - displayFn(process: any) { + displayFn(process: any): string { if (process) { let processName = process; if (typeof process !== 'string') { @@ -300,6 +303,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr } return processName; } + return undefined; } displayDropdown(event) { diff --git a/lib/process-services/src/lib/task-list/components/start-task.component.ts b/lib/process-services/src/lib/task-list/components/start-task.component.ts index 40b82ee475..d48cec83c5 100644 --- a/lib/process-services/src/lib/task-list/components/start-task.component.ts +++ b/lib/process-services/src/lib/task-list/components/start-task.component.ts @@ -109,7 +109,7 @@ export class StartTaskComponent implements OnInit, OnDestroy { this.onDestroy$.complete(); } - buildForm() { + buildForm(): void { this.taskForm = this.formBuilder.group({ name: new FormControl(this.taskDetailsModel.name, [Validators.required, Validators.maxLength(this.maxTaskNameLength), this.whitespaceValidator]), description: new FormControl('', [this.whitespaceValidator]), @@ -121,25 +121,26 @@ export class StartTaskComponent implements OnInit, OnDestroy { .subscribe(taskFormValues => this.setTaskDetails(taskFormValues)); } - public whitespaceValidator(control: FormControl) { + whitespaceValidator(control: FormControl): any { if (control.value) { const isWhitespace = (control.value || '').trim().length === 0; const isValid = control.value.length === 0 || !isWhitespace; return isValid ? null : { 'whitespace': true }; } + return null; } - setTaskDetails(form) { + setTaskDetails(form: any) { this.taskDetailsModel.name = form.name; this.taskDetailsModel.description = form.description; this.taskDetailsModel.formKey = form.formKey ? form.formKey.toString() : null; } - isFormValid() { + isFormValid(): boolean { return this.taskForm.valid && !this.dateError && !this.loading; } - public saveTask(): void { + saveTask(): void { this.loading = true; if (this.appId) { this.taskDetailsModel.category = this.appId.toString(); @@ -169,7 +170,7 @@ export class StartTaskComponent implements OnInit, OnDestroy { }); } - getAssigneeId(userId) { + getAssigneeId(userId: number): void { this.assigneeId = userId; } @@ -189,7 +190,7 @@ export class StartTaskComponent implements OnInit, OnDestroy { return response; } - public onCancel(): void { + onCancel(): void { this.cancel.emit(); } @@ -197,7 +198,7 @@ export class StartTaskComponent implements OnInit, OnDestroy { this.forms$ = this.taskService.getFormList(); } - public isUserNameEmpty(user: UserProcessModel): boolean { + isUserNameEmpty(user: UserProcessModel): boolean { return !user || (this.isEmpty(user.firstName) && this.isEmpty(user.lastName)); } @@ -205,7 +206,7 @@ export class StartTaskComponent implements OnInit, OnDestroy { return data === undefined || data === null || data.trim().length === 0; } - public getDisplayUser(firstName: string, lastName: string, delimiter: string = '-'): string { + getDisplayUser(firstName: string, lastName: string, delimiter: string = '-'): string { firstName = (firstName !== null ? firstName : ''); lastName = (lastName !== null ? lastName : ''); return firstName + delimiter + lastName; @@ -215,7 +216,7 @@ export class StartTaskComponent implements OnInit, OnDestroy { this.dateError = false; if (newDateValue) { - let momentDate; + let momentDate: moment.Moment; if (typeof newDateValue === 'string') { momentDate = moment(newDateValue, this.FORMAT_DATE, true); diff --git a/lib/process-services/src/lib/task-list/components/task-details.component.ts b/lib/process-services/src/lib/task-list/components/task-details.component.ts index ecf06fb37c..0ece45c490 100644 --- a/lib/process-services/src/lib/task-list/components/task-details.component.ts +++ b/lib/process-services/src/lib/task-list/components/task-details.component.ts @@ -335,11 +335,11 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy { this.isExternalIdEqual(this.taskDetails.assignee.externalId, this.currentLoggedUser.externalId); } - private isEmailEqual(assigneeMail, currentLoggedEmail): boolean { + private isEmailEqual(assigneeMail: string, currentLoggedEmail: string): boolean { return assigneeMail.toLocaleLowerCase() === currentLoggedEmail.toLocaleLowerCase(); } - private isExternalIdEqual(assigneeExternalId, currentUserExternalId): boolean { + private isExternalIdEqual(assigneeExternalId: string, currentUserExternalId: string): boolean { return assigneeExternalId.toLocaleLowerCase() === currentUserExternalId.toLocaleLowerCase(); } diff --git a/lib/process-services/src/lib/task-list/components/task-header.component.ts b/lib/process-services/src/lib/task-list/components/task-header.component.ts index d19e284c47..15202a428f 100644 --- a/lib/process-services/src/lib/task-list/components/task-header.component.ts +++ b/lib/process-services/src/lib/task-list/components/task-header.component.ts @@ -225,10 +225,11 @@ export class TaskHeaderComponent implements OnChanges, OnInit { /** * Return the process parent information */ - getParentInfo() { + getParentInfo(): Map { if (this.taskDetails.processInstanceId && this.taskDetails.processDefinitionName) { return new Map([[this.taskDetails.processInstanceId, this.taskDetails.processDefinitionName]]); } + return new Map(); } /** @@ -241,7 +242,7 @@ export class TaskHeaderComponent implements OnChanges, OnInit { /** * Returns true if the task is assigned to logged in user */ - public isAssignedTo(userId): boolean { + public isAssignedTo(userId: number): boolean { return this.hasAssignee() ? this.taskDetails.assignee.id === userId : false; } @@ -255,7 +256,7 @@ export class TaskHeaderComponent implements OnChanges, OnInit { /** * Return true if the user is a candidate member */ - isCandidateMember() { + isCandidateMember(): boolean { return this.taskDetails.managerOfCandidateGroup || this.taskDetails.memberOfCandidateGroup || this.taskDetails.memberOfCandidateUsers; } diff --git a/lib/process-services/src/lib/task-list/services/tasklist.service.spec.ts b/lib/process-services/src/lib/task-list/services/tasklist.service.spec.ts index 084d0305a2..0e928be281 100644 --- a/lib/process-services/src/lib/task-list/services/tasklist.service.spec.ts +++ b/lib/process-services/src/lib/task-list/services/tasklist.service.spec.ts @@ -36,6 +36,7 @@ import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from ' import { TaskDetailsModel } from '../models/task-details.model'; import { TaskListService } from './tasklist.service'; import { AlfrescoApiServiceMock, LogService, AppConfigService } from '@alfresco/adf-core'; +import { TaskUpdateRepresentation } from '@alfresco/js-api'; declare let jasmine: any; @@ -452,8 +453,11 @@ describe('Activiti TaskList Service', () => { it('should update a task', (done) => { const taskId = '111'; + const updated: TaskUpdateRepresentation = { + name: 'someName' + }; - service.updateTask(taskId, { property: 'value' }).subscribe(() => { + service.updateTask(taskId, updated).subscribe(() => { done(); }); diff --git a/lib/process-services/src/lib/task-list/services/tasklist.service.ts b/lib/process-services/src/lib/task-list/services/tasklist.service.ts index 080822c41c..4e7f4e6dc6 100644 --- a/lib/process-services/src/lib/task-list/services/tasklist.service.ts +++ b/lib/process-services/src/lib/task-list/services/tasklist.service.ts @@ -25,7 +25,8 @@ import { TaskDetailsModel } from '../models/task-details.model'; import { TaskListModel } from '../models/task-list.model'; import { TaskQueryRepresentation, - AssigneeIdentifierRepresentation + AssigneeIdentifierRepresentation, + TaskUpdateRepresentation } from '@alfresco/js-api'; @Injectable({ @@ -363,7 +364,7 @@ export class TaskListService { * @param updated Data to update the task (as a `TaskUpdateRepresentation` instance). * @returns Updated task details */ - updateTask(taskId: any, updated): Observable { + updateTask(taskId: any, updated: TaskUpdateRepresentation): Observable { return from(this.apiService.taskApi.updateTask(taskId, updated)) .pipe( map((result) => result), diff --git a/lib/tsconfig.json b/lib/tsconfig.json index 5b6800c499..7643c7528c 100644 --- a/lib/tsconfig.json +++ b/lib/tsconfig.json @@ -13,7 +13,7 @@ "noUnusedParameters": true, "noUnusedLocals": true, "noImplicitAny": false, - "noImplicitReturns": false, + "noImplicitReturns": true, "noImplicitUseStrict": false, "noFallthroughCasesInSwitch": true, "removeComments": true, diff --git a/tsconfig.json b/tsconfig.json index ea92770d79..6e2db5e1f6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "skipLibCheck": true, "noUnusedLocals": true, "noUnusedParameters": true, + "noImplicitReturns": true, "target": "es5", "allowSyntheticDefaultImports": true, "typeRoots": [