mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Improved naming and coverage
This commit is contained in:
@@ -34,7 +34,7 @@ describe('ActivitiForm', () => {
|
|||||||
'upgradeAllRegistered'
|
'upgradeAllRegistered'
|
||||||
]);
|
]);
|
||||||
visibilityService = jasmine.createSpyObj('WidgetVisibilityService', [
|
visibilityService = jasmine.createSpyObj('WidgetVisibilityService', [
|
||||||
'updateVisibilityForForm', 'getTaskProcessVariableModelsForTask'
|
'refreshVisibility', 'getTaskProcessVariable'
|
||||||
]);
|
]);
|
||||||
window['componentHandler'] = componentHandler;
|
window['componentHandler'] = componentHandler;
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ describe('ActivitiForm', () => {
|
|||||||
formComponent.loadForm();
|
formComponent.loadForm();
|
||||||
|
|
||||||
expect(formComponent.getFormByTaskId).toHaveBeenCalledWith(taskId);
|
expect(formComponent.getFormByTaskId).toHaveBeenCalledWith(taskId);
|
||||||
expect(visibilityService.getTaskProcessVariableModelsForTask).toHaveBeenCalledWith(taskId);
|
expect(visibilityService.getTaskProcessVariable).toHaveBeenCalledWith(taskId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get form definition by form id on load', () => {
|
it('should get form definition by form id on load', () => {
|
||||||
@@ -623,15 +623,15 @@ describe('ActivitiForm', () => {
|
|||||||
it('should check visibility only if field with form provided', () => {
|
it('should check visibility only if field with form provided', () => {
|
||||||
|
|
||||||
formComponent.checkVisibility(null);
|
formComponent.checkVisibility(null);
|
||||||
expect(visibilityService.updateVisibilityForForm).not.toHaveBeenCalled();
|
expect(visibilityService.refreshVisibility).not.toHaveBeenCalled();
|
||||||
|
|
||||||
let field = new FormFieldModel(null);
|
let field = new FormFieldModel(null);
|
||||||
formComponent.checkVisibility(field);
|
formComponent.checkVisibility(field);
|
||||||
expect(visibilityService.updateVisibilityForForm).not.toHaveBeenCalled();
|
expect(visibilityService.refreshVisibility).not.toHaveBeenCalled();
|
||||||
|
|
||||||
field = new FormFieldModel(new FormModel());
|
field = new FormFieldModel(new FormModel());
|
||||||
formComponent.checkVisibility(field);
|
formComponent.checkVisibility(field);
|
||||||
expect(visibilityService.updateVisibilityForForm).toHaveBeenCalledWith(field.form);
|
expect(visibilityService.refreshVisibility).toHaveBeenCalledWith(field.form);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -279,7 +279,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
loadForm() {
|
loadForm() {
|
||||||
if (this.taskId) {
|
if (this.taskId) {
|
||||||
this.getFormByTaskId(this.taskId);
|
this.getFormByTaskId(this.taskId);
|
||||||
this.visibilityService.getTaskProcessVariableModelsForTask(this.taskId);
|
this.visibilityService.getTaskProcessVariable(this.taskId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,7 +416,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
|
|
||||||
checkVisibility(field: FormFieldModel) {
|
checkVisibility(field: FormFieldModel) {
|
||||||
if (field && field.form) {
|
if (field && field.form) {
|
||||||
this.visibilityService.updateVisibilityForForm(field.form);
|
this.visibilityService.refreshVisibility(field.form);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,13 +52,23 @@ export var fakeFormJson = {
|
|||||||
numberOfColumns: 2,
|
numberOfColumns: 2,
|
||||||
fields: {
|
fields: {
|
||||||
1: [
|
1: [
|
||||||
|
{
|
||||||
|
fieldType: 'FormFieldRepresentation',
|
||||||
|
id: 'FIELD_TEST',
|
||||||
|
name: 'FIELD_TEST',
|
||||||
|
type: 'text',
|
||||||
|
value: 'RIGHT_FORM_FIELD_VALUE',
|
||||||
|
visibilityCondition: null,
|
||||||
|
isVisible: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldType: 'FormFieldRepresentation',
|
fieldType: 'FormFieldRepresentation',
|
||||||
id: 'FIELD_WITH_CONDITION',
|
id: 'FIELD_WITH_CONDITION',
|
||||||
name: 'FIELD_WITH_CONDITION',
|
name: 'FIELD_WITH_CONDITION',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
value: 'field_with_condition_value',
|
value: 'field_with_condition_value',
|
||||||
visibilityCondition: null
|
visibilityCondition: null,
|
||||||
|
isVisible: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldType: 'FormFieldRepresentation',
|
fieldType: 'FormFieldRepresentation',
|
||||||
@@ -66,7 +76,8 @@ export var fakeFormJson = {
|
|||||||
name: 'LEFT_FORM_FIELD_NAME',
|
name: 'LEFT_FORM_FIELD_NAME',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
value: 'LEFT_FORM_FIELD_VALUE',
|
value: 'LEFT_FORM_FIELD_VALUE',
|
||||||
visibilityCondition: null
|
visibilityCondition: null,
|
||||||
|
isVisible: true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
2: [
|
2: [
|
||||||
@@ -76,7 +87,8 @@ export var fakeFormJson = {
|
|||||||
name: 'RIGHT_FORM_FIELD_NAME',
|
name: 'RIGHT_FORM_FIELD_NAME',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
value: 'RIGHT_FORM_FIELD_VALUE',
|
value: 'RIGHT_FORM_FIELD_VALUE',
|
||||||
visibilityCondition: null
|
visibilityCondition: null,
|
||||||
|
isVisible: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ import {
|
|||||||
fakeFormJson
|
fakeFormJson
|
||||||
} from './assets/widget-visibility.service.mock';
|
} from './assets/widget-visibility.service.mock';
|
||||||
import { WidgetVisibilityService } from './widget-visibility.service';
|
import { WidgetVisibilityService } from './widget-visibility.service';
|
||||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
|
import { AlfrescoSettingsService, AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
|
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
|
||||||
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
|
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
|
||||||
import { FormModel, FormFieldModel } from '../components/widgets/core/index';
|
import { FormModel, FormFieldModel } from '../components/widgets/core/index';
|
||||||
@@ -41,6 +41,8 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
imports: [HttpModule],
|
imports: [HttpModule],
|
||||||
providers: [
|
providers: [
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoApiService,
|
||||||
WidgetVisibilityService
|
WidgetVisibilityService
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -96,6 +98,11 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
booleanResult = service.evaluateLogicalOperation('or-not', false, true);
|
booleanResult = service.evaluateLogicalOperation('or-not', false, true);
|
||||||
expect(booleanResult).toBeFalsy();
|
expect(booleanResult).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should fail with invalid operation', () => {
|
||||||
|
booleanResult = service.evaluateLogicalOperation(undefined, false, true);
|
||||||
|
expect(booleanResult).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('should be able to evaluate next condition operations', () => {
|
describe('should be able to evaluate next condition operations', () => {
|
||||||
@@ -135,6 +142,11 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
expect(booleanResult).toBeTruthy();
|
expect(booleanResult).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('using empty with empty string value and return false', () => {
|
||||||
|
booleanResult = service.evaluateCondition('fake_value', undefined, 'empty');
|
||||||
|
expect(booleanResult).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
it('using > and return false', () => {
|
it('using > and return false', () => {
|
||||||
booleanResult = service.evaluateCondition(2, 3, '>');
|
booleanResult = service.evaluateCondition(2, 3, '>');
|
||||||
expect(booleanResult).toBeFalsy();
|
expect(booleanResult).toBeFalsy();
|
||||||
@@ -149,6 +161,26 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
booleanResult = service.evaluateCondition('', '', '!empty');
|
booleanResult = service.evaluateCondition('', '', '!empty');
|
||||||
expect(booleanResult).toBeFalsy();
|
expect(booleanResult).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('using <= and return false', () => {
|
||||||
|
booleanResult = service.evaluateCondition(2, 1, '<=');
|
||||||
|
expect(booleanResult).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('using <= and return true for different values', () => {
|
||||||
|
booleanResult = service.evaluateCondition(1, 2, '<=');
|
||||||
|
expect(booleanResult).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('using <= and return true for same values', () => {
|
||||||
|
booleanResult = service.evaluateCondition(2, 2, '<=');
|
||||||
|
expect(booleanResult).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return undefined for invalid operation', () => {
|
||||||
|
booleanResult = service.evaluateCondition(null, null, undefined);
|
||||||
|
expect(booleanResult).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('should retrive the process variables', () => {
|
describe('should retrive the process variables', () => {
|
||||||
@@ -161,7 +193,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return the process variables for task', (done) => {
|
it('should return the process variables for task', (done) => {
|
||||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
service.getTaskProcessVariable('9999').subscribe(
|
||||||
(res: TaskProcessVariableModel[]) => {
|
(res: TaskProcessVariableModel[]) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res.length).toEqual(3);
|
expect(res.length).toEqual(3);
|
||||||
@@ -179,10 +211,10 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to retrieve the value of a process variable', (done) => {
|
it('should be able to retrieve the value of a process variable', (done) => {
|
||||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
service.getTaskProcessVariable('9999').subscribe(
|
||||||
(res: TaskProcessVariableModel[]) => {
|
(res: TaskProcessVariableModel[]) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
let varValue = service.getValueFromVariable(formTest, 'TEST_VAR_1', res);
|
let varValue = service.getVariableValue(formTest, 'TEST_VAR_1', res);
|
||||||
expect(varValue).not.toBeUndefined();
|
expect(varValue).not.toBeUndefined();
|
||||||
expect(varValue).toBe('test_value_1');
|
expect(varValue).toBe('test_value_1');
|
||||||
done();
|
done();
|
||||||
@@ -196,9 +228,9 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return undefined if the variable does not exist', (done) => {
|
it('should return undefined if the variable does not exist', (done) => {
|
||||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
service.getTaskProcessVariable('9999').subscribe(
|
||||||
(res: TaskProcessVariableModel[]) => {
|
(res: TaskProcessVariableModel[]) => {
|
||||||
let varValue = service.getValueFromVariable(formTest, 'TEST_MYSTERY_VAR', res);
|
let varValue = service.getVariableValue(formTest, 'TEST_MYSTERY_VAR', res);
|
||||||
expect(varValue).toBeUndefined();
|
expect(varValue).toBeUndefined();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@@ -211,7 +243,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should retrieve the value for the right field when it is a process variable', (done) => {
|
it('should retrieve the value for the right field when it is a process variable', (done) => {
|
||||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
service.getTaskProcessVariable('9999').subscribe(
|
||||||
(res: TaskProcessVariableModel[]) => {
|
(res: TaskProcessVariableModel[]) => {
|
||||||
visibilityObjTest.rightRestResponseId = 'TEST_VAR_2';
|
visibilityObjTest.rightRestResponseId = 'TEST_VAR_2';
|
||||||
let rightValue = service.getRightValue(formTest, visibilityObjTest);
|
let rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
@@ -229,7 +261,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should retrieve the value for the left field when it is a process variable', (done) => {
|
it('should retrieve the value for the left field when it is a process variable', (done) => {
|
||||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
service.getTaskProcessVariable('9999').subscribe(
|
||||||
(res: TaskProcessVariableModel[]) => {
|
(res: TaskProcessVariableModel[]) => {
|
||||||
visibilityObjTest.leftRestResponseId = 'TEST_VAR_2';
|
visibilityObjTest.leftRestResponseId = 'TEST_VAR_2';
|
||||||
let rightValue = service.getLeftValue(formTest, visibilityObjTest);
|
let rightValue = service.getLeftValue(formTest, visibilityObjTest);
|
||||||
@@ -247,12 +279,12 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should evaluate the visibility for the field between form value and process var', (done) => {
|
it('should evaluate the visibility for the field between form value and process var', (done) => {
|
||||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
service.getTaskProcessVariable('9999').subscribe(
|
||||||
(res: TaskProcessVariableModel[]) => {
|
(res: TaskProcessVariableModel[]) => {
|
||||||
visibilityObjTest.leftFormFieldId = 'LEFT_FORM_FIELD_ID';
|
visibilityObjTest.leftFormFieldId = 'LEFT_FORM_FIELD_ID';
|
||||||
visibilityObjTest.operator = '!=';
|
visibilityObjTest.operator = '!=';
|
||||||
visibilityObjTest.rightRestResponseId = 'TEST_VAR_2';
|
visibilityObjTest.rightRestResponseId = 'TEST_VAR_2';
|
||||||
let isVisible = service.evaluateVisibilityForField(fakeFormWithField, visibilityObjTest);
|
let isVisible = service.isFieldVisible(fakeFormWithField, visibilityObjTest);
|
||||||
|
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
done();
|
done();
|
||||||
@@ -266,7 +298,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should evaluate visibility with multiple conditions', (done) => {
|
it('should evaluate visibility with multiple conditions', (done) => {
|
||||||
service.getTaskProcessVariableModelsForTask('9999').subscribe(
|
service.getTaskProcessVariable('9999').subscribe(
|
||||||
(res: TaskProcessVariableModel[]) => {
|
(res: TaskProcessVariableModel[]) => {
|
||||||
visibilityObjTest.leftFormFieldId = 'LEFT_FORM_FIELD_ID';
|
visibilityObjTest.leftFormFieldId = 'LEFT_FORM_FIELD_ID';
|
||||||
visibilityObjTest.operator = '!=';
|
visibilityObjTest.operator = '!=';
|
||||||
@@ -276,7 +308,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
chainedVisibilityObj.operator = '!empty';
|
chainedVisibilityObj.operator = '!empty';
|
||||||
visibilityObjTest.nextCondition = chainedVisibilityObj;
|
visibilityObjTest.nextCondition = chainedVisibilityObj;
|
||||||
|
|
||||||
let isVisible = service.evaluateVisibilityForField(fakeFormWithField, visibilityObjTest);
|
let isVisible = service.isFieldVisible(fakeFormWithField, visibilityObjTest);
|
||||||
|
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
done();
|
done();
|
||||||
@@ -314,27 +346,27 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to retrieve a field value searching in the form', () => {
|
it('should be able to retrieve a field value searching in the form', () => {
|
||||||
let formValue = service.getFormValueByName(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
let formValue = service.searchForm(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
||||||
|
|
||||||
expect(formValue).not.toBeNull();
|
expect(formValue).not.toBeNull();
|
||||||
expect(formValue).toBe('field_with_condition_value');
|
expect(formValue).toBe('field_with_condition_value');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return undefined if the field value is not in the form', () => {
|
it('should return undefined if the field value is not in the form', () => {
|
||||||
let formValue = service.getFormValueByName(stubFormWithFields, 'FIELD_MYSTERY');
|
let formValue = service.searchForm(stubFormWithFields, 'FIELD_MYSTERY');
|
||||||
|
|
||||||
expect(formValue).toBeUndefined();
|
expect(formValue).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should search in the form if element value is not in form values', () => {
|
it('should search in the form if element value is not in form values', () => {
|
||||||
let value = service.getFieldValueFromForm(fakeFormWithField, 'FIELD_WITH_CONDITION');
|
let value = service.getFormValue(fakeFormWithField, 'FIELD_WITH_CONDITION');
|
||||||
|
|
||||||
expect(value).not.toBeNull();
|
expect(value).not.toBeNull();
|
||||||
expect(value).toBe('field_with_condition_value');
|
expect(value).toBe('field_with_condition_value');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return undefined if the element is not present anywhere', () => {
|
it('should return undefined if the element is not present anywhere', () => {
|
||||||
let formValue = service.getFieldValueFromForm(fakeFormWithField, 'FIELD_MYSTERY');
|
let formValue = service.getFormValue(fakeFormWithField, 'FIELD_MYSTERY');
|
||||||
|
|
||||||
expect(formValue).toBeUndefined();
|
expect(formValue).toBeUndefined();
|
||||||
});
|
});
|
||||||
@@ -355,7 +387,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should take the value from form values if it is present', () => {
|
it('should take the value from form values if it is present', () => {
|
||||||
let formValue = service.getFieldValueFromForm(formTest, 'test_1');
|
let formValue = service.getFormValue(formTest, 'test_1');
|
||||||
|
|
||||||
expect(formValue).not.toBeNull();
|
expect(formValue).not.toBeNull();
|
||||||
expect(formValue).toBe('value_1');
|
expect(formValue).toBe('value_1');
|
||||||
@@ -396,7 +428,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
visibilityObjTest.leftFormFieldId = 'test_1';
|
visibilityObjTest.leftFormFieldId = 'test_1';
|
||||||
visibilityObjTest.operator = '==';
|
visibilityObjTest.operator = '==';
|
||||||
visibilityObjTest.rightFormFieldId = 'test_3';
|
visibilityObjTest.rightFormFieldId = 'test_3';
|
||||||
let isVisible = service.evaluateVisibilityForField(formTest, visibilityObjTest);
|
let isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
});
|
});
|
||||||
@@ -405,7 +437,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
visibilityObjTest.leftFormFieldId = 'test_1';
|
visibilityObjTest.leftFormFieldId = 'test_1';
|
||||||
visibilityObjTest.operator = '==';
|
visibilityObjTest.operator = '==';
|
||||||
visibilityObjTest.rightValue = 'value_1';
|
visibilityObjTest.rightValue = 'value_1';
|
||||||
let isVisible = service.evaluateVisibilityForField(formTest, visibilityObjTest);
|
let isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
});
|
});
|
||||||
@@ -421,7 +453,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
visibilityObjTest.leftFormFieldId = 'LEFT_FORM_FIELD_ID';
|
visibilityObjTest.leftFormFieldId = 'LEFT_FORM_FIELD_ID';
|
||||||
visibilityObjTest.operator = '!=';
|
visibilityObjTest.operator = '!=';
|
||||||
visibilityObjTest.rightFormFieldId = 'RIGHT_FORM_FIELD_ID';
|
visibilityObjTest.rightFormFieldId = 'RIGHT_FORM_FIELD_ID';
|
||||||
let isVisible = service.evaluateVisibilityForField(fakeFormWithField, visibilityObjTest);
|
let isVisible = service.isFieldVisible(fakeFormWithField, visibilityObjTest);
|
||||||
|
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
});
|
});
|
||||||
@@ -431,7 +463,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
visibilityObjTest.operator = '!=';
|
visibilityObjTest.operator = '!=';
|
||||||
visibilityObjTest.rightFormFieldId = 'test_3';
|
visibilityObjTest.rightFormFieldId = 'test_3';
|
||||||
let fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
let fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
||||||
service.refreshVisibilityForField(fakeFormField);
|
service.refreshFieldVisibility(fakeFormField);
|
||||||
|
|
||||||
expect(fakeFormField.isVisible).toBeFalsy();
|
expect(fakeFormField.isVisible).toBeFalsy();
|
||||||
});
|
});
|
||||||
@@ -440,7 +472,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
visibilityObjTest.leftFormFieldId = '';
|
visibilityObjTest.leftFormFieldId = '';
|
||||||
visibilityObjTest.leftRestResponseId = '';
|
visibilityObjTest.leftRestResponseId = '';
|
||||||
visibilityObjTest.operator = '!=';
|
visibilityObjTest.operator = '!=';
|
||||||
let isVisible = service.getVisiblityForField(formTest, visibilityObjTest);
|
let isVisible = service.evaluateVisibility(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
});
|
});
|
||||||
@@ -449,18 +481,24 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
jsonFieldFake.visibilityCondition = null;
|
jsonFieldFake.visibilityCondition = null;
|
||||||
let fakeFormField: FormFieldModel = new FormFieldModel(fakeFormWithField, jsonFieldFake);
|
let fakeFormField: FormFieldModel = new FormFieldModel(fakeFormWithField, jsonFieldFake);
|
||||||
fakeFormField.isVisible = false;
|
fakeFormField.isVisible = false;
|
||||||
service.refreshVisibilityForField(fakeFormField);
|
service.refreshFieldVisibility(fakeFormField);
|
||||||
|
|
||||||
expect(fakeFormField.isVisible).toBeFalsy();
|
expect(fakeFormField.isVisible).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to retrieve the value of a form variable', () => {
|
it('should be able to retrieve the value of a form variable', () => {
|
||||||
let varValue = service.getValueFromVariable(fakeForm, 'FORM_VARIABLE_TEST', null);
|
let varValue = service.getVariableValue(fakeForm, 'FORM_VARIABLE_TEST', null);
|
||||||
|
|
||||||
expect(varValue).not.toBeUndefined();
|
expect(varValue).not.toBeUndefined();
|
||||||
expect(varValue).toBe('form_value_test');
|
expect(varValue).toBe('form_value_test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return undefined for not existing form variable', () => {
|
||||||
|
let varValue = service.getVariableValue(fakeForm, 'MISTERY_FORM_VARIABLE', null);
|
||||||
|
|
||||||
|
expect(varValue).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
it('should retrieve the value for the left field when it is a form variable', () => {
|
it('should retrieve the value for the left field when it is a form variable', () => {
|
||||||
visibilityObjTest.leftRestResponseId = 'FORM_VARIABLE_TEST';
|
visibilityObjTest.leftRestResponseId = 'FORM_VARIABLE_TEST';
|
||||||
let leftValue = service.getLeftValue(fakeForm, visibilityObjTest);
|
let leftValue = service.getLeftValue(fakeForm, visibilityObjTest);
|
||||||
@@ -470,7 +508,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should determine visibility for dropdown on label condition', () => {
|
it('should determine visibility for dropdown on label condition', () => {
|
||||||
let dropdownValue = service.getDropDownValueForLabel(formTest.values, 'dropdown_LABEL');
|
let dropdownValue = service.getDropDownName(formTest.values, 'dropdown_LABEL');
|
||||||
|
|
||||||
expect(dropdownValue).not.toBeNull();
|
expect(dropdownValue).not.toBeNull();
|
||||||
expect(dropdownValue).toBeDefined();
|
expect(dropdownValue).toBeDefined();
|
||||||
@@ -478,7 +516,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to get the value for a dropdown filtered with Label', () => {
|
it('should be able to get the value for a dropdown filtered with Label', () => {
|
||||||
let dropdownValue = service.getValueFromFormValues(formTest.values, 'dropdown_LABEL');
|
let dropdownValue = service.getValue(formTest.values, 'dropdown_LABEL');
|
||||||
|
|
||||||
expect(dropdownValue).not.toBeNull();
|
expect(dropdownValue).not.toBeNull();
|
||||||
expect(dropdownValue).toBeDefined();
|
expect(dropdownValue).toBeDefined();
|
||||||
@@ -486,7 +524,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to get the value for a standard field', () => {
|
it('should be able to get the value for a standard field', () => {
|
||||||
let dropdownValue = service.getValueFromFormValues(formTest.values, 'test_2');
|
let dropdownValue = service.getValue(formTest.values, 'test_2');
|
||||||
|
|
||||||
expect(dropdownValue).not.toBeNull();
|
expect(dropdownValue).not.toBeNull();
|
||||||
expect(dropdownValue).toBeDefined();
|
expect(dropdownValue).toBeDefined();
|
||||||
@@ -494,7 +532,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get the dropdown label value from a form', () => {
|
it('should get the dropdown label value from a form', () => {
|
||||||
let dropdownValue = service.getFieldValueFromForm(formTest, 'dropdown_LABEL');
|
let dropdownValue = service.getFormValue(formTest, 'dropdown_LABEL');
|
||||||
|
|
||||||
expect(dropdownValue).not.toBeNull();
|
expect(dropdownValue).not.toBeNull();
|
||||||
expect(dropdownValue).toBeDefined();
|
expect(dropdownValue).toBeDefined();
|
||||||
@@ -502,7 +540,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get the dropdown id value from a form', () => {
|
it('should get the dropdown id value from a form', () => {
|
||||||
let dropdownValue = service.getFieldValueFromForm(formTest, 'dropdown');
|
let dropdownValue = service.getFormValue(formTest, 'dropdown');
|
||||||
|
|
||||||
expect(dropdownValue).not.toBeNull();
|
expect(dropdownValue).not.toBeNull();
|
||||||
expect(dropdownValue).toBeDefined();
|
expect(dropdownValue).toBeDefined();
|
||||||
@@ -530,7 +568,7 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
visibilityObjTest.operator = '==';
|
visibilityObjTest.operator = '==';
|
||||||
visibilityObjTest.rightFormFieldId = 'dropdown_LABEL';
|
visibilityObjTest.rightFormFieldId = 'dropdown_LABEL';
|
||||||
let fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
let fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
||||||
service.refreshVisibilityForField(fakeFormField);
|
service.refreshFieldVisibility(fakeFormField);
|
||||||
|
|
||||||
expect(fakeFormField.isVisible).toBeTruthy();
|
expect(fakeFormField.isVisible).toBeTruthy();
|
||||||
});
|
});
|
||||||
@@ -540,17 +578,48 @@ describe('WidgetVisibilityService (mockBackend)', () => {
|
|||||||
visibilityObjTest.operator = '==';
|
visibilityObjTest.operator = '==';
|
||||||
visibilityObjTest.rightFormFieldId = 'dropdown';
|
visibilityObjTest.rightFormFieldId = 'dropdown';
|
||||||
let fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
let fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
||||||
service.refreshVisibilityForField(fakeFormField);
|
service.refreshFieldVisibility(fakeFormField);
|
||||||
|
|
||||||
expect(fakeFormField.isVisible).toBeTruthy();
|
expect(fakeFormField.isVisible).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to get value from form values', () => {
|
it('should be able to get value from form values', () => {
|
||||||
let res = service.getFieldValueFromForm(formTest, 'test_1');
|
let res = service.getFormValue(formTest, 'test_1');
|
||||||
|
|
||||||
expect(res).not.toBeNull();
|
expect(res).not.toBeNull();
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res).toBe('value_1');
|
expect(res).toBe('value_1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not refresh visibility if the form is undefined', () => {
|
||||||
|
spyOn(service, 'refreshFieldVisibility');
|
||||||
|
spyOn(service, 'refreshTabVisibility');
|
||||||
|
service.refreshVisibility(undefined);
|
||||||
|
|
||||||
|
expect(service.refreshFieldVisibility).not.toHaveBeenCalled();
|
||||||
|
expect(service.refreshTabVisibility).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not refresh visibility if the form does not have fields or tabs', () => {
|
||||||
|
spyOn(service, 'refreshFieldVisibility');
|
||||||
|
spyOn(service, 'refreshTabVisibility');
|
||||||
|
service.refreshVisibility(formTest);
|
||||||
|
|
||||||
|
expect(service.refreshFieldVisibility).not.toHaveBeenCalled();
|
||||||
|
expect(service.refreshTabVisibility).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should refresh the visibility for field', () => {
|
||||||
|
visibilityObjTest.leftFormFieldId = 'FIELD_TEST';
|
||||||
|
visibilityObjTest.operator = '!=';
|
||||||
|
visibilityObjTest.rightFormFieldId = 'RIGHT_FORM_FIELD_ID';
|
||||||
|
fakeFormWithField.fields[0].columns[0].fields[0].visibilityCondition = visibilityObjTest;
|
||||||
|
service.refreshVisibility(fakeFormWithField);
|
||||||
|
|
||||||
|
expect(fakeFormWithField.fields[0].columns[0].fields[0].isVisible).toBeFalsy();
|
||||||
|
expect(fakeFormWithField.fields[0].columns[0].fields[1].isVisible).toBeTruthy();
|
||||||
|
expect(fakeFormWithField.fields[0].columns[0].fields[2].isVisible).toBeTruthy();
|
||||||
|
expect(fakeFormWithField.fields[0].columns[1].fields[0].isVisible).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Response, Http, Headers, RequestOptions } from '@angular/http';
|
import { Response, Http, Headers, RequestOptions } from '@angular/http';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
import {AlfrescoSettingsService} from 'ng2-alfresco-core';
|
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||||
import { FormModel, FormFieldModel, TabModel } from '../components/widgets/core/index';
|
import { FormModel, FormFieldModel, TabModel } from '../components/widgets/core/index';
|
||||||
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
|
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
|
||||||
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
|
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
|
||||||
@@ -29,59 +29,51 @@ export class WidgetVisibilityService {
|
|||||||
private processVarList: TaskProcessVariableModel[];
|
private processVarList: TaskProcessVariableModel[];
|
||||||
|
|
||||||
constructor(private http: Http,
|
constructor(private http: Http,
|
||||||
private alfrescoSettingsService: AlfrescoSettingsService) {
|
private alfrescoSettingsService: AlfrescoSettingsService,
|
||||||
|
private authService: AlfrescoAuthenticationService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateVisibilityForForm(form: FormModel) {
|
public refreshVisibility(form: FormModel) {
|
||||||
if (form && form.tabs && form.tabs.length > 0) {
|
if (form && form.tabs && form.tabs.length > 0) {
|
||||||
form.tabs.map(tabModel => this.refreshVisibilityForTab(tabModel));
|
form.tabs.map(tabModel => this.refreshTabVisibility(tabModel));
|
||||||
}
|
}
|
||||||
if (form && form.fields.length > 0) {
|
if (form && form.fields.length > 0) {
|
||||||
form.fields
|
form.fields.map(contModel =>
|
||||||
.map(
|
contModel.columns.map(contColModel =>
|
||||||
contModel =>
|
contColModel.fields.map(field => this.refreshFieldVisibility(field))));
|
||||||
contModel.columns
|
|
||||||
.map(
|
|
||||||
contColModel =>
|
|
||||||
contColModel
|
|
||||||
.fields.map(
|
|
||||||
field =>
|
|
||||||
this.refreshVisibilityForField(field))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshVisibilityForField(field: FormFieldModel) {
|
refreshFieldVisibility(field: FormFieldModel) {
|
||||||
if (field.visibilityCondition) {
|
if (field.visibilityCondition) {
|
||||||
field.isVisible = this.getVisiblityForField(field.form, field.visibilityCondition);
|
field.isVisible = this.evaluateVisibility(field.form, field.visibilityCondition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshVisibilityForTab(tab: TabModel) {
|
refreshTabVisibility(tab: TabModel) {
|
||||||
if (tab.visibilityCondition) {
|
if (tab.visibilityCondition) {
|
||||||
tab.isVisible = this.getVisiblityForField(tab.form, tab.visibilityCondition);
|
tab.isVisible = this.evaluateVisibility(tab.form, tab.visibilityCondition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getVisiblityForField(form: FormModel, visibilityObj: WidgetVisibilityModel): boolean {
|
evaluateVisibility(form: FormModel, visibilityObj: WidgetVisibilityModel): boolean {
|
||||||
let isLeftFieldPresent = visibilityObj.leftFormFieldId || visibilityObj.leftRestResponseId;
|
let isLeftFieldPresent = visibilityObj.leftFormFieldId || visibilityObj.leftRestResponseId;
|
||||||
if (!isLeftFieldPresent || isLeftFieldPresent === 'null') {
|
if (!isLeftFieldPresent || isLeftFieldPresent === 'null') {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return this.evaluateVisibilityForField(form, visibilityObj);
|
return this.isFieldVisible(form, visibilityObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluateVisibilityForField(form: FormModel, visibilityObj: WidgetVisibilityModel): boolean {
|
isFieldVisible(form: FormModel, visibilityObj: WidgetVisibilityModel): boolean {
|
||||||
let leftValue = this.getLeftValue(form, visibilityObj);
|
let leftValue = this.getLeftValue(form, visibilityObj);
|
||||||
let rightValue = this.getRightValue(form, visibilityObj);
|
let rightValue = this.getRightValue(form, visibilityObj);
|
||||||
let actualResult = this.evaluateCondition(leftValue, rightValue, visibilityObj.operator);
|
let actualResult = this.evaluateCondition(leftValue, rightValue, visibilityObj.operator);
|
||||||
if (visibilityObj.nextCondition) {
|
if (visibilityObj.nextCondition) {
|
||||||
return this.evaluateLogicalOperation(visibilityObj.nextConditionOperator,
|
return this.evaluateLogicalOperation(
|
||||||
|
visibilityObj.nextConditionOperator,
|
||||||
actualResult,
|
actualResult,
|
||||||
this.evaluateVisibilityForField(
|
this.isFieldVisible(form, visibilityObj.nextCondition)
|
||||||
form, visibilityObj.nextCondition)
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return actualResult;
|
return actualResult;
|
||||||
@@ -90,39 +82,39 @@ export class WidgetVisibilityService {
|
|||||||
|
|
||||||
getLeftValue(form: FormModel, visibilityObj: WidgetVisibilityModel) {
|
getLeftValue(form: FormModel, visibilityObj: WidgetVisibilityModel) {
|
||||||
if (visibilityObj.leftRestResponseId) {
|
if (visibilityObj.leftRestResponseId) {
|
||||||
return this.getValueFromVariable(form, visibilityObj.leftRestResponseId, this.processVarList);
|
return this.getVariableValue(form, visibilityObj.leftRestResponseId, this.processVarList);
|
||||||
}
|
}
|
||||||
return this.getFieldValueFromForm(form, visibilityObj.leftFormFieldId);
|
return this.getFormValue(form, visibilityObj.leftFormFieldId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getRightValue(form: FormModel, visibilityObj: WidgetVisibilityModel) {
|
getRightValue(form: FormModel, visibilityObj: WidgetVisibilityModel) {
|
||||||
let valueFound = null;
|
let valueFound = null;
|
||||||
if (visibilityObj.rightRestResponseId) {
|
if (visibilityObj.rightRestResponseId) {
|
||||||
valueFound = this.getValueFromVariable(form, visibilityObj.rightRestResponseId, this.processVarList);
|
valueFound = this.getVariableValue(form, visibilityObj.rightRestResponseId, this.processVarList);
|
||||||
} else if (visibilityObj.rightFormFieldId) {
|
} else if (visibilityObj.rightFormFieldId) {
|
||||||
valueFound = this.getFieldValueFromForm(form, visibilityObj.rightFormFieldId);
|
valueFound = this.getFormValue(form, visibilityObj.rightFormFieldId);
|
||||||
} else {
|
} else {
|
||||||
valueFound = visibilityObj.rightValue;
|
valueFound = visibilityObj.rightValue;
|
||||||
}
|
}
|
||||||
return valueFound;
|
return valueFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFieldValueFromForm(form: FormModel, field: string) {
|
getFormValue(form: FormModel, field: string) {
|
||||||
let value = this.getValueFromFormValues(form.values, field);
|
let value = this.getValue(form.values, field);
|
||||||
value = value && value.id ? value.id : value;
|
value = value && value.id ? value.id : value;
|
||||||
return value ? value : this.getFormValueByName(form, field);
|
return value ? value : this.searchForm(form, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
getValueFromFormValues(values: any, fieldName: string) {
|
getValue(values: any, fieldName: string) {
|
||||||
return this.getFieldValue(values, fieldName) ||
|
return this.getFieldValue(values, fieldName) ||
|
||||||
this.getDropDownValueForLabel(values, fieldName);
|
this.getDropDownName(values, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFieldValue(valueList: any, fieldName: string) {
|
getFieldValue(valueList: any, fieldName: string) {
|
||||||
return fieldName ? valueList[fieldName] : fieldName;
|
return fieldName ? valueList[fieldName] : fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDropDownValueForLabel(valueList: any, fieldName: string) {
|
getDropDownName(valueList: any, fieldName: string) {
|
||||||
let dropDownFilterByName;
|
let dropDownFilterByName;
|
||||||
if (fieldName && fieldName.indexOf('_LABEL') > 0) {
|
if (fieldName && fieldName.indexOf('_LABEL') > 0) {
|
||||||
dropDownFilterByName = fieldName.substring(0, fieldName.length - 6);
|
dropDownFilterByName = fieldName.substring(0, fieldName.length - 6);
|
||||||
@@ -131,7 +123,7 @@ export class WidgetVisibilityService {
|
|||||||
valueList[dropDownFilterByName].name : dropDownFilterByName;
|
valueList[dropDownFilterByName].name : dropDownFilterByName;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFormValueByName(form: FormModel, name: string) {
|
searchForm(form: FormModel, name: string) {
|
||||||
for (let columns of form.json.fields) {
|
for (let columns of form.json.fields) {
|
||||||
for (let i in columns.fields) {
|
for (let i in columns.fields) {
|
||||||
if (columns.fields.hasOwnProperty(i)) {
|
if (columns.fields.hasOwnProperty(i)) {
|
||||||
@@ -144,26 +136,22 @@ export class WidgetVisibilityService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getValueFromVariable(form: FormModel, name: string, processVarList: TaskProcessVariableModel[]) {
|
getVariableValue(form: FormModel, name: string, processVarList: TaskProcessVariableModel[]) {
|
||||||
return this.getFormVariableValue(form, name) ||
|
return this.getFormVariableValue(form, name) ||
|
||||||
this.getProcessVariableValue(name, processVarList);
|
this.getProcessVariableValue(name, processVarList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getFormVariableValue(form: FormModel, name: string) {
|
private getFormVariableValue(form: FormModel, name: string) {
|
||||||
if (form.json.variables) {
|
if (form.json.variables) {
|
||||||
let variableFromForm = form.json.variables.find(formVar => formVar.name === name);
|
let formVariable = form.json.variables.find(formVar => formVar.name === name);
|
||||||
if (variableFromForm) {
|
return formVariable ? formVariable.value : formVariable;
|
||||||
return variableFromForm ? variableFromForm.value : variableFromForm;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getProcessVariableValue(name: string, processVarList: TaskProcessVariableModel[]) {
|
private getProcessVariableValue(name: string, processVarList: TaskProcessVariableModel[]) {
|
||||||
if (this.processVarList) {
|
if (this.processVarList) {
|
||||||
let variableFromProcess = this.processVarList.find(variable => variable.id === name);
|
let processVariable = this.processVarList.find(variable => variable.id === name);
|
||||||
if (variableFromProcess) {
|
return processVariable ? processVariable.value : processVariable;
|
||||||
return variableFromProcess ? variableFromProcess.value : variableFromProcess;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,11 +174,11 @@ export class WidgetVisibilityService {
|
|||||||
evaluateCondition(leftValue, rightValue, operator): boolean {
|
evaluateCondition(leftValue, rightValue, operator): boolean {
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case '==':
|
case '==':
|
||||||
return String(leftValue) === String(rightValue);
|
return leftValue + '' === rightValue + '';
|
||||||
case '<':
|
case '<':
|
||||||
return leftValue < rightValue;
|
return leftValue < rightValue;
|
||||||
case '!=':
|
case '!=':
|
||||||
return String(leftValue) !== String(rightValue);
|
return leftValue + '' !== rightValue + '';
|
||||||
case '>':
|
case '>':
|
||||||
return leftValue > rightValue;
|
return leftValue > rightValue;
|
||||||
case '>=':
|
case '>=':
|
||||||
@@ -208,7 +196,7 @@ export class WidgetVisibilityService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTaskProcessVariableModelsForTask(taskId: string): Observable<TaskProcessVariableModel[]> {
|
getTaskProcessVariable(taskId: string): Observable<TaskProcessVariableModel[]> {
|
||||||
let url = `${this.alfrescoSettingsService.getBPMApiBaseUrl()}/app/rest/task-forms/${taskId}/variables`;
|
let url = `${this.alfrescoSettingsService.getBPMApiBaseUrl()}/app/rest/task-forms/${taskId}/variables`;
|
||||||
let options = this.getRequestOptions();
|
let options = this.getRequestOptions();
|
||||||
return this.http
|
return this.http
|
||||||
@@ -220,7 +208,8 @@ export class WidgetVisibilityService {
|
|||||||
private getHeaders(): Headers {
|
private getHeaders(): Headers {
|
||||||
return new Headers({
|
return new Headers({
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': this.authService.getTicketBpm()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user