[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
65 changed files with 366 additions and 319 deletions

View File

@@ -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);

View File

@@ -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();
}

View File

@@ -225,10 +225,11 @@ export class TaskHeaderComponent implements OnChanges, OnInit {
/**
* Return the process parent information
*/
getParentInfo() {
getParentInfo(): Map<string, string> {
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;
}

View File

@@ -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();
});

View File

@@ -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<TaskDetailsModel> {
updateTask(taskId: any, updated: TaskUpdateRepresentation): Observable<TaskDetailsModel> {
return from(this.apiService.taskApi.updateTask(taskId, updated))
.pipe(
map((result) => <TaskDetailsModel> result),