mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -231,7 +231,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
});
|
||||
}
|
||||
|
||||
private getDomainHost(urlToCheck) {
|
||||
private getDomainHost(urlToCheck: string): string {
|
||||
const result = urlToCheck.match('^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/?\n]+)');
|
||||
return result[1];
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ export class PeopleSearchComponent implements OnInit {
|
||||
this.performSearch = this.performSearchCallback.bind(this);
|
||||
}
|
||||
|
||||
private performSearchCallback(event): Observable<UserProcessModel[]> {
|
||||
private performSearchCallback(event: any): Observable<UserProcessModel[]> {
|
||||
this.searchPeople.emit(event);
|
||||
return this.filteredResults$;
|
||||
}
|
||||
|
@@ -145,7 +145,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
||||
* Pass the selected filter as next
|
||||
* @param filter
|
||||
*/
|
||||
public selectFilter(filter: ProcessInstanceFilterRepresentation) {
|
||||
selectFilter(filter: ProcessInstanceFilterRepresentation) {
|
||||
this.currentFilter = filter;
|
||||
this.filterClick.emit(filter);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
||||
/**
|
||||
* Select the first filter of a list if present
|
||||
*/
|
||||
public selectProcessFilter(filterParam: FilterProcessRepresentationModel) {
|
||||
selectProcessFilter(filterParam: FilterProcessRepresentationModel) {
|
||||
if (filterParam) {
|
||||
this.filters.filter((processFilter: UserProcessInstanceFilterRepresentation, index) => {
|
||||
if (filterParam.name && filterParam.name.toLowerCase() === processFilter.name.toLowerCase() ||
|
||||
@@ -172,14 +172,14 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
||||
/**
|
||||
* Select the Running filter
|
||||
*/
|
||||
public selectRunningFilter() {
|
||||
selectRunningFilter() {
|
||||
this.selectProcessFilter(this.processFilterService.getRunningFilterInstance(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Select as default task filter the first in the list
|
||||
*/
|
||||
public selectDefaultTaskFilter() {
|
||||
selectDefaultTaskFilter() {
|
||||
if (!this.isFilterListEmpty()) {
|
||||
this.currentFilter = this.filters[0];
|
||||
this.filterSelected.emit(this.filters[0]);
|
||||
@@ -215,7 +215,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
||||
/**
|
||||
* Return current filter icon
|
||||
*/
|
||||
getFilterIcon(icon): string {
|
||||
getFilterIcon(icon: string): string {
|
||||
return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(icon);
|
||||
}
|
||||
}
|
||||
|
@@ -52,21 +52,21 @@ export class ProcessInstanceDetailsComponent implements OnChanges {
|
||||
|
||||
/** Emitted when the current process is cancelled by the user from within the component. */
|
||||
@Output()
|
||||
processCancelled: EventEmitter<any> = new EventEmitter<any>();
|
||||
processCancelled = new EventEmitter<any>();
|
||||
|
||||
/** Emitted when an error occurs. */
|
||||
@Output()
|
||||
error: EventEmitter<any> = new EventEmitter<any>();
|
||||
error = new EventEmitter<any>();
|
||||
|
||||
/** Emitted when a task is clicked. */
|
||||
@Output()
|
||||
taskClick: EventEmitter<TaskDetailsEvent> = new EventEmitter<TaskDetailsEvent>();
|
||||
taskClick = new EventEmitter<TaskDetailsEvent>();
|
||||
|
||||
processInstanceDetails: ProcessInstance;
|
||||
|
||||
/** Emitted when the "show diagram" button is clicked. */
|
||||
@Output()
|
||||
showProcessDiagram: EventEmitter<any> = new EventEmitter<any>();
|
||||
showProcessDiagram = new EventEmitter<any>();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -124,7 +124,7 @@ export class ProcessInstanceDetailsComponent implements OnChanges {
|
||||
this.taskClick.emit(event);
|
||||
}
|
||||
|
||||
getProcessNameOrDescription(dateFormat): string {
|
||||
getProcessNameOrDescription(dateFormat: string): string {
|
||||
let name = '';
|
||||
if (this.processInstanceDetails) {
|
||||
name = this.processInstanceDetails.name ||
|
||||
@@ -133,7 +133,7 @@ export class ProcessInstanceDetailsComponent implements OnChanges {
|
||||
return name;
|
||||
}
|
||||
|
||||
getFormatDate(value, format: string) {
|
||||
getFormatDate(value: any, format: string): any {
|
||||
const datePipe = new DatePipe('en-US');
|
||||
try {
|
||||
return datePipe.transform(value, format);
|
||||
|
@@ -120,6 +120,7 @@ export class ProcessInstanceHeaderComponent implements OnChanges {
|
||||
if (this.processInstance) {
|
||||
return this.isRunning() ? 'Running' : 'Completed';
|
||||
}
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
getStartedByFullName(): string {
|
||||
|
@@ -144,7 +144,7 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr
|
||||
return this.processInstanceDetails && this.processInstanceDetails.startFormDefined === true;
|
||||
}
|
||||
|
||||
getUserFullName(user: any) {
|
||||
getUserFullName(user: any): string {
|
||||
if (user) {
|
||||
return (user.firstName && user.firstName !== 'null'
|
||||
? user.firstName + ' ' : '') +
|
||||
@@ -153,12 +153,13 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr
|
||||
return 'Nobody';
|
||||
}
|
||||
|
||||
getFormatDate(value, format: string) {
|
||||
getFormatDate(value: any, format: string): any {
|
||||
const datePipe = new DatePipe('en-US');
|
||||
try {
|
||||
return datePipe.transform(value, format);
|
||||
} catch (err) {
|
||||
this.logService.error(`ProcessListInstanceTask: error parsing date ${value} to format ${format}`);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -292,7 +292,7 @@ export class ProcessInstanceListComponent extends DataTableSchema implements On
|
||||
return instances;
|
||||
}
|
||||
|
||||
getProcessNameOrDescription(processInstance, dateFormat): string {
|
||||
getProcessNameOrDescription(processInstance, dateFormat: string): string {
|
||||
let name = '';
|
||||
if (processInstance) {
|
||||
name = processInstance.name ||
|
||||
@@ -301,7 +301,7 @@ export class ProcessInstanceListComponent extends DataTableSchema implements On
|
||||
return name;
|
||||
}
|
||||
|
||||
getFormatDate(value, format: string) {
|
||||
getFormatDate(value: any, format: string) {
|
||||
const datePipe = new DatePipe('en-US');
|
||||
try {
|
||||
return datePipe.transform(value, format);
|
||||
@@ -310,7 +310,7 @@ export class ProcessInstanceListComponent extends DataTableSchema implements On
|
||||
}
|
||||
}
|
||||
|
||||
private createRequestNode() {
|
||||
private createRequestNode(): ProcessFilterParamRepresentationModel {
|
||||
const requestNode = {
|
||||
appDefinitionId: this.appId,
|
||||
processDefinitionId: this.processDefinitionId,
|
||||
|
@@ -152,9 +152,11 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
}
|
||||
return filteredProcess;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
getSelectedProcess(selectedProcess) {
|
||||
getSelectedProcess(selectedProcess: string): ProcessDefinitionRepresentation {
|
||||
let processSelected = this.processDefinitions.find((process) => process.name.toLowerCase() === selectedProcess);
|
||||
|
||||
if (!processSelected) {
|
||||
@@ -163,7 +165,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
return processSelected;
|
||||
}
|
||||
|
||||
public loadStartProcess() {
|
||||
loadStartProcess(): void {
|
||||
this.resetSelectedProcessDefinition();
|
||||
this.resetErrorMessage();
|
||||
|
||||
@@ -206,7 +208,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
return alfrescoRepositoryName + 'Alfresco';
|
||||
}
|
||||
|
||||
moveNodeFromCStoPS() {
|
||||
moveNodeFromCStoPS(): void {
|
||||
const accountIdentifier = this.getAlfrescoRepositoryName();
|
||||
|
||||
for (const key in this.values) {
|
||||
@@ -222,7 +224,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
}
|
||||
}
|
||||
|
||||
public startProcess(outcome?: string) {
|
||||
startProcess(outcome?: string) {
|
||||
if (this.selectedProcessDef && this.selectedProcessDef.id && this.name) {
|
||||
this.resetErrorMessage();
|
||||
const formValues = this.startForm ? this.startForm.form.values : undefined;
|
||||
@@ -239,7 +241,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
}
|
||||
}
|
||||
|
||||
public cancelStartProcess() {
|
||||
cancelStartProcess(): void {
|
||||
this.cancel.emit();
|
||||
}
|
||||
|
||||
@@ -247,8 +249,9 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
return this.selectedProcessDef && this.selectedProcessDef.hasStartForm;
|
||||
}
|
||||
|
||||
isProcessDefinitionEmpty() {
|
||||
return this.processDefinitions ? (this.processDefinitions.length > 0 || this.errorMessageId) : this.errorMessageId;
|
||||
isProcessDefinitionEmpty(): boolean {
|
||||
const hasErrorMessage = this.errorMessageId ? true : false;
|
||||
return this.processDefinitions ? (this.processDefinitions.length > 0 || hasErrorMessage) : hasErrorMessage;
|
||||
}
|
||||
|
||||
isStartFormMissingOrValid(): boolean {
|
||||
@@ -279,7 +282,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
this.startProcess(outcome);
|
||||
}
|
||||
|
||||
public reset() {
|
||||
reset(): void {
|
||||
this.resetSelectedProcessDefinition();
|
||||
this.name = '';
|
||||
if (this.startForm) {
|
||||
@@ -292,7 +295,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
return this.name ? true : false;
|
||||
}
|
||||
|
||||
displayFn(process: any) {
|
||||
displayFn(process: any): string {
|
||||
if (process) {
|
||||
let processName = process;
|
||||
if (typeof process !== 'string') {
|
||||
@@ -300,6 +303,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
}
|
||||
return processName;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
displayDropdown(event) {
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
});
|
||||
|
||||
|
@@ -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),
|
||||
|
Reference in New Issue
Block a user