mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +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:
@@ -98,7 +98,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
checkUserAndValidateForm(list, value) {
|
||||
checkUserAndValidateForm(list: UserProcessModel[], value: string): void {
|
||||
const isValidUser = this.isValidUser(list, value);
|
||||
if (isValidUser || value === '') {
|
||||
this.field.validationSummary.message = '';
|
||||
@@ -111,7 +111,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
isValidUser(users: UserProcessModel[], name: string) {
|
||||
isValidUser(users: UserProcessModel[], name: string): boolean {
|
||||
if (users) {
|
||||
return users.find((user) => {
|
||||
const selectedUser = this.getDisplayName(user).toLocaleLowerCase() === name.toLocaleLowerCase();
|
||||
@@ -119,8 +119,9 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
||||
this.peopleSelected.emit(user && user.id || undefined);
|
||||
}
|
||||
return selectedUser;
|
||||
});
|
||||
}) ? true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
getDisplayName(model: UserProcessModel) {
|
||||
|
@@ -202,7 +202,7 @@ describe('UploadWidgetComponent', () => {
|
||||
}));
|
||||
|
||||
it('should update the form after deleted a file', async(() => {
|
||||
spyOn(contentService, 'createTemporaryRawRelatedContent').and.callFake((file) => {
|
||||
spyOn(contentService, 'createTemporaryRawRelatedContent').and.callFake((file: any) => {
|
||||
if (file.name === 'file-fake.png') {
|
||||
return of(fakePngAnswer);
|
||||
}
|
||||
@@ -210,6 +210,8 @@ describe('UploadWidgetComponent', () => {
|
||||
if (file.name === 'file-fake.jpg') {
|
||||
return of(fakeJpgAnswer);
|
||||
}
|
||||
|
||||
return of();
|
||||
});
|
||||
|
||||
uploadWidgetComponent.field.params.multiple = true;
|
||||
@@ -230,7 +232,7 @@ describe('UploadWidgetComponent', () => {
|
||||
}));
|
||||
|
||||
it('should set has field value all the files uploaded', async(() => {
|
||||
spyOn(contentService, 'createTemporaryRawRelatedContent').and.callFake((file) => {
|
||||
spyOn(contentService, 'createTemporaryRawRelatedContent').and.callFake((file: any) => {
|
||||
if (file.name === 'file-fake.png') {
|
||||
return of(fakePngAnswer);
|
||||
}
|
||||
@@ -238,6 +240,8 @@ describe('UploadWidgetComponent', () => {
|
||||
if (file.name === 'file-fake.jpg') {
|
||||
return of(fakeJpgAnswer);
|
||||
}
|
||||
|
||||
return of();
|
||||
});
|
||||
|
||||
uploadWidgetComponent.field.params.multiple = true;
|
||||
|
@@ -16,90 +16,92 @@
|
||||
*/
|
||||
|
||||
export class WidgetVisibilityModel {
|
||||
rightRestResponseId?: string;
|
||||
rightFormFieldId?: string;
|
||||
leftRestResponseId?: string;
|
||||
leftFormFieldId?: string;
|
||||
operator: string;
|
||||
nextCondition: WidgetVisibilityModel;
|
||||
nextConditionOperator: string;
|
||||
rightRestResponseId?: string;
|
||||
rightFormFieldId?: string;
|
||||
leftRestResponseId?: string;
|
||||
leftFormFieldId?: string;
|
||||
operator: string;
|
||||
nextCondition: WidgetVisibilityModel;
|
||||
nextConditionOperator: string;
|
||||
|
||||
constructor(private json?: any) {
|
||||
if (json) {
|
||||
this.operator = json.operator;
|
||||
this.nextCondition = new WidgetVisibilityModel(json.nextCondition);
|
||||
this.nextConditionOperator = json.nextConditionOperator;
|
||||
this.rightRestResponseId = json.rightRestResponseId;
|
||||
this.rightFormFieldId = json.rightFormFieldId;
|
||||
this.leftFormFieldId = json.leftFormFieldId;
|
||||
this.leftRestResponseId = json.leftRestResponseId;
|
||||
} else {
|
||||
this.json = {};
|
||||
}
|
||||
constructor(private json?: any) {
|
||||
if (json) {
|
||||
this.operator = json.operator;
|
||||
this.nextCondition = new WidgetVisibilityModel(json.nextCondition);
|
||||
this.nextConditionOperator = json.nextConditionOperator;
|
||||
this.rightRestResponseId = json.rightRestResponseId;
|
||||
this.rightFormFieldId = json.rightFormFieldId;
|
||||
this.leftFormFieldId = json.leftFormFieldId;
|
||||
this.leftRestResponseId = json.leftRestResponseId;
|
||||
} else {
|
||||
this.json = {};
|
||||
}
|
||||
}
|
||||
|
||||
get leftType(): string {
|
||||
if (this.leftFormFieldId) {
|
||||
return WidgetTypeEnum.field;
|
||||
} else if (this.leftRestResponseId) {
|
||||
return WidgetTypeEnum.variable;
|
||||
} else if (!!this.json.leftType) {
|
||||
return this.json.leftType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
set leftType(leftType: string) {
|
||||
this.json.leftType = leftType;
|
||||
}
|
||||
|
||||
get leftValue(): any {
|
||||
if (this.json.leftValue) {
|
||||
return this.json.leftValue;
|
||||
} else if (this.leftFormFieldId) {
|
||||
return this.leftFormFieldId;
|
||||
} else {
|
||||
return this.leftRestResponseId;
|
||||
}
|
||||
}
|
||||
|
||||
set leftValue(leftValue: any) {
|
||||
this.json.leftValue = leftValue;
|
||||
}
|
||||
|
||||
get rightType(): string {
|
||||
if (!!this.json.rightType) {
|
||||
return this.json.rightType;
|
||||
} else if (this.json.rightValue) {
|
||||
return WidgetTypeEnum.value;
|
||||
} else if (this.rightRestResponseId) {
|
||||
return WidgetTypeEnum.variable;
|
||||
} else if (this.rightFormFieldId) {
|
||||
return WidgetTypeEnum.field;
|
||||
}
|
||||
|
||||
set leftType(leftType: string) {
|
||||
this.json.leftType = leftType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
set rightType(rightType: string) {
|
||||
this.json.rightType = rightType;
|
||||
}
|
||||
set rightType(rightType: string) {
|
||||
this.json.rightType = rightType;
|
||||
}
|
||||
|
||||
set leftValue(leftValue: string) {
|
||||
this.json.leftValue = leftValue;
|
||||
}
|
||||
|
||||
set rightValue(rightValue: string) {
|
||||
this.json.rightValue = rightValue;
|
||||
}
|
||||
|
||||
get leftType() {
|
||||
if (this.leftFormFieldId) {
|
||||
return WidgetTypeEnum.field;
|
||||
} else if (this.leftRestResponseId) {
|
||||
return WidgetTypeEnum.variable;
|
||||
} else if ( !!this.json.leftType) {
|
||||
return this.json.leftType;
|
||||
}
|
||||
}
|
||||
|
||||
get leftValue() {
|
||||
if ( this.json.leftValue ) {
|
||||
return this.json.leftValue;
|
||||
} else if (this.leftFormFieldId) {
|
||||
return this.leftFormFieldId;
|
||||
} else {
|
||||
return this.leftRestResponseId;
|
||||
}
|
||||
}
|
||||
|
||||
get rightType() {
|
||||
if ( !!this.json.rightType ) {
|
||||
return this.json.rightType;
|
||||
} else if (this.json.rightValue) {
|
||||
return WidgetTypeEnum.value;
|
||||
} else if (this.rightRestResponseId) {
|
||||
return WidgetTypeEnum.variable;
|
||||
} else if (this.rightFormFieldId) {
|
||||
return WidgetTypeEnum.field;
|
||||
}
|
||||
}
|
||||
|
||||
get rightValue() {
|
||||
if (this.json.rightValue) {
|
||||
return this.json.rightValue;
|
||||
} else if (this.rightFormFieldId) {
|
||||
return this.rightFormFieldId;
|
||||
} else {
|
||||
return this.rightRestResponseId;
|
||||
}
|
||||
get rightValue(): any {
|
||||
if (this.json.rightValue) {
|
||||
return this.json.rightValue;
|
||||
} else if (this.rightFormFieldId) {
|
||||
return this.rightFormFieldId;
|
||||
} else {
|
||||
return this.rightRestResponseId;
|
||||
}
|
||||
}
|
||||
|
||||
set rightValue(rightValue: any) {
|
||||
this.json.rightValue = rightValue;
|
||||
}
|
||||
}
|
||||
|
||||
export enum WidgetTypeEnum {
|
||||
field = 'field',
|
||||
variable = 'variable',
|
||||
value = 'value'
|
||||
field = 'field',
|
||||
variable = 'variable',
|
||||
value = 'value'
|
||||
}
|
||||
|
@@ -249,7 +249,7 @@ export class WidgetVisibilityService {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
evaluateLogicalOperation(logicOp, previousValue, newValue): boolean {
|
||||
evaluateLogicalOperation(logicOp: string, previousValue: any, newValue: any): boolean | undefined {
|
||||
switch (logicOp) {
|
||||
case 'and':
|
||||
return previousValue && newValue;
|
||||
@@ -260,12 +260,12 @@ export class WidgetVisibilityService {
|
||||
case 'or-not':
|
||||
return previousValue || !newValue;
|
||||
default:
|
||||
this.logService.error('NO valid operation! wrong op request : ' + logicOp);
|
||||
break;
|
||||
this.logService.error(`Invalid operator: ${logicOp}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
evaluateCondition(leftValue, rightValue, operator): boolean {
|
||||
evaluateCondition(leftValue: any, rightValue: any, operator: string): boolean | undefined {
|
||||
switch (operator) {
|
||||
case '==':
|
||||
return leftValue + '' === rightValue + '';
|
||||
@@ -284,10 +284,9 @@ export class WidgetVisibilityService {
|
||||
case '!empty':
|
||||
return leftValue ? leftValue !== '' : false;
|
||||
default:
|
||||
this.logService.error('NO valid operation!');
|
||||
break;
|
||||
this.logService.error(`Invalid operator: ${operator}`);
|
||||
return undefined;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cleanProcessVariable() {
|
||||
|
Reference in New Issue
Block a user