mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
enable prefer-const rule for tslint, fix issues (#4409)
* enable prefer-const rule for tslint, fix issues * Update content-node-selector.component.spec.ts * Update content-node-selector.component.spec.ts * fix const * fix lint issues * update tests * update tests * update tests * fix code * fix page class
This commit is contained in:
committed by
Eugenio Romano
parent
26c5982a1a
commit
a7a48e8b2b
@@ -43,8 +43,8 @@ export class ActivitiContentService {
|
||||
* @param folderId
|
||||
*/
|
||||
getAlfrescoNodes(accountId: string, folderId: string): Observable<[ExternalContent]> {
|
||||
let apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
|
||||
let accountShortId = accountId.replace('alfresco-', '');
|
||||
const apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
|
||||
const accountShortId = accountId.replace('alfresco-', '');
|
||||
return from(apiService.activiti.alfrescoApi.getContentInFolder(accountShortId, folderId))
|
||||
.pipe(
|
||||
map(this.toJsonArray),
|
||||
@@ -59,7 +59,7 @@ export class ActivitiContentService {
|
||||
* @param folderId
|
||||
*/
|
||||
getAlfrescoRepositories(tenantId: number, includeAccount: boolean): Observable<any> {
|
||||
let apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
|
||||
const apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
|
||||
const opts = {
|
||||
tenantId: tenantId,
|
||||
includeAccounts: includeAccount
|
||||
@@ -94,7 +94,7 @@ export class ActivitiContentService {
|
||||
}
|
||||
|
||||
applyAlfrescoNode(node: MinimalNode, siteId: string, accountId: string) {
|
||||
let apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
|
||||
const apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
|
||||
const currentSideId = siteId ? siteId : this.getSiteNameFromNodePath(node);
|
||||
const params: RelatedContentRepresentation = {
|
||||
source: accountId,
|
||||
|
@@ -63,7 +63,7 @@ describe('EcmModelService', () => {
|
||||
|
||||
it('Should fetch ECM types', (done) => {
|
||||
|
||||
let modelName = 'modelTest';
|
||||
const modelName = 'modelTest';
|
||||
|
||||
service.getEcmType(modelName).subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + modelName + '/types')).toBeTruthy();
|
||||
@@ -79,7 +79,7 @@ describe('EcmModelService', () => {
|
||||
|
||||
it('Should create ECM types', (done) => {
|
||||
|
||||
let typeName = 'typeTest';
|
||||
const typeName = 'typeTest';
|
||||
|
||||
service.createEcmType(typeName, EcmModelService.MODEL_NAME, EcmModelService.TYPE_MODEL).subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + EcmModelService.MODEL_NAME + '/types')).toBeTruthy();
|
||||
@@ -98,8 +98,8 @@ describe('EcmModelService', () => {
|
||||
|
||||
it('Should create ECM types with a clean and preserve real name in the title', (done) => {
|
||||
|
||||
let typeName = 'typeTest:testName@#$*!';
|
||||
let cleanName = 'testName';
|
||||
const typeName = 'typeTest:testName@#$*!';
|
||||
const cleanName = 'testName';
|
||||
|
||||
service.createEcmType(typeName, EcmModelService.MODEL_NAME, EcmModelService.TYPE_MODEL).subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + EcmModelService.MODEL_NAME + '/types')).toBeTruthy();
|
||||
@@ -118,8 +118,8 @@ describe('EcmModelService', () => {
|
||||
|
||||
it('Should add property to a type', (done) => {
|
||||
|
||||
let typeName = 'typeTest';
|
||||
let formFields = {
|
||||
const typeName = 'typeTest';
|
||||
const formFields = {
|
||||
values: {
|
||||
test: 'test',
|
||||
test2: 'test2'
|
||||
@@ -157,9 +157,9 @@ describe('EcmModelService', () => {
|
||||
|
||||
it('Should add property to a type and clean name type', (done) => {
|
||||
|
||||
let typeName = 'typeTest:testName@#$*!';
|
||||
let cleanName = 'testName';
|
||||
let formFields = {
|
||||
const typeName = 'typeTest:testName@#$*!';
|
||||
const cleanName = 'testName';
|
||||
const formFields = {
|
||||
values: {
|
||||
test: 'test',
|
||||
test2: 'test2'
|
||||
|
@@ -160,7 +160,7 @@ export class EcmModelService {
|
||||
}
|
||||
|
||||
public createEcmType(typeName: string, modelName: string, parentType: string): Observable<any> {
|
||||
let name = this.cleanNameType(typeName);
|
||||
const name = this.cleanNameType(typeName);
|
||||
|
||||
return from(this.apiService.getInstance().core.customModelApi.createCustomType(modelName, name, parentType, typeName, ''))
|
||||
.pipe(
|
||||
@@ -170,11 +170,11 @@ export class EcmModelService {
|
||||
}
|
||||
|
||||
public addPropertyToAType(modelName: string, typeName: string, formFields: any) {
|
||||
let name = this.cleanNameType(typeName);
|
||||
const name = this.cleanNameType(typeName);
|
||||
|
||||
let properties = [];
|
||||
const properties = [];
|
||||
if (formFields && formFields.values) {
|
||||
for (let key in formFields.values) {
|
||||
for (const key in formFields.values) {
|
||||
if (key) {
|
||||
properties.push({
|
||||
name: key,
|
||||
|
@@ -33,37 +33,37 @@ describe('FormRenderingService', () => {
|
||||
});
|
||||
|
||||
it('should resolve Upload field as Upload widget', () => {
|
||||
let field = new FormFieldModel(null, {
|
||||
const field = new FormFieldModel(null, {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
params: {
|
||||
link: null
|
||||
}
|
||||
});
|
||||
let type = service.resolveComponentType(field);
|
||||
const type = service.resolveComponentType(field);
|
||||
expect(type).toBe(UploadWidgetComponent);
|
||||
});
|
||||
|
||||
it('should resolve Upload widget for Upload field', () => {
|
||||
let resolver = service.getComponentTypeResolver(FormFieldTypes.UPLOAD);
|
||||
let type = resolver(null);
|
||||
const resolver = service.getComponentTypeResolver(FormFieldTypes.UPLOAD);
|
||||
const type = resolver(null);
|
||||
expect(type).toBe(UploadWidgetComponent);
|
||||
});
|
||||
|
||||
it('should resolve Unknown widget for unknown field type', () => {
|
||||
let resolver = service.getComponentTypeResolver('missing-type');
|
||||
let type = resolver(null);
|
||||
const resolver = service.getComponentTypeResolver('missing-type');
|
||||
const type = resolver(null);
|
||||
expect(type).toBe(UnknownWidgetComponent);
|
||||
});
|
||||
|
||||
it('should fallback to default resolver when field type missing', () => {
|
||||
let resolver = service.getComponentTypeResolver(null);
|
||||
let type = resolver(null);
|
||||
const resolver = service.getComponentTypeResolver(null);
|
||||
const type = resolver(null);
|
||||
expect(type).toBe(UnknownWidgetComponent);
|
||||
});
|
||||
|
||||
it('should fallback to custom resolver when field type missing', () => {
|
||||
let resolver = service.getComponentTypeResolver(null, UploadWidgetComponent);
|
||||
let type = resolver(null);
|
||||
const resolver = service.getComponentTypeResolver(null, UploadWidgetComponent);
|
||||
const type = resolver(null);
|
||||
expect(type).toBe(UploadWidgetComponent);
|
||||
});
|
||||
|
||||
@@ -96,13 +96,13 @@ describe('FormRenderingService', () => {
|
||||
});
|
||||
|
||||
it('should override existing resolver with explicit flag', () => {
|
||||
let customResolver = DynamicComponentResolver.fromType(UnknownWidgetComponent);
|
||||
const customResolver = DynamicComponentResolver.fromType(UnknownWidgetComponent);
|
||||
service.setComponentTypeResolver(FormFieldTypes.TEXT, customResolver, true);
|
||||
expect(service.getComponentTypeResolver(FormFieldTypes.TEXT)).toBe(customResolver);
|
||||
});
|
||||
|
||||
it('should override existing resolver without explicit flag', () => {
|
||||
let customResolver = DynamicComponentResolver.fromType(UnknownWidgetComponent);
|
||||
const customResolver = DynamicComponentResolver.fromType(UnknownWidgetComponent);
|
||||
service.setComponentTypeResolver(FormFieldTypes.TEXT, customResolver);
|
||||
expect(service.getComponentTypeResolver(FormFieldTypes.TEXT)).toBe(customResolver);
|
||||
});
|
||||
|
@@ -26,7 +26,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
let fakeGroupResponse = {
|
||||
const fakeGroupResponse = {
|
||||
'size': 2,
|
||||
'total': 2,
|
||||
'start': 0,
|
||||
@@ -39,7 +39,7 @@ let fakeGroupResponse = {
|
||||
}, { 'id': 2005, 'name': 'PEOPLE_GROUP_2', 'externalId': null, 'status': 'active', 'groups': null }]
|
||||
};
|
||||
|
||||
let fakePeopleResponse = {
|
||||
const fakePeopleResponse = {
|
||||
'size': 3,
|
||||
'total': 3,
|
||||
'start': 0,
|
||||
@@ -78,19 +78,19 @@ describe('Form service', () => {
|
||||
|
||||
describe('Content tests', () => {
|
||||
|
||||
let responseBody = {
|
||||
const responseBody = {
|
||||
data: [
|
||||
{ id: '1' },
|
||||
{ id: '2' }
|
||||
]
|
||||
};
|
||||
|
||||
let values = {
|
||||
const values = {
|
||||
field1: 'one',
|
||||
field2: 'two'
|
||||
};
|
||||
|
||||
let simpleResponseBody = { id: 1, modelType: 'test' };
|
||||
const simpleResponseBody = { id: 1, modelType: 'test' };
|
||||
|
||||
it('should fetch and parse process definitions', (done) => {
|
||||
service.getProcessDefinitions().subscribe((result) => {
|
||||
@@ -211,7 +211,7 @@ describe('Form service', () => {
|
||||
it('should get form definition id by name', (done) => {
|
||||
const formName = 'form1';
|
||||
const formId = 1;
|
||||
let response = {
|
||||
const response = {
|
||||
data: [
|
||||
{ id: formId }
|
||||
]
|
||||
@@ -232,7 +232,7 @@ describe('Form service', () => {
|
||||
|
||||
it('should get start form definition by process definition id', (done) => {
|
||||
|
||||
let processApiSpy = jasmine.createSpyObj(['getProcessDefinitionStartForm']);
|
||||
const processApiSpy = jasmine.createSpyObj(['getProcessDefinitionStartForm']);
|
||||
spyOn(apiService, 'getInstance').and.returnValue({
|
||||
activiti: {
|
||||
processApi: processApiSpy
|
||||
@@ -327,7 +327,7 @@ describe('Form service', () => {
|
||||
});
|
||||
|
||||
it('should search for Form with modelType=2', (done) => {
|
||||
let response = { data: [{ id: 1, name: 'findMe' }, { id: 2, name: 'testForm' }] };
|
||||
const response = { data: [{ id: 1, name: 'findMe' }, { id: 2, name: 'testForm' }] };
|
||||
|
||||
service.searchFrom('findMe').subscribe((result) => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('models?modelType=2')).toBeTruthy();
|
||||
@@ -360,7 +360,7 @@ describe('Form service', () => {
|
||||
|
||||
it('should return list of people', (done) => {
|
||||
spyOn(service, 'getUserProfileImageApi').and.returnValue('/app/rest/users/2002/picture');
|
||||
let fakeFilter: string = 'whatever';
|
||||
const fakeFilter: string = 'whatever';
|
||||
|
||||
service.getWorkflowUsers(fakeFilter).subscribe((result) => {
|
||||
expect(result).toBeDefined();
|
||||
@@ -378,7 +378,7 @@ describe('Form service', () => {
|
||||
});
|
||||
|
||||
it('should return list of groups', (done) => {
|
||||
let fakeFilter: string = 'whatever';
|
||||
const fakeFilter: string = 'whatever';
|
||||
|
||||
service.getWorkflowGroups(fakeFilter).subscribe((result) => {
|
||||
expect(result).toBeDefined();
|
||||
@@ -403,9 +403,9 @@ describe('Form service', () => {
|
||||
|
||||
it('should create a Form form a Node', (done) => {
|
||||
|
||||
let nameForm = 'testNode';
|
||||
const nameForm = 'testNode';
|
||||
|
||||
let formId = 100;
|
||||
const formId = 100;
|
||||
|
||||
stubCreateForm();
|
||||
|
||||
|
@@ -102,7 +102,7 @@ export class FormService {
|
||||
*/
|
||||
parseForm(json: any, data?: FormValues, readOnly: boolean = false): FormModel {
|
||||
if (json) {
|
||||
let form = new FormModel(json, data, readOnly, this);
|
||||
const form = new FormModel(json, data, readOnly, this);
|
||||
if (!json.fields) {
|
||||
form.outcomes = [
|
||||
new FormOutcomeModel(form, {
|
||||
@@ -128,7 +128,7 @@ export class FormService {
|
||||
(form) => {
|
||||
this.ecmModelService.searchEcmType(formName, EcmModelService.MODEL_NAME).subscribe(
|
||||
(customType) => {
|
||||
let formDefinitionModel = new FormDefinitionModel(form.id, form.name, form.lastUpdatedByFullName, form.lastUpdated, customType.entry.properties);
|
||||
const formDefinitionModel = new FormDefinitionModel(form.id, form.name, form.lastUpdatedByFullName, form.lastUpdated, customType.entry.properties);
|
||||
from(
|
||||
this.editorApi.saveForm(form.id, formDefinitionModel)
|
||||
).subscribe((formData) => {
|
||||
@@ -148,7 +148,7 @@ export class FormService {
|
||||
* @returns The new form
|
||||
*/
|
||||
createForm(formName: string): Observable<any> {
|
||||
let dataModel = {
|
||||
const dataModel = {
|
||||
name: formName,
|
||||
description: '',
|
||||
modelType: 2,
|
||||
@@ -178,7 +178,7 @@ export class FormService {
|
||||
* @returns Form model(s) matching the search name
|
||||
*/
|
||||
searchFrom(name: string): Observable<any> {
|
||||
let opts = {
|
||||
const opts = {
|
||||
'modelType': 2
|
||||
};
|
||||
|
||||
@@ -198,7 +198,7 @@ export class FormService {
|
||||
* @returns List of form models
|
||||
*/
|
||||
getForms(): Observable<any> {
|
||||
let opts = {
|
||||
const opts = {
|
||||
'modelType': 2
|
||||
};
|
||||
|
||||
@@ -266,7 +266,7 @@ export class FormService {
|
||||
* @returns Null response when the operation is complete
|
||||
*/
|
||||
saveTaskForm(taskId: string, formValues: FormValues): Observable<any> {
|
||||
let saveFormRepresentation = <SaveFormRepresentation> { values: formValues };
|
||||
const saveFormRepresentation = <SaveFormRepresentation> { values: formValues };
|
||||
|
||||
return from(this.taskApi.saveTaskForm(taskId, saveFormRepresentation))
|
||||
.pipe(
|
||||
@@ -282,7 +282,7 @@ export class FormService {
|
||||
* @returns Null response when the operation is complete
|
||||
*/
|
||||
completeTaskForm(taskId: string, formValues: FormValues, outcome?: string): Observable<any> {
|
||||
let completeFormRepresentation: any = <CompleteFormRepresentation> { values: formValues };
|
||||
const completeFormRepresentation: any = <CompleteFormRepresentation> { values: formValues };
|
||||
if (outcome) {
|
||||
completeFormRepresentation.outcome = outcome;
|
||||
}
|
||||
@@ -325,7 +325,7 @@ export class FormService {
|
||||
* @returns Form definition
|
||||
*/
|
||||
getFormDefinitionByName(name: string): Observable<any> {
|
||||
let opts = {
|
||||
const opts = {
|
||||
'filter': 'myReusableForms',
|
||||
'filterText': name,
|
||||
'modelType': 2
|
||||
@@ -447,7 +447,7 @@ export class FormService {
|
||||
* @returns Array of users
|
||||
*/
|
||||
getWorkflowUsers(filter: string, groupId?: string): Observable<UserProcessModel[]> {
|
||||
let option: any = { filter: filter };
|
||||
const option: any = { filter: filter };
|
||||
if (groupId) {
|
||||
option.groupId = groupId;
|
||||
}
|
||||
@@ -471,7 +471,7 @@ export class FormService {
|
||||
* @returns Array of groups
|
||||
*/
|
||||
getWorkflowGroups(filter: string, groupId?: string): Observable<GroupModel[]> {
|
||||
let option: any = { filter: filter };
|
||||
const option: any = { filter: filter };
|
||||
if (groupId) {
|
||||
option.groupId = groupId;
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ describe('NodeService', () => {
|
||||
});
|
||||
|
||||
it('Should fetch and node metadata', (done) => {
|
||||
let responseBody = {
|
||||
const responseBody = {
|
||||
entry: {
|
||||
id: '111-222-33-44-1123',
|
||||
nodeType: 'typeTest',
|
||||
@@ -67,7 +67,7 @@ describe('NodeService', () => {
|
||||
|
||||
service.getNodeMetadata('-nodeid-').subscribe((result) => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('nodes/-nodeid-')).toBeTruthy();
|
||||
let node = new NodeMetadata({
|
||||
const node = new NodeMetadata({
|
||||
test: 'test',
|
||||
testdata: 'testdata'
|
||||
}, 'typeTest');
|
||||
@@ -83,7 +83,7 @@ describe('NodeService', () => {
|
||||
});
|
||||
|
||||
it('Should clean the metadata from :', (done) => {
|
||||
let responseBody = {
|
||||
const responseBody = {
|
||||
entry: {
|
||||
id: '111-222-33-44-1123',
|
||||
nodeType: 'typeTest',
|
||||
@@ -96,7 +96,7 @@ describe('NodeService', () => {
|
||||
|
||||
service.getNodeMetadata('-nodeid-').subscribe((result) => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('nodes/-nodeid-')).toBeTruthy();
|
||||
let node = new NodeMetadata({
|
||||
const node = new NodeMetadata({
|
||||
test: 'test',
|
||||
testdata: 'testdata'
|
||||
}, 'typeTest');
|
||||
@@ -112,12 +112,12 @@ describe('NodeService', () => {
|
||||
});
|
||||
|
||||
it('Should create a node with metadata', (done) => {
|
||||
let data = {
|
||||
const data = {
|
||||
test: 'test',
|
||||
testdata: 'testdata'
|
||||
};
|
||||
|
||||
let responseBody = {
|
||||
const responseBody = {
|
||||
id: 'a74d91fb-ea8a-4812-ad98-ad878366b5be',
|
||||
isFile: false,
|
||||
isFolder: true
|
||||
@@ -136,7 +136,7 @@ describe('NodeService', () => {
|
||||
});
|
||||
|
||||
it('Should add activitiForms suffix to the metadata properties', (done) => {
|
||||
let data = {
|
||||
const data = {
|
||||
test: 'test',
|
||||
testdata: 'testdata'
|
||||
};
|
||||
@@ -156,7 +156,7 @@ describe('NodeService', () => {
|
||||
});
|
||||
|
||||
it('Should assign an UUID to the name when name not passed', (done) => {
|
||||
let data = {
|
||||
const data = {
|
||||
test: 'test',
|
||||
testdata: 'testdata'
|
||||
};
|
||||
|
@@ -50,8 +50,8 @@ export class NodeService {
|
||||
* @returns The created node
|
||||
*/
|
||||
public createNodeMetadata(nodeType: string, nameSpace: any, data: any, path: string, name?: string): Observable<NodeEntry> {
|
||||
let properties = {};
|
||||
for (let key in data) {
|
||||
const properties = {};
|
||||
for (const key in data) {
|
||||
if (data[key]) {
|
||||
properties[nameSpace + ':' + key] = data[key];
|
||||
}
|
||||
@@ -69,29 +69,29 @@ export class NodeService {
|
||||
* @returns The created node
|
||||
*/
|
||||
public createNode(name: string, nodeType: string, properties: any, path: string): Observable<NodeEntry> {
|
||||
let body = {
|
||||
const body = {
|
||||
name: name,
|
||||
nodeType: nodeType,
|
||||
properties: properties,
|
||||
relativePath: path
|
||||
};
|
||||
|
||||
let apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
|
||||
const apiService: AlfrescoApiCompatibility = this.apiService.getInstance();
|
||||
return from(apiService.nodes.addNode('-root-', body, {}));
|
||||
}
|
||||
|
||||
private generateUuid() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
let r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
const r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
private cleanMetadataFromSemicolon(nodeEntry: NodeEntry): NodeMetadata {
|
||||
let metadata = {};
|
||||
const metadata = {};
|
||||
|
||||
if (nodeEntry && nodeEntry.entry.properties) {
|
||||
for (let key in nodeEntry.entry.properties) {
|
||||
for (const key in nodeEntry.entry.properties) {
|
||||
if (key) {
|
||||
if (key.indexOf(':') !== -1) {
|
||||
metadata [key.split(':')[1]] = nodeEntry.entry.properties[key];
|
||||
|
@@ -26,7 +26,7 @@ import { AlfrescoApiServiceMock } from '../../mock/alfresco-api.service.mock';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
let fileContentPdfResponseBody = {
|
||||
const fileContentPdfResponseBody = {
|
||||
id: 999,
|
||||
name: 'fake-name.pdf',
|
||||
created: '2017-01-23T12:12:53.219+0000',
|
||||
@@ -40,7 +40,7 @@ let fileContentPdfResponseBody = {
|
||||
thumbnailStatus: 'created'
|
||||
};
|
||||
|
||||
let fileContentJpgResponseBody = {
|
||||
const fileContentJpgResponseBody = {
|
||||
id: 888,
|
||||
name: 'fake-name.jpg',
|
||||
created: '2017-01-23T12:12:53.219+0000',
|
||||
@@ -55,9 +55,9 @@ let fileContentJpgResponseBody = {
|
||||
};
|
||||
|
||||
function createFakeBlob() {
|
||||
let data = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';
|
||||
const data = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';
|
||||
|
||||
let bytes = new Uint8Array(data.length / 2);
|
||||
const bytes = new Uint8Array(data.length / 2);
|
||||
|
||||
for (let i = 0; i < data.length; i += 2) {
|
||||
bytes[i / 2] = parseInt(data.substring(i, i + 2), /* base = */ 16);
|
||||
@@ -144,7 +144,7 @@ describe('ProcessContentService', () => {
|
||||
});
|
||||
|
||||
it('should return the unsupported content when the file is an image', (done) => {
|
||||
let contentId: number = 888;
|
||||
const contentId: number = 888;
|
||||
|
||||
service.getFileContent(contentId).subscribe((result) => {
|
||||
expect(result.id).toEqual(contentId);
|
||||
@@ -162,7 +162,7 @@ describe('ProcessContentService', () => {
|
||||
});
|
||||
|
||||
it('should return the supported content when the file is a pdf', (done) => {
|
||||
let contentId: number = 999;
|
||||
const contentId: number = 999;
|
||||
|
||||
service.getFileContent(contentId).subscribe((result) => {
|
||||
expect(result.id).toEqual(contentId);
|
||||
@@ -180,14 +180,14 @@ describe('ProcessContentService', () => {
|
||||
});
|
||||
|
||||
it('should return the raw content URL', () => {
|
||||
let contentId: number = 999;
|
||||
let contentUrl = service.getFileRawContentUrl(contentId);
|
||||
const contentId: number = 999;
|
||||
const contentUrl = service.getFileRawContentUrl(contentId);
|
||||
expect(contentUrl).toContain(`/api/enterprise/content/${contentId}/raw`);
|
||||
});
|
||||
|
||||
it('should return a Blob as thumbnail', (done) => {
|
||||
let contentId: number = 999;
|
||||
let blob = createFakeBlob();
|
||||
const contentId: number = 999;
|
||||
const blob = createFakeBlob();
|
||||
spyOn(service, 'getContentThumbnail').and.returnValue(of(blob));
|
||||
service.getContentThumbnail(contentId).subscribe((result) => {
|
||||
expect(result).toEqual(jasmine.any(Blob));
|
||||
|
@@ -38,7 +38,7 @@ describe('WidgetVisibilityService', () => {
|
||||
|
||||
let service: WidgetVisibilityService;
|
||||
let booleanResult: boolean;
|
||||
let stubFormWithFields = new FormModel(fakeFormJson);
|
||||
const stubFormWithFields = new FormModel(fakeFormJson);
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -186,9 +186,9 @@ describe('WidgetVisibilityService', () => {
|
||||
});
|
||||
|
||||
describe('should retrieve the process variables', () => {
|
||||
let fakeFormWithField = new FormModel(fakeFormJson);
|
||||
const fakeFormWithField = new FormModel(fakeFormJson);
|
||||
let visibilityObjTest: WidgetVisibilityModel;
|
||||
let chainedVisibilityObj = new WidgetVisibilityModel();
|
||||
const chainedVisibilityObj = new WidgetVisibilityModel();
|
||||
|
||||
beforeEach(() => {
|
||||
visibilityObjTest = new WidgetVisibilityModel();
|
||||
@@ -216,7 +216,7 @@ describe('WidgetVisibilityService', () => {
|
||||
service.getTaskProcessVariable('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
expect(res).toBeDefined();
|
||||
let varValue = service.getVariableValue(formTest, 'TEST_VAR_1', res);
|
||||
const varValue = service.getVariableValue(formTest, 'TEST_VAR_1', res);
|
||||
expect(varValue).not.toBeUndefined();
|
||||
expect(varValue).toBe('test_value_1');
|
||||
done();
|
||||
@@ -232,7 +232,7 @@ describe('WidgetVisibilityService', () => {
|
||||
it('should return undefined if the variable does not exist', (done) => {
|
||||
service.getTaskProcessVariable('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
let varValue = service.getVariableValue(formTest, 'TEST_MYSTERY_VAR', res);
|
||||
const varValue = service.getVariableValue(formTest, 'TEST_MYSTERY_VAR', res);
|
||||
expect(varValue).toBeUndefined();
|
||||
done();
|
||||
}
|
||||
@@ -248,7 +248,7 @@ describe('WidgetVisibilityService', () => {
|
||||
service.getTaskProcessVariable('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
visibilityObjTest.rightRestResponseId = 'TEST_VAR_2';
|
||||
let rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).not.toBeNull();
|
||||
expect(rightValue).toBe('test_value_2');
|
||||
@@ -266,7 +266,7 @@ describe('WidgetVisibilityService', () => {
|
||||
service.getTaskProcessVariable('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
visibilityObjTest.leftRestResponseId = 'TEST_VAR_2';
|
||||
let rightValue = service.getLeftValue(formTest, visibilityObjTest);
|
||||
const rightValue = service.getLeftValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).not.toBeNull();
|
||||
expect(rightValue).toBe('test_value_2');
|
||||
@@ -286,7 +286,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'LEFT_FORM_FIELD_ID';
|
||||
visibilityObjTest.operator = '!=';
|
||||
visibilityObjTest.rightRestResponseId = 'TEST_VAR_2';
|
||||
let isVisible = service.isFieldVisible(fakeFormWithField, visibilityObjTest);
|
||||
const isVisible = service.isFieldVisible(fakeFormWithField, visibilityObjTest);
|
||||
|
||||
expect(isVisible).toBeTruthy();
|
||||
done();
|
||||
@@ -310,7 +310,7 @@ describe('WidgetVisibilityService', () => {
|
||||
chainedVisibilityObj.operator = '!empty';
|
||||
visibilityObjTest.nextCondition = chainedVisibilityObj;
|
||||
|
||||
let isVisible = service.isFieldVisible(fakeFormWithField, visibilityObjTest);
|
||||
const isVisible = service.isFieldVisible(fakeFormWithField, visibilityObjTest);
|
||||
|
||||
expect(isVisible).toBeTruthy();
|
||||
done();
|
||||
@@ -337,13 +337,13 @@ describe('WidgetVisibilityService', () => {
|
||||
|
||||
describe('should return the value of the field', () => {
|
||||
let visibilityObjTest: WidgetVisibilityModel;
|
||||
let fakeFormWithField = new FormModel(fakeFormJson);
|
||||
let jsonFieldFake = {
|
||||
const fakeFormWithField = new FormModel(fakeFormJson);
|
||||
const jsonFieldFake = {
|
||||
id: 'FAKE_FORM_FIELD_ID',
|
||||
value: 'FAKE_FORM_FIELD_VALUE',
|
||||
visibilityCondition: undefined
|
||||
};
|
||||
let fakeForm = new FormModel({
|
||||
const fakeForm = new FormModel({
|
||||
variables: [
|
||||
{
|
||||
name: 'FORM_VARIABLE_TEST',
|
||||
@@ -363,28 +363,28 @@ describe('WidgetVisibilityService', () => {
|
||||
});
|
||||
|
||||
it('should be able to retrieve a field value searching in the form', () => {
|
||||
let formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
||||
const formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
||||
|
||||
expect(formValue).not.toBeNull();
|
||||
expect(formValue).toBe('field_with_condition_value');
|
||||
});
|
||||
|
||||
it('should return empty string if the field value is not in the form', () => {
|
||||
let formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_MYSTERY');
|
||||
const formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_MYSTERY');
|
||||
|
||||
expect(formValue).not.toBeUndefined();
|
||||
expect(formValue).toBe('');
|
||||
});
|
||||
|
||||
it('should search in the form if element value is not in form values', () => {
|
||||
let value = service.getFormValue(fakeFormWithField, 'FIELD_WITH_CONDITION');
|
||||
const value = service.getFormValue(fakeFormWithField, 'FIELD_WITH_CONDITION');
|
||||
|
||||
expect(value).not.toBeNull();
|
||||
expect(value).toBe('field_with_condition_value');
|
||||
});
|
||||
|
||||
it('should return empty string if the element is not present anywhere', () => {
|
||||
let formValue = service.getFormValue(fakeFormWithField, 'FIELD_MYSTERY');
|
||||
const formValue = service.getFormValue(fakeFormWithField, 'FIELD_MYSTERY');
|
||||
|
||||
expect(formValue).not.toBeUndefined();
|
||||
expect(formValue).toBe('');
|
||||
@@ -392,35 +392,35 @@ describe('WidgetVisibilityService', () => {
|
||||
|
||||
it('should retrieve the value for the right field when it is a value', () => {
|
||||
visibilityObjTest.rightValue = '100';
|
||||
let rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).toBe('100');
|
||||
});
|
||||
|
||||
it('should return formatted date when right value is a date', () => {
|
||||
visibilityObjTest.rightValue = '9999-12-31';
|
||||
let rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).toBe('9999-12-31T00:00:00.000Z');
|
||||
});
|
||||
|
||||
it('should return the value when right value is not a date', () => {
|
||||
visibilityObjTest.rightValue = '9999-99-99';
|
||||
let rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).toBe('9999-99-99');
|
||||
});
|
||||
|
||||
it('should retrieve the value for the right field when it is a form variable', () => {
|
||||
visibilityObjTest.rightFormFieldId = 'RIGHT_FORM_FIELD_ID';
|
||||
let rightValue = service.getRightValue(fakeFormWithField, visibilityObjTest);
|
||||
const rightValue = service.getRightValue(fakeFormWithField, visibilityObjTest);
|
||||
|
||||
expect(rightValue).not.toBeNull();
|
||||
expect(rightValue).toBe('RIGHT_FORM_FIELD_VALUE');
|
||||
});
|
||||
|
||||
it('should take the value from form values if it is present', () => {
|
||||
let formValue = service.getFormValue(formTest, 'test_1');
|
||||
const formValue = service.getFormValue(formTest, 'test_1');
|
||||
|
||||
expect(formValue).not.toBeNull();
|
||||
expect(formValue).toBe('value_1');
|
||||
@@ -428,7 +428,7 @@ describe('WidgetVisibilityService', () => {
|
||||
|
||||
it('should retrieve right value from form values if it is present', () => {
|
||||
visibilityObjTest.rightFormFieldId = 'test_2';
|
||||
let rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).not.toBeNull();
|
||||
expect(formTest.values).toEqual(formValues);
|
||||
@@ -437,7 +437,7 @@ describe('WidgetVisibilityService', () => {
|
||||
|
||||
it('should retrieve the value for the left field when it is a form value', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'FIELD_WITH_CONDITION';
|
||||
let leftValue = service.getLeftValue(fakeFormWithField, visibilityObjTest);
|
||||
const leftValue = service.getLeftValue(fakeFormWithField, visibilityObjTest);
|
||||
|
||||
expect(leftValue).not.toBeNull();
|
||||
expect(leftValue).toBe('field_with_condition_value');
|
||||
@@ -445,14 +445,14 @@ describe('WidgetVisibilityService', () => {
|
||||
|
||||
it('should retrieve left value from form values if it is present', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'test_2';
|
||||
let leftValue = service.getLeftValue(formTest, visibilityObjTest);
|
||||
const leftValue = service.getLeftValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(leftValue).not.toBeNull();
|
||||
expect(leftValue).toBe('value_2');
|
||||
});
|
||||
|
||||
it('should return an empty string for a value that is not on variable or form', () => {
|
||||
let leftValue = service.getLeftValue(fakeFormWithField, visibilityObjTest);
|
||||
const leftValue = service.getLeftValue(fakeFormWithField, visibilityObjTest);
|
||||
|
||||
expect(leftValue).toBe('');
|
||||
});
|
||||
@@ -461,7 +461,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'test_1';
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightFormFieldId = 'test_3';
|
||||
let isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||
|
||||
expect(isVisible).toBeTruthy();
|
||||
});
|
||||
@@ -470,14 +470,14 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'test_1';
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightValue = 'value_1';
|
||||
let isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||
|
||||
expect(isVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return empty string for a value that is not on variable or form', () => {
|
||||
visibilityObjTest.rightFormFieldId = 'NO_FIELD_FORM';
|
||||
let rightValue = service.getRightValue(fakeFormWithField, visibilityObjTest);
|
||||
const rightValue = service.getRightValue(fakeFormWithField, visibilityObjTest);
|
||||
|
||||
expect(rightValue).not.toBeUndefined();
|
||||
expect(rightValue).toBe('');
|
||||
@@ -487,7 +487,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'LEFT_FORM_FIELD_ID';
|
||||
visibilityObjTest.operator = '!=';
|
||||
visibilityObjTest.rightFormFieldId = 'RIGHT_FORM_FIELD_ID';
|
||||
let isVisible = service.isFieldVisible(fakeFormWithField, visibilityObjTest);
|
||||
const isVisible = service.isFieldVisible(fakeFormWithField, visibilityObjTest);
|
||||
|
||||
expect(isVisible).toBeTruthy();
|
||||
});
|
||||
@@ -496,7 +496,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'test_1';
|
||||
visibilityObjTest.operator = '!=';
|
||||
visibilityObjTest.rightFormFieldId = 'test_3';
|
||||
let fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
||||
const fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
||||
service.refreshEntityVisibility(fakeFormField);
|
||||
|
||||
expect(fakeFormField.isVisible).toBeFalsy();
|
||||
@@ -506,14 +506,14 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = '';
|
||||
visibilityObjTest.leftRestResponseId = '';
|
||||
visibilityObjTest.operator = '!=';
|
||||
let isVisible = service.evaluateVisibility(formTest, visibilityObjTest);
|
||||
const isVisible = service.evaluateVisibility(formTest, visibilityObjTest);
|
||||
|
||||
expect(isVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return always true when field does not have a visibility condition', () => {
|
||||
jsonFieldFake.visibilityCondition = null;
|
||||
let fakeFormField: FormFieldModel = new FormFieldModel(fakeFormWithField, jsonFieldFake);
|
||||
const fakeFormField: FormFieldModel = new FormFieldModel(fakeFormWithField, jsonFieldFake);
|
||||
fakeFormField.isVisible = false;
|
||||
service.refreshEntityVisibility(fakeFormField);
|
||||
|
||||
@@ -521,28 +521,28 @@ describe('WidgetVisibilityService', () => {
|
||||
});
|
||||
|
||||
it('should be able to retrieve the value of a form variable', () => {
|
||||
let varValue = service.getVariableValue(fakeForm, 'FORM_VARIABLE_TEST', null);
|
||||
const varValue = service.getVariableValue(fakeForm, 'FORM_VARIABLE_TEST', null);
|
||||
|
||||
expect(varValue).not.toBeUndefined();
|
||||
expect(varValue).toBe('form_value_test');
|
||||
});
|
||||
|
||||
it('should return undefined for not existing form variable', () => {
|
||||
let varValue = service.getVariableValue(fakeForm, 'MYSTERY_FORM_VARIABLE', null);
|
||||
const varValue = service.getVariableValue(fakeForm, 'MYSTERY_FORM_VARIABLE', null);
|
||||
|
||||
expect(varValue).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should retrieve the value for the left field when it is a form variable', () => {
|
||||
visibilityObjTest.leftRestResponseId = 'FORM_VARIABLE_TEST';
|
||||
let leftValue = service.getLeftValue(fakeForm, visibilityObjTest);
|
||||
const leftValue = service.getLeftValue(fakeForm, visibilityObjTest);
|
||||
|
||||
expect(leftValue).not.toBeNull();
|
||||
expect(leftValue).toBe('form_value_test');
|
||||
});
|
||||
|
||||
it('should determine visibility for dropdown on label condition', () => {
|
||||
let dropdownValue = service.getFieldValue(formTest.values, 'dropdown_LABEL');
|
||||
const dropdownValue = service.getFieldValue(formTest.values, 'dropdown_LABEL');
|
||||
|
||||
expect(dropdownValue).not.toBeNull();
|
||||
expect(dropdownValue).toBeDefined();
|
||||
@@ -550,7 +550,7 @@ describe('WidgetVisibilityService', () => {
|
||||
});
|
||||
|
||||
it('should be able to get the value for a dropdown filtered with Label', () => {
|
||||
let dropdownValue = service.getFieldValue(formTest.values, 'dropdown_LABEL');
|
||||
const dropdownValue = service.getFieldValue(formTest.values, 'dropdown_LABEL');
|
||||
|
||||
expect(dropdownValue).not.toBeNull();
|
||||
expect(dropdownValue).toBeDefined();
|
||||
@@ -558,7 +558,7 @@ describe('WidgetVisibilityService', () => {
|
||||
});
|
||||
|
||||
it('should be able to get the value for a standard field', () => {
|
||||
let dropdownValue = service.getFieldValue(formTest.values, 'test_2');
|
||||
const dropdownValue = service.getFieldValue(formTest.values, 'test_2');
|
||||
|
||||
expect(dropdownValue).not.toBeNull();
|
||||
expect(dropdownValue).toBeDefined();
|
||||
@@ -566,7 +566,7 @@ describe('WidgetVisibilityService', () => {
|
||||
});
|
||||
|
||||
it('should get the dropdown label value from a form', () => {
|
||||
let dropdownValue = service.getFormValue(formTest, 'dropdown_LABEL');
|
||||
const dropdownValue = service.getFormValue(formTest, 'dropdown_LABEL');
|
||||
|
||||
expect(dropdownValue).not.toBeNull();
|
||||
expect(dropdownValue).toBeDefined();
|
||||
@@ -574,7 +574,7 @@ describe('WidgetVisibilityService', () => {
|
||||
});
|
||||
|
||||
it('should get the dropdown id value from a form', () => {
|
||||
let dropdownValue = service.getFormValue(formTest, 'dropdown');
|
||||
const dropdownValue = service.getFormValue(formTest, 'dropdown');
|
||||
|
||||
expect(dropdownValue).not.toBeNull();
|
||||
expect(dropdownValue).toBeDefined();
|
||||
@@ -583,7 +583,7 @@ describe('WidgetVisibilityService', () => {
|
||||
|
||||
it('should retrieve the value for the right field when it is a dropdown id', () => {
|
||||
visibilityObjTest.rightFormFieldId = 'dropdown';
|
||||
let rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).toBeDefined();
|
||||
expect(rightValue).toBe('dropdown_id');
|
||||
@@ -591,7 +591,7 @@ describe('WidgetVisibilityService', () => {
|
||||
|
||||
it('should retrieve the value for the right field when it is a dropdown label', () => {
|
||||
visibilityObjTest.rightFormFieldId = 'dropdown_LABEL';
|
||||
let rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||
|
||||
expect(rightValue).toBeDefined();
|
||||
expect(rightValue).toBe('dropdown_label');
|
||||
@@ -601,7 +601,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'test_5';
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightFormFieldId = 'dropdown_LABEL';
|
||||
let fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
||||
const fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
||||
service.refreshEntityVisibility(fakeFormField);
|
||||
|
||||
expect(fakeFormField.isVisible).toBeTruthy();
|
||||
@@ -611,14 +611,14 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'test_4';
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightFormFieldId = 'dropdown';
|
||||
let fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
||||
const fakeFormField: FormFieldModel = new FormFieldModel(formTest, jsonFieldFake);
|
||||
service.refreshEntityVisibility(fakeFormField);
|
||||
|
||||
expect(fakeFormField.isVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be able to get value from form values', () => {
|
||||
let res = service.getFormValue(formTest, 'test_1');
|
||||
const res = service.getFormValue(formTest, 'test_1');
|
||||
|
||||
expect(res).not.toBeNull();
|
||||
expect(res).toBeDefined();
|
||||
@@ -630,9 +630,9 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.operator = '!=';
|
||||
visibilityObjTest.rightFormFieldId = 'RIGHT_FORM_FIELD_ID';
|
||||
|
||||
let container = <ContainerModel> fakeFormWithField.fields[0];
|
||||
let column0 = container.field.columns[0];
|
||||
let column1 = container.field.columns[1];
|
||||
const container = <ContainerModel> fakeFormWithField.fields[0];
|
||||
const column0 = container.field.columns[0];
|
||||
const column1 = container.field.columns[1];
|
||||
|
||||
column0.fields[0].visibilityCondition = visibilityObjTest;
|
||||
service.refreshVisibility(fakeFormWithField);
|
||||
@@ -647,7 +647,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'FIELD_TEST';
|
||||
visibilityObjTest.operator = '!=';
|
||||
visibilityObjTest.rightFormFieldId = 'RIGHT_FORM_FIELD_ID';
|
||||
let tab = new TabModel(fakeFormWithField, { id: 'fake-tab-id', title: 'fake-tab-title', isVisible: true });
|
||||
const tab = new TabModel(fakeFormWithField, { id: 'fake-tab-id', title: 'fake-tab-title', isVisible: true });
|
||||
tab.visibilityCondition = visibilityObjTest;
|
||||
fakeFormWithField.tabs.push(tab);
|
||||
service.refreshVisibility(fakeFormWithField);
|
||||
@@ -659,7 +659,7 @@ describe('WidgetVisibilityService', () => {
|
||||
service.getTaskProcessVariable('9999').subscribe(
|
||||
(res: TaskProcessVariableModel[]) => {
|
||||
expect(res).toBeDefined();
|
||||
let varValue = service.getVariableValue(formTest, 'FIELD_FORM_EMPTY', res);
|
||||
const varValue = service.getVariableValue(formTest, 'FIELD_FORM_EMPTY', res);
|
||||
expect(varValue).not.toBeUndefined();
|
||||
expect(varValue).toBe('PROCESS_RIGHT_FORM_FIELD_VALUE');
|
||||
|
||||
@@ -667,7 +667,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightValue = 'RIGHT_FORM_FIELD_VALUE';
|
||||
|
||||
let myForm = new FormModel({
|
||||
const myForm = new FormModel({
|
||||
id: '9999',
|
||||
name: 'FORM_PROCESS_VARIABLE_VISIBILITY',
|
||||
processDefinitionId: 'PROCESS_TEST:9:9999',
|
||||
@@ -733,7 +733,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightValue = 'PROCESS_RIGHT_FORM_FIELD_VALUE';
|
||||
|
||||
let myForm = new FormModel({
|
||||
const myForm = new FormModel({
|
||||
id: '9999',
|
||||
name: 'FORM_PROCESS_VARIABLE_VISIBILITY',
|
||||
processDefinitionId: 'PROCESS_TEST:9:9999',
|
||||
@@ -799,7 +799,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightValue = 'RIGHT_FORM_FIELD_VALUE';
|
||||
|
||||
let myForm = new FormModel({
|
||||
const myForm = new FormModel({
|
||||
id: '9999',
|
||||
name: 'FORM_PROCESS_VARIABLE_VISIBILITY',
|
||||
processDefinitionId: 'PROCESS_TEST:9:9999',
|
||||
@@ -859,7 +859,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'FIELD_TEST';
|
||||
visibilityObjTest.operator = '!=';
|
||||
visibilityObjTest.rightFormFieldId = 'RIGHT_FORM_FIELD_ID';
|
||||
let tab = new TabModel(fakeFormWithField, { id: 'fake-tab-id', title: 'fake-tab-title', isVisible: true });
|
||||
const tab = new TabModel(fakeFormWithField, { id: 'fake-tab-id', title: 'fake-tab-title', isVisible: true });
|
||||
tab.visibilityCondition = visibilityObjTest;
|
||||
service.refreshEntityVisibility(tab);
|
||||
|
||||
@@ -870,7 +870,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'FIELD_TEST';
|
||||
visibilityObjTest.operator = '==';
|
||||
visibilityObjTest.rightFormFieldId = 'LEFT_FORM_FIELD_ID';
|
||||
let contModel = new ContainerModel(new FormFieldModel(fakeFormWithField, {
|
||||
const contModel = new ContainerModel(new FormFieldModel(fakeFormWithField, {
|
||||
id: 'fake-container-id',
|
||||
type: FormFieldTypes.GROUP,
|
||||
name: 'fake-container-name',
|
||||
@@ -887,7 +887,7 @@ describe('WidgetVisibilityService', () => {
|
||||
visibilityObjTest.leftFormFieldId = 'FIELD_TEST';
|
||||
visibilityObjTest.operator = '!=';
|
||||
visibilityObjTest.rightFormFieldId = 'RIGHT_FORM_FIELD_ID';
|
||||
let contModel = new ContainerModel(new FormFieldModel(fakeFormWithField, {
|
||||
const contModel = new ContainerModel(new FormFieldModel(fakeFormWithField, {
|
||||
id: 'fake-container-id',
|
||||
type: FormFieldTypes.GROUP,
|
||||
name: 'fake-container-name',
|
||||
|
@@ -47,12 +47,12 @@ export class WidgetVisibilityService {
|
||||
}
|
||||
|
||||
refreshEntityVisibility(element: FormFieldModel | TabModel) {
|
||||
let visible = this.evaluateVisibility(element.form, element.visibilityCondition);
|
||||
const visible = this.evaluateVisibility(element.form, element.visibilityCondition);
|
||||
element.isVisible = visible;
|
||||
}
|
||||
|
||||
evaluateVisibility(form: FormModel, visibilityObj: WidgetVisibilityModel): boolean {
|
||||
let isLeftFieldPresent = visibilityObj && ( visibilityObj.leftFormFieldId || visibilityObj.leftRestResponseId );
|
||||
const isLeftFieldPresent = visibilityObj && ( visibilityObj.leftFormFieldId || visibilityObj.leftRestResponseId );
|
||||
if (!isLeftFieldPresent || isLeftFieldPresent === 'null') {
|
||||
return true;
|
||||
} else {
|
||||
@@ -61,9 +61,9 @@ export class WidgetVisibilityService {
|
||||
}
|
||||
|
||||
isFieldVisible(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);
|
||||
const leftValue = this.getLeftValue(form, visibilityObj);
|
||||
const rightValue = this.getRightValue(form, visibilityObj);
|
||||
const actualResult = this.evaluateCondition(leftValue, rightValue, visibilityObj.operator);
|
||||
if (visibilityObj.nextCondition) {
|
||||
return this.evaluateLogicalOperation(
|
||||
visibilityObj.nextConditionOperator,
|
||||
@@ -150,7 +150,7 @@ export class WidgetVisibilityService {
|
||||
if (field.value && field.value.name) {
|
||||
value = field.value.name;
|
||||
} else if (field.options) {
|
||||
let option = field.options.find((opt) => opt.id === field.value);
|
||||
const option = field.options.find((opt) => opt.id === field.value);
|
||||
if (option) {
|
||||
value = this.getValueFromOption(fieldId, option);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ export class WidgetVisibilityService {
|
||||
}
|
||||
|
||||
private isSearchedField(field: FormFieldModel, fieldToFind: string): boolean {
|
||||
let formattedFieldName = this.removeLabel(field, fieldToFind);
|
||||
const formattedFieldName = this.removeLabel(field, fieldToFind);
|
||||
return field.id ? field.id.toUpperCase() === formattedFieldName.toUpperCase() : false;
|
||||
}
|
||||
|
||||
@@ -188,14 +188,14 @@ export class WidgetVisibilityService {
|
||||
|
||||
private getFormVariableValue(form: FormModel, name: string) {
|
||||
if (form.json.variables) {
|
||||
let formVariable = form.json.variables.find((formVar) => formVar.name === name);
|
||||
const formVariable = form.json.variables.find((formVar) => formVar.name === name);
|
||||
return formVariable ? formVariable.value : formVariable;
|
||||
}
|
||||
}
|
||||
|
||||
private getProcessVariableValue(name: string, processVarList: TaskProcessVariableModel[]) {
|
||||
if (this.processVarList) {
|
||||
let processVariable = this.processVarList.find((variable) => variable.id === name);
|
||||
const processVariable = this.processVarList.find((variable) => variable.id === name);
|
||||
return processVariable ? processVariable.value : processVariable;
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ export class WidgetVisibilityService {
|
||||
return from(this.apiService.getInstance().activiti.taskFormsApi.getTaskFormVariables(taskId))
|
||||
.pipe(
|
||||
map((res) => {
|
||||
let jsonRes = this.toJson(res);
|
||||
const jsonRes = this.toJson(res);
|
||||
this.processVarList = <TaskProcessVariableModel[]> jsonRes;
|
||||
return jsonRes;
|
||||
}),
|
||||
|
Reference in New Issue
Block a user