[ACS-5991] ESLint fixes and code quality improvements (#8893)

* prefer-optional-chain: core

* prefer-optional-chain: content, fix typings

* prefer-optional-chain: process, fix typings

* prefer-optional-chain: process-cloud, fix typings, fix ts configs and eslint

* [ci: force] sonar errors fixes, insights lib

* [ci:force] fix security issues

* [ci:force] fix metadata e2e bug, js assignment bugs

* [ci:force] fix lint issue

* [ci:force] fix tests
This commit is contained in:
Denys Vuika
2023-09-18 09:42:16 +01:00
committed by GitHub
parent 99f591ed67
commit a1dd270c5d
203 changed files with 4155 additions and 4960 deletions

View File

@@ -15,17 +15,17 @@
* limitations under the License.
*/
import { AlfrescoApiService, FormValues, LogService, TaskProcessVariableModel } from '@alfresco/adf-core';
import { AlfrescoApiService, FormFieldOption, FormValues, LogService, TaskProcessVariableModel } from '@alfresco/adf-core';
import { Injectable } from '@angular/core';
import { from, Observable, throwError } from 'rxjs';
import { CompleteFormRepresentation, SaveFormRepresentation, TaskFormsApi } from '@alfresco/js-api';
import { catchError, map } from 'rxjs/operators';
import { DynamicTableColumnOption } from '../widgets/dynamic-table/editors/models/dynamic-table-column-option.model';
@Injectable({
providedIn: 'root'
})
export class TaskFormService {
static UNKNOWN_ERROR_MESSAGE: string = 'Unknown error';
static GENERIC_ERROR_MESSAGE: string = 'Server error';
@@ -35,8 +35,7 @@ export class TaskFormService {
return this._taskFormsApi;
}
constructor(private apiService: AlfrescoApiService, private logService: LogService) {
}
constructor(private apiService: AlfrescoApiService, private logService: LogService) {}
/**
* Saves a task form.
@@ -48,10 +47,7 @@ export class TaskFormService {
saveTaskForm(taskId: string, formValues: FormValues): Observable<any> {
const saveFormRepresentation = { values: formValues } as SaveFormRepresentation;
return from(this.taskFormsApi.saveTaskForm(taskId, saveFormRepresentation))
.pipe(
catchError((err) => this.handleError(err))
);
return from(this.taskFormsApi.saveTaskForm(taskId, saveFormRepresentation)).pipe(catchError((err) => this.handleError(err)));
}
/**
@@ -68,10 +64,7 @@ export class TaskFormService {
completeFormRepresentation.outcome = outcome;
}
return from(this.taskFormsApi.completeTaskForm(taskId, completeFormRepresentation))
.pipe(
catchError((err) => this.handleError(err))
);
return from(this.taskFormsApi.completeTaskForm(taskId, completeFormRepresentation)).pipe(catchError((err) => this.handleError(err)));
}
/**
@@ -81,11 +74,10 @@ export class TaskFormService {
* @returns Form definition
*/
getTaskForm(taskId: string): Observable<any> {
return from(this.taskFormsApi.getTaskForm(taskId))
.pipe(
map(this.toJson),
catchError((err) => this.handleError(err))
);
return from(this.taskFormsApi.getTaskForm(taskId)).pipe(
map(this.toJson),
catchError((err) => this.handleError(err))
);
}
/**
@@ -95,11 +87,8 @@ export class TaskFormService {
* @param field Field identifier
* @returns Field values
*/
getRestFieldValues(taskId: string, field: string): Observable<any> {
return from(this.taskFormsApi.getRestFieldValues(taskId, field))
.pipe(
catchError((err) => this.handleError(err))
);
getRestFieldValues(taskId: string, field: string): Observable<FormFieldOption[]> {
return from(this.taskFormsApi.getRestFieldValues(taskId, field)).pipe(catchError((err) => this.handleError(err)));
}
/**
@@ -110,19 +99,15 @@ export class TaskFormService {
* @param column Column identifier
* @returns Field values
*/
getRestFieldValuesColumn(taskId: string, field: string, column?: string): Observable<any> {
return from(this.taskFormsApi.getRestFieldColumnValues(taskId, field, column))
.pipe(
catchError((err) => this.handleError(err))
);
getRestFieldValuesColumn(taskId: string, field: string, column?: string): Observable<DynamicTableColumnOption[]> {
return from(this.taskFormsApi.getRestFieldColumnValues(taskId, field, column)).pipe(catchError((err) => this.handleError(err)));
}
getTaskProcessVariable(taskId: string): Observable<TaskProcessVariableModel[]> {
return from(this.taskFormsApi.getTaskFormVariables(taskId))
.pipe(
map((res) => this.toJson(res)),
catchError((err) => this.handleError(err))
);
return from(this.taskFormsApi.getTaskFormVariables(taskId)).pipe(
map((res) => this.toJson(res)),
catchError((err) => this.handleError(err))
);
}
/**
@@ -147,11 +132,9 @@ export class TaskFormService {
private handleError(error: any): Observable<any> {
let errMsg = TaskFormService.UNKNOWN_ERROR_MESSAGE;
if (error) {
errMsg = (error.message) ? error.message :
error.status ? `${error.status} - ${error.statusText}` : TaskFormService.GENERIC_ERROR_MESSAGE;
errMsg = error.message ? error.message : error.status ? `${error.status} - ${error.statusText}` : TaskFormService.GENERIC_ERROR_MESSAGE;
}
this.logService.error(errMsg);
return throwError(errMsg);
}
}