[AAE-622] No implicit returns (#5157)

* enable noImplicitReturns rule

* type fixes

* fix return types

* fix return value

* fix tests

* fix visibility service

* update tests

* add missing types

* fix test
This commit is contained in:
Denys Vuika 2019-10-17 09:35:39 +01:00 committed by GitHub
parent 48aca2d30f
commit d7ab0417b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 366 additions and 319 deletions

View File

@ -386,7 +386,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
return node && node.list && node.list.entries.length === 0; return node && node.list && node.list.entries.length === 0;
} }
onContentActionError(errors) { onContentActionError(errors: any) {
const errorStatusCode = JSON.parse(errors.message).error.statusCode; const errorStatusCode = JSON.parse(errors.message).error.statusCode;
let translatedErrorMessage: any; let translatedErrorMessage: any;
@ -404,24 +404,24 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
this.openSnackMessage(translatedErrorMessage); this.openSnackMessage(translatedErrorMessage);
} }
onContentActionSuccess(message) { onContentActionSuccess(message: string) {
const translatedMessage: any = this.translateService.instant(message); const translatedMessage: any = this.translateService.instant(message);
this.openSnackMessage(translatedMessage); this.openSnackMessage(translatedMessage);
this.documentList.reload(); this.documentList.reload();
} }
onDeleteActionSuccess(message) { onDeleteActionSuccess(message: string) {
this.uploadService.fileDeleted.next(message); this.uploadService.fileDeleted.next(message);
this.deleteElementSuccess.emit(); this.deleteElementSuccess.emit();
this.documentList.reload(); this.documentList.reload();
this.openSnackMessage(message); this.openSnackMessage(message);
} }
onPermissionRequested(node) { onPermissionRequested(node: any) {
this.router.navigate(['/permissions', node.value.entry.id]); this.router.navigate(['/permissions', node.value.entry.id]);
} }
onManageVersions(event) { onManageVersions(event: any) {
const contentEntry = event.value.entry; const contentEntry = event.value.entry;
const showComments = this.showVersionComments; const showComments = this.showVersionComments;
const allowDownload = this.allowVersionDownload; 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; const contentEntry = event.value.entry;
if (this.contentService.hasAllowableOperations(contentEntry, 'update')) { if (this.contentService.hasAllowableOperations(contentEntry, 'update')) {
@ -499,7 +499,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
return false; return false;
} }
startProcessAction($event) { startProcessAction($event: any) {
this.formValues['file'] = $event.value.entry; this.formValues['file'] = $event.value.entry;
const dialogRef = this.dialog.open(SelectAppsDialogComponent, { const dialogRef = this.dialog.open(SelectAppsDialogComponent, {
@ -588,15 +588,15 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
return true; return true;
} }
runCustomAction(event) { runCustomAction(event: any) {
this.logService.log(event); this.logService.log(event);
} }
getFileFiltering() { getFileFiltering(): string {
return this.acceptedFilesTypeShow ? this.acceptedFilesType : '*'; return this.acceptedFilesTypeShow ? this.acceptedFilesType : '*';
} }
createLibrary() { createLibrary(): void {
const dialogInstance: any = this.dialog.open(LibraryDialogComponent, { const dialogInstance: any = this.dialog.open(LibraryDialogComponent, {
width: '400px' width: '400px'
}); });
@ -610,5 +610,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
if (search && search.highlight) { if (search && search.highlight) {
return search.highlight.map((currentHighlight) => currentHighlight.snippets).join(', '); return search.highlight.map((currentHighlight) => currentHighlight.snippets).join(', ');
} }
return '';
} }
} }

View File

@ -8,12 +8,12 @@
CLICKED NODE: {{clickedNodeName}} CLICKED NODE: {{clickedNodeName}}
</span> </span>
<adf-tree-view-list *ngIf="!errorMessage; else erroOccurred" <adf-tree-view-list *ngIf="!errorMessage; else errorOccurred"
[nodeId]="nodeIdSample" [nodeId]="nodeIdSample"
(nodeClicked)="onClick($event)" (nodeClicked)="onClick($event)"
(error)="onErrorOccurred($event)"> (error)="onErrorOccurred($event)">
</adf-tree-view-list> </adf-tree-view-list>
<ng-template #erroOccurred> <ng-template #errorOccurred>
<span>An Error Occurred </span> <span>An Error Occurred </span>
<span>{{errorMessage}}</span> <span>{{errorMessage}}</span>
</ng-template> </ng-template>

View File

@ -25,7 +25,7 @@ import { Component } from '@angular/core';
export class TreeViewSampleComponent { export class TreeViewSampleComponent {
clickedNodeName: string = ''; clickedNodeName: string = '';
errorMessage = ''; errorMessage: string = '';
nodeIdSample: string = '-my-'; nodeIdSample: string = '-my-';
@ -38,7 +38,7 @@ export class TreeViewSampleComponent {
this.errorMessage = ''; this.errorMessage = '';
} }
onErrorOccurred(error) { onErrorOccurred(error: string) {
this.clickedNodeName = ''; this.clickedNodeName = '';
this.errorMessage = error; this.errorMessage = error;
} }

View File

@ -12,6 +12,7 @@
"skipLibCheck": true, "skipLibCheck": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noImplicitReturns": true,
"target": "es5", "target": "es5",
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"typeRoots": [ "typeRoots": [

View File

@ -38,7 +38,7 @@ export class ContentMetadataConfigFactory {
constructor(private appConfigService: AppConfigService, private logService: LogService) {} constructor(private appConfigService: AppConfigService, private logService: LogService) {}
public get(presetName: string = 'default'): ContentMetadataConfig { public get(presetName: string = 'default'): ContentMetadataConfig {
let presetConfig; let presetConfig: PresetConfig;
try { try {
presetConfig = this.appConfigService.config['content-metadata'].presets[presetName]; presetConfig = this.appConfigService.config['content-metadata'].presets[presetName];
} catch { } catch {
@ -74,7 +74,7 @@ export class ContentMetadataConfigFactory {
return Array.isArray(presetConfig); return Array.isArray(presetConfig);
} }
private isObject(x) { private isObject(x: any): boolean {
return x != null && typeof x === 'object'; return x != null && typeof x === 'object';
} }
} }

View File

@ -608,11 +608,8 @@ describe('ContentNodeSelectorComponent', () => {
}); });
it('should pass through the rowFilter to the documentList', () => { it('should pass through the rowFilter to the documentList', () => {
const filter = (shareDataRow: ShareDataRow) => { const filter = (shareDataRow: ShareDataRow) =>
if (shareDataRow.node.entry.name === 'impossible-name') { shareDataRow.node.entry.name === 'impossible-name';
return true;
}
};
component.rowFilter = filter; component.rowFilter = filter;

View File

@ -37,11 +37,7 @@ describe('ContentNodeSelectorDialogComponent', () => {
title: 'Move along citizen...', title: 'Move along citizen...',
actionName: 'move', actionName: 'move',
select: new EventEmitter<Node>(), select: new EventEmitter<Node>(),
rowFilter: (shareDataRow: ShareDataRow) => { rowFilter: (shareDataRow: ShareDataRow) => shareDataRow.node.entry.name === 'impossible-name',
if (shareDataRow.node.entry.name === 'impossible-name') {
return true;
}
},
imageResolver: () => 'piccolo', imageResolver: () => 'piccolo',
currentFolderId: 'cat-girl-nuku-nuku' currentFolderId: 'cat-girl-nuku-nuku'
}; };

View File

@ -37,12 +37,13 @@ describe('NameLocationCellComponent', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
rowData = <DataRow> { rowData = <DataRow> {
getValue(key) { getValue(key): any {
if (key === 'name') { if (key === 'name') {
return 'file-name'; return 'file-name';
} else if (key === 'path') { } else if (key === 'path') {
return { name: '/path/to/location' }; return { name: '/path/to/location' };
} }
return undefined;
} }
}; };
component.row = rowData; component.row = rowData;

View File

@ -19,6 +19,15 @@ import { Component, Inject, ViewEncapsulation, SecurityContext } from '@angular/
import { MAT_DIALOG_DATA } from '@angular/material'; import { MAT_DIALOG_DATA } from '@angular/material';
import { DomSanitizer } from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser';
export interface ConfirmDialogComponentProps {
title?: string;
message?: string;
yesLabel?: string;
thirdOptionLabel?: string;
noLabel?: string;
htmlContent?: string;
}
@Component({ @Component({
selector: 'adf-confirm-dialog', selector: 'adf-confirm-dialog',
templateUrl: './confirm.dialog.html', templateUrl: './confirm.dialog.html',
@ -35,7 +44,7 @@ export class ConfirmDialogComponent {
thirdOptionLabel: string; thirdOptionLabel: string;
htmlContent: string; htmlContent: string;
constructor(@Inject(MAT_DIALOG_DATA) data, private sanitizer: DomSanitizer) { constructor(@Inject(MAT_DIALOG_DATA) data: ConfirmDialogComponentProps, private sanitizer: DomSanitizer) {
data = data || {}; data = data || {};
this.title = data.title || 'ADF_CONFIRM_DIALOG.CONFIRM'; this.title = data.title || 'ADF_CONFIRM_DIALOG.CONFIRM';
this.message = data.message || 'ADF_CONFIRM_DIALOG.MESSAGE'; this.message = data.message || 'ADF_CONFIRM_DIALOG.MESSAGE';
@ -45,7 +54,7 @@ export class ConfirmDialogComponent {
this.htmlContent = data.htmlContent; this.htmlContent = data.htmlContent;
} }
public sanitizedHtmlContent() { sanitizedHtmlContent(): string {
return this.sanitizer.sanitize(SecurityContext.HTML, this.htmlContent); return this.sanitizer.sanitize(SecurityContext.HTML, this.htmlContent);
} }

View File

@ -18,7 +18,7 @@
import { ContentService, TranslationService } from '@alfresco/adf-core'; import { ContentService, TranslationService } from '@alfresco/adf-core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { NodeEntry } from '@alfresco/js-api'; 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 { ContentActionHandler } from '../models/content-action.model';
import { PermissionModel } from '../models/permissions.model'; import { PermissionModel } from '../models/permissions.model';
import { DocumentListService } from './document-list.service'; import { DocumentListService } from './document-list.service';
@ -119,11 +119,9 @@ export class DocumentActionsService {
} }
private deleteNode(node: NodeEntry, _target?: any, permission?: string): Observable<any> { private deleteNode(node: NodeEntry, _target?: any, permission?: string): Observable<any> {
let handlerObservable;
if (this.canExecuteAction(node)) { if (this.canExecuteAction(node)) {
if (this.contentService.hasAllowableOperations(node.entry, permission)) { if (this.contentService.hasAllowableOperations(node.entry, permission)) {
handlerObservable = this.documentListService.deleteNode(node.entry.id); const handlerObservable = this.documentListService.deleteNode(node.entry.id);
handlerObservable.subscribe(() => { handlerObservable.subscribe(() => {
const message = this.translation.instant('CORE.DELETE_NODE.SINGULAR', { name: node.entry.name }); const message = this.translation.instant('CORE.DELETE_NODE.SINGULAR', { name: node.entry.name });
this.success.next(message); this.success.next(message);
@ -141,5 +139,7 @@ export class DocumentActionsService {
return throwError(new Error('No permission to delete')); return throwError(new Error('No permission to delete'));
} }
} }
return of();
} }
} }

View File

@ -18,7 +18,7 @@
import { ContentService, TranslationService } from '@alfresco/adf-core'; import { ContentService, TranslationService } from '@alfresco/adf-core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { NodeEntry } from '@alfresco/js-api'; 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 { ContentActionHandler } from '../models/content-action.model';
import { PermissionModel } from '../models/permissions.model'; import { PermissionModel } from '../models/permissions.model';
import { DocumentListService } from './document-list.service'; import { DocumentListService } from './document-list.service';
@ -102,7 +102,7 @@ export class FolderActionsService {
return actionObservable; return actionObservable;
} }
private prepareHandlers(actionObservable, target?: any): void { private prepareHandlers(actionObservable: Observable<any>, target?: any): void {
actionObservable.subscribe( actionObservable.subscribe(
(fileOperationMessage) => { (fileOperationMessage) => {
if (target && typeof target.reload === 'function') { if (target && typeof target.reload === 'function') {
@ -115,11 +115,9 @@ export class FolderActionsService {
} }
private deleteNode(node: NodeEntry, target?: any, permission?: string): Observable<any> { private deleteNode(node: NodeEntry, target?: any, permission?: string): Observable<any> {
let handlerObservable: Observable<any>;
if (this.canExecuteAction(node)) { if (this.canExecuteAction(node)) {
if (this.contentService.hasAllowableOperations(node.entry, permission)) { if (this.contentService.hasAllowableOperations(node.entry, permission)) {
handlerObservable = this.documentListService.deleteNode(node.entry.id); const handlerObservable = this.documentListService.deleteNode(node.entry.id);
handlerObservable.subscribe(() => { handlerObservable.subscribe(() => {
if (target && typeof target.reload === 'function') { if (target && typeof target.reload === 'function') {
target.reload(); target.reload();
@ -138,5 +136,7 @@ export class FolderActionsService {
return throwError(new Error('No permission to delete')); return throwError(new Error('No permission to delete'));
} }
} }
return of();
} }
} }

View File

@ -148,10 +148,13 @@ export class NodePermissionService {
removePermission(node: Node, permissionToRemove: PermissionElement): Observable<Node> { removePermission(node: Node, permissionToRemove: PermissionElement): Observable<Node> {
const permissionBody = { permissions: { locallySet: [] } }; const permissionBody = { permissions: { locallySet: [] } };
const index = node.permissions.locallySet.map((permission) => permission.authorityId).indexOf(permissionToRemove.authorityId); const index = node.permissions.locallySet.map((permission) => permission.authorityId).indexOf(permissionToRemove.authorityId);
if (index !== -1) { if (index !== -1) {
node.permissions.locallySet.splice(index, 1); node.permissions.locallySet.splice(index, 1);
permissionBody.permissions.locallySet = node.permissions.locallySet; permissionBody.permissions.locallySet = node.permissions.locallySet;
return this.nodeService.updateNode(node.id, permissionBody); return this.nodeService.updateNode(node.id, permissionBody);
} else {
return of(node);
} }
} }

View File

@ -49,7 +49,7 @@ export class FileUploadingListComponent {
/** Emitted when a file in the list has an error. */ /** Emitted when a file in the list has an error. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter(); error = new EventEmitter<any>();
constructor( constructor(
private uploadService: UploadService, private uploadService: UploadService,
@ -161,7 +161,7 @@ export class FileUploadingListComponent {
); );
} }
private cancelNodeVersionInstances(file) { private cancelNodeVersionInstances(file: FileModel) {
this.files this.files
.filter( .filter(
(item) => (item) =>
@ -192,15 +192,12 @@ export class FileUploadingListComponent {
this.error.emit(messageError); this.error.emit(messageError);
} }
private getUploadingFiles() { private getUploadingFiles(): FileModel[] {
return this.files.filter((item) => { return this.files.filter(
if ( item =>
item.status === FileUploadStatus.Pending || item.status === FileUploadStatus.Pending ||
item.status === FileUploadStatus.Progress || item.status === FileUploadStatus.Progress ||
item.status === FileUploadStatus.Starting item.status === FileUploadStatus.Starting
) { );
return item;
}
});
} }
} }

View File

@ -260,10 +260,11 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
return rows.map((row) => new ObjectDataRow(row, row.isSelected)); return rows.map((row) => new ObjectDataRow(row, row.isSelected));
} }
convertToDataSorting(sorting: any[]): DataSorting { convertToDataSorting(sorting: any[]): DataSorting | null {
if (sorting && sorting.length > 0) { if (sorting && sorting.length > 0) {
return new DataSorting(sorting[0], sorting[1]); return new DataSorting(sorting[0], sorting[1]);
} }
return null;
} }
private initAndSubscribeClickStream() { private initAndSubscribeClickStream() {
@ -362,7 +363,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
} }
} }
private setTableSorting(sorting) { private setTableSorting(sorting: any[]) {
if (this.data) { if (this.data) {
this.data.setSorting(this.convertToDataSorting(sorting)); this.data.setSorting(this.convertToDataSorting(sorting));
} }
@ -610,10 +611,12 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
return `${row.cssClass} ${this.rowStyleClass}`; return `${row.cssClass} ${this.rowStyleClass}`;
} }
getSortingKey(): string { getSortingKey(): string | null {
if (this.data.getSorting()) { if (this.data.getSorting()) {
return this.data.getSorting().key; return this.data.getSorting().key;
} }
return null;
} }
selectRow(row: DataRow, value: boolean) { selectRow(row: DataRow, value: boolean) {

View File

@ -258,13 +258,7 @@ describe('NodeDeleteDirective', () => {
return Promise.reject(null); return Promise.reject(null);
} }
if (id === '2') { return Promise.resolve();
return Promise.resolve();
}
if (id === '3') {
return Promise.resolve();
}
}); });
component.selection = [ component.selection = [

View File

@ -96,7 +96,9 @@ export class NodeDeleteDirective implements OnChanges {
const processedItems: ProcessStatus = this.processStatus(data); const processedItems: ProcessStatus = this.processStatus(data);
const message = this.getMessage(processedItems); 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<ProcessedNodeData> { private deleteNode(node: NodeEntry | DeletedNodeEntity): Observable<ProcessedNodeData> {
const id = (<any> node.entry).nodeId || node.entry.id; const id = (<any> node.entry).nodeId || node.entry.id;
let promise; let promise: Promise<any>;
if (node.entry.hasOwnProperty('archivedAt') && node.entry['archivedAt']) { if (node.entry.hasOwnProperty('archivedAt') && node.entry['archivedAt']) {
promise = this.alfrescoApiService.nodesApi.purgeDeletedNode(id); 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) { if (status.allFailed && !status.oneFailed) {
return this.translation.instant( return this.translation.instant(
'CORE.DELETE_NODE.ERROR_PLURAL', 'CORE.DELETE_NODE.ERROR_PLURAL',
@ -214,5 +216,7 @@ export class NodeDeleteDirective implements OnChanges {
{ name: status.success[0].entry.name } { name: status.success[0].entry.name }
); );
} }
return null;
} }
} }

View File

@ -160,23 +160,17 @@ describe('NodeRestoreDirective', () => {
it('should notify on multiple fails', (done) => { it('should notify on multiple fails', (done) => {
const error = { message: '{ "error": {} }' }; const error = { message: '{ "error": {} }' };
directiveInstance.restore.subscribe((event) => { directiveInstance.restore.subscribe((event: any) => {
expect(event.message).toEqual('CORE.RESTORE_NODE.PARTIAL_PLURAL'); expect(event.message).toEqual('CORE.RESTORE_NODE.PARTIAL_PLURAL');
done(); done();
}); });
restoreNodeSpy.and.callFake((id) => { restoreNodeSpy.and.callFake((id: string) => {
if (id === '1') { if (id === '1') {
return Promise.resolve(); return Promise.resolve();
} }
if (id === '2') { return Promise.reject(error);
return Promise.reject(error);
}
if (id === '3') {
return Promise.reject(error);
}
}); });
component.selection = [ component.selection = [
@ -232,7 +226,7 @@ describe('NodeRestoreDirective', () => {
restoreNodeSpy.and.returnValue(Promise.reject(error)); restoreNodeSpy.and.returnValue(Promise.reject(error));
directiveInstance.restore.subscribe((event) => { directiveInstance.restore.subscribe((event: any) => {
expect(event.message).toEqual('CORE.RESTORE_NODE.LOCATION_MISSING'); expect(event.message).toEqual('CORE.RESTORE_NODE.LOCATION_MISSING');
done(); done();
}); });
@ -247,20 +241,14 @@ describe('NodeRestoreDirective', () => {
it('should notify success when restore multiple nodes', (done) => { 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'); expect(event.message).toEqual('CORE.RESTORE_NODE.PLURAL');
done(); done();
}); });
restoreNodeSpy.and.callFake((id) => { restoreNodeSpy.and.callFake(() => {
if (id === '1') { return Promise.resolve();
return Promise.resolve();
}
if (id === '2') {
return Promise.resolve();
}
}); });
component.selection = [ component.selection = [

View File

@ -182,7 +182,7 @@ export class NodeRestoreDirective {
); );
} }
private getRestoreMessage(): string { private getRestoreMessage(): string | null {
const { restoreProcessStatus: status } = this; const { restoreProcessStatus: status } = this;
if (status.someFailed && !status.oneFailed) { if (status.someFailed && !status.oneFailed) {
@ -233,6 +233,8 @@ export class NodeRestoreDirective {
} }
); );
} }
return null;
} }
private notification(): void { private notification(): void {

View File

@ -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); const isValidUser = this.isValidUser(list, value);
if (isValidUser || value === '') { if (isValidUser || value === '') {
this.field.validationSummary.message = ''; 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) { if (users) {
return users.find((user) => { return users.find((user) => {
const selectedUser = this.getDisplayName(user).toLocaleLowerCase() === name.toLocaleLowerCase(); 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); this.peopleSelected.emit(user && user.id || undefined);
} }
return selectedUser; return selectedUser;
}); }) ? true : false;
} }
return false;
} }
getDisplayName(model: UserProcessModel) { getDisplayName(model: UserProcessModel) {

View File

@ -202,7 +202,7 @@ describe('UploadWidgetComponent', () => {
})); }));
it('should update the form after deleted a file', async(() => { 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') { if (file.name === 'file-fake.png') {
return of(fakePngAnswer); return of(fakePngAnswer);
} }
@ -210,6 +210,8 @@ describe('UploadWidgetComponent', () => {
if (file.name === 'file-fake.jpg') { if (file.name === 'file-fake.jpg') {
return of(fakeJpgAnswer); return of(fakeJpgAnswer);
} }
return of();
}); });
uploadWidgetComponent.field.params.multiple = true; uploadWidgetComponent.field.params.multiple = true;
@ -230,7 +232,7 @@ describe('UploadWidgetComponent', () => {
})); }));
it('should set has field value all the files uploaded', async(() => { 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') { if (file.name === 'file-fake.png') {
return of(fakePngAnswer); return of(fakePngAnswer);
} }
@ -238,6 +240,8 @@ describe('UploadWidgetComponent', () => {
if (file.name === 'file-fake.jpg') { if (file.name === 'file-fake.jpg') {
return of(fakeJpgAnswer); return of(fakeJpgAnswer);
} }
return of();
}); });
uploadWidgetComponent.field.params.multiple = true; uploadWidgetComponent.field.params.multiple = true;

View File

@ -16,90 +16,92 @@
*/ */
export class WidgetVisibilityModel { export class WidgetVisibilityModel {
rightRestResponseId?: string; rightRestResponseId?: string;
rightFormFieldId?: string; rightFormFieldId?: string;
leftRestResponseId?: string; leftRestResponseId?: string;
leftFormFieldId?: string; leftFormFieldId?: string;
operator: string; operator: string;
nextCondition: WidgetVisibilityModel; nextCondition: WidgetVisibilityModel;
nextConditionOperator: string; nextConditionOperator: string;
constructor(private json?: any) { constructor(private json?: any) {
if (json) { if (json) {
this.operator = json.operator; this.operator = json.operator;
this.nextCondition = new WidgetVisibilityModel(json.nextCondition); this.nextCondition = new WidgetVisibilityModel(json.nextCondition);
this.nextConditionOperator = json.nextConditionOperator; this.nextConditionOperator = json.nextConditionOperator;
this.rightRestResponseId = json.rightRestResponseId; this.rightRestResponseId = json.rightRestResponseId;
this.rightFormFieldId = json.rightFormFieldId; this.rightFormFieldId = json.rightFormFieldId;
this.leftFormFieldId = json.leftFormFieldId; this.leftFormFieldId = json.leftFormFieldId;
this.leftRestResponseId = json.leftRestResponseId; this.leftRestResponseId = json.leftRestResponseId;
} else { } else {
this.json = {}; 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) { return null;
this.json.leftType = leftType; }
}
set rightType(rightType: string) { set rightType(rightType: string) {
this.json.rightType = rightType; this.json.rightType = rightType;
} }
set leftValue(leftValue: string) { get rightValue(): any {
this.json.leftValue = leftValue; if (this.json.rightValue) {
} return this.json.rightValue;
} else if (this.rightFormFieldId) {
set rightValue(rightValue: string) { return this.rightFormFieldId;
this.json.rightValue = rightValue; } else {
} return this.rightRestResponseId;
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;
}
} }
}
set rightValue(rightValue: any) {
this.json.rightValue = rightValue;
}
} }
export enum WidgetTypeEnum { export enum WidgetTypeEnum {
field = 'field', field = 'field',
variable = 'variable', variable = 'variable',
value = 'value' value = 'value'
} }

View File

@ -249,7 +249,7 @@ export class WidgetVisibilityService {
return undefined; return undefined;
} }
evaluateLogicalOperation(logicOp, previousValue, newValue): boolean { evaluateLogicalOperation(logicOp: string, previousValue: any, newValue: any): boolean | undefined {
switch (logicOp) { switch (logicOp) {
case 'and': case 'and':
return previousValue && newValue; return previousValue && newValue;
@ -260,12 +260,12 @@ export class WidgetVisibilityService {
case 'or-not': case 'or-not':
return previousValue || !newValue; return previousValue || !newValue;
default: default:
this.logService.error('NO valid operation! wrong op request : ' + logicOp); this.logService.error(`Invalid operator: ${logicOp}`);
break; return undefined;
} }
} }
evaluateCondition(leftValue, rightValue, operator): boolean { evaluateCondition(leftValue: any, rightValue: any, operator: string): boolean | undefined {
switch (operator) { switch (operator) {
case '==': case '==':
return leftValue + '' === rightValue + ''; return leftValue + '' === rightValue + '';
@ -284,10 +284,9 @@ export class WidgetVisibilityService {
case '!empty': case '!empty':
return leftValue ? leftValue !== '' : false; return leftValue ? leftValue !== '' : false;
default: default:
this.logService.error('NO valid operation!'); this.logService.error(`Invalid operator: ${operator}`);
break; return undefined;
} }
return;
} }
cleanProcessVariable() { cleanProcessVariable() {

View File

@ -15,7 +15,7 @@
* limitations under the License. * 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 { MatSidenav } from '@angular/material';
import { sidenavAnimation, contentAnimation } from '../../helpers/animations'; import { sidenavAnimation, contentAnimation } from '../../helpers/animations';
import { Direction } from '@angular/cdk/bidi'; import { Direction } from '@angular/cdk/bidi';
@ -80,7 +80,7 @@ export class LayoutContainerComponent implements OnInit, OnDestroy, OnChanges {
this.mediaQueryList.removeListener(this.onMediaQueryChange); this.mediaQueryList.removeListener(this.onMediaQueryChange);
} }
ngOnChanges(changes) { ngOnChanges(changes: SimpleChanges) {
if (changes && changes.direction) { if (changes && changes.direction) {
this.contentAnimationState = this.toggledContentAnimation; this.contentAnimationState = this.toggledContentAnimation;
} }
@ -99,17 +99,17 @@ export class LayoutContainerComponent implements OnInit, OnDestroy, OnChanges {
return this.mediaQueryList.matches; return this.mediaQueryList.matches;
} }
getContentAnimationState() { getContentAnimationState(): any {
return this.contentAnimationState; return this.contentAnimationState;
} }
private get toggledSidenavAnimation() { private get toggledSidenavAnimation(): any {
return this.sidenavAnimationState === this.SIDENAV_STATES.EXPANDED return this.sidenavAnimationState === this.SIDENAV_STATES.EXPANDED
? this.SIDENAV_STATES.COMPACT ? this.SIDENAV_STATES.COMPACT
: this.SIDENAV_STATES.EXPANDED; : this.SIDENAV_STATES.EXPANDED;
} }
private get toggledContentAnimation() { private get toggledContentAnimation(): any {
if (this.isMobileScreenSize) { if (this.isMobileScreenSize) {
return this.CONTENT_STATES.MOBILE; 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.sidenavAnimationState = this.SIDENAV_STATES.EXPANDED;
this.contentAnimationState = this.toggledContentAnimation; this.contentAnimationState = this.toggledContentAnimation;
} }

View File

@ -197,7 +197,7 @@ export class LoginComponent implements OnInit, OnDestroy {
* @param values * @param values
* @param event * @param event
*/ */
onSubmit(values: any) { onSubmit(values: any): void {
this.disableError(); this.disableError();
if (this.authService.isOauth() && !this.authService.isSSODiscoveryConfigured()) { if (this.authService.isOauth() && !this.authService.isSSODiscoveryConfigured()) {
@ -209,9 +209,7 @@ export class LoginComponent implements OnInit, OnDestroy {
}); });
this.executeSubmit.emit(args); this.executeSubmit.emit(args);
if (args.defaultPrevented) { if (!args.defaultPrevented) {
return false;
} else {
this.performLogin(values); this.performLogin(values);
} }
} }

View File

@ -17,7 +17,7 @@
export class DemoForm { export class DemoForm {
easyForm = { easyForm: any = {
'id': 1001, 'id': 1001,
'name': 'ISSUE_FORM', 'name': 'ISSUE_FORM',
'tabs': [], 'tabs': [],
@ -365,7 +365,7 @@ export class DemoForm {
'globalDateFormat': 'D-M-YYYY' 'globalDateFormat': 'D-M-YYYY'
}; };
formDefinition = { formDefinition: any = {
'id': 3003, 'id': 3003,
'name': 'demo-01', 'name': 'demo-01',
'taskId': '7501', 'taskId': '7501',
@ -1482,7 +1482,7 @@ export class DemoForm {
'globalDateFormat': 'D-M-YYYY' 'globalDateFormat': 'D-M-YYYY'
}; };
simpleFormDefinition = { simpleFormDefinition: any = {
'id': 1001, 'id': 1001,
'name': 'SIMPLE_FORM_EXAMPLE', 'name': 'SIMPLE_FORM_EXAMPLE',
'description': '', 'description': '',
@ -1765,7 +1765,7 @@ export class DemoForm {
} }
}; };
cloudFormDefinition = { cloudFormDefinition: any = {
'formRepresentation': { 'formRepresentation': {
'id': 'text-form', 'id': 'text-form',
'name': 'test-start-form', 'name': 'test-start-form',

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
export let fakeForm = { export const fakeForm: any = {
id: 1001, id: 1001,
name: 'ISSUE_FORM', name: 'ISSUE_FORM',
processDefinitionId: 'ISSUE_APP:1:2504', processDefinitionId: 'ISSUE_APP:1:2504',

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
export let formModelTabs = { export const formModelTabs: any = {
id: 16, id: 16,
name: 'start event', name: 'start event',
description: '', description: '',

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
export let formDefinitionTwoTextFields = { export const formDefinitionTwoTextFields: any = {
id: 20, id: 20,
name: 'formTextDefinition', name: 'formTextDefinition',
processDefinitionId: 'textDefinition:1:153', processDefinitionId: 'textDefinition:1:153',
@ -160,7 +160,7 @@ export let formDefinitionTwoTextFields = {
globalDateFormat: 'D-M-YYYY' globalDateFormat: 'D-M-YYYY'
}; };
export let formDefinitionDropdownField = { export const formDefinitionDropdownField: any = {
id: 21, id: 21,
name: 'dropdownDefinition', name: 'dropdownDefinition',
processDefinitionId: 'textDefinition:2:163', processDefinitionId: 'textDefinition:2:163',
@ -282,7 +282,7 @@ export let formDefinitionDropdownField = {
globalDateFormat: 'D-M-YYYY' globalDateFormat: 'D-M-YYYY'
}; };
export let formDefinitionRequiredField = { export const formDefinitionRequiredField: any = {
id: 21, id: 21,
name: 'dropdownDefinition', name: 'dropdownDefinition',
processDefinitionId: 'textDefinition:2:163', processDefinitionId: 'textDefinition:2:163',

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
export let formReadonlyTwoTextFields = { export const formReadonlyTwoTextFields: any = {
id: 22, id: 22,
name: 'formTextDefinition', name: 'formTextDefinition',
processDefinitionId: 'textDefinition:3:182', processDefinitionId: 'textDefinition:3:182',

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
export let formDefVisibilitiFieldDependsOnNextOne = { export const formDefVisibilitiFieldDependsOnNextOne: any = {
id: 19, id: 19,
processDefinitionId: 'visibility:1:148', processDefinitionId: 'visibility:1:148',
processDefinitionName: 'visibility', processDefinitionName: 'visibility',
@ -181,7 +181,7 @@ export let formDefVisibilitiFieldDependsOnNextOne = {
globalDateFormat: 'D-M-YYYY' globalDateFormat: 'D-M-YYYY'
}; };
export let formDefVisibilitiFieldDependsOnPreviousOne = { export const formDefVisibilitiFieldDependsOnPreviousOne: any = {
id: 19, id: 19,
processDefinitionId: 'visibility:1:148', processDefinitionId: 'visibility:1:148',
processDefinitionName: 'visibility', processDefinitionName: 'visibility',

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
export let startFormDateWidgetMock = { export const startFormDateWidgetMock: any = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@ -38,7 +38,7 @@ export let startFormDateWidgetMock = {
}] }]
}; };
export let startFormNumberWidgetMock = { export const startFormNumberWidgetMock: any = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@ -61,7 +61,7 @@ export let startFormNumberWidgetMock = {
}] }]
}; };
export let startFormAmountWidgetMock = { export const startFormAmountWidgetMock: any = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@ -84,7 +84,7 @@ export let startFormAmountWidgetMock = {
}] }]
}; };
export let startFormRadioButtonWidgetMock = { export const startFormRadioButtonWidgetMock: any = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@ -107,7 +107,7 @@ export let startFormRadioButtonWidgetMock = {
}] }]
}; };
export let startFormTextDefinitionMock = { export const startFormTextDefinitionMock: any = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@ -130,7 +130,7 @@ export let startFormTextDefinitionMock = {
}] }]
}; };
export let startFormDropdownDefinitionMock = { export const startFormDropdownDefinitionMock: any = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@ -179,7 +179,7 @@ export let startFormDropdownDefinitionMock = {
}] }]
}; };
export let startMockForm = { export const startMockForm: any = {
id: 4, id: 4,
name: 'Claim Review Process', name: 'Claim Review Process',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',
@ -593,7 +593,7 @@ export let startMockForm = {
globalDateFormat: 'D - M - YYYY' globalDateFormat: 'D - M - YYYY'
}; };
export let startMockFormWithTab = { export const startMockFormWithTab: any = {
id: 4, id: 4,
taskName: 'Mock Title', taskName: 'Mock Title',
processDefinitionId: 'ClaimReviewProcess:2: 93', processDefinitionId: 'ClaimReviewProcess:2: 93',

View File

@ -19,13 +19,13 @@ import { FormModel, FormValues } from '../../form/components/widgets/core/index'
export let formTest = new FormModel({}); export let formTest = new FormModel({});
export let fakeTaskProcessVariableModels = [ export const fakeTaskProcessVariableModels = [
{ id: 'TEST_VAR_1', type: 'string', value: 'test_value_1' }, { id: 'TEST_VAR_1', type: 'string', value: 'test_value_1' },
{ id: 'TEST_VAR_2', type: 'string', value: 'test_value_2' }, { id: 'TEST_VAR_2', type: 'string', value: 'test_value_2' },
{ id: 'TEST_VAR_3', type: 'string', value: 'test_value_3' } { id: 'TEST_VAR_3', type: 'string', value: 'test_value_3' }
]; ];
export let formValues: FormValues = { export const formValues: FormValues = {
'test_1': 'value_1', 'test_1': 'value_1',
'test_2': 'value_2', 'test_2': 'value_2',
'test_3': 'value_1', 'test_3': 'value_1',
@ -34,7 +34,7 @@ export let formValues: FormValues = {
'dropdown': { 'id': 'dropdown_id', 'name': 'dropdown_label' } 'dropdown': { 'id': 'dropdown_id', 'name': 'dropdown_label' }
}; };
export let fakeFormJson = { export const fakeFormJson: any = {
id: '9999', id: '9999',
name: 'FORM_VISIBILITY', name: 'FORM_VISIBILITY',
processDefinitionId: 'PROCESS_TEST:9:9999', processDefinitionId: 'PROCESS_TEST:9:9999',
@ -116,7 +116,7 @@ export let fakeFormJson = {
] ]
}; };
export let complexVisibilityJsonVisible = { export const complexVisibilityJsonVisible: any = {
'id': 47591, 'id': 47591,
'name': 'Test-visibility', 'name': 'Test-visibility',
'description': '', 'description': '',
@ -481,7 +481,7 @@ export let complexVisibilityJsonVisible = {
'gridsterForm': false 'gridsterForm': false
} }
}; };
export let complexVisibilityJsonNotVisible = { export const complexVisibilityJsonNotVisible: any = {
'id': 47591, 'id': 47591,
'name': 'Test-visibility', 'name': 'Test-visibility',
'description': '', 'description': '',
@ -847,7 +847,7 @@ export let complexVisibilityJsonNotVisible = {
} }
}; };
export let nextConditionForm = { export const nextConditionForm: any = {
id: '9999', id: '9999',
name: 'FORM_PROCESS_VARIABLE_VISIBILITY', name: 'FORM_PROCESS_VARIABLE_VISIBILITY',
processDefinitionId: 'PROCESS_TEST:9:9999', 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', 'id': 'form-f0823c05-51eb-4703-8634-75a6d5e15df5',
'name': 'text_form', 'name': 'text_form',
'description': '', 'description': '',

View File

@ -19,13 +19,13 @@ import { FormModel, FormValues } from '../../form/components/widgets/core/index'
export let formTest = new FormModel({}); export let formTest = new FormModel({});
export let fakeTaskProcessVariableModels = [ export const fakeTaskProcessVariableModels = [
{ id: 'TEST_VAR_1', type: 'string', value: 'test_value_1' }, { id: 'TEST_VAR_1', type: 'string', value: 'test_value_1' },
{ id: 'TEST_VAR_2', type: 'string', value: 'test_value_2' }, { id: 'TEST_VAR_2', type: 'string', value: 'test_value_2' },
{ id: 'TEST_VAR_3', type: 'string', value: 'test_value_3' } { id: 'TEST_VAR_3', type: 'string', value: 'test_value_3' }
]; ];
export let formValues: FormValues = { export const formValues: FormValues = {
'test_1': 'value_1', 'test_1': 'value_1',
'test_2': 'value_2', 'test_2': 'value_2',
'test_3': 'value_1', 'test_3': 'value_1',
@ -34,7 +34,7 @@ export let formValues: FormValues = {
'dropdown': { 'id': 'dropdown_id', 'name': 'dropdown_label' } 'dropdown': { 'id': 'dropdown_id', 'name': 'dropdown_label' }
}; };
export let fakeFormJson = { export const fakeFormJson: any = {
id: '9999', id: '9999',
name: 'FORM_VISIBILITY', name: 'FORM_VISIBILITY',
processDefinitionId: 'PROCESS_TEST: 9: 9999', processDefinitionId: 'PROCESS_TEST: 9: 9999',
@ -116,7 +116,7 @@ export let fakeFormJson = {
] ]
}; };
export let complexVisibilityJsonVisible = { export const complexVisibilityJsonVisible: any = {
'id': 47591, 'id': 47591,
'name': 'Test-visibility', 'name': 'Test-visibility',
'description': '', 'description': '',
@ -489,7 +489,8 @@ export let complexVisibilityJsonVisible = {
'gridsterForm': false 'gridsterForm': false
} }
}; };
export let complexVisibilityJsonNotVisible = {
export const complexVisibilityJsonNotVisible: any = {
'id': 47591, 'id': 47591,
'name': 'Test-visibility', 'name': 'Test-visibility',
'description': '', 'description': '',
@ -859,7 +860,7 @@ export let complexVisibilityJsonNotVisible = {
} }
}; };
export let tabVisibilityJsonMock = { export const tabVisibilityJsonMock: any = {
'id': 45231, 'id': 45231,
'name': 'visibility-form', 'name': 'visibility-form',
'description': '', 'description': '',
@ -1000,7 +1001,7 @@ export let tabVisibilityJsonMock = {
} }
}; };
export const tabInvalidFormVisibility = { export const tabInvalidFormVisibility: any = {
'id': 'form-0668939d-34b2-440c-ab4d-01ab8b05a881', 'id': 'form-0668939d-34b2-440c-ab4d-01ab8b05a881',
'name': 'tab-visibility', 'name': 'tab-visibility',
'description': '', 'description': '',

View File

@ -163,6 +163,7 @@ export class AuthenticationService {
if (this.alfrescoApi.getInstance()) { if (this.alfrescoApi.getInstance()) {
return this.alfrescoApi.getInstance().logout(); return this.alfrescoApi.getInstance().logout();
} }
return Promise.resolve();
} }
/** /**

View File

@ -17,7 +17,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; 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 { catchError, map } from 'rxjs/operators';
import { Pagination } from '@alfresco/js-api'; import { Pagination } from '@alfresco/js-api';
import { IdentityRoleModel } from '../models/identity-role.model'; import { IdentityRoleModel } from '../models/identity-role.model';
@ -90,6 +90,7 @@ export class IdentityRoleService {
.post(`${this.identityHost}/roles`, request) .post(`${this.identityHost}/roles`, request)
.pipe(catchError(error => this.handleError(error))); .pipe(catchError(error => this.handleError(error)));
} }
return of();
} }
/** /**
@ -119,6 +120,7 @@ export class IdentityRoleService {
.put(`${this.identityHost}/roles-by-id/${roleId}`, request) .put(`${this.identityHost}/roles-by-id/${roleId}`, request)
.pipe(catchError(error => this.handleError(error))); .pipe(catchError(error => this.handleError(error)));
} }
return of();
} }
private handleError(error: any) { private handleError(error: any) {

View File

@ -59,14 +59,18 @@ export class LockService {
return node.properties['cm:lockType'] === 'WRITE_LOCK' && node.properties['cm:lockLifetime'] === 'PERSISTENT'; 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']) { if (node.properties['cm:expiryDate']) {
return moment(node.properties['cm:expiryDate'], 'yyyy-MM-ddThh:mm:ssZ'); return moment(node.properties['cm:expiryDate'], 'yyyy-MM-ddThh:mm:ssZ');
} }
return undefined;
} }
private isLockExpired(node: Node): boolean { private isLockExpired(node: Node): boolean {
const expiryLockTime = this.getLockExpiryTime(node); const expiryLockTime = this.getLockExpiryTime(node);
return moment().isAfter(expiryLockTime); if (expiryLockTime) {
return moment().isAfter(expiryLockTime);
}
return false;
} }
} }

View File

@ -139,9 +139,9 @@ export class UserPreferencesService {
* @param property Name of the property * @param property Name of the property
* @returns True if the item is present, false otherwise * @returns True if the item is present, false otherwise
*/ */
hasItem(property: string) { hasItem(property: string): boolean {
if (!property) { if (!property) {
return; return false;
} }
return this.storage.hasItem( return this.storage.hasItem(
this.getPropertyKey(property) this.getPropertyKey(property)

View File

@ -50,7 +50,7 @@ export class MomentDateAdapter extends DateAdapter<Moment> {
case 'narrow': case 'narrow':
return this.localeData.monthsShort().map((month) => month[0]); return this.localeData.monthsShort().map((month) => month[0]);
default : default :
return; return [];
} }
} }
@ -72,7 +72,7 @@ export class MomentDateAdapter extends DateAdapter<Moment> {
case 'narrow': case 'narrow':
return this.localeData.weekdaysShort(); return this.localeData.weekdaysShort();
default : default :
return; return [];
} }
} }

View File

@ -336,7 +336,7 @@ describe('Test PdfViewer component', () => {
fixtureUrlTestPasswordComponent = TestBed.createComponent(UrlTestPasswordComponent); fixtureUrlTestPasswordComponent = TestBed.createComponent(UrlTestPasswordComponent);
componentUrlTestPasswordComponent = fixtureUrlTestPasswordComponent.componentInstance; 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) { if (context.data.reason === pdfjsLib.PasswordResponses.NEED_PASSWORD) {
return { return {
afterClosed: () => of('wrong_password') afterClosed: () => of('wrong_password')
@ -348,6 +348,8 @@ describe('Test PdfViewer component', () => {
afterClosed: () => of('password') afterClosed: () => of('password')
}; };
} }
return undefined;
}); });
fixtureUrlTestPasswordComponent.detectChanges(); fixtureUrlTestPasswordComponent.detectChanges();

View File

@ -55,6 +55,8 @@ export class TxtViewerComponent implements OnChanges {
if (!this.urlFile && !this.blobFile) { if (!this.urlFile && !this.blobFile) {
throw new Error('Attribute urlFile or blobFile is required'); throw new Error('Attribute urlFile or blobFile is required');
} }
return Promise.resolve();
} }
private getUrlContent(url: string): Promise<any> { private getUrlContent(url: string): Promise<any> {

View File

@ -126,6 +126,8 @@ export class ViewUtilService {
return await this.waitRendition(nodeId, renditionId, retries); return await this.waitRendition(nodeId, renditionId, retries);
} }
} }
return Promise.resolve(null);
} }
getViewerTypeByMimeType(mimeType: string): string { getViewerTypeByMimeType(mimeType: string): string {

View File

@ -102,7 +102,7 @@ export function reduceEmptyMenus(
return acc.concat(el); return acc.concat(el);
} }
export function mergeObjects(...objects): any { export function mergeObjects(...objects: object[]): any {
const result = {}; const result = {};
objects.forEach((source) => { objects.forEach((source) => {

View File

@ -62,8 +62,6 @@ export class ContentCloudNodeSelectorService {
} }
private isNodeFile(entry: Node): boolean { private isNodeFile(entry: Node): boolean {
if (entry) { return entry && entry.isFile;
return entry.isFile;
}
} }
} }

View File

@ -221,17 +221,16 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
return this.filterProperties.indexOf(EditProcessFilterCloudComponent.LAST_MODIFIED) >= 0; return this.filterProperties.indexOf(EditProcessFilterCloudComponent.LAST_MODIFIED) >= 0;
} }
removeOrderProperty(filteredProperties: ProcessFilterProperties[]) { removeOrderProperty(filteredProperties: ProcessFilterProperties[]): ProcessFilterProperties[] {
if (filteredProperties && filteredProperties.length > 0) { if (filteredProperties && filteredProperties.length > 0) {
const propertiesWithOutOrderProperty = filteredProperties.filter( return filteredProperties.filter(
(property: ProcessFilterProperties) => { property => property.key !== EditProcessFilterCloudComponent.ORDER
return property.key !== EditProcessFilterCloudComponent.ORDER; );
});
return propertiesWithOutOrderProperty;
} }
return [];
} }
get createSortProperties(): any { get createSortProperties(): ProcessFilterOptions[] {
this.checkMandatorySortProperties(); this.checkMandatorySortProperties();
const sortProperties = this.sortProperties.map((property: string) => { const sortProperties = this.sortProperties.map((property: string) => {
return <ProcessFilterOptions> { label: property.charAt(0).toUpperCase() + property.slice(1), value: property }; return <ProcessFilterOptions> { 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) { if (action.actionType === EditProcessFilterCloudComponent.ACTION_DELETE) {
return false; return false;
} }
return false;
} }
private setLastModifiedToFilter(formValues: ProcessFilterCloudModel) { private setLastModifiedToFilter(formValues: ProcessFilterCloudModel) {

View File

@ -152,11 +152,14 @@ export class ProcessFilterCloudService {
*/ */
deleteFilter(deletedFilter: ProcessFilterCloudModel): Observable<ProcessFilterCloudModel[]> { deleteFilter(deletedFilter: ProcessFilterCloudModel): Observable<ProcessFilterCloudModel[]> {
const key = this.prepareKey(deletedFilter.appName); const key = this.prepareKey(deletedFilter.appName);
return this.getProcessFiltersByKey(deletedFilter.appName, key).pipe( return this.getProcessFiltersByKey(deletedFilter.appName, key).pipe(
switchMap((filters: any) => { switchMap(filters => {
if (filters && filters.length > 0) { 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); return this.updateProcessFilters(deletedFilter.appName, key, filters);
} else {
return [];
} }
}), }),
map((filters: ProcessFilterCloudModel[]) => { map((filters: ProcessFilterCloudModel[]) => {

View File

@ -57,16 +57,17 @@ export class ProcessListCloudService extends BaseCloudService {
return throwError('Appname not configured'); return throwError('Appname not configured');
} }
} }
private buildQueryUrl(requestNode: ProcessQueryCloudRequestModel) {
private buildQueryUrl(requestNode: ProcessQueryCloudRequestModel): string {
this.contextRoot = this.appConfigService.get('bpmHost', ''); this.contextRoot = this.appConfigService.get('bpmHost', '');
return `${this.getBasePath(requestNode.appName)}/query/v1/process-instances`; 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; return requestNode[property] !== '' && requestNode[property] !== null && requestNode[property] !== undefined;
} }
private buildQueryParams(requestNode: ProcessQueryCloudRequestModel) { private buildQueryParams(requestNode: ProcessQueryCloudRequestModel): Object {
const queryParam = {}; const queryParam = {};
for (const property in requestNode) { for (const property in requestNode) {
if (requestNode.hasOwnProperty(property) && if (requestNode.hasOwnProperty(property) &&
@ -78,7 +79,7 @@ export class ProcessListCloudService extends BaseCloudService {
return queryParam; return queryParam;
} }
private isExcludedField(property) { private isExcludedField(property: string): boolean {
return property === 'appName' || property === 'sorting'; return property === 'appName' || property === 'sorting';
} }

View File

@ -34,6 +34,13 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf
if (key || key === '') { if (key || key === '') {
return of(this.prepareLocalPreferenceResponse(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<any> { updatePreference(_: string, key: string, updatedPreference: any): Observable<any> {
if (key) { if (key) {
this.storage.setItem(key, JSON.stringify(updatedPreference)); 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<any> { deletePreference(key: string, preferences: any): Observable<any> {
if (key) { if (key) {
this.storage.setItem(key, JSON.stringify(preferences)); this.storage.setItem(key, JSON.stringify(preferences));
return of(preferences);
} }
return of(preferences);
} }
prepareLocalPreferenceResponse(key: string): any { prepareLocalPreferenceResponse(key: string): any {

View File

@ -242,11 +242,11 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
return this.filterProperties.indexOf(EditTaskFilterCloudComponent.SORT) >= 0; return this.filterProperties.indexOf(EditTaskFilterCloudComponent.SORT) >= 0;
} }
removeOrderProperty(filteredProperties: TaskFilterProperties[]) { removeOrderProperty(filteredProperties: TaskFilterProperties[]): TaskFilterProperties[] {
if (filteredProperties && filteredProperties.length > 0) { if (filteredProperties && filteredProperties.length > 0) {
const propertiesWithOutOrderProperty = filteredProperties.filter((property: TaskFilterProperties) => { return property.key !== EditTaskFilterCloudComponent.ORDER; }); return filteredProperties.filter(property => property.key !== EditTaskFilterCloudComponent.ORDER);
return propertiesWithOutOrderProperty;
} }
return [];
} }
hasLastModifiedProperty(): boolean { hasLastModifiedProperty(): boolean {
@ -261,19 +261,19 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
return sortProperties; return sortProperties;
} }
checkMandatorySortProperties() { checkMandatorySortProperties(): void {
if (this.sortProperties === undefined || this.sortProperties.length === 0) { if (this.sortProperties === undefined || this.sortProperties.length === 0) {
this.sortProperties = EditTaskFilterCloudComponent.DEFAULT_SORT_PROPERTIES; this.sortProperties = EditTaskFilterCloudComponent.DEFAULT_SORT_PROPERTIES;
} }
} }
createAndFilterActions() { createAndFilterActions(): TaskFilterAction[] {
this.checkMandatoryActions(); this.checkMandatoryActions();
const allActions = this.createFilterActions(); return this.createFilterActions()
return allActions.filter((action: TaskFilterAction) => this.isValidAction(this.actions, action)); .filter(action => this.isValidAction(this.actions, action));
} }
checkMandatoryActions() { checkMandatoryActions(): void {
if (this.actions === undefined || this.actions.length === 0) { if (this.actions === undefined || this.actions.length === 0) {
this.actions = EditTaskFilterCloudComponent.DEFAULT_ACTIONS; 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(); return JSON.stringify(editedQuery).toLowerCase() === JSON.stringify(currentQuery).toLowerCase();
} }
getRunningApplications() { getRunningApplications(): void {
this.appsProcessCloudService.getDeployedApplicationsByStatus(EditTaskFilterCloudComponent.APP_RUNNING_STATUS) this.appsProcessCloudService
.pipe(takeUntil(this.onDestroy$)).subscribe((applications: ApplicationInstanceModel[]) => { .getDeployedApplicationsByStatus(EditTaskFilterCloudComponent.APP_RUNNING_STATUS)
.pipe(takeUntil(this.onDestroy$))
.subscribe((applications: ApplicationInstanceModel[]) => {
if (applications && applications.length > 0) { if (applications && applications.length > 0) {
applications.map((application) => { applications.map((application) => {
this.applicationNames.push({ label: application.name, value: application.name }); this.applicationNames.push({ label: application.name, value: application.name });
@ -337,24 +339,28 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
} }
} }
save(saveAction: TaskFilterAction) { save(saveAction: TaskFilterAction): void {
this.taskFilterCloudService.updateFilter(this.changedTaskFilter) this.taskFilterCloudService
.pipe(takeUntil(this.onDestroy$)).subscribe(() => { .updateFilter(this.changedTaskFilter)
saveAction.filter = this.changedTaskFilter; .pipe(takeUntil(this.onDestroy$))
this.action.emit(saveAction); .subscribe(() => {
this.formHasBeenChanged = this.compareFilters(this.changedTaskFilter, this.taskFilter); saveAction.filter = this.changedTaskFilter;
}); this.action.emit(saveAction);
this.formHasBeenChanged = this.compareFilters(this.changedTaskFilter, this.taskFilter);
});
} }
delete(deleteAction: TaskFilterAction) { delete(deleteAction: TaskFilterAction): void {
this.taskFilterCloudService.deleteFilter(this.taskFilter) this.taskFilterCloudService
.pipe(takeUntil(this.onDestroy$)).subscribe(() => { .deleteFilter(this.taskFilter)
deleteAction.filter = this.taskFilter; .pipe(takeUntil(this.onDestroy$))
this.action.emit(deleteAction); .subscribe(() => {
}); deleteAction.filter = this.taskFilter;
this.action.emit(deleteAction);
});
} }
saveAs(saveAsAction: TaskFilterAction) { saveAs(saveAsAction: TaskFilterAction): void {
const dialogRef = this.dialog.open(TaskFilterDialogCloudComponent, { const dialogRef = this.dialog.open(TaskFilterDialogCloudComponent, {
data: { data: {
name: this.translateService.instant(this.taskFilter.name) name: this.translateService.instant(this.taskFilter.name)
@ -404,11 +410,11 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
return this.showFilterActions; return this.showFilterActions;
} }
onExpand() { onExpand(): void {
this.toggleFilterActions = true; this.toggleFilterActions = true;
} }
onClose() { onClose(): void {
this.toggleFilterActions = false; this.toggleFilterActions = false;
} }
@ -438,6 +444,8 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
if (action.actionType === EditTaskFilterCloudComponent.ACTION_DELETE) { if (action.actionType === EditTaskFilterCloudComponent.ACTION_DELETE) {
return false; return false;
} }
return false;
} }
createFilterActions(): TaskFilterAction[] { createFilterActions(): TaskFilterAction[] {

View File

@ -201,13 +201,14 @@ export class TaskFilterCloudService {
deleteFilter(deletedFilter: TaskFilterCloudModel): Observable<TaskFilterCloudModel[]> { deleteFilter(deletedFilter: TaskFilterCloudModel): Observable<TaskFilterCloudModel[]> {
const key = this.prepareKey(deletedFilter.appName); const key = this.prepareKey(deletedFilter.appName);
return this.getTaskFiltersByKey(deletedFilter.appName, key).pipe( return this.getTaskFiltersByKey(deletedFilter.appName, key).pipe(
switchMap((filters: any) => { switchMap(filters => {
if (filters && filters.length > 0) { 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 this.updateTaskFilters(deletedFilter.appName, key, filters);
} }
return [];
}), }),
map((filters: TaskFilterCloudModel[]) => { map(filters => {
this.addFiltersToStream(filters); this.addFiltersToStream(filters);
return filters; return filters;
}), }),

View File

@ -65,8 +65,8 @@ export class TaskListCloudService extends BaseCloudService {
return `${this.getBasePath(requestNode.appName)}/query/v1/tasks`; return `${this.getBasePath(requestNode.appName)}/query/v1/tasks`;
} }
private buildQueryParams(requestNode: TaskQueryCloudRequestModel) { private buildQueryParams(requestNode: TaskQueryCloudRequestModel): Object {
const queryParam = {}; const queryParam: Object = {};
for (const property in requestNode) { for (const property in requestNode) {
if (requestNode.hasOwnProperty(property) && if (requestNode.hasOwnProperty(property) &&
!this.isExcludedField(property) && !this.isExcludedField(property) &&
@ -77,11 +77,11 @@ export class TaskListCloudService extends BaseCloudService {
return queryParam; return queryParam;
} }
private isExcludedField(property) { private isExcludedField(property: string): boolean {
return property === 'appName' || property === 'sorting'; 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; return requestNode[property] !== '' && requestNode[property] !== null && requestNode[property] !== undefined;
} }

View File

@ -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]+)'); const result = urlToCheck.match('^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/?\n]+)');
return result[1]; return result[1];
} }

View File

@ -65,7 +65,7 @@ export class PeopleSearchComponent implements OnInit {
this.performSearch = this.performSearchCallback.bind(this); this.performSearch = this.performSearchCallback.bind(this);
} }
private performSearchCallback(event): Observable<UserProcessModel[]> { private performSearchCallback(event: any): Observable<UserProcessModel[]> {
this.searchPeople.emit(event); this.searchPeople.emit(event);
return this.filteredResults$; return this.filteredResults$;
} }

View File

@ -145,7 +145,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
* Pass the selected filter as next * Pass the selected filter as next
* @param filter * @param filter
*/ */
public selectFilter(filter: ProcessInstanceFilterRepresentation) { selectFilter(filter: ProcessInstanceFilterRepresentation) {
this.currentFilter = filter; this.currentFilter = filter;
this.filterClick.emit(filter); this.filterClick.emit(filter);
} }
@ -153,7 +153,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
/** /**
* Select the first filter of a list if present * Select the first filter of a list if present
*/ */
public selectProcessFilter(filterParam: FilterProcessRepresentationModel) { selectProcessFilter(filterParam: FilterProcessRepresentationModel) {
if (filterParam) { if (filterParam) {
this.filters.filter((processFilter: UserProcessInstanceFilterRepresentation, index) => { this.filters.filter((processFilter: UserProcessInstanceFilterRepresentation, index) => {
if (filterParam.name && filterParam.name.toLowerCase() === processFilter.name.toLowerCase() || if (filterParam.name && filterParam.name.toLowerCase() === processFilter.name.toLowerCase() ||
@ -172,14 +172,14 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
/** /**
* Select the Running filter * Select the Running filter
*/ */
public selectRunningFilter() { selectRunningFilter() {
this.selectProcessFilter(this.processFilterService.getRunningFilterInstance(null)); this.selectProcessFilter(this.processFilterService.getRunningFilterInstance(null));
} }
/** /**
* Select as default task filter the first in the list * Select as default task filter the first in the list
*/ */
public selectDefaultTaskFilter() { selectDefaultTaskFilter() {
if (!this.isFilterListEmpty()) { if (!this.isFilterListEmpty()) {
this.currentFilter = this.filters[0]; this.currentFilter = this.filters[0];
this.filterSelected.emit(this.filters[0]); this.filterSelected.emit(this.filters[0]);
@ -215,7 +215,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
/** /**
* Return current filter icon * Return current filter icon
*/ */
getFilterIcon(icon): string { getFilterIcon(icon: string): string {
return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(icon); return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(icon);
} }
} }

View File

@ -52,21 +52,21 @@ export class ProcessInstanceDetailsComponent implements OnChanges {
/** Emitted when the current process is cancelled by the user from within the component. */ /** Emitted when the current process is cancelled by the user from within the component. */
@Output() @Output()
processCancelled: EventEmitter<any> = new EventEmitter<any>(); processCancelled = new EventEmitter<any>();
/** Emitted when an error occurs. */ /** Emitted when an error occurs. */
@Output() @Output()
error: EventEmitter<any> = new EventEmitter<any>(); error = new EventEmitter<any>();
/** Emitted when a task is clicked. */ /** Emitted when a task is clicked. */
@Output() @Output()
taskClick: EventEmitter<TaskDetailsEvent> = new EventEmitter<TaskDetailsEvent>(); taskClick = new EventEmitter<TaskDetailsEvent>();
processInstanceDetails: ProcessInstance; processInstanceDetails: ProcessInstance;
/** Emitted when the "show diagram" button is clicked. */ /** Emitted when the "show diagram" button is clicked. */
@Output() @Output()
showProcessDiagram: EventEmitter<any> = new EventEmitter<any>(); showProcessDiagram = new EventEmitter<any>();
/** /**
* Constructor * Constructor
@ -124,7 +124,7 @@ export class ProcessInstanceDetailsComponent implements OnChanges {
this.taskClick.emit(event); this.taskClick.emit(event);
} }
getProcessNameOrDescription(dateFormat): string { getProcessNameOrDescription(dateFormat: string): string {
let name = ''; let name = '';
if (this.processInstanceDetails) { if (this.processInstanceDetails) {
name = this.processInstanceDetails.name || name = this.processInstanceDetails.name ||
@ -133,7 +133,7 @@ export class ProcessInstanceDetailsComponent implements OnChanges {
return name; return name;
} }
getFormatDate(value, format: string) { getFormatDate(value: any, format: string): any {
const datePipe = new DatePipe('en-US'); const datePipe = new DatePipe('en-US');
try { try {
return datePipe.transform(value, format); return datePipe.transform(value, format);

View File

@ -120,6 +120,7 @@ export class ProcessInstanceHeaderComponent implements OnChanges {
if (this.processInstance) { if (this.processInstance) {
return this.isRunning() ? 'Running' : 'Completed'; return this.isRunning() ? 'Running' : 'Completed';
} }
return 'Unknown';
} }
getStartedByFullName(): string { getStartedByFullName(): string {

View File

@ -144,7 +144,7 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr
return this.processInstanceDetails && this.processInstanceDetails.startFormDefined === true; return this.processInstanceDetails && this.processInstanceDetails.startFormDefined === true;
} }
getUserFullName(user: any) { getUserFullName(user: any): string {
if (user) { if (user) {
return (user.firstName && user.firstName !== 'null' return (user.firstName && user.firstName !== 'null'
? user.firstName + ' ' : '') + ? user.firstName + ' ' : '') +
@ -153,12 +153,13 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr
return 'Nobody'; return 'Nobody';
} }
getFormatDate(value, format: string) { getFormatDate(value: any, format: string): any {
const datePipe = new DatePipe('en-US'); const datePipe = new DatePipe('en-US');
try { try {
return datePipe.transform(value, format); return datePipe.transform(value, format);
} catch (err) { } catch (err) {
this.logService.error(`ProcessListInstanceTask: error parsing date ${value} to format ${format}`); this.logService.error(`ProcessListInstanceTask: error parsing date ${value} to format ${format}`);
return value;
} }
} }

View File

@ -292,7 +292,7 @@ export class ProcessInstanceListComponent extends DataTableSchema implements On
return instances; return instances;
} }
getProcessNameOrDescription(processInstance, dateFormat): string { getProcessNameOrDescription(processInstance, dateFormat: string): string {
let name = ''; let name = '';
if (processInstance) { if (processInstance) {
name = processInstance.name || name = processInstance.name ||
@ -301,7 +301,7 @@ export class ProcessInstanceListComponent extends DataTableSchema implements On
return name; return name;
} }
getFormatDate(value, format: string) { getFormatDate(value: any, format: string) {
const datePipe = new DatePipe('en-US'); const datePipe = new DatePipe('en-US');
try { try {
return datePipe.transform(value, format); return datePipe.transform(value, format);
@ -310,7 +310,7 @@ export class ProcessInstanceListComponent extends DataTableSchema implements On
} }
} }
private createRequestNode() { private createRequestNode(): ProcessFilterParamRepresentationModel {
const requestNode = { const requestNode = {
appDefinitionId: this.appId, appDefinitionId: this.appId,
processDefinitionId: this.processDefinitionId, processDefinitionId: this.processDefinitionId,

View File

@ -152,9 +152,11 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
} }
return filteredProcess; return filteredProcess;
} }
return [];
} }
getSelectedProcess(selectedProcess) { getSelectedProcess(selectedProcess: string): ProcessDefinitionRepresentation {
let processSelected = this.processDefinitions.find((process) => process.name.toLowerCase() === selectedProcess); let processSelected = this.processDefinitions.find((process) => process.name.toLowerCase() === selectedProcess);
if (!processSelected) { if (!processSelected) {
@ -163,7 +165,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
return processSelected; return processSelected;
} }
public loadStartProcess() { loadStartProcess(): void {
this.resetSelectedProcessDefinition(); this.resetSelectedProcessDefinition();
this.resetErrorMessage(); this.resetErrorMessage();
@ -206,7 +208,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
return alfrescoRepositoryName + 'Alfresco'; return alfrescoRepositoryName + 'Alfresco';
} }
moveNodeFromCStoPS() { moveNodeFromCStoPS(): void {
const accountIdentifier = this.getAlfrescoRepositoryName(); const accountIdentifier = this.getAlfrescoRepositoryName();
for (const key in this.values) { 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) { if (this.selectedProcessDef && this.selectedProcessDef.id && this.name) {
this.resetErrorMessage(); this.resetErrorMessage();
const formValues = this.startForm ? this.startForm.form.values : undefined; 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(); this.cancel.emit();
} }
@ -247,8 +249,9 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
return this.selectedProcessDef && this.selectedProcessDef.hasStartForm; return this.selectedProcessDef && this.selectedProcessDef.hasStartForm;
} }
isProcessDefinitionEmpty() { isProcessDefinitionEmpty(): boolean {
return this.processDefinitions ? (this.processDefinitions.length > 0 || this.errorMessageId) : this.errorMessageId; const hasErrorMessage = this.errorMessageId ? true : false;
return this.processDefinitions ? (this.processDefinitions.length > 0 || hasErrorMessage) : hasErrorMessage;
} }
isStartFormMissingOrValid(): boolean { isStartFormMissingOrValid(): boolean {
@ -279,7 +282,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
this.startProcess(outcome); this.startProcess(outcome);
} }
public reset() { reset(): void {
this.resetSelectedProcessDefinition(); this.resetSelectedProcessDefinition();
this.name = ''; this.name = '';
if (this.startForm) { if (this.startForm) {
@ -292,7 +295,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
return this.name ? true : false; return this.name ? true : false;
} }
displayFn(process: any) { displayFn(process: any): string {
if (process) { if (process) {
let processName = process; let processName = process;
if (typeof process !== 'string') { if (typeof process !== 'string') {
@ -300,6 +303,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
} }
return processName; return processName;
} }
return undefined;
} }
displayDropdown(event) { displayDropdown(event) {

View File

@ -109,7 +109,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
this.onDestroy$.complete(); this.onDestroy$.complete();
} }
buildForm() { buildForm(): void {
this.taskForm = this.formBuilder.group({ this.taskForm = this.formBuilder.group({
name: new FormControl(this.taskDetailsModel.name, [Validators.required, Validators.maxLength(this.maxTaskNameLength), this.whitespaceValidator]), name: new FormControl(this.taskDetailsModel.name, [Validators.required, Validators.maxLength(this.maxTaskNameLength), this.whitespaceValidator]),
description: new FormControl('', [this.whitespaceValidator]), description: new FormControl('', [this.whitespaceValidator]),
@ -121,25 +121,26 @@ export class StartTaskComponent implements OnInit, OnDestroy {
.subscribe(taskFormValues => this.setTaskDetails(taskFormValues)); .subscribe(taskFormValues => this.setTaskDetails(taskFormValues));
} }
public whitespaceValidator(control: FormControl) { whitespaceValidator(control: FormControl): any {
if (control.value) { if (control.value) {
const isWhitespace = (control.value || '').trim().length === 0; const isWhitespace = (control.value || '').trim().length === 0;
const isValid = control.value.length === 0 || !isWhitespace; const isValid = control.value.length === 0 || !isWhitespace;
return isValid ? null : { 'whitespace': true }; return isValid ? null : { 'whitespace': true };
} }
return null;
} }
setTaskDetails(form) { setTaskDetails(form: any) {
this.taskDetailsModel.name = form.name; this.taskDetailsModel.name = form.name;
this.taskDetailsModel.description = form.description; this.taskDetailsModel.description = form.description;
this.taskDetailsModel.formKey = form.formKey ? form.formKey.toString() : null; this.taskDetailsModel.formKey = form.formKey ? form.formKey.toString() : null;
} }
isFormValid() { isFormValid(): boolean {
return this.taskForm.valid && !this.dateError && !this.loading; return this.taskForm.valid && !this.dateError && !this.loading;
} }
public saveTask(): void { saveTask(): void {
this.loading = true; this.loading = true;
if (this.appId) { if (this.appId) {
this.taskDetailsModel.category = this.appId.toString(); 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; this.assigneeId = userId;
} }
@ -189,7 +190,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
return response; return response;
} }
public onCancel(): void { onCancel(): void {
this.cancel.emit(); this.cancel.emit();
} }
@ -197,7 +198,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
this.forms$ = this.taskService.getFormList(); this.forms$ = this.taskService.getFormList();
} }
public isUserNameEmpty(user: UserProcessModel): boolean { isUserNameEmpty(user: UserProcessModel): boolean {
return !user || (this.isEmpty(user.firstName) && this.isEmpty(user.lastName)); 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; 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 : ''); firstName = (firstName !== null ? firstName : '');
lastName = (lastName !== null ? lastName : ''); lastName = (lastName !== null ? lastName : '');
return firstName + delimiter + lastName; return firstName + delimiter + lastName;
@ -215,7 +216,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
this.dateError = false; this.dateError = false;
if (newDateValue) { if (newDateValue) {
let momentDate; let momentDate: moment.Moment;
if (typeof newDateValue === 'string') { if (typeof newDateValue === 'string') {
momentDate = moment(newDateValue, this.FORMAT_DATE, true); momentDate = moment(newDateValue, this.FORMAT_DATE, true);

View File

@ -335,11 +335,11 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
this.isExternalIdEqual(this.taskDetails.assignee.externalId, this.currentLoggedUser.externalId); 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(); return assigneeMail.toLocaleLowerCase() === currentLoggedEmail.toLocaleLowerCase();
} }
private isExternalIdEqual(assigneeExternalId, currentUserExternalId): boolean { private isExternalIdEqual(assigneeExternalId: string, currentUserExternalId: string): boolean {
return assigneeExternalId.toLocaleLowerCase() === currentUserExternalId.toLocaleLowerCase(); return assigneeExternalId.toLocaleLowerCase() === currentUserExternalId.toLocaleLowerCase();
} }

View File

@ -225,10 +225,11 @@ export class TaskHeaderComponent implements OnChanges, OnInit {
/** /**
* Return the process parent information * Return the process parent information
*/ */
getParentInfo() { getParentInfo(): Map<string, string> {
if (this.taskDetails.processInstanceId && this.taskDetails.processDefinitionName) { if (this.taskDetails.processInstanceId && this.taskDetails.processDefinitionName) {
return new Map([[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 * 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; 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 * Return true if the user is a candidate member
*/ */
isCandidateMember() { isCandidateMember(): boolean {
return this.taskDetails.managerOfCandidateGroup || this.taskDetails.memberOfCandidateGroup || this.taskDetails.memberOfCandidateUsers; return this.taskDetails.managerOfCandidateGroup || this.taskDetails.memberOfCandidateGroup || this.taskDetails.memberOfCandidateUsers;
} }

View File

@ -36,6 +36,7 @@ import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './tasklist.service'; import { TaskListService } from './tasklist.service';
import { AlfrescoApiServiceMock, LogService, AppConfigService } from '@alfresco/adf-core'; import { AlfrescoApiServiceMock, LogService, AppConfigService } from '@alfresco/adf-core';
import { TaskUpdateRepresentation } from '@alfresco/js-api';
declare let jasmine: any; declare let jasmine: any;
@ -452,8 +453,11 @@ describe('Activiti TaskList Service', () => {
it('should update a task', (done) => { it('should update a task', (done) => {
const taskId = '111'; const taskId = '111';
const updated: TaskUpdateRepresentation = {
name: 'someName'
};
service.updateTask(taskId, { property: 'value' }).subscribe(() => { service.updateTask(taskId, updated).subscribe(() => {
done(); done();
}); });

View File

@ -25,7 +25,8 @@ import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListModel } from '../models/task-list.model'; import { TaskListModel } from '../models/task-list.model';
import { import {
TaskQueryRepresentation, TaskQueryRepresentation,
AssigneeIdentifierRepresentation AssigneeIdentifierRepresentation,
TaskUpdateRepresentation
} from '@alfresco/js-api'; } from '@alfresco/js-api';
@Injectable({ @Injectable({
@ -363,7 +364,7 @@ export class TaskListService {
* @param updated Data to update the task (as a `TaskUpdateRepresentation` instance). * @param updated Data to update the task (as a `TaskUpdateRepresentation` instance).
* @returns Updated task details * @returns Updated task details
*/ */
updateTask(taskId: any, updated): Observable<TaskDetailsModel> { updateTask(taskId: any, updated: TaskUpdateRepresentation): Observable<TaskDetailsModel> {
return from(this.apiService.taskApi.updateTask(taskId, updated)) return from(this.apiService.taskApi.updateTask(taskId, updated))
.pipe( .pipe(
map((result) => <TaskDetailsModel> result), map((result) => <TaskDetailsModel> result),

View File

@ -13,7 +13,7 @@
"noUnusedParameters": true, "noUnusedParameters": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noImplicitAny": false, "noImplicitAny": false,
"noImplicitReturns": false, "noImplicitReturns": true,
"noImplicitUseStrict": false, "noImplicitUseStrict": false,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"removeComments": true, "removeComments": true,

View File

@ -11,6 +11,7 @@
"skipLibCheck": true, "skipLibCheck": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noImplicitReturns": true,
"target": "es5", "target": "es5",
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"typeRoots": [ "typeRoots": [