mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Merge pull request #855 from Alfresco/dev-valbano-545
Add fix for tests and visibility
This commit is contained in:
commit
d20a750816
@ -10,7 +10,7 @@
|
||||
</div>
|
||||
<div class="mdl-card__media">
|
||||
<div *ngIf="form.hasTabs()">
|
||||
<tabs-widget [tabs]="form.tabs"></tabs-widget>
|
||||
<tabs-widget [tabs]="form.tabs" (formTabChanged)="checkVisibility($event);"></tabs-widget>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!form.hasTabs() && form.hasFields()">
|
||||
|
@ -31,6 +31,7 @@ describe('TabModel', () => {
|
||||
let model = new TabModel(null, json);
|
||||
expect(model.id).toBe(json.id);
|
||||
expect(model.title).toBe(json.title);
|
||||
expect(model.isVisible).toBe(true);
|
||||
expect(model.visibilityCondition).toBe(json.visibilityCondition);
|
||||
});
|
||||
|
||||
@ -38,6 +39,8 @@ describe('TabModel', () => {
|
||||
let model = new TabModel(null, null);
|
||||
expect(model.id).toBeUndefined();
|
||||
expect(model.title).toBeUndefined();
|
||||
expect(model.isVisible).toBeDefined();
|
||||
expect(model.isVisible).toBe(true);
|
||||
expect(model.visibilityCondition).toBeUndefined();
|
||||
});
|
||||
|
||||
|
@ -23,6 +23,7 @@ export class TabModel extends FormWidgetModel {
|
||||
|
||||
id: string;
|
||||
title: string;
|
||||
isVisible: boolean = true;
|
||||
visibilityCondition: any;
|
||||
|
||||
fields: ContainerModel[] = [];
|
||||
|
@ -13,8 +13,9 @@
|
||||
[attr.id]="tab.id">
|
||||
<container-widget
|
||||
*ngFor="let field of tab.fields"
|
||||
[content]="field">
|
||||
[content]="field" (formValueChanged)="tabChanged($event);">
|
||||
</container-widget>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-
|
||||
|
@ -15,8 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, AfterViewInit } from '@angular/core';
|
||||
import { TabModel } from './../core/index';
|
||||
import { Component, Input, AfterViewInit, EventEmitter, Output } from '@angular/core';
|
||||
import { TabModel, FormFieldModel } from './../core/index';
|
||||
|
||||
declare let __moduleName: string;
|
||||
declare var componentHandler;
|
||||
@ -31,6 +31,9 @@ export class TabsWidget implements AfterViewInit {
|
||||
@Input()
|
||||
tabs: TabModel[] = [];
|
||||
|
||||
@Output()
|
||||
formTabChanged: EventEmitter<FormFieldModel> = new EventEmitter<FormFieldModel>();
|
||||
|
||||
hasTabs() {
|
||||
return this.tabs && this.tabs.length > 0;
|
||||
}
|
||||
@ -47,4 +50,9 @@ export class TabsWidget implements AfterViewInit {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
tabChanged( field: FormFieldModel ) {
|
||||
this.formTabChanged.emit(field);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,28 +15,39 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
||||
|
||||
import {
|
||||
async, inject, TestBed
|
||||
} from '@angular/core/testing';
|
||||
|
||||
import {
|
||||
MockBackend,
|
||||
MockConnection
|
||||
} from '@angular/http/testing';
|
||||
|
||||
import {
|
||||
HttpModule,
|
||||
Http,
|
||||
XHRBackend,
|
||||
Response,
|
||||
ResponseOptions
|
||||
} from '@angular/http';
|
||||
import { WidgetVisibilityService } from './widget-visibility.service';
|
||||
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
import { HTTP_PROVIDERS } from '@angular/http';
|
||||
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
|
||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
|
||||
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
|
||||
import { FormModel, FormValues, FormFieldModel } from '../components/widgets/core/index';
|
||||
|
||||
declare let AlfrescoApi: any;
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('WidgetVisibilityService', () => {
|
||||
let service;
|
||||
//////// Tests /////////////
|
||||
describe('WidgetVisibilityService (mockBackend)', () => {
|
||||
let formTest = new FormModel({});
|
||||
let formValues: FormValues = { 'test_1': 'value_1', 'test_2': 'value_2', 'test_3': 'value_1' };
|
||||
let fakeTaskProcessVariableModels = [
|
||||
{id: 'TEST_VAR_1', type: 'string', value: 'test_value_1'},
|
||||
{id: 'TEST_VAR_2', type: 'string', value: 'test_value_2'},
|
||||
{id: 'TEST_VAR_3', type: 'string', value: 'test_value_3'}
|
||||
];
|
||||
|
||||
let formValues: FormValues = { 'test_1': 'value_1', 'test_2': 'value_2', 'test_3': 'value_1' };
|
||||
let fakeFormJson = {
|
||||
id: '9999',
|
||||
name: 'FORM_VISIBILITY',
|
||||
@ -87,44 +98,46 @@ describe('WidgetVisibilityService', () => {
|
||||
]
|
||||
};
|
||||
|
||||
beforeEachProviders(() => {
|
||||
return [
|
||||
HTTP_PROVIDERS,
|
||||
beforeEach( async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ HttpModule ],
|
||||
providers: [
|
||||
WidgetVisibilityService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoAuthenticationService,
|
||||
WidgetVisibilityService
|
||||
];
|
||||
});
|
||||
|
||||
beforeEach(
|
||||
inject([WidgetVisibilityService], (activitiService: WidgetVisibilityService) => {
|
||||
jasmine.Ajax.install();
|
||||
service = activitiService;
|
||||
{ provide: XHRBackend, useClass: MockBackend }
|
||||
]
|
||||
})
|
||||
);
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
it('can instantiate service when inject service',
|
||||
inject([WidgetVisibilityService], (service: WidgetVisibilityService) => {
|
||||
expect(service instanceof WidgetVisibilityService).toBe(true);
|
||||
}));
|
||||
|
||||
it('should return the process variables for task', (done) => {
|
||||
service.getTaskProcessVariableModelsForTask(9999).subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.length).toEqual(3);
|
||||
expect(res[0].id).toEqual('TEST_VAR_1');
|
||||
expect(res[0].type).toEqual('string');
|
||||
expect(res[0].value).toEqual('test_value_1');
|
||||
done();
|
||||
}
|
||||
);
|
||||
it('can instantiate service with "new"', inject([Http], (http: Http) => {
|
||||
expect(http).not.toBeNull('http should be provided');
|
||||
let service = new WidgetVisibilityService(http, null);
|
||||
expect(service instanceof WidgetVisibilityService).toBe(true, 'new service should be ok');
|
||||
}));
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeTaskProcessVariableModels)
|
||||
});
|
||||
});
|
||||
|
||||
it('can provide the mockBackend as XHRBackend',
|
||||
inject([XHRBackend], (backend: MockBackend) => {
|
||||
expect(backend).not.toBeNull('backend should be provided');
|
||||
}));
|
||||
|
||||
describe('when service is ready', () => {
|
||||
let backend: MockBackend;
|
||||
let service: WidgetVisibilityService;
|
||||
|
||||
beforeEach(inject([Http, XHRBackend, AlfrescoSettingsService],
|
||||
(http: Http,
|
||||
be: MockBackend,
|
||||
setting: AlfrescoSettingsService) => {
|
||||
backend = be;
|
||||
service = new WidgetVisibilityService(http, setting);
|
||||
}));
|
||||
|
||||
it('should evaluate logic operation for two values', () => {
|
||||
let res: boolean;
|
||||
@ -137,11 +150,11 @@ describe('WidgetVisibilityService', () => {
|
||||
|
||||
expect(res).toBeTruthy();
|
||||
|
||||
res = service.evaluateLogicalOperation( 'and not', true, false);
|
||||
res = service.evaluateLogicalOperation( 'and-not', true, false);
|
||||
|
||||
expect(res).toBeTruthy();
|
||||
|
||||
res = service.evaluateLogicalOperation( 'or not', true, true );
|
||||
res = service.evaluateLogicalOperation( 'or-not', true, true );
|
||||
|
||||
expect(res).toBeTruthy();
|
||||
|
||||
@ -153,11 +166,11 @@ describe('WidgetVisibilityService', () => {
|
||||
|
||||
expect(res).toBeFalsy();
|
||||
|
||||
res = service.evaluateLogicalOperation( 'and not', false, false );
|
||||
res = service.evaluateLogicalOperation( 'and-not', false, false );
|
||||
|
||||
expect(res).toBeFalsy();
|
||||
|
||||
res = service.evaluateLogicalOperation( 'or not', false, true );
|
||||
res = service.evaluateLogicalOperation( 'or-not', false, true );
|
||||
|
||||
expect(res).toBeFalsy();
|
||||
});
|
||||
@ -206,9 +219,32 @@ describe('WidgetVisibilityService', () => {
|
||||
expect(res).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return the process variables for task', (done) => {
|
||||
let options = new ResponseOptions({status: 200,
|
||||
body: fakeTaskProcessVariableModels });
|
||||
let response = new Response(options);
|
||||
backend.connections.subscribe((c: MockConnection) => c.mockRespond(response));
|
||||
|
||||
|
||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.length).toEqual(3);
|
||||
expect(res[0].id).toEqual('TEST_VAR_1');
|
||||
expect(res[0].type).toEqual('string');
|
||||
expect(res[0].value).toEqual('test_value_1');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should be able to retrieve the value of a process variable', (done) => {
|
||||
service.getTaskProcessVariableModelsForTask(9999).subscribe(
|
||||
let options = new ResponseOptions({status: 200,
|
||||
body: fakeTaskProcessVariableModels });
|
||||
let response = new Response(options);
|
||||
backend.connections.subscribe((c: MockConnection) => c.mockRespond(response));
|
||||
|
||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
expect(res).toBeDefined();
|
||||
let varValue = service.getValueFromVariable(formTest, 'TEST_VAR_1', res);
|
||||
@ -217,11 +253,6 @@ describe('WidgetVisibilityService', () => {
|
||||
done();
|
||||
}
|
||||
);
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeTaskProcessVariableModels)
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to retrieve the value of a form variable', () => {
|
||||
@ -236,25 +267,21 @@ describe('WidgetVisibilityService', () => {
|
||||
expect(varValue).toBe('form_value_test');
|
||||
});
|
||||
|
||||
|
||||
it('should return undefined if the variable does not exist', (done) => {
|
||||
service.getTaskProcessVariableModelsForTask(9999).subscribe(
|
||||
let options = new ResponseOptions({status: 200,
|
||||
body: fakeTaskProcessVariableModels });
|
||||
let response = new Response(options);
|
||||
backend.connections.subscribe((c: MockConnection) => c.mockRespond(response));
|
||||
|
||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
let varValue = service.getValueFromVariable(formTest, 'TEST_MYSTERY_VAR', res);
|
||||
expect(varValue).toBeUndefined();
|
||||
done();
|
||||
}
|
||||
);
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeTaskProcessVariableModels)
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should be able to retrieve a field value searching in the form', () => {
|
||||
let stubFormWithFields = new FormModel(fakeFormJson);
|
||||
let formValue = service.getFormValueByName(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
||||
@ -309,7 +336,12 @@ describe('WidgetVisibilityService', () => {
|
||||
});
|
||||
|
||||
it('should retrieve the value for the right field when it is a process variable', (done) => {
|
||||
service.getTaskProcessVariableModelsForTask(9999).subscribe(
|
||||
let options = new ResponseOptions({status: 200,
|
||||
body: fakeTaskProcessVariableModels });
|
||||
let response = new Response(options);
|
||||
backend.connections.subscribe((c: MockConnection) => c.mockRespond(response));
|
||||
|
||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
let visibilityObjTest = new WidgetVisibilityModel();
|
||||
visibilityObjTest.rightRestResponseId = 'TEST_VAR_2';
|
||||
@ -321,11 +353,6 @@ describe('WidgetVisibilityService', () => {
|
||||
done();
|
||||
}
|
||||
);
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeTaskProcessVariableModels)
|
||||
});
|
||||
});
|
||||
|
||||
it('should retrieve the value for the right field when it is a form variable', () => {
|
||||
@ -363,7 +390,12 @@ describe('WidgetVisibilityService', () => {
|
||||
});
|
||||
|
||||
it('should retrieve the value for the left field when it is a process variable', (done) => {
|
||||
service.getTaskProcessVariableModelsForTask(9999).subscribe(
|
||||
let options = new ResponseOptions({status: 200,
|
||||
body: fakeTaskProcessVariableModels });
|
||||
let response = new Response(options);
|
||||
backend.connections.subscribe((c: MockConnection) => c.mockRespond(response));
|
||||
|
||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
let visibilityObjTest = new WidgetVisibilityModel();
|
||||
visibilityObjTest.leftRestResponseId = 'TEST_VAR_2';
|
||||
@ -375,11 +407,6 @@ describe('WidgetVisibilityService', () => {
|
||||
done();
|
||||
}
|
||||
);
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeTaskProcessVariableModels)
|
||||
});
|
||||
});
|
||||
|
||||
it('should retrieve the value for the left field when it is a form variable', () => {
|
||||
@ -465,7 +492,12 @@ describe('WidgetVisibilityService', () => {
|
||||
});
|
||||
|
||||
it('should evaluate the visibility for the field between form value and process var', (done) => {
|
||||
service.getTaskProcessVariableModelsForTask(9999).subscribe(
|
||||
let options = new ResponseOptions({status: 200,
|
||||
body: fakeTaskProcessVariableModels });
|
||||
let response = new Response(options);
|
||||
backend.connections.subscribe((c: MockConnection) => c.mockRespond(response));
|
||||
|
||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
let fakeFormWithField = new FormModel(fakeFormJson);
|
||||
let visibilityObjTest = new WidgetVisibilityModel();
|
||||
@ -479,16 +511,15 @@ describe('WidgetVisibilityService', () => {
|
||||
done();
|
||||
}
|
||||
);
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeTaskProcessVariableModels)
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should evaluate visibility with multiple conditions', (done) => {
|
||||
service.getTaskProcessVariableModelsForTask(9999).subscribe(
|
||||
let options = new ResponseOptions({status: 200,
|
||||
body: fakeTaskProcessVariableModels });
|
||||
let response = new Response(options);
|
||||
backend.connections.subscribe((c: MockConnection) => c.mockRespond(response));
|
||||
|
||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
let fakeFormWithField = new FormModel(fakeFormJson);
|
||||
let visibilityObjTest = new WidgetVisibilityModel();
|
||||
@ -507,11 +538,6 @@ describe('WidgetVisibilityService', () => {
|
||||
done();
|
||||
}
|
||||
);
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeTaskProcessVariableModels)
|
||||
});
|
||||
});
|
||||
|
||||
it('should return true when the visibility condition is not valid', () => {
|
||||
@ -552,4 +578,4 @@ describe('WidgetVisibilityService', () => {
|
||||
expect(fakeFormField.isVisible).toBeFalsy();
|
||||
});
|
||||
});
|
||||
*/
|
||||
});
|
||||
|
@ -19,7 +19,7 @@ import { Injectable } from '@angular/core';
|
||||
import { Response, Http, Headers, RequestOptions } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { FormModel, FormFieldModel } from '../components/widgets/core/index';
|
||||
import { FormModel, FormFieldModel, TabModel } from '../components/widgets/core/index';
|
||||
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
|
||||
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
|
||||
|
||||
@ -33,6 +33,9 @@ export class WidgetVisibilityService {
|
||||
}
|
||||
|
||||
public updateVisibilityForForm(form: FormModel) {
|
||||
if ( form && form.tabs && form.tabs.length > 0) {
|
||||
form.tabs.map( tabModel => this.refreshVisibilityForTab(tabModel) );
|
||||
}
|
||||
if ( form && form.fields.length > 0 ) {
|
||||
form.fields
|
||||
.map(
|
||||
@ -55,16 +58,22 @@ export class WidgetVisibilityService {
|
||||
}
|
||||
}
|
||||
|
||||
public refreshVisibilityForTab(tab: TabModel) {
|
||||
if ( tab.visibilityCondition ) {
|
||||
tab.isVisible = this.getVisiblityForField(tab.form, tab.visibilityCondition);
|
||||
}
|
||||
}
|
||||
|
||||
public getVisiblityForField(form: FormModel, visibilityObj: WidgetVisibilityModel): boolean {
|
||||
let isLeftFieldPresent = visibilityObj.leftFormFieldId || visibilityObj.leftRestResponseId;
|
||||
if ( !isLeftFieldPresent ) {
|
||||
if ( !isLeftFieldPresent || isLeftFieldPresent === 'null' ) {
|
||||
return true;
|
||||
}else {
|
||||
return this.evaluateVisibilityForField(form, visibilityObj);
|
||||
}
|
||||
}
|
||||
|
||||
private evaluateVisibilityForField(form: FormModel, visibilityObj: WidgetVisibilityModel): boolean {
|
||||
evaluateVisibilityForField(form: FormModel, visibilityObj: WidgetVisibilityModel): boolean {
|
||||
let leftValue = this.getLeftValue(form, visibilityObj);
|
||||
let rightValue = this.getRightValue(form, visibilityObj);
|
||||
let actualResult = this.evaluateCondition(leftValue, rightValue, visibilityObj.operator);
|
||||
@ -79,14 +88,14 @@ export class WidgetVisibilityService {
|
||||
}
|
||||
}
|
||||
|
||||
private getLeftValue(form: FormModel, visibilityObj: WidgetVisibilityModel) {
|
||||
getLeftValue(form: FormModel, visibilityObj: WidgetVisibilityModel) {
|
||||
if ( visibilityObj.leftRestResponseId ) {
|
||||
return this.getValueFromVariable(form, visibilityObj.leftRestResponseId, this.processVarList);
|
||||
}
|
||||
return this.getValueOField(form, visibilityObj.leftFormFieldId);
|
||||
}
|
||||
|
||||
private getRightValue(form: FormModel, visibilityObj: WidgetVisibilityModel) {
|
||||
getRightValue(form: FormModel, visibilityObj: WidgetVisibilityModel) {
|
||||
let valueFound = null;
|
||||
if ( visibilityObj.rightRestResponseId ) {
|
||||
valueFound = this.getValueFromVariable(form, visibilityObj.rightRestResponseId, this.processVarList);
|
||||
@ -98,14 +107,14 @@ export class WidgetVisibilityService {
|
||||
return valueFound;
|
||||
}
|
||||
|
||||
private getValueOField(form: FormModel, field: string) {
|
||||
getValueOField(form: FormModel, field: string) {
|
||||
let value = form.values[field] ?
|
||||
form.values[field] :
|
||||
this.getFormValueByName(form, field);
|
||||
return value;
|
||||
}
|
||||
|
||||
private getFormValueByName(form: FormModel, name: string) {
|
||||
getFormValueByName(form: FormModel, name: string) {
|
||||
for (let columns of form.json.fields) {
|
||||
for ( let i in columns.fields ) {
|
||||
if ( columns.fields.hasOwnProperty( i ) ) {
|
||||
@ -118,7 +127,7 @@ export class WidgetVisibilityService {
|
||||
}
|
||||
}
|
||||
|
||||
private getValueFromVariable( form: FormModel, name: string, processVarList: TaskProcessVariableModel[] ) {
|
||||
getValueFromVariable( form: FormModel, name: string, processVarList: TaskProcessVariableModel[] ) {
|
||||
return this.getFormVariableValue(form, name) ||
|
||||
this.getProcessVariableValue(name, processVarList);
|
||||
}
|
||||
@ -141,30 +150,30 @@ export class WidgetVisibilityService {
|
||||
}
|
||||
}
|
||||
|
||||
private evaluateLogicalOperation(logicOp, previousValue, newValue): boolean {
|
||||
evaluateLogicalOperation(logicOp, previousValue, newValue): boolean {
|
||||
switch ( logicOp ) {
|
||||
case 'and':
|
||||
return previousValue && newValue;
|
||||
case 'or' :
|
||||
return previousValue || newValue;
|
||||
case 'and not':
|
||||
case 'and-not':
|
||||
return previousValue && !newValue;
|
||||
case 'or not':
|
||||
case 'or-not':
|
||||
return previousValue || !newValue;
|
||||
default:
|
||||
console.error( 'NO valid operation!' );
|
||||
console.error( 'NO valid operation! wrong op request : ' + logicOp );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private evaluateCondition(leftValue, rightValue, operator): boolean {
|
||||
evaluateCondition(leftValue, rightValue, operator): boolean {
|
||||
switch ( operator ) {
|
||||
case '==':
|
||||
return leftValue + '' === rightValue;
|
||||
return String(leftValue) === String(rightValue);
|
||||
case '<':
|
||||
return leftValue < rightValue;
|
||||
case '!=':
|
||||
return leftValue + '' !== rightValue;
|
||||
return String(leftValue) !== String(rightValue);
|
||||
case '>':
|
||||
return leftValue > rightValue;
|
||||
case '>=':
|
||||
|
Loading…
x
Reference in New Issue
Block a user