diff --git a/demo-shell/src/app/components/cloud/processes-cloud-demo.component.ts b/demo-shell/src/app/components/cloud/processes-cloud-demo.component.ts index f25934dc8dc..2310f062264 100644 --- a/demo-shell/src/app/components/cloud/processes-cloud-demo.component.ts +++ b/demo-shell/src/app/components/cloud/processes-cloud-demo.component.ts @@ -16,7 +16,7 @@ */ import { Component, OnInit, OnDestroy } from '@angular/core'; -import { EditProcessFilterCloudComponent, ProcessFilterAction, ProcessFilterCloudModel } from '@alfresco/adf-process-services-cloud'; +import { ProcessFilterAction, ProcessFilterCloudModel, PROCESS_FILTER_ACTION_DELETE, PROCESS_FILTER_ACTION_SAVE, PROCESS_FILTER_ACTION_SAVE_AS } from '@alfresco/adf-process-services-cloud'; import { ActivatedRoute, Router } from '@angular/router'; import { UserPreferencesService, DataCellEvent } from '@alfresco/adf-core'; import { CloudLayoutService, CloudServiceSettings } from './services/cloud-layout.service'; @@ -124,13 +124,13 @@ export class ProcessesCloudDemoComponent implements OnInit, OnDestroy { } onProcessFilterAction(filterAction: ProcessFilterAction) { - if (filterAction.actionType === EditProcessFilterCloudComponent.ACTION_DELETE) { + if (filterAction.actionType === PROCESS_FILTER_ACTION_DELETE) { this.cloudLayoutService.setCurrentProcessFilterParam({ index: 0 }); } else { this.cloudLayoutService.setCurrentProcessFilterParam({ id: filterAction.filter.id }); } - if ([EditProcessFilterCloudComponent.ACTION_SAVE, EditProcessFilterCloudComponent.ACTION_SAVE_AS].includes(filterAction.actionType)) { + if ([PROCESS_FILTER_ACTION_SAVE, PROCESS_FILTER_ACTION_SAVE_AS].includes(filterAction.actionType)) { this.onFilterChange(filterAction.filter); } } diff --git a/lib/process-services-cloud/.eslintrc.json b/lib/process-services-cloud/.eslintrc.json index c6f96091247..7ab8c8cc3fd 100644 --- a/lib/process-services-cloud/.eslintrc.json +++ b/lib/process-services-cloud/.eslintrc.json @@ -24,13 +24,14 @@ "@typescript-eslint/naming-convention": "warn", "@typescript-eslint/consistent-type-assertions": "warn", "@typescript-eslint/prefer-for-of": "warn", - "no-underscore-dangle": "warn", + "@typescript-eslint/member-ordering": "off", + "no-underscore-dangle": ["error", { "allowAfterThis": true }], "no-shadow": "warn", "quote-props": "warn", "object-shorthand": "warn", "prefer-const": "warn", "arrow-body-style": "warn", - "@angular-eslint/no-output-native": "warn", + "@angular-eslint/no-output-native": "off", "space-before-function-paren": "warn", "@angular-eslint/component-selector": [ diff --git a/lib/process-services-cloud/src/lib/app/components/app-details-cloud.component.ts b/lib/process-services-cloud/src/lib/app/components/app-details-cloud.component.ts index f2f43ad4bf5..0aa990a1e17 100644 --- a/lib/process-services-cloud/src/lib/app/components/app-details-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/app/components/app-details-cloud.component.ts @@ -35,6 +35,7 @@ export class AppDetailsCloudComponent { /** * Pass the selected app as next + * * @param app */ onSelectApp(app: ApplicationInstanceModel): void { diff --git a/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts index 57114dd030f..b2f98d2a65b 100644 --- a/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts @@ -21,7 +21,7 @@ import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core'; import { of, throwError } from 'rxjs'; import { fakeApplicationInstance } from '../mock/app-model.mock'; -import { AppListCloudComponent } from './app-list-cloud.component'; +import { AppListCloudComponent, LAYOUT_GRID, LAYOUT_LIST } from './app-list-cloud.component'; import { AppsProcessCloudService } from '../services/apps-process-cloud.service'; import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module'; import { TranslateModule } from '@ngx-translate/core'; @@ -38,9 +38,7 @@ describe('AppListCloudComponent', () => { oauth2Auth: { callCustomApi: () => Promise.resolve(fakeApplicationInstance) }, - isEcmLoggedIn() { - return false; - }, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') }; @@ -155,7 +153,7 @@ describe('AppListCloudComponent', () => { }); it('should display a grid when configured to', () => { - component.layoutType = AppListCloudComponent.LAYOUT_GRID; + component.layoutType = LAYOUT_GRID; fixture.detectChanges(); expect(component.isGrid()).toBe(true); expect(component.isList()).toBe(false); @@ -170,7 +168,7 @@ describe('AppListCloudComponent', () => { describe('List Layout ', () => { beforeEach(() => { - component.layoutType = AppListCloudComponent.LAYOUT_LIST; + component.layoutType = LAYOUT_LIST; }); it('should display a LIST when configured to', () => { diff --git a/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.ts b/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.ts index e6238329d33..2b8d060a5df 100644 --- a/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.ts @@ -22,17 +22,16 @@ import { AppsProcessCloudService } from '../services/apps-process-cloud.service' import { ApplicationInstanceModel } from '../models/application-instance.model'; import { catchError } from 'rxjs/operators'; +export const LAYOUT_LIST: string = 'LIST'; +export const LAYOUT_GRID: string = 'GRID'; +export const RUNNING_STATUS: string = 'RUNNING'; + @Component({ selector: 'adf-cloud-app-list', templateUrl: './app-list-cloud.component.html', styleUrls: ['./app-list-cloud.component.scss'] }) export class AppListCloudComponent implements OnInit, AfterContentInit { - - public static LAYOUT_LIST: string = 'LIST'; - public static LAYOUT_GRID: string = 'GRID'; - public static RUNNING_STATUS: string = 'RUNNING'; - @ContentChild(CustomEmptyContentTemplateDirective) emptyCustomContent: CustomEmptyContentTemplateDirective; @@ -40,7 +39,7 @@ export class AppListCloudComponent implements OnInit, AfterContentInit { * values, "GRID" and "LIST". */ @Input() - layoutType: string = AppListCloudComponent.LAYOUT_GRID; + layoutType: string = LAYOUT_GRID; /** Emitted when an app entry is clicked. */ @Output() @@ -57,7 +56,7 @@ export class AppListCloudComponent implements OnInit, AfterContentInit { this.setDefaultLayoutType(); } - this.apps$ = this.appsProcessCloudService.getDeployedApplicationsByStatus(AppListCloudComponent.RUNNING_STATUS) + this.apps$ = this.appsProcessCloudService.getDeployedApplicationsByStatus(RUNNING_STATUS) .pipe( catchError(() => { this.loadingError$.next(true); @@ -80,7 +79,7 @@ export class AppListCloudComponent implements OnInit, AfterContentInit { * Check if the value of the layoutType property is an allowed value */ isValidType(): boolean { - if (this.layoutType && (this.layoutType === AppListCloudComponent.LAYOUT_LIST || this.layoutType === AppListCloudComponent.LAYOUT_GRID)) { + if (this.layoutType && (this.layoutType === LAYOUT_LIST || this.layoutType === LAYOUT_GRID)) { return true; } return false; @@ -90,20 +89,20 @@ export class AppListCloudComponent implements OnInit, AfterContentInit { * Assign the default value to LayoutType */ setDefaultLayoutType(): void { - this.layoutType = AppListCloudComponent.LAYOUT_GRID; + this.layoutType = LAYOUT_GRID; } /** * Return true if the layout type is LIST */ isList(): boolean { - return this.layoutType === AppListCloudComponent.LAYOUT_LIST; + return this.layoutType === LAYOUT_LIST; } /** * Return true if the layout type is GRID */ isGrid(): boolean { - return this.layoutType === AppListCloudComponent.LAYOUT_GRID; + return this.layoutType === LAYOUT_GRID; } } diff --git a/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.spec.ts index 5c630fbbaa6..c56b8fdf0cf 100644 --- a/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.spec.ts @@ -34,9 +34,7 @@ describe('AppsProcessCloudService', () => { oauth2Auth: { callCustomApi: () => Promise.resolve({list : { entries: [ {entry: fakeApplicationInstance[0]}, {entry: fakeApplicationInstance[1]}] }}) }, - isEcmLoggedIn() { - return false; - }, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') }; diff --git a/lib/process-services-cloud/src/lib/common/date-range-filter/date-range-filter.component.spec.ts b/lib/process-services-cloud/src/lib/common/date-range-filter/date-range-filter.component.spec.ts index b7c2d1bd985..2c86f5bdf30 100644 --- a/lib/process-services-cloud/src/lib/common/date-range-filter/date-range-filter.component.spec.ts +++ b/lib/process-services-cloud/src/lib/common/date-range-filter/date-range-filter.component.spec.ts @@ -102,7 +102,7 @@ describe('DateRangeFilterComponent', () => { it('should not emit any date change events when any type is selected', () => { spyOn(component.dateChanged, 'emit'); - const value = { value: DateCloudFilterType.RANGE }; + const value = { value: DateCloudFilterType.RANGE } as MatSelectChange; component.onSelectionChange(value); expect(component.dateChanged.emit).not.toHaveBeenCalled(); }); @@ -114,7 +114,7 @@ describe('DateRangeFilterComponent', () => { }); it('should show date-range picker when type is range', async () => { - const value = { value: DateCloudFilterType.RANGE }; + const value = { value: DateCloudFilterType.RANGE } as MatSelectChange; component.onSelectionChange(value); fixture.detectChanges(); await fixture.whenStable(); @@ -127,7 +127,9 @@ describe('DateRangeFilterComponent', () => { component.ngOnInit(); fixture.detectChanges(); + // eslint-disable-next-line no-underscore-dangle expect(component.dateRangeForm.get('from').value).toEqual(moment(mockFilterProperty.value._startFrom)); + // eslint-disable-next-line no-underscore-dangle expect(component.dateRangeForm.get('to').value).toEqual(moment(mockFilterProperty.value._startTo)); }); diff --git a/lib/process-services-cloud/src/lib/form/components/cloud-form-rendering.service.ts b/lib/process-services-cloud/src/lib/form/components/cloud-form-rendering.service.ts index d282fa79050..265d7eb454d 100644 --- a/lib/process-services-cloud/src/lib/form/components/cloud-form-rendering.service.ts +++ b/lib/process-services-cloud/src/lib/form/components/cloud-form-rendering.service.ts @@ -33,10 +33,10 @@ export class CloudFormRenderingService extends FormRenderingService { super(); this.register({ - 'upload': () => AttachFileCloudWidgetComponent, - 'dropdown': () => DropdownCloudWidgetComponent, - 'date': () => DateCloudWidgetComponent, - 'people': () => PeopleCloudWidgetComponent, + upload: () => AttachFileCloudWidgetComponent, + dropdown: () => DropdownCloudWidgetComponent, + date: () => DateCloudWidgetComponent, + people: () => PeopleCloudWidgetComponent, 'functional-group': () => GroupCloudWidgetComponent, 'properties-viewer': () => PropertiesViewerWidgetComponent, 'radio-buttons': () => RadioButtonsCloudWidgetComponent diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts index c1bbaf13710..0b4c33e8a50 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts @@ -15,6 +15,8 @@ * limitations under the License. */ +/* eslint-disable @typescript-eslint/naming-convention */ + import { Component, DebugElement, SimpleChange, NgModule, Injector, ComponentFactoryResolver, ViewChild } from '@angular/core'; import { By } from '@angular/platform-browser'; import { ComponentFixture, TestBed } from '@angular/core/testing'; @@ -85,7 +87,7 @@ describe('FormCloudComponent', () => { }) class CustomUploadModule { } - function buildWidget(type: string, injector: Injector): any { + const buildWidget = (type: string, injector: Injector): any => { const resolver = formRenderingService.getComponentTypeResolver(type); const widgetType = resolver(null); @@ -94,7 +96,7 @@ describe('FormCloudComponent', () => { const componentRef = factory.create(injector); return componentRef.instance; - } + }; setupTestBed({ imports: [ @@ -231,14 +233,14 @@ describe('FormCloudComponent', () => { it('should enable custom outcome buttons', () => { const formModel = new FormModel(); formComponent.form = formModel; - const outcome = new FormOutcomeModel( formModel, { id: 'action1', name: 'Action 1' }); + const outcome = new FormOutcomeModel(formModel, { id: 'action1', name: 'Action 1' }); expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy(); }); it('should allow controlling [complete] button visibility', () => { const formModel = new FormModel(); formComponent.form = formModel; - const outcome = new FormOutcomeModel( formModel, { id: '$save', name: FormOutcomeModel.SAVE_ACTION }); + const outcome = new FormOutcomeModel(formModel, { id: '$save', name: FormOutcomeModel.SAVE_ACTION }); formComponent.showSaveButton = true; expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy(); @@ -251,7 +253,7 @@ describe('FormCloudComponent', () => { const formModel = new FormModel(); formModel.readOnly = true; formComponent.form = formModel; - const outcome = new FormOutcomeModel( formModel, { id: '$complete', name: FormOutcomeModel.COMPLETE_ACTION }); + const outcome = new FormOutcomeModel(formModel, { id: '$complete', name: FormOutcomeModel.COMPLETE_ACTION }); formComponent.showCompleteButton = true; expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy(); @@ -261,7 +263,7 @@ describe('FormCloudComponent', () => { const formModel = new FormModel(); formModel.readOnly = true; formComponent.form = formModel; - const outcome = new FormOutcomeModel( formModel, { id: '$save', name: FormOutcomeModel.SAVE_ACTION }); + const outcome = new FormOutcomeModel(formModel, { id: '$save', name: FormOutcomeModel.SAVE_ACTION }); formComponent.showSaveButton = true; expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeFalsy(); @@ -271,13 +273,13 @@ describe('FormCloudComponent', () => { const formModel = new FormModel({ selectedOutcome: 'custom-outcome' }); formModel.readOnly = true; formComponent.form = formModel; - let outcome = new FormOutcomeModel( formModel, { id: '$customoutome', name: 'custom-outcome' }); + let outcome = new FormOutcomeModel(formModel, { id: '$customoutome', name: 'custom-outcome' }); formComponent.showCompleteButton = true; formComponent.showSaveButton = true; expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy(); - outcome = new FormOutcomeModel( formModel, { id: '$customoutome2', name: 'custom-outcome2' }); + outcome = new FormOutcomeModel(formModel, { id: '$customoutome2', name: 'custom-outcome2' }); expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeFalsy(); }); @@ -285,7 +287,7 @@ describe('FormCloudComponent', () => { const formModel = new FormModel(); formModel.readOnly = false; formComponent.form = formModel; - const outcome = new FormOutcomeModel( formModel, { id: '$save', name: FormOutcomeModel.COMPLETE_ACTION }); + const outcome = new FormOutcomeModel(formModel, { id: '$save', name: FormOutcomeModel.COMPLETE_ACTION }); formComponent.showCompleteButton = true; expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy(); @@ -302,20 +304,16 @@ describe('FormCloudComponent', () => { }); it('should get task variables if a task form is rendered', () => { - spyOn(formCloudService, 'getTaskForm').and.callFake((currentTaskId) => { - return new Observable((observer) => { - observer.next({ formRepresentation: { taskId: currentTaskId } }); - observer.complete(); - }); - }); + spyOn(formCloudService, 'getTaskForm').and.callFake((currentTaskId) => new Observable((observer) => { + observer.next({ formRepresentation: { taskId: currentTaskId } }); + observer.complete(); + })); spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([])); - spyOn(formCloudService, 'getTask').and.callFake((currentTaskId) => { - return new Observable((observer) => { - observer.next({ formRepresentation: { taskId: currentTaskId } } as any); - observer.complete(); - }); - }); + spyOn(formCloudService, 'getTask').and.callFake((currentTaskId) => new Observable((observer) => { + observer.next({ formRepresentation: { taskId: currentTaskId } } as any); + observer.complete(); + })); const taskId = '123'; const appName = 'test-app'; @@ -327,12 +325,10 @@ describe('FormCloudComponent', () => { }); it('should not get task variables and form if task id is not specified', () => { - spyOn(formCloudService, 'getTaskForm').and.callFake((currentTaskId) => { - return new Observable((observer) => { - observer.next({ taskId: currentTaskId }); - observer.complete(); - }); - }); + spyOn(formCloudService, 'getTaskForm').and.callFake((currentTaskId) => new Observable((observer) => { + observer.next({ taskId: currentTaskId }); + observer.complete(); + })); spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([])); @@ -380,7 +376,7 @@ describe('FormCloudComponent', () => { formComponent.appName = appName; formComponent.appVersion = 1; const change = new SimpleChange(null, taskId, true); - formComponent.ngOnChanges({ 'taskId': change }); + formComponent.ngOnChanges({ taskId: change }); expect(formComponent.getFormByTaskId).toHaveBeenCalledWith(appName, taskId, 1); }); @@ -393,7 +389,7 @@ describe('FormCloudComponent', () => { formComponent.appName = appName; formComponent.appVersion = 1; const change = new SimpleChange(null, formId, true); - formComponent.ngOnChanges({ 'formId': change }); + formComponent.ngOnChanges({ formId: change }); expect(formComponent.getFormById).toHaveBeenCalledWith(appName, formId, 1); }); @@ -414,7 +410,7 @@ describe('FormCloudComponent', () => { spyOn(formComponent, 'getFormByTaskId').and.stub(); spyOn(formComponent, 'getFormById').and.stub(); - formComponent.ngOnChanges({ 'tag': new SimpleChange(null, 'hello world', false) }); + formComponent.ngOnChanges({ tag: new SimpleChange(null, 'hello world', false) }); expect(formComponent.getFormByTaskId).not.toHaveBeenCalled(); expect(formComponent.getFormById).not.toHaveBeenCalled(); @@ -423,7 +419,7 @@ describe('FormCloudComponent', () => { it('should complete form on custom outcome click', () => { const formModel = new FormModel(); const outcomeName = 'Custom Action'; - const outcome = new FormOutcomeModel( formModel, { id: 'custom1', name: outcomeName }); + const outcome = new FormOutcomeModel(formModel, { id: 'custom1', name: outcomeName }); let saved = false; formComponent.form = formModel; @@ -438,7 +434,7 @@ describe('FormCloudComponent', () => { it('should save form on [save] outcome click', () => { const formModel = new FormModel(); - const outcome = new FormOutcomeModel( formModel, { + const outcome = new FormOutcomeModel(formModel, { id: FormCloudComponent.SAVE_OUTCOME_ID, name: 'Save', isSystem: true @@ -454,7 +450,7 @@ describe('FormCloudComponent', () => { it('should complete form on [complete] outcome click', () => { const formModel = new FormModel(); - const outcome = new FormOutcomeModel( formModel, { + const outcome = new FormOutcomeModel(formModel, { id: FormCloudComponent.COMPLETE_OUTCOME_ID, name: 'Complete', isSystem: true @@ -470,7 +466,7 @@ describe('FormCloudComponent', () => { it('should emit form saved event on custom outcome click', () => { const formModel = new FormModel(); - const outcome = new FormOutcomeModel( formModel, { + const outcome = new FormOutcomeModel(formModel, { id: FormCloudComponent.CUSTOM_OUTCOME_ID, name: 'Custom', isSystem: true @@ -488,7 +484,7 @@ describe('FormCloudComponent', () => { it('should do nothing when clicking outcome for readonly form', () => { const formModel = new FormModel(); const outcomeName = 'Custom Action'; - const outcome = new FormOutcomeModel( formModel, { id: 'custom1', name: outcomeName }); + const outcome = new FormOutcomeModel(formModel, { id: 'custom1', name: outcomeName }); formComponent.form = formModel; spyOn(formComponent, 'completeTaskForm').and.stub(); @@ -507,7 +503,7 @@ describe('FormCloudComponent', () => { it('should require loaded form when clicking outcome', () => { const formModel = new FormModel(); const outcomeName = 'Custom Action'; - const outcome = new FormOutcomeModel( formModel, { id: 'custom1', name: outcomeName }); + const outcome = new FormOutcomeModel(formModel, { id: 'custom1', name: outcomeName }); formComponent.readOnly = false; formComponent.form = null; @@ -516,7 +512,7 @@ describe('FormCloudComponent', () => { it('should not execute unknown system outcome', () => { const formModel = new FormModel(); - const outcome = new FormOutcomeModel( formModel, { id: 'unknown', name: 'Unknown', isSystem: true }); + const outcome = new FormOutcomeModel(formModel, { id: 'unknown', name: 'Unknown', isSystem: true }); formComponent.form = formModel; expect(formComponent.onOutcomeClicked(outcome)).toBeFalsy(); @@ -524,12 +520,12 @@ describe('FormCloudComponent', () => { it('should require custom action name to complete form', () => { const formModel = new FormModel(); - let outcome = new FormOutcomeModel( formModel, { id: 'custom' }); + let outcome = new FormOutcomeModel(formModel, { id: 'custom' }); formComponent.form = formModel; expect(formComponent.onOutcomeClicked(outcome)).toBeFalsy(); - outcome = new FormOutcomeModel( formModel, { id: 'custom', name: 'Custom' }); + outcome = new FormOutcomeModel(formModel, { id: 'custom', name: 'Custom' }); spyOn(formComponent, 'completeTaskForm').and.stub(); expect(formComponent.onOutcomeClicked(outcome)).toBeTruthy(); }); @@ -540,7 +536,7 @@ describe('FormCloudComponent', () => { spyOn(formCloudService, 'getTask').and.returnValue(of({})); spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([])); - spyOn(formCloudService, 'getTaskForm').and.returnValue(of({ taskId: taskId, selectedOutcome: 'custom-outcome' })); + spyOn(formCloudService, 'getTaskForm').and.returnValue(of({ taskId, selectedOutcome: 'custom-outcome' })); formComponent.formLoaded.subscribe(() => { expect(formCloudService.getTaskForm).toHaveBeenCalledWith(appName, taskId, 1); @@ -561,9 +557,7 @@ describe('FormCloudComponent', () => { spyOn(formCloudService, 'getTask').and.returnValue(of({})); spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([])); spyOn(formComponent, 'handleError').and.stub(); - spyOn(formCloudService, 'getTaskForm').and.callFake(() => { - return throwError(error); - }); + spyOn(formCloudService, 'getTaskForm').and.callFake(() => throwError(error)); formComponent.getFormByTaskId('test-app', '123').then((_) => { expect(formComponent.handleError).toHaveBeenCalledWith(error); @@ -609,16 +603,14 @@ describe('FormCloudComponent', () => { const formValues: any[] = []; const change = new SimpleChange(null, formValues, false); formComponent.data = formValues; - formComponent.ngOnChanges({ 'data': change }); + formComponent.ngOnChanges({ data: change }); }); it('should save task form and raise corresponding event', () => { - spyOn(formCloudService, 'saveTaskForm').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(formCloudService, 'saveTaskForm').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); let saved = false; let savedForm = null; @@ -633,7 +625,7 @@ describe('FormCloudComponent', () => { const formModel = new FormModel({ id: '23', - taskId: taskId, + taskId, fields: [ { id: 'field1' }, { id: 'field2' } @@ -660,7 +652,7 @@ describe('FormCloudComponent', () => { const appName = 'test-app'; const formModel = new FormModel({ id: '23', - taskId: taskId, + taskId, fields: [ { id: 'field1' }, { id: 'field2' } @@ -711,12 +703,10 @@ describe('FormCloudComponent', () => { }); it('should complete form and raise corresponding event', () => { - spyOn(formCloudService, 'completeTaskForm').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(formCloudService, 'completeTaskForm').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); const outcome = 'complete'; let completed = false; @@ -729,7 +719,7 @@ describe('FormCloudComponent', () => { const formModel = new FormModel({ id: '23', - taskId: taskId, + taskId, fields: [ { id: 'field1' }, { id: 'field2' } @@ -767,7 +757,7 @@ describe('FormCloudComponent', () => { it('should prevent default outcome execution', () => { - const outcome = new FormOutcomeModel( new FormModel(), { + const outcome = new FormOutcomeModel(new FormModel(), { id: FormCloudComponent.CUSTOM_OUTCOME_ID, name: 'Custom' }); @@ -784,7 +774,7 @@ describe('FormCloudComponent', () => { }); it('should not prevent default outcome execution', () => { - const outcome = new FormOutcomeModel( new FormModel(), { + const outcome = new FormOutcomeModel(new FormModel(), { id: FormCloudComponent.CUSTOM_OUTCOME_ID, name: 'Custom' }); @@ -812,7 +802,7 @@ describe('FormCloudComponent', () => { formComponent.checkVisibility(field); expect(visibilityService.refreshVisibility).not.toHaveBeenCalled(); - field = new FormFieldModel( new FormModel()); + field = new FormFieldModel(new FormModel()); formComponent.checkVisibility(field); expect(visibilityService.refreshVisibility).toHaveBeenCalledWith(field.form); }); @@ -822,7 +812,7 @@ describe('FormCloudComponent', () => { formModel.readOnly = true; formComponent.form = formModel; - const outcome = new FormOutcomeModel( new FormModel(), { + const outcome = new FormOutcomeModel(new FormModel(), { id: FormCloudComponent.CUSTOM_OUTCOME_ID, name: 'Custom' }); @@ -901,7 +891,7 @@ describe('FormCloudComponent', () => { done(); }); - const outcome = new FormOutcomeModel( new FormModel(), { + const outcome = new FormOutcomeModel(new FormModel(), { id: FormCloudComponent.CUSTOM_OUTCOME_ID, name: 'Custom' }); @@ -935,7 +925,7 @@ describe('FormCloudComponent', () => { done(); }); - formComponent.ngOnChanges({ 'data': change }); + formComponent.ngOnChanges({ data: change }); }); it('should refresh radio buttons value when id is given to data', () => { @@ -947,7 +937,7 @@ describe('FormCloudComponent', () => { const formValues: any[] = [{ name: 'radiobuttons1', value: 'option_2' }]; const change = new SimpleChange(null, formValues, false); formComponent.data = formValues; - formComponent.ngOnChanges({ 'data': change }); + formComponent.ngOnChanges({ data: change }); formFields = formComponent.form.getFormFields(); radioFieldById = formFields.find((field) => field.id === 'radiobuttons1'); @@ -962,7 +952,7 @@ describe('FormCloudComponent', () => { formComponent.formId = formId; formComponent.appVersion = 1; - formComponent.ngOnChanges({ 'appName': new SimpleChange(null, appName, true) }); + formComponent.ngOnChanges({ appName: new SimpleChange(null, appName, true) }); expect(formCloudService.getForm).toHaveBeenCalledWith(appName, formId, 1); fixture.detectChanges(); @@ -984,7 +974,7 @@ describe('FormCloudComponent', () => { formComponent.formId = formId; formComponent.appVersion = 1; - formComponent.ngOnChanges({ 'appName': new SimpleChange(null, appName, true) }); + formComponent.ngOnChanges({ appName: new SimpleChange(null, appName, true) }); expect(formCloudService.getForm).toHaveBeenCalledWith(appName, formId, 1); fixture.detectChanges(); @@ -1009,7 +999,7 @@ describe('FormCloudComponent', () => { formComponent.formId = formId; formComponent.appVersion = 1; - formComponent.ngOnChanges({ 'appName': new SimpleChange(null, appName, true) }); + formComponent.ngOnChanges({ appName: new SimpleChange(null, appName, true) }); expect(formCloudService.getForm).toHaveBeenCalledWith(appName, formId, 1); fixture.detectChanges(); @@ -1029,10 +1019,10 @@ describe('FormCloudComponent', () => { expect(getLabelValue('amountField')).toEqual('Champ Montant'); }); - function getLabelValue(containerId: string): string { + const getLabelValue = (containerId: string): string => { const label = fixture.debugElement.nativeElement.querySelector(`[id="field-${containerId}-container"] label`); return label.innerText; - } + }; }); }); @@ -1144,7 +1134,7 @@ describe('retrieve metadata on submit', () => { let fixture: ComponentFixture; let formService: FormService; - const fakeNodeWithProperties: Node = { + const fakeNodeWithProperties = { id: 'fake-properties', name: 'fake-properties-name', content: { @@ -1154,7 +1144,7 @@ describe('retrieve metadata on submit', () => { 'pfx:property_one': 'testValue', 'pfx:property_two': true } - }; + } as Node; beforeEach(() => { const apiService = TestBed.inject(AlfrescoApiService); @@ -1225,7 +1215,7 @@ describe('retrieve metadata on submit', () => { }); it('should cancel bubbling a keydown event', () => { - const escapeKeyboardEvent = new KeyboardEvent('keydown', { 'keyCode': ESCAPE } as any); + const escapeKeyboardEvent = new KeyboardEvent('keydown', { keyCode: ESCAPE } as any); fixture.debugElement.triggerEventHandler('keydown', escapeKeyboardEvent); expect(escapeKeyboardEvent.cancelBubble).toBe(true); diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts index 32a63b05009..315b32d9f9a 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts @@ -210,7 +210,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, this.data = data[1]; const parsedForm = this.parseForm(this.formCloudRepresentationJSON); - this.visibilityService.refreshVisibility( parsedForm, this.data); + this.visibilityService.refreshVisibility(parsedForm, this.data); parsedForm.validateForm(); this.form = parsedForm; this.form.nodeId = '-my-'; @@ -239,7 +239,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, (form) => { this.formCloudRepresentationJSON = form; const parsedForm = this.parseForm(form); - this.visibilityService.refreshVisibility( parsedForm); + this.visibilityService.refreshVisibility(parsedForm); parsedForm.validateForm(); this.form = parsedForm; this.form.nodeId = '-my-'; @@ -300,11 +300,12 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, /** * Get custom set of outcomes for a Form Definition. + * * @param form Form definition model. */ getFormDefinitionOutcomes(form: FormModel): FormOutcomeModel[] { return [ - new FormOutcomeModel( form, { id: '$save', name: FormOutcomeModel.SAVE_ACTION, isSystem: true }) + new FormOutcomeModel(form, { id: '$save', name: FormOutcomeModel.SAVE_ACTION, isSystem: true }) ]; } diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts index 1e3763c8b34..55b388defa3 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts @@ -25,7 +25,6 @@ import { FormFieldModel, FormModel, FormFieldTypes, - FormFieldMetadata, FormService, DownloadService, AppConfigService, @@ -84,22 +83,22 @@ describe('AttachFileCloudWidgetComponent', () => { let openUploadFileDialogSpy: jasmine.Spy; let localizedDataPipe: LocalizedDatePipe; - function createUploadWidgetField(form: FormModel, fieldId: string, value?: any, params?: any, multiple?: boolean, name?: string, readOnly?: boolean) { + const createUploadWidgetField = (form: FormModel, fieldId: string, value?: any, params?: any, multiple?: boolean, name?: string, readOnly?: boolean) => { widget.field = new FormFieldModel(form, { type: FormFieldTypes.UPLOAD, - value: value, + value, id: fieldId, - readOnly: readOnly, - name: name, + readOnly, + name, tooltip: 'attach file widget', - params: { ...params, multiple: multiple } + params: { ...params, multiple } }); - } + }; - function clickOnAttachFileWidget(id: string) { + const clickOnAttachFileWidget = (id: string) => { const attachButton: HTMLButtonElement = element.querySelector(`#${id}`); attachButton.click(); - } + }; setupTestBed({ imports: [ @@ -204,7 +203,7 @@ describe('AttachFileCloudWidgetComponent', () => { describe('Upload widget with displayable ContentModel properties', () => { - it('should display CM Properties if the file contains value', async() => { + it('should display CM Properties if the file contains value', async () => { createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [fakeLocalPngHavingCMProperties], displayableCMParams); fixture.detectChanges(); await fixture.whenStable(); @@ -214,7 +213,7 @@ describe('AttachFileCloudWidgetComponent', () => { expect(element.querySelector('#fileProperty-1155-age').textContent).toBe('34'); }); - it('should display defaultValue if the file does not contain value for respective displayableCMProperties', async() => { + it('should display defaultValue if the file does not contain value for respective displayableCMProperties', async () => { createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [fakeLocalPngResponse], displayableCMParams); fixture.detectChanges(); await fixture.whenStable(); @@ -223,7 +222,7 @@ describe('AttachFileCloudWidgetComponent', () => { expect(element.querySelector('#fileProperty-1155-age').textContent).toBe('--'); }); - it('should not display CM Properties in table if the field does not contain displayableCMProperties', async() => { + it('should not display CM Properties in table if the field does not contain displayableCMProperties', async () => { createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [fakeLocalPngHavingCMProperties], allSourceParams); fixture.detectChanges(); await fixture.whenStable(); @@ -232,7 +231,7 @@ describe('AttachFileCloudWidgetComponent', () => { expect(element.querySelector('#fileProperty-1155-age')).toBeNull(); }); - it('should display date property in converted form based on dataType', async() => { + it('should display date property in converted form based on dataType', async () => { createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [fakeLocalPngHavingCMProperties], displayableCMParams); fixture.detectChanges(); await fixture.whenStable(); @@ -366,7 +365,7 @@ describe('AttachFileCloudWidgetComponent', () => { appConfigService.config = Object.assign(appConfigService.config, { 'alfresco-deployed-apps': [ { - 'name': 'fakeapp' + name: 'fakeapp' } ] }); @@ -464,10 +463,7 @@ describe('AttachFileCloudWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const menuButton = ( - fixture.debugElement.query(By.css('#file-1155-option-menu')) - .nativeElement - ); + const menuButton = fixture.debugElement.query(By.css('#file-1155-option-menu')).nativeElement as HTMLButtonElement; menuButton.click(); fixture.detectChanges(); @@ -498,7 +494,7 @@ describe('AttachFileCloudWidgetComponent', () => { value: [] }); widget.field.id = 'attach-file-alfresco'; - widget.field.params = menuTestSourceParam; + widget.field.params = menuTestSourceParam; fixture.detectChanges(); await fixture.whenStable(); @@ -511,16 +507,10 @@ describe('AttachFileCloudWidgetComponent', () => { it('should remove file when remove is clicked', (done) => { fixture.detectChanges(); - const menuButton: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-fake-properties-option-menu')) - .nativeElement - ); + const menuButton = fixture.debugElement.query(By.css('#file-fake-properties-option-menu')).nativeElement as HTMLButtonElement; menuButton.click(); fixture.detectChanges(); - const removeOption: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-fake-properties-remove')) - .nativeElement - ); + const removeOption = fixture.debugElement.query(By.css('#file-fake-properties-remove')).nativeElement as HTMLButtonElement; removeOption.click(); fixture.detectChanges(); fixture.whenRenderingDone().then(() => { @@ -536,19 +526,11 @@ describe('AttachFileCloudWidgetComponent', () => { fixture.detectChanges(); - const menuButton: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-fake-properties-option-menu')) - .nativeElement - ); - + const menuButton = fixture.debugElement.query(By.css('#file-fake-properties-option-menu')).nativeElement as HTMLButtonElement; menuButton.click(); fixture.detectChanges(); - const downloadOption: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-fake-properties-download-file')) - .nativeElement - ); - + const downloadOption = fixture.debugElement.query(By.css('#file-fake-properties-download-file')).nativeElement as HTMLButtonElement; downloadOption.click(); fixture.detectChanges(); @@ -568,18 +550,10 @@ describe('AttachFileCloudWidgetComponent', () => { ); fixture.detectChanges(); - const menuButton: HTMLButtonElement = ( - fixture.debugElement.query( - By.css('#file-fake-properties-option-menu') - ).nativeElement - ); + const menuButton = fixture.debugElement.query(By.css('#file-fake-properties-option-menu')).nativeElement as HTMLButtonElement; menuButton.click(); fixture.detectChanges(); - const showOption: HTMLButtonElement = ( - fixture.debugElement.query( - By.css('#file-fake-properties-show-file') - ).nativeElement - ); + const showOption = fixture.debugElement.query(By.css('#file-fake-properties-show-file')).nativeElement as HTMLButtonElement; showOption.click(); }); @@ -588,19 +562,11 @@ describe('AttachFileCloudWidgetComponent', () => { widget.field.value = [fakeNodeWithProperties]; fixture.detectChanges(); - const menuButton: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-fake-properties-option-menu')) - .nativeElement - ); - + const menuButton = fixture.debugElement.query(By.css('#file-fake-properties-option-menu')).nativeElement as HTMLButtonElement; menuButton.click(); fixture.detectChanges(); - const retrieveMetadataOption: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-fake-properties-retrieve-file-metadata')) - .nativeElement - ); - + const retrieveMetadataOption = fixture.debugElement.query(By.css('#file-fake-properties-retrieve-file-metadata')).nativeElement as HTMLButtonElement; retrieveMetadataOption.click(); expect(apiServiceSpy).toHaveBeenCalledWith(fakeNodeWithProperties.id); @@ -612,7 +578,7 @@ describe('AttachFileCloudWidgetComponent', () => { }); it('should display the default menu options if no options are provided', () => { - widget.field.params = onlyLocalParams; + widget.field.params = onlyLocalParams; fixture.detectChanges(); fixture.whenStable().then(() => { const inputDebugElement = fixture.debugElement.query( @@ -622,30 +588,14 @@ describe('AttachFileCloudWidgetComponent', () => { target: { files: [fakeLocalPngAnswer] } }); fixture.detectChanges(); - const menuButton: HTMLButtonElement = ( - fixture.debugElement.query( - By.css('#file-1155-option-menu') - ).nativeElement - ); + const menuButton = fixture.debugElement.query(By.css('#file-1155-option-menu')).nativeElement as HTMLButtonElement; menuButton.click(); fixture.detectChanges(); - const showOption: HTMLButtonElement = ( - fixture.debugElement.query( - By.css('#file-1155-show-file') - ).nativeElement - ); - const downloadOption: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-1155-download-file')) - .nativeElement - ); - const retrieveMetadataOption: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-1155-retrieve-file-metadata')) - .nativeElement - ); - const removeOption: HTMLButtonElement = ( - fixture.debugElement.query(By.css('#file-1155-remove')) - .nativeElement - ); + + const showOption = fixture.debugElement.query(By.css('#file-1155-show-file')).nativeElement as HTMLButtonElement; + const downloadOption = fixture.debugElement.query(By.css('#file-1155-download-file')).nativeElement as HTMLButtonElement; + const retrieveMetadataOption = fixture.debugElement.query(By.css('#file-1155-retrieve-file-metadata')).nativeElement as HTMLButtonElement; + const removeOption = fixture.debugElement.query(By.css('#file-1155-remove')).nativeElement as HTMLButtonElement; expect(showOption).not.toBeNull(); expect(downloadOption).not.toBeNull(); @@ -668,7 +618,7 @@ describe('AttachFileCloudWidgetComponent', () => { }); widget.field.id = 'attach-file-alfresco'; - widget.field.params = menuTestSourceParam; + widget.field.params = menuTestSourceParam; fixture.detectChanges(); await fixture.whenStable(); }); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts index be1c6b9ef9a..ad55e625904 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts @@ -37,6 +37,12 @@ import { UploadCloudWidgetComponent } from './upload-cloud.widget'; import { DestinationFolderPathModel, DestinationFolderPathType } from '../../../models/form-cloud-representation.model'; import { ContentNodeSelectorPanelService } from '@alfresco/adf-content-services'; +export const RETRIEVE_METADATA_OPTION = 'retrieveMetadata'; +export const ALIAS_ROOT_FOLDER = '-root-'; +export const ALIAS_USER_FOLDER = '-my-'; +export const APP_NAME = '-appname-'; +export const VALID_ALIAS = [ ALIAS_ROOT_FOLDER, ALIAS_USER_FOLDER, '-shared-' ]; + @Component({ selector: 'adf-cloud-attach-file-cloud-widget', templateUrl: './attach-file-cloud-widget.component.html', @@ -55,18 +61,8 @@ import { ContentNodeSelectorPanelService } from '@alfresco/adf-content-services' encapsulation: ViewEncapsulation.None }) export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent implements OnInit, OnDestroy { - - static ALIAS_ROOT_FOLDER = '-root-'; - static ALIAS_USER_FOLDER = '-my-'; - static APP_NAME = '-appname-'; - static VALID_ALIAS = [ - AttachFileCloudWidgetComponent.ALIAS_ROOT_FOLDER, - AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER, '-shared-' - ]; - static RETRIEVE_METADATA_OPTION = 'retrieveMetadata'; - typeId = 'AttachFileCloudWidgetComponent'; - rootNodeId = AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER; + rootNodeId = ALIAS_USER_FOLDER; selectedNode: Node; _nodesApi: NodesApi; @@ -121,9 +117,9 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i } replaceAppNameAliasWithValue(path: string): string { - if (path?.match(AttachFileCloudWidgetComponent.APP_NAME)) { + if (path?.match(APP_NAME)) { const appName = this.fetchAppNameFromAppConfig(); - return path.replace(AttachFileCloudWidgetComponent.APP_NAME, appName); + return path.replace(APP_NAME, appName); } return path; } @@ -131,7 +127,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i async openSelectDialog() { const selectedMode = this.field.params.multiple ? 'multiple' : 'single'; const nodeId = await this.getDestinationFolderNodeId(); - this.rootNodeId = nodeId ? nodeId : AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER; + this.rootNodeId = nodeId ? nodeId : ALIAS_USER_FOLDER; this.contentNodeSelectorPanelService.customModels = this.field.params.customModels; this.contentNodeSelectorService @@ -160,7 +156,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i rootNodeId = await this.getNodeIdFromFolderVariableValue(this.field.params.fileSource.destinationFolderPath); break; default: - rootNodeId = await this.getNodeIdFromPath({ type: '', value: AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER }); + rootNodeId = await this.getNodeIdFromPath({ type: '', value: ALIAS_USER_FOLDER }); break; } @@ -183,7 +179,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i async getNodeIdFromFolderVariableValue(destinationFolderPath: DestinationFolderPath): Promise { let nodeId: string; try { - nodeId = await this.contentNodeSelectorService.getNodeIdFromFolderVariableValue(destinationFolderPath.value, AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER); + nodeId = await this.contentNodeSelectorService.getNodeIdFromFolderVariableValue(destinationFolderPath.value, ALIAS_USER_FOLDER); } catch (error) { this.logService.error(error); } @@ -203,7 +199,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i } } - return this.isValidAlias(alias) ? { alias, path } : { alias: AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER, path: undefined }; + return this.isValidAlias(alias) ? { alias, path } : { alias: ALIAS_USER_FOLDER, path: undefined }; } removeExistingSelection(selections: Node[]) { @@ -252,11 +248,11 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i } isRetrieveMetadataOptionEnabled(): boolean { - return this.field?.params?.menuOptions && this.field.params.menuOptions[AttachFileCloudWidgetComponent.RETRIEVE_METADATA_OPTION]; + return this.field?.params?.menuOptions && this.field.params.menuOptions[RETRIEVE_METADATA_OPTION]; } isValidAlias(alias: string): boolean { - return alias && AttachFileCloudWidgetComponent.VALID_ALIAS.includes(alias); + return alias && VALID_ALIAS.includes(alias); } ngOnDestroy() { diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.ts index 25f61b779bc..4fba9f160f0 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/file-properties-table-cloud.component.ts @@ -21,15 +21,14 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; import { LocalizedDatePipe, ThumbnailService } from '@alfresco/adf-core'; import { Node } from '@alfresco/js-api'; +export const RETRIEVE_METADATA_OPTION = 'retrieveMetadata'; + @Component({ selector: 'adf-cloud-file-properties-table', templateUrl: './file-properties-table-cloud.component.html', styleUrls: ['./file-properties-table-cloud.component.scss'] }) export class FilePropertiesTableCloudComponent { - - static RETRIEVE_METADATA_OPTION = 'retrieveMetadata'; - @Input() uploadedFiles; @@ -109,6 +108,6 @@ export class FilePropertiesTableCloudComponent { } displayMenuOption(option: string): boolean { - return this.field?.params?.menuOptions ? this.field.params.menuOptions[option] : option !== FilePropertiesTableCloudComponent.RETRIEVE_METADATA_OPTION; + return this.field?.params?.menuOptions ? this.field.params.menuOptions[option] : option !== RETRIEVE_METADATA_OPTION; } } diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.spec.ts index 77e1a763ee0..31a09e53a0a 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.spec.ts @@ -16,7 +16,7 @@ */ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { DateCloudWidgetComponent } from './date-cloud.widget'; +import { DateCloudWidgetComponent, DATE_FORMAT_CLOUD } from './date-cloud.widget'; import { setupTestBed, FormFieldModel, FormModel } from '@alfresco/adf-core'; import moment from 'moment-es6'; import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module'; @@ -46,19 +46,19 @@ describe('DateWidgetComponent', () => { widget.field = new FormFieldModel(null, { id: 'date-id', name: 'date-name', - minValue: minValue + minValue }); widget.ngOnInit(); - const expected = moment(minValue, widget.DATE_FORMAT_CLOUD); + const expected = moment(minValue, DATE_FORMAT_CLOUD); expect(widget.minDate.isSame(expected)).toBeTruthy(); }); it('should date field be present', () => { const minValue = '1982-03-13'; widget.field = new FormFieldModel(null, { - minValue: minValue + minValue }); fixture.detectChanges(); @@ -70,11 +70,11 @@ describe('DateWidgetComponent', () => { it('should setup max value for date picker', () => { const maxValue = '1982-03-13'; widget.field = new FormFieldModel(null, { - maxValue: maxValue + maxValue }); widget.ngOnInit(); - const expected = moment(maxValue, widget.DATE_FORMAT_CLOUD); + const expected = moment(maxValue, DATE_FORMAT_CLOUD); expect(widget.maxDate.isSame(expected)).toBeTruthy(); }); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts index 24285cd6118..c0d3acea79c 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts @@ -28,6 +28,8 @@ import { UserPreferencesService, UserPreferenceValues, FormService } from '@alfresco/adf-core'; +export const DATE_FORMAT_CLOUD = 'YYYY-MM-DD'; + @Component({ selector: 'date-widget', providers: [ @@ -49,9 +51,7 @@ import { encapsulation: ViewEncapsulation.None }) export class DateCloudWidgetComponent extends WidgetComponent implements OnInit, OnDestroy { - typeId = 'DateCloudWidgetComponent'; - DATE_FORMAT_CLOUD = 'YYYY-MM-DD'; minDate: Moment; maxDate: Moment; @@ -70,16 +70,16 @@ export class DateCloudWidgetComponent extends WidgetComponent implements OnInit, .pipe(takeUntil(this.onDestroy$)) .subscribe(locale => this.dateAdapter.setLocale(locale)); - const momentDateAdapter = this.dateAdapter; + const momentDateAdapter = this.dateAdapter as MomentDateAdapter; momentDateAdapter.overrideDisplayFormat = this.field.dateDisplayFormat; if (this.field) { if (this.field.minValue) { - this.minDate = moment(this.field.minValue, this.DATE_FORMAT_CLOUD); + this.minDate = moment(this.field.minValue, DATE_FORMAT_CLOUD); } if (this.field.maxValue) { - this.maxDate = moment(this.field.maxValue, this.DATE_FORMAT_CLOUD); + this.maxDate = moment(this.field.maxValue, DATE_FORMAT_CLOUD); } } } diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts index 71f1f8566e3..8f05d60f792 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts @@ -41,13 +41,13 @@ describe('DropdownCloudWidgetComponent', () => { let fixture: ComponentFixture; let element: HTMLElement; - async function openSelect(_selector?: string) { + const openSelect = async (_selector?: string) => { const dropdown: HTMLElement = element.querySelector('.mat-select-trigger'); dropdown.click(); fixture.detectChanges(); await fixture.whenStable(); fixture.detectChanges(); - } + }; setupTestBed({ imports: [ @@ -71,9 +71,7 @@ describe('DropdownCloudWidgetComponent', () => { describe('Simple Dropdown', () => { beforeEach(() => { - spyOn(formService, 'getRestFieldValues').and.callFake(() => { - return of(fakeOptionList); - }); + spyOn(formService, 'getRestFieldValues').and.callFake(() => of(fakeOptionList)); widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), { id: 'dropdown-id', name: 'date-name', @@ -366,7 +364,7 @@ describe('DropdownCloudWidgetComponent', () => { await openSelect('child-dropdown-id'); const defaultOption: any = fixture.debugElement.query(By.css('[id="empty"]')); - expect(widget.field.options).toEqual([{ 'id': 'empty', 'name': 'Choose one...' }]); + expect(widget.field.options).toEqual([{ id: 'empty', name: 'Choose one...' }]); expect(defaultOption.context.value).toBe('empty'); expect(defaultOption.context.viewValue).toBe('Choose one...'); }); @@ -396,11 +394,11 @@ describe('DropdownCloudWidgetComponent', () => { const mockParentDropdown = { id: 'parentDropdown', value: 'mock-value', validate: () => true }; spyOn(widget.field.form, 'getFormFields').and.returnValue([mockParentDropdown]); - function selectParentOption(parentOptionName: string) { + const selectParentOption = (parentOptionName: string) => { parentDropdown.value = parentOptionName; widget.selectionChangedForField(parentDropdown); fixture.detectChanges(); - } + }; selectParentOption('UK'); await openSelect('child-dropdown-id'); @@ -495,7 +493,7 @@ describe('DropdownCloudWidgetComponent', () => { await openSelect('child-dropdown-id'); const defaultOption: any = fixture.debugElement.query(By.css('[id="empty"]')); - expect(widget.field.options).toEqual([{ 'id': 'empty', 'name': 'Choose one...' }]); + expect(widget.field.options).toEqual([{ id: 'empty', name: 'Choose one...' }]); expect(defaultOption.context.value).toBe('empty'); expect(defaultOption.context.viewValue).toBe('Choose one...'); }); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts index 89206e1e7b9..a95dcfeb39e 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts @@ -31,6 +31,12 @@ import { FormCloudService } from '../../../services/form-cloud.service'; import { BehaviorSubject, combineLatest, Observable, of, Subject } from 'rxjs'; import { filter, map, takeUntil } from 'rxjs/operators'; +export const DEFAULT_OPTION = { + id: 'empty', + name: 'Choose one...' +}; +export const HIDE_FILTER_LIMIT = 5; + /* eslint-disable @angular-eslint/component-selector */ @Component({ @@ -51,13 +57,7 @@ import { filter, map, takeUntil } from 'rxjs/operators'; encapsulation: ViewEncapsulation.None }) export class DropdownCloudWidgetComponent extends WidgetComponent implements OnInit, OnDestroy { - static DEFAULT_OPTION = { - id: 'empty', - name: 'Choose one...' - }; - typeId = 'DropdownCloudWidgetComponent'; - HIDE_FILTER_LIMIT = 5; showInputFilter = false; isRestApiFailed = false; restApiHostName: string; @@ -151,7 +151,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI } private isDefaultValue(value: string): boolean { - return value === DropdownCloudWidgetComponent.DEFAULT_OPTION.id; + return value === DEFAULT_OPTION.id; } private getFormFieldById(fieldId): FormFieldModel { @@ -200,7 +200,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI } private addDefaultOption() { - this.field.options = [DropdownCloudWidgetComponent.DEFAULT_OPTION]; + this.field.options = [DEFAULT_OPTION]; this.updateOptions(); } @@ -252,7 +252,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI } let optionValue: string = ''; - if (option.id === DropdownCloudWidgetComponent.DEFAULT_OPTION.id || option.name !== fieldValue) { + if (option.id === DEFAULT_OPTION.id || option.name !== fieldValue) { optionValue = option.id; } else { optionValue = option.name; @@ -278,7 +278,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI } updateOptions(): void { - this.showInputFilter = this.field.options.length > this.appConfig.get('form.dropDownFilterLimit', this.HIDE_FILTER_LIMIT); + this.showInputFilter = this.field.options.length > this.appConfig.get('form.dropDownFilterLimit', HIDE_FILTER_LIMIT); this.list$ = combineLatest([of(this.field.options), this.filter$]) .pipe( map(([items, search]) => { diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.spec.ts index caeb57e4906..21a3c79479c 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.spec.ts @@ -60,7 +60,7 @@ describe('RadioButtonsCloudWidgetComponent', () => { const fieldId = ''; const form = new FormModel({ - taskId: taskId + taskId }); widget.field = new FormFieldModel(form, { @@ -124,13 +124,13 @@ describe('RadioButtonsCloudWidgetComponent', () => { expect(widgetLabel.innerText).toBe('radio-name-label*'); expect(widget.field.isValid).toBe(false); - const option: HTMLElement = element.querySelector('#radio-id-opt-1 label'); + const option = element.querySelector('#radio-id-opt-1 label'); option.click(); fixture.detectChanges(); await fixture.whenStable(); fixture.detectChanges(); - const selectedOption: HTMLElement = element.querySelector('[class*="mat-radio-checked"]'); + const selectedOption = element.querySelector('[class*="mat-radio-checked"]'); expect(selectedOption.innerText).toBe('opt-name-1'); expect(widget.field.isValid).toBe(true); }); @@ -149,7 +149,7 @@ describe('RadioButtonsCloudWidgetComponent', () => { }); fixture.detectChanges(); - const selectedOption: HTMLElement = element.querySelector('[class*="mat-radio-checked"]'); + const selectedOption = element.querySelector('[class*="mat-radio-checked"]'); expect(selectedOption.innerText).toBe('opt-name-2'); expect(widget.field.isValid).toBe(true); }); @@ -168,7 +168,7 @@ describe('RadioButtonsCloudWidgetComponent', () => { }); fixture.detectChanges(); - const selectedOption: HTMLElement = element.querySelector('[class*="mat-radio-checked"]'); + const selectedOption = element.querySelector('[class*="mat-radio-checked"]'); expect(selectedOption.innerText).toBe('opt-name-1'); expect(widget.field.isValid).toBe(true); }); diff --git a/lib/process-services-cloud/src/lib/form/mocks/attach-file-cloud-widget.mock.ts b/lib/process-services-cloud/src/lib/form/mocks/attach-file-cloud-widget.mock.ts index 61de593cc02..1bba0a4eb7a 100644 --- a/lib/process-services-cloud/src/lib/form/mocks/attach-file-cloud-widget.mock.ts +++ b/lib/process-services-cloud/src/lib/form/mocks/attach-file-cloud-widget.mock.ts @@ -15,7 +15,10 @@ * limitations under the License. */ +/* eslint-disable @typescript-eslint/naming-convention */ + import { Node } from '@alfresco/js-api'; +import { FormFieldMetadata } from '@alfresco/adf-core'; import { FileSourceTypes, DestinationFolderPathType } from '../models/form-cloud-representation.model'; export const fakeLocalPngResponse = { @@ -101,14 +104,14 @@ export const onlyLocalParams = { fileSource: { serviceId: 'local-file' } -}; +} as FormFieldMetadata; export const contentSourceParam = { fileSource: { name: 'mock-alf-content', serviceId: FileSourceTypes.ALFRESCO_CONTENT_SOURCES_SERVICE_ID } -}; +} as FormFieldMetadata; export const menuTestSourceParam = { fileSource: { @@ -121,7 +124,7 @@ export const menuTestSourceParam = { retrieveMetadata: true, remove: true } -}; +} as FormFieldMetadata; export const allSourceParamsWithRelativePath = { fileSource: { @@ -156,32 +159,32 @@ export const displayableCMParams = { }, displayableCMProperties: [ { - 'name': 'name', - 'prefixedName': 'a:name', - 'title': '', - 'dataType': 'd:text', - 'defaultValue': 'Bob' + name: 'name', + prefixedName: 'a:name', + title: '', + dataType: 'd:text', + defaultValue: 'Bob' }, { - 'name': 'age', - 'prefixedName': 'a:age', - 'title': 'Age', - 'dataType': 'd:text', - 'defaultValue': '' + name: 'age', + prefixedName: 'a:age', + title: 'Age', + dataType: 'd:text', + defaultValue: '' }, { - 'name': 'dob', - 'prefixedName': 'a:dob', - 'title': 'Date of Birth', - 'dataType': 'd:date', - 'defaultValue': '' + name: 'dob', + prefixedName: 'a:dob', + title: 'Date of Birth', + dataType: 'd:date', + defaultValue: '' }, { - 'name': 'doj', - 'prefixedName': 'a:doj', - 'title': 'Date of Joining', - 'dataType': 'd:datetime', - 'defaultValue': '' + name: 'doj', + prefixedName: 'a:doj', + title: 'Date of Joining', + dataType: 'd:datetime', + defaultValue: '' } ] }; @@ -260,15 +263,15 @@ export const allSourceWithoutValueProperty = { } }; -export const fakeMinimalNode: Node = { +export const fakeMinimalNode = { id: 'fake', name: 'fake-name', content: { mimeType: 'application/pdf' } -}; +} as Node; -export const fakeNodeWithProperties: Node = { +export const fakeNodeWithProperties = { id: 'fake-properties', name: 'fake-properties-name', content: { @@ -278,22 +281,22 @@ export const fakeNodeWithProperties: Node = { 'pfx:property_one': 'testValue', 'pfx:property_two': true } -}; +} as Node; export const expectedValues = { pfx_property_one: 'testValue', pfx_property_two: true }; -export const mockNodeId = new Promise(function(resolve) { +export const mockNodeId = new Promise((resolve) => { resolve('mock-node-id'); }); -export const mockNodeIdBasedOnStringVariableValue = new Promise(function(resolve) { +export const mockNodeIdBasedOnStringVariableValue = new Promise((resolve) => { resolve('mock-string-value-node-id'); }); -export const mockNodeIdBasedOnFolderVariableValue = new Promise(function(resolve) { +export const mockNodeIdBasedOnFolderVariableValue = new Promise((resolve) => { resolve('mock-folder-value-node-id'); }); @@ -391,61 +394,61 @@ export const mockAllFileSourceWithRenamedFolderVariablePathType = { export const formVariables = [ { - 'id': 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', - 'name': 'name1', - 'type': 'string', - 'value': 'hello' + id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', + name: 'name1', + type: 'string', + value: 'hello' }, { - 'id': '3ed9f28a-dbae-463f-b991-47ef06658bb6', - 'name': 'name2', - 'type': 'folder' + id: '3ed9f28a-dbae-463f-b991-47ef06658bb6', + name: 'name2', + type: 'folder' }, { - 'id': 'booleanVar', - 'name': 'bool', - 'type': 'boolean', - 'value': 'true' + id: 'booleanVar', + name: 'bool', + type: 'boolean', + value: 'true' } ]; export const processVariables = [ { - 'serviceName': 'mock-variable-mapping-rb', - 'serviceFullName': 'mock-variable-mapping-rb', - 'serviceVersion': '', - 'appName': 'mock-variable-mapping', - 'appVersion': '', - 'serviceType': null, - 'id': 3, - 'type': 'string', - 'name': 'variables.name1', - 'createTime': 1566989626284, - 'lastUpdatedTime': 1566989626284, - 'executionId': null, - 'value': '-root-/pathBasedOnStringvariablevalue', - 'markedAsDeleted': false, - 'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44', - 'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44', - 'taskVariable': true + serviceName: 'mock-variable-mapping-rb', + serviceFullName: 'mock-variable-mapping-rb', + serviceVersion: '', + appName: 'mock-variable-mapping', + appVersion: '', + serviceType: null, + id: 3, + type: 'string', + name: 'variables.name1', + createTime: 1566989626284, + lastUpdatedTime: 1566989626284, + executionId: null, + value: '-root-/pathBasedOnStringvariablevalue', + markedAsDeleted: false, + processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44', + taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44', + taskVariable: true }, { - 'serviceName': 'mock-variable-mapping-rb', - 'serviceFullName': 'mock-variable-mapping-rb', - 'serviceVersion': '', - 'appName': 'mock-variable-mapping', - 'appVersion': '', - 'serviceType': null, - 'id': 1, - 'type': 'folder', - 'name': 'variables.name2', - 'createTime': 1566989626283, - 'lastUpdatedTime': 1566989626283, - 'executionId': null, - 'value': [{ id: 'mock-folder-id'}], - 'markedAsDeleted': false, - 'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44', - 'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44', - 'taskVariable': true + serviceName: 'mock-variable-mapping-rb', + serviceFullName: 'mock-variable-mapping-rb', + serviceVersion: '', + appName: 'mock-variable-mapping', + appVersion: '', + serviceType: null, + id: 1, + type: 'folder', + name: 'variables.name2', + createTime: 1566989626283, + lastUpdatedTime: 1566989626283, + executionId: null, + value: [{ id: 'mock-folder-id'}], + markedAsDeleted: false, + processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44', + taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44', + taskVariable: true } ]; diff --git a/lib/process-services-cloud/src/lib/form/mocks/cloud-form.mock.ts b/lib/process-services-cloud/src/lib/form/mocks/cloud-form.mock.ts index 2394924369c..011325d8953 100644 --- a/lib/process-services-cloud/src/lib/form/mocks/cloud-form.mock.ts +++ b/lib/process-services-cloud/src/lib/form/mocks/cloud-form.mock.ts @@ -16,582 +16,582 @@ */ export const cloudFormMock = { - 'id': 'form-b661635a-dc3e-4557-914a-3498ed47189c', - 'name': 'form-with-all-fields', - 'description': '', - 'version': 0, - 'tabs': [], - 'fields': [ + id: 'form-b661635a-dc3e-4557-914a-3498ed47189c', + name: 'form-with-all-fields', + description: '', + version: 0, + tabs: [], + fields: [ { - 'fieldType': 'ContainerRepresentation', - 'id': '26b10e64-0403-4686-a75b-0d45279ce3a8', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '26b10e64-0403-4686-a75b-0d45279ce3a8', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'text1', - 'name': 'Text1', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': true, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'text1', + name: 'Text1', + type: 'text', + value: null, + required: false, + readOnly: true, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'text2', - 'name': 'Text2', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': true, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'text2', + name: 'Text2', + type: 'text', + value: null, + required: false, + readOnly: true, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '69c1390a-8d8d-423c-8efb-8e43401efa42', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '69c1390a-8d8d-423c-8efb-8e43401efa42', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'multilinetext1', - 'name': 'Multiline text1', - 'type': 'multi-line-text', - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'required': false, - 'readOnly': true, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'multilinetext1', + name: 'Multiline text1', + type: 'multi-line-text', + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + required: false, + readOnly: true, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'multilinetext2', - 'name': 'Multiline text2', - 'type': 'multi-line-text', - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'required': false, - 'readOnly': true, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'multilinetext2', + name: 'Multiline text2', + type: 'multi-line-text', + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + required: false, + readOnly: true, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': 'df046463-2d65-4388-9ee1-0e1517985215', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: 'df046463-2d65-4388-9ee1-0e1517985215', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'number1', - 'overrideId': false, - 'name': 'Number1', - 'type': 'integer', - 'colspan': 1, - 'placeholder': null, - 'readOnly': true, - 'minValue': null, - 'maxValue': null, - 'required': false, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'number1', + overrideId: false, + name: 'Number1', + type: 'integer', + colspan: 1, + placeholder: null, + readOnly: true, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'number2', - 'overrideId': false, - 'name': 'Number2', - 'type': 'integer', - 'colspan': 1, - 'placeholder': null, - 'readOnly': true, - 'minValue': null, - 'maxValue': null, - 'required': false, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'number2', + overrideId: false, + name: 'Number2', + type: 'integer', + colspan: 1, + placeholder: null, + readOnly: true, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '9672cc7b-1959-49c9-96be-3816e57bdfc1', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '9672cc7b-1959-49c9-96be-3816e57bdfc1', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'checkbox1', - 'name': 'Checkbox1', - 'type': 'boolean', - 'required': false, - 'readOnly': true, - 'colspan': 1, - 'overrideId': false, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'checkbox1', + name: 'Checkbox1', + type: 'boolean', + required: false, + readOnly: true, + colspan: 1, + overrideId: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'checkbox2', - 'name': 'Checkbox2', - 'type': 'boolean', - 'required': false, - 'readOnly': true, - 'colspan': 1, - 'overrideId': false, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'checkbox2', + name: 'Checkbox2', + type: 'boolean', + required: false, + readOnly: true, + colspan: 1, + overrideId: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '054d193e-a899-4494-9a3e-b489315b7d57', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '054d193e-a899-4494-9a3e-b489315b7d57', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'dropdown1', - 'name': 'Dropdown1', - 'type': 'dropdown', - 'value': null, - 'required': false, - 'readOnly': true, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'optionType': 'manual', - 'options': [], - 'endpoint': null, - 'requestHeaders': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'dropdown1', + name: 'Dropdown1', + type: 'dropdown', + value: null, + required: false, + readOnly: true, + overrideId: false, + colspan: 1, + placeholder: null, + optionType: 'manual', + options: [], + endpoint: null, + requestHeaders: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'dropdown2', - 'name': 'Dropdown2', - 'type': 'dropdown', - 'value': null, - 'required': false, - 'readOnly': true, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'optionType': 'manual', - 'options': [], - 'endpoint': null, - 'requestHeaders': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'dropdown2', + name: 'Dropdown2', + type: 'dropdown', + value: null, + required: false, + readOnly: true, + overrideId: false, + colspan: 1, + placeholder: null, + optionType: 'manual', + options: [], + endpoint: null, + requestHeaders: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1f8f0b66-e022-4667-91b4-bbbf2ddc36fb', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '1f8f0b66-e022-4667-91b4-bbbf2ddc36fb', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'amount1', - 'name': 'Amount1', - 'type': 'amount', - 'value': null, - 'required': false, - 'readOnly': true, - 'overrideId': false, - 'colspan': 1, - 'placeholder': '123', - 'minValue': null, - 'maxValue': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'amount1', + name: 'Amount1', + type: 'amount', + value: null, + required: false, + readOnly: true, + overrideId: false, + colspan: 1, + placeholder: '123', + minValue: null, + maxValue: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'enableFractions': false, - 'currency': '$' + enableFractions: false, + currency: '$' } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'amount2', - 'name': 'Amount2', - 'type': 'amount', - 'value': null, - 'required': false, - 'readOnly': true, - 'overrideId': false, - 'colspan': 1, - 'placeholder': '123', - 'minValue': null, - 'maxValue': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'amount2', + name: 'Amount2', + type: 'amount', + value: null, + required: false, + readOnly: true, + overrideId: false, + colspan: 1, + placeholder: '123', + minValue: null, + maxValue: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'enableFractions': false, - 'currency': '$' + enableFractions: false, + currency: '$' } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '541a368b-67ee-4a7c-ae7e-232c050b9e24', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '541a368b-67ee-4a7c-ae7e-232c050b9e24', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'date1', - 'name': 'Date1', - 'type': 'date', - 'overrideId': false, - 'required': false, - 'readOnly': true, - 'colspan': 1, - 'placeholder': null, - 'minValue': null, - 'maxValue': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'date1', + name: 'Date1', + type: 'date', + overrideId: false, + required: false, + readOnly: true, + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': 'D-M-YYYY' + dateDisplayFormat: 'D-M-YYYY' } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'date2', - 'name': 'Date2', - 'type': 'date', - 'overrideId': false, - 'required': false, - 'readOnly': true, - 'colspan': 1, - 'placeholder': null, - 'minValue': null, - 'maxValue': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'date2', + name: 'Date2', + type: 'date', + overrideId: false, + required: false, + readOnly: true, + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': 'D-M-YYYY' + dateDisplayFormat: 'D-M-YYYY' } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': 'e79cb7e2-3dc1-4c79-8158-28662c28a9f3', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: 'e79cb7e2-3dc1-4c79-8158-28662c28a9f3', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'radiobuttons1', - 'name': 'Radio buttons1', - 'type': 'radio-buttons', - 'value': null, - 'required': false, - 'readOnly': true, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'optionType': 'manual', - 'options': [ + fieldType: 'FormFieldRepresentation', + id: 'radiobuttons1', + name: 'Radio buttons1', + type: 'radio-buttons', + value: null, + required: false, + readOnly: true, + overrideId: false, + colspan: 1, + placeholder: null, + optionType: 'manual', + options: [ { - 'id': 'option_1', - 'name': 'Option 1' + id: 'option_1', + name: 'Option 1' }, { - 'id': 'option_2', - 'name': 'Option 2' + id: 'option_2', + name: 'Option 2' } ], - 'endpoint': null, - 'requestHeaders': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + endpoint: null, + requestHeaders: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'radiobuttons2', - 'name': 'Radio buttons2', - 'type': 'radio-buttons', - 'value': null, - 'required': false, - 'readOnly': true, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'optionType': 'manual', - 'options': [ + fieldType: 'FormFieldRepresentation', + id: 'radiobuttons2', + name: 'Radio buttons2', + type: 'radio-buttons', + value: null, + required: false, + readOnly: true, + overrideId: false, + colspan: 1, + placeholder: null, + optionType: 'manual', + options: [ { - 'id': 'option_1', - 'name': 'Option 1' + id: 'option_1', + name: 'Option 1' }, { - 'id': 'option_2', - 'name': 'Option 2' + id: 'option_2', + name: 'Option 2' } ], - 'endpoint': null, - 'requestHeaders': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + endpoint: null, + requestHeaders: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '7c01ed35-be86-4be7-9c28-ed640a5a2ae1', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '7c01ed35-be86-4be7-9c28-ed640a5a2ae1', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'AttachFileFieldRepresentation', - 'id': 'attachfile1', - 'name': 'Attach file1', - 'type': 'upload', - 'value': null, - 'required': false, - 'readOnly': true, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'fileSource': { - 'serviceId': 'all-file-sources', - 'name': 'All file sources' + fieldType: 'AttachFileFieldRepresentation', + id: 'attachfile1', + name: 'Attach file1', + type: 'upload', + value: null, + required: false, + readOnly: true, + overrideId: false, + colspan: 1, + placeholder: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + fileSource: { + serviceId: 'all-file-sources', + name: 'All file sources' }, - 'multiple': false, - 'link': false + multiple: false, + link: false } } ], - '2': [ + 2: [ { - 'fieldType': 'AttachFileFieldRepresentation', - 'id': 'attachfile2', - 'name': 'Attach file2', - 'type': 'upload', - 'value': null, - 'required': false, - 'readOnly': true, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'fileSource': { - 'serviceId': 'all-file-sources', - 'name': 'All file sources' + fieldType: 'AttachFileFieldRepresentation', + id: 'attachfile2', + name: 'Attach file2', + type: 'upload', + value: null, + required: false, + readOnly: true, + overrideId: false, + colspan: 1, + placeholder: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + fileSource: { + serviceId: 'all-file-sources', + name: 'All file sources' }, - 'multiple': false, - 'link': false + multiple: false, + link: false } } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '07b13b96-d469-4a1e-8a9a-9bb957c68869', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '07b13b96-d469-4a1e-8a9a-9bb957c68869', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'displayvalue1', - 'name': 'Display value1', - 'type': 'readonly', - 'value': 'No field selected', - 'readOnly': true, - 'required': false, - 'overrideId': false, - 'colspan': 1, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'field': { - 'id': 'displayvalue', - 'name': 'Display value', - 'type': 'text', - 'responseVariable': true + fieldType: 'FormFieldRepresentation', + id: 'displayvalue1', + name: 'Display value1', + type: 'readonly', + value: 'No field selected', + readOnly: true, + required: false, + overrideId: false, + colspan: 1, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + field: { + id: 'displayvalue', + name: 'Display value', + type: 'text', + responseVariable: true } } } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'displayvalue2', - 'name': 'Display value2', - 'type': 'readonly', - 'value': 'No field selected', - 'readOnly': true, - 'required': false, - 'overrideId': false, - 'colspan': 1, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'field': { - 'id': 'displayvalue', - 'name': 'Display value', - 'type': 'text', - 'responseVariable': true + fieldType: 'FormFieldRepresentation', + id: 'displayvalue2', + name: 'Display value2', + type: 'readonly', + value: 'No field selected', + readOnly: true, + required: false, + overrideId: false, + colspan: 1, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + field: { + id: 'displayvalue', + name: 'Display value', + type: 'text', + responseVariable: true } } } @@ -599,733 +599,733 @@ export const cloudFormMock = { } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1576ef25-c842-494c-ab84-265a1e3bf68d', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '1576ef25-c842-494c-ab84-265a1e3bf68d', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'displaytext1', - 'name': 'Display text1', - 'type': 'readonly-text', - 'value': 'Display text as part of the form', - 'readOnly': true, - 'required': false, - 'overrideId': false, - 'colspan': 1, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'displaytext1', + name: 'Display text1', + type: 'readonly-text', + value: 'Display text as part of the form', + readOnly: true, + required: false, + overrideId: false, + colspan: 1, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'displaytext2', - 'name': 'Display text2', - 'type': 'readonly-text', - 'value': 'Display text as part of the form', - 'readOnly': true, - 'required': false, - 'overrideId': false, - 'colspan': 1, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'displaytext2', + name: 'Display text2', + type: 'readonly-text', + value: 'Display text as part of the form', + readOnly: true, + required: false, + overrideId: false, + colspan: 1, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ] } } ], - 'outcomes': [], - 'metadata': {}, - 'variables': [ + outcomes: [], + metadata: {}, + variables: [ { - 'name': 'FormVarStr', - 'type': 'string', - 'value': '' + name: 'FormVarStr', + type: 'string', + value: '' }, { - 'name': 'FormVarInt', - 'type': 'integer', - 'value': '' + name: 'FormVarInt', + type: 'integer', + value: '' }, { - 'name': 'FormVarBool', - 'type': 'boolean', - 'value': '' + name: 'FormVarBool', + type: 'boolean', + value: '' }, { - 'name': 'FormVarDate', - 'type': 'date', - 'value': '' + name: 'FormVarDate', + type: 'date', + value: '' }, { - 'name': 'NewVar', - 'type': 'string', - 'value': '' + name: 'NewVar', + type: 'string', + value: '' } ] }; -export let fakeCloudForm = { - 'formRepresentation': { - 'id': 'form-de8895be-d0d7-4434-beef-559b15305d72', - 'name': 'StartEventForm', - 'description': '', - 'version': 0, - 'formDefinition': { - 'tabs': [], - 'fields': [ +export const fakeCloudForm = { + formRepresentation: { + id: 'form-de8895be-d0d7-4434-beef-559b15305d72', + name: 'StartEventForm', + description: '', + version: 0, + formDefinition: { + tabs: [], + fields: [ { - 'type': 'container', - 'id': '5a6b24c1-db2b-45e9-9aff-142395433d23', - 'name': 'Label', - 'tab': null, - 'fields': { - '1': [ + type: 'container', + id: '5a6b24c1-db2b-45e9-9aff-142395433d23', + name: 'Label', + tab: null, + fields: { + 1: [ { - 'type': 'text', - 'id': 'firstName', - 'name': 'firstName', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'text', + id: 'firstName', + name: 'firstName', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': false, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: false, + minLength: 0, + maxLength: 0, + regexPattern: null } ], - '2': [ + 2: [ { - 'type': 'text', - 'id': 'lastName', - 'name': 'lastName', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'text', + id: 'lastName', + name: 'lastName', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': false, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: false, + minLength: 0, + maxLength: 0, + regexPattern: null } ] }, - 'numberOfColumns': 2 + numberOfColumns: 2 } ], - 'outcomes': [], - 'metadata': {}, - 'variables': [] + outcomes: [], + metadata: {}, + variables: [] } } }; export const emptyFormRepresentationJSON = { - 'description': '', - 'fields': [], - 'id': 'form-3de070b6-63df-4058-8028-ac82283d64fa', - 'metadata': {}, - 'name': 'form', - 'outcomes': [], - 'length': 0, - 'processDefinitionId': 'ed4a6233-0ad8-11ea-8616-e6267bbdb057', - 'processInstanceId': 'ec921948-0ad9-11ea-8616-e6267bbdb057', - 'processVariables': [], - 'standAlone': true, - 'tabs': [], - 'taskId': 'ec92194b-0ad9-11ea-8616-e6267bbdb057', - 'taskName': null, - 'variables': [], - 'version': 0 + description: '', + fields: [], + id: 'form-3de070b6-63df-4058-8028-ac82283d64fa', + metadata: {}, + name: 'form', + outcomes: [], + length: 0, + processDefinitionId: 'ed4a6233-0ad8-11ea-8616-e6267bbdb057', + processInstanceId: 'ec921948-0ad9-11ea-8616-e6267bbdb057', + processVariables: [], + standAlone: true, + tabs: [], + taskId: 'ec92194b-0ad9-11ea-8616-e6267bbdb057', + taskName: null, + variables: [], + version: 0 }; export const conditionalUploadWidgetsMock: any = { - 'formRepresentation': { - 'id': 'form-fb7858f7-5cf6-4afe-b462-c15a5dc0c34c', - 'name': 'AttachVisibility', - 'description': '', - 'version': 0, - 'formDefinition': { - 'tabs': [], - 'fields': [ + formRepresentation: { + id: 'form-fb7858f7-5cf6-4afe-b462-c15a5dc0c34c', + name: 'AttachVisibility', + description: '', + version: 0, + formDefinition: { + tabs: [], + fields: [ { - 'id': '1dc63387-aa9d-4f06-adfa-37817e8fd394', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + id: '1dc63387-aa9d-4f06-adfa-37817e8fd394', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'id': 'Text0xlk8n', - 'name': 'Text', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'Text0xlk8n', + name: 'Text', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'id': 'Attachfile0h9fr1', - 'name': 'Attach file', - 'type': 'upload', - 'required': false, - 'colspan': 1, - 'visibilityCondition': { - 'leftFormFieldId': 'Text0xlk8n', - 'leftRestResponseId': '', - 'operator': '==', - 'rightValue': 'Attach', - 'rightType': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': '', - 'nextCondition': null + id: 'Attachfile0h9fr1', + name: 'Attach file', + type: 'upload', + required: false, + colspan: 1, + visibilityCondition: { + leftFormFieldId: 'Text0xlk8n', + leftRestResponseId: '', + operator: '==', + rightValue: 'Attach', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: '', + nextCondition: null }, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'fileSource': { - 'serviceId': 'alfresco-content', - 'name': 'Alfresco Content' + params: { + existingColspan: 1, + maxColspan: 2, + fileSource: { + serviceId: 'alfresco-content', + name: 'Alfresco Content' }, - 'multiple': false, - 'link': false + multiple: false, + link: false } } ] } } ], - 'outcomes': [ + outcomes: [ { - 'id': '5f2f1c2d-5a79-4ed1-a262-4fef190d41eb', - 'name': 'Custom Outcome', - 'visibilityCondition': { - 'leftType': 'field', - 'leftValue': 'Text0xlk8n', - 'operator': '==', - 'rightValue': 'hi', - 'rightType': 'value', - 'nextConditionOperator': '', - 'nextCondition': null + id: '5f2f1c2d-5a79-4ed1-a262-4fef190d41eb', + name: 'Custom Outcome', + visibilityCondition: { + leftType: 'field', + leftValue: 'Text0xlk8n', + operator: '==', + rightValue: 'hi', + rightType: 'value', + nextConditionOperator: '', + nextCondition: null } } ], - 'metadata': {}, - 'variables': [] + metadata: {}, + variables: [] } } }; export const multilingualForm: any = { - 'formRepresentation': { - 'id': 'form-2aaaf20e-43d3-46bf-89be-859d5f512dd2', - 'name': 'multilingualform', - 'description': '', - 'version': 0, - 'formDefinition': { - 'tabs': [], - 'fields': [ + formRepresentation: { + id: 'form-2aaaf20e-43d3-46bf-89be-859d5f512dd2', + name: 'multilingualform', + description: '', + version: 0, + formDefinition: { + tabs: [], + fields: [ { - 'id': '451e2235-3310-4c2d-9b4a-08b53ae1640c', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + id: '451e2235-3310-4c2d-9b4a-08b53ae1640c', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'id': 'textField', - 'name': 'TEXT_FIELD.TITLE', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'textField', + name: 'TEXT_FIELD.TITLE', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [] + 2: [] } }, { - 'id': '1c87df6c-514e-45a7-96bc-508562683bb3', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + id: '1c87df6c-514e-45a7-96bc-508562683bb3', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'id': 'fildUploadField', - 'name': 'FILE_UPLOAD_FIELD.TITLE', - 'type': 'multi-line-text', - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'required': false, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'fildUploadField', + name: 'FILE_UPLOAD_FIELD.TITLE', + type: 'multi-line-text', + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'id': 'amountField', - 'name': 'AMOUNT_FIELD.TITLE', - 'type': 'amount', - 'required': false, - 'colspan': 1, - 'placeholder': '123', - 'minValue': null, - 'maxValue': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'amountField', + name: 'AMOUNT_FIELD.TITLE', + type: 'amount', + required: false, + colspan: 1, + placeholder: '123', + minValue: null, + maxValue: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'enableFractions': false, - 'currency': '$' + enableFractions: false, + currency: '$' } ] } }, { - 'id': '33138eea-130f-4bba-b5a5-29ea60f31786', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + id: '33138eea-130f-4bba-b5a5-29ea60f31786', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'id': 'dateField', - 'name': 'DATE_FIELD.TITLE', - 'type': 'date', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minValue': null, - 'maxValue': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'dateField', + name: 'DATE_FIELD.TITLE', + type: 'date', + required: false, + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': 'D-M-YYYY' + dateDisplayFormat: 'D-M-YYYY' } ], - '2': [] + 2: [] } } ], - 'outcomes': [], - 'metadata': {}, - 'variables': [] + outcomes: [], + metadata: {}, + variables: [] } } }; -export let fakeMetadataForm = { - 'id': 'form-de8895be-d0d7-4434-beef-559b15305d72', - 'name': 'StartEventForm', - 'description': '', - 'version': 0, - 'formDefinition': { - 'tabs': [], - 'fields': [ +export const fakeMetadataForm = { + id: 'form-de8895be-d0d7-4434-beef-559b15305d72', + name: 'StartEventForm', + description: '', + version: 0, + formDefinition: { + tabs: [], + fields: [ { - 'type': 'container', - 'id': '5a6b24c1-db2b-45e9-9aff-142395433d23', - 'name': 'Label', - 'tab': null, - 'fields': { - '1': [ + type: 'container', + id: '5a6b24c1-db2b-45e9-9aff-142395433d23', + name: 'Label', + tab: null, + fields: { + 1: [ { - 'type': 'text', - 'id': 'pfx_property_one', - 'name': 'pfx_property_one', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'text', + id: 'pfx_property_one', + name: 'pfx_property_one', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': false, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: false, + minLength: 0, + maxLength: 0, + regexPattern: null } ], - '2': [ + 2: [ { - 'type': 'boolean', - 'id': 'pfx_property_two', - 'name': 'pfx_property_two', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'boolean', + id: 'pfx_property_two', + name: 'pfx_property_two', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': false, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: false, + minLength: 0, + maxLength: 0, + regexPattern: null } ], - '3': [ + 3: [ { - 'id': 'content_form_nodes', - 'name': 'Nodes', - 'type': 'upload', - 'readOnly': false, - 'required': true, - 'colspan': 1, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'fileSource': { - 'serviceId': 'alfresco-content', - 'name': 'Alfresco Content', - 'metadataAllowed': true + id: 'content_form_nodes', + name: 'Nodes', + type: 'upload', + readOnly: false, + required: true, + colspan: 1, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + fileSource: { + serviceId: 'alfresco-content', + name: 'Alfresco Content', + metadataAllowed: true }, - 'multiple': true, - 'menuOptions': { - 'show': true, - 'download': true, - 'retrieveMetadata': true, - 'remove': true + multiple: true, + menuOptions: { + show: true, + download: true, + retrieveMetadata: true, + remove: true }, - 'link': false + link: false } } ], - '4': [ + 4: [ { - 'id': 'pfx_property_three', - 'name': 'pfx_property_three', - 'required': false, - 'readOnly': false, - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'pfx_property_three', + name: 'pfx_property_three', + required: false, + readOnly: false, + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'type': 'dropdown', - 'optionType': 'manual', - 'options': [ + visibilityCondition: null, + type: 'dropdown', + optionType: 'manual', + options: [ { - 'id': 'empty', - 'name': 'Choose one...' + id: 'empty', + name: 'Choose one...' }, { - 'id': 'opt_1', - 'name': 'Option 1' + id: 'opt_1', + name: 'Option 1' }, { - 'id': 'opt_2', - 'name': 'Option 2' + id: 'opt_2', + name: 'Option 2' } ], - 'value': 'empty', - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null + value: 'empty', + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null } ], - '5': [ + 5: [ { - 'id': 'pfx_property_four', - 'name': 'pfx_property_four', - 'required': false, - 'readOnly': false, - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'pfx_property_four', + name: 'pfx_property_four', + required: false, + readOnly: false, + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'type': 'dropdown', - 'optionType': 'manual', - 'options': [ + visibilityCondition: null, + type: 'dropdown', + optionType: 'manual', + options: [ { - 'id': 'empty', - 'name': 'Choose one...' + id: 'empty', + name: 'Choose one...' }, { - 'id': 'option_1', - 'name': 'Option: 1' + id: 'option_1', + name: 'Option: 1' }, { - 'id': 'option_2', - 'name': 'Option: 2' + id: 'option_2', + name: 'Option: 2' } ], - 'value': 'empty', - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null + value: 'empty', + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null } ], - '6': [ + 6: [ { - 'id': 'pfx_property_five', - 'name': 'pfx_property_five', - 'required': false, - 'readOnly': false, - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'pfx_property_five', + name: 'pfx_property_five', + required: false, + readOnly: false, + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'type': 'dropdown', - 'optionType': 'manual', - 'options': [ + visibilityCondition: null, + type: 'dropdown', + optionType: 'manual', + options: [ { - 'id': 'empty', - 'name': 'Choose one...' + id: 'empty', + name: 'Choose one...' }, { - 'id': 'green', - 'name': 'Colour green' + id: 'green', + name: 'Colour green' }, { - 'id': 'orange', - 'name': 'Colour orange' + id: 'orange', + name: 'Colour orange' } ], - 'value': 'empty', - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null + value: 'empty', + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null } ], - '7': [ + 7: [ { - 'id': 'cmfb85b2a7295ba41209750bca176ccaf9a', - 'name': 'File viewer', - 'type': 'file-viewer', - 'readOnly': false, - 'required': false, - 'colspan': 1, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'uploadWidget': 'content_form_nodes' + id: 'cmfb85b2a7295ba41209750bca176ccaf9a', + name: 'File viewer', + type: 'file-viewer', + readOnly: false, + required: false, + colspan: 1, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + uploadWidget: 'content_form_nodes' } } ], - '8': [ + 8: [ { - 'type': 'text', - 'id': 'pfx_property_six', - 'name': 'pfx_property_six', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'text', + id: 'pfx_property_six', + name: 'pfx_property_six', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': false, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: false, + minLength: 0, + maxLength: 0, + regexPattern: null } ], - '9': [ + 9: [ { - 'type': 'text', - 'id': 'pfx_property_seven', - 'name': 'pfx_property_seven', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'text', + id: 'pfx_property_seven', + name: 'pfx_property_seven', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': false, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: false, + minLength: 0, + maxLength: 0, + regexPattern: null } ], - '10': [ + 10: [ { - 'type': 'text', - 'id': 'pfx_property_eight', - 'name': 'pfx_property_eight', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'text', + id: 'pfx_property_eight', + name: 'pfx_property_eight', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': false, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: false, + minLength: 0, + maxLength: 0, + regexPattern: null } ] }, - 'numberOfColumns': 2 + numberOfColumns: 2 } ], - 'outcomes': [], - 'metadata': {}, - 'variables': [] + outcomes: [], + metadata: {}, + variables: [] } }; -export let fakeViewerForm = { - 'id': 'form-de8895be-d0d7-4434-beef-559b15305d72', - 'name': 'StartEventForm', - 'description': '', - 'version': 0, - 'formDefinition': { - 'tabs': [], - 'fields': [ +export const fakeViewerForm = { + id: 'form-de8895be-d0d7-4434-beef-559b15305d72', + name: 'StartEventForm', + description: '', + version: 0, + formDefinition: { + tabs: [], + fields: [ { - 'type': 'container', - 'id': '5a6b24c1-db2b-45e9-9aff-142395433d23', - 'name': 'Label', - 'tab': null, - 'fields': { - '1': [ + type: 'container', + id: '5a6b24c1-db2b-45e9-9aff-142395433d23', + name: 'Label', + tab: null, + fields: { + 1: [ { - 'id': 'content_form_nodes', - 'name': 'Nodes', - 'type': 'upload', - 'readOnly': false, - 'required': true, - 'colspan': 1, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'fileSource': { - 'serviceId': 'alfresco-content', - 'name': 'Alfresco Content', - 'metadataAllowed': true + id: 'content_form_nodes', + name: 'Nodes', + type: 'upload', + readOnly: false, + required: true, + colspan: 1, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + fileSource: { + serviceId: 'alfresco-content', + name: 'Alfresco Content', + metadataAllowed: true }, - 'multiple': true, - 'menuOptions': { - 'show': true, - 'download': true, - 'retrieveMetadata': true, - 'remove': true + multiple: true, + menuOptions: { + show: true, + download: true, + retrieveMetadata: true, + remove: true }, - 'link': false + link: false } } ], - '2': [ + 2: [ { - 'id': 'upload_widget', - 'name': 'Nodes', - 'type': 'upload', - 'readOnly': false, - 'required': true, - 'colspan': 1, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'fileSource': { - 'serviceId': 'alfresco-content', - 'name': 'Alfresco Content', - 'metadataAllowed': true + id: 'upload_widget', + name: 'Nodes', + type: 'upload', + readOnly: false, + required: true, + colspan: 1, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + fileSource: { + serviceId: 'alfresco-content', + name: 'Alfresco Content', + metadataAllowed: true }, - 'multiple': true, - 'menuOptions': { - 'show': true, - 'download': true, - 'retrieveMetadata': true, - 'remove': true + multiple: true, + menuOptions: { + show: true, + download: true, + retrieveMetadata: true, + remove: true }, - 'link': false + link: false } } ], - '3': [ + 3: [ { - 'id': 'cmfb85b2a7295ba41209750bca176ccaf9a', - 'name': 'File viewer', - 'type': 'file-viewer', - 'readOnly': false, - 'required': false, - 'colspan': 1, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2, - 'uploadWidget': 'content_form_nodes' + id: 'cmfb85b2a7295ba41209750bca176ccaf9a', + name: 'File viewer', + type: 'file-viewer', + readOnly: false, + required: false, + colspan: 1, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2, + uploadWidget: 'content_form_nodes' } } ] }, - 'numberOfColumns': 2 + numberOfColumns: 2 } ], - 'outcomes': [], - 'metadata': {}, - 'variables': [] + outcomes: [], + metadata: {}, + variables: [] } }; diff --git a/lib/process-services-cloud/src/lib/form/mocks/form-cloud.service.mock.ts b/lib/process-services-cloud/src/lib/form/mocks/form-cloud.service.mock.ts index 15d65831772..754a48cdcef 100644 --- a/lib/process-services-cloud/src/lib/form/mocks/form-cloud.service.mock.ts +++ b/lib/process-services-cloud/src/lib/form/mocks/form-cloud.service.mock.ts @@ -32,22 +32,20 @@ export class FormCloudServiceMock implements FormCloudServiceInterface { getTaskForm(appName: string, taskId: string, version?: number): Observable { return this.getTask(appName, taskId).pipe( - switchMap((task) => { - return this.getForm(appName, task.formKey, version).pipe( - map((form: FormContent) => { - const flattenForm = { - ...form.formRepresentation, - ...form.formRepresentation.formDefinition, - taskId: task.id, - taskName: task.name, - processDefinitionId: task.processDefinitionId, - processInstanceId: task.processInstanceId - }; - delete flattenForm.formDefinition; - return flattenForm; - }) - ); - }) + switchMap((task) => this.getForm(appName, task.formKey, version).pipe( + map((form: FormContent) => { + const flattenForm = { + ...form.formRepresentation, + ...form.formRepresentation.formDefinition, + taskId: task.id, + taskName: task.name, + processDefinitionId: task.processDefinitionId, + processInstanceId: task.processInstanceId + }; + delete flattenForm.formDefinition; + return flattenForm; + }) + )) ); } diff --git a/lib/process-services-cloud/src/lib/form/mocks/form-definition-selector-cloud.service.mock.ts b/lib/process-services-cloud/src/lib/form/mocks/form-definition-selector-cloud.service.mock.ts index 84d279f0a0b..d716b89c054 100644 --- a/lib/process-services-cloud/src/lib/form/mocks/form-definition-selector-cloud.service.mock.ts +++ b/lib/process-services-cloud/src/lib/form/mocks/form-definition-selector-cloud.service.mock.ts @@ -27,10 +27,10 @@ import { mockFormRepresentations } from './form-representation.mock'; export class FormDefinitionSelectorCloudServiceMock implements FormDefinitionSelectorCloudServiceInterface { getForms(_appName: string): Observable { - return of(mockFormRepresentations.map(response => response.formRepresentation)); + return of(mockFormRepresentations.map(response => response.formRepresentation)); } getStandAloneTaskForms(_appName: string): Observable { - return of(mockFormRepresentations.map(response => response.formRepresentation).filter((form: any) => form.standalone ? form : undefined)); + return of(mockFormRepresentations.map(response => response.formRepresentation).filter((form: any) => form.standalone ? form : undefined)); } } diff --git a/lib/process-services-cloud/src/lib/form/models/form-cloud-representation.model.ts b/lib/process-services-cloud/src/lib/form/models/form-cloud-representation.model.ts index e37d085d949..4ebfeb45725 100644 --- a/lib/process-services-cloud/src/lib/form/models/form-cloud-representation.model.ts +++ b/lib/process-services-cloud/src/lib/form/models/form-cloud-representation.model.ts @@ -15,6 +15,8 @@ * limitations under the License. */ +/* eslint-disable no-shadow */ +/* eslint-disable @typescript-eslint/naming-convention */ export class FormCloudRepresentation { id?: string; diff --git a/lib/process-services-cloud/src/lib/form/models/form-cloud.model.spec.ts b/lib/process-services-cloud/src/lib/form/models/form-cloud.model.spec.ts index bc6e3cc3581..c30fed2ab7a 100644 --- a/lib/process-services-cloud/src/lib/form/models/form-cloud.model.spec.ts +++ b/lib/process-services-cloud/src/lib/form/models/form-cloud.model.spec.ts @@ -77,7 +77,7 @@ describe('FormCloud', () => { form.fields = []; expect(form.hasFields()).toBeFalsy(); - const field = new FormFieldModel( form); + const field = new FormFieldModel(form); form.fields = [new ContainerModel(field)]; expect(form.hasFields()).toBeTruthy(); }); diff --git a/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts b/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts index 6b0633b8b18..26b4c055c4d 100644 --- a/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts +++ b/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts @@ -51,7 +51,7 @@ export class ContentCloudNodeSelectorService { openUploadFileDialog(currentFolderId?: string, selectionMode?: string, isAllFileSources?: boolean, restrictRootToCurrentFolderId?: boolean): Observable { const select = new Subject(); select.subscribe({ complete: this.close.bind(this) }); - const data = { + const data = { title: 'Select a file', actionName: NodeAction.ATTACH, currentFolderId, @@ -62,7 +62,7 @@ export class ContentCloudNodeSelectorService { showFilesInResult: true, showDropdownSiteList: false, showLocalUploadButton: isAllFileSources - }; + } as ContentNodeSelectorComponentData; this.openContentNodeDialog(data, 'adf-content-node-selector-dialog', '66%'); return select; } diff --git a/lib/process-services-cloud/src/lib/form/services/form-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/form/services/form-cloud.service.spec.ts index 0273609da06..2e6b4d46e16 100644 --- a/lib/process-services-cloud/src/lib/form/services/form-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/form/services/form-cloud.service.spec.ts @@ -51,10 +51,8 @@ describe('Form Cloud service', () => { apiService = TestBed.inject(AlfrescoApiService); spyOn(apiService, 'getInstance').and.returnValue({ - oauth2Auth: oauth2Auth, - isEcmLoggedIn() { - return false; - }, + oauth2Auth, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') } as any); }); @@ -102,36 +100,36 @@ describe('Form Cloud service', () => { it('should fetch task variables', (done) => { oauth2Auth.callCustomApi.and.returnValue(Promise.resolve({ - 'list': { - 'entries': [ + list: { + entries: [ { - 'entry': { - 'serviceName': 'fake-rb', - 'serviceFullName': 'fake-rb', - 'serviceVersion': '', - 'appName': 'fake', - 'appVersion': '', - 'serviceType': null, - 'id': 25, - 'type': 'string', - 'name': 'fakeProperty', - 'createTime': 1556112661342, - 'lastUpdatedTime': 1556112661342, - 'executionId': null, - 'value': 'fakeValue', - 'markedAsDeleted': false, - 'processInstanceId': '18e16bc7-6694-11e9-9c1b-0a586460028a', - 'taskId': '18e192da-6694-11e9-9c1b-0a586460028a', - 'taskVariable': true + entry: { + serviceName: 'fake-rb', + serviceFullName: 'fake-rb', + serviceVersion: '', + appName: 'fake', + appVersion: '', + serviceType: null, + id: 25, + type: 'string', + name: 'fakeProperty', + createTime: 1556112661342, + lastUpdatedTime: 1556112661342, + executionId: null, + value: 'fakeValue', + markedAsDeleted: false, + processInstanceId: '18e16bc7-6694-11e9-9c1b-0a586460028a', + taskId: '18e192da-6694-11e9-9c1b-0a586460028a', + taskVariable: true } } ], - 'pagination': { - 'skipCount': 0, - 'maxItems': 100, - 'count': 1, - 'hasMoreItems': false, - 'totalItems': 1 + pagination: { + skipCount: 0, + maxItems: 100, + count: 1, + hasMoreItems: false, + totalItems: 1 } } })); @@ -149,36 +147,36 @@ describe('Form Cloud service', () => { it('should fetch result if the variable value is 0', (done) => { oauth2Auth.callCustomApi.and.returnValue(Promise.resolve({ - 'list': { - 'entries': [ + list: { + entries: [ { - 'entry': { - 'serviceName': 'fake-rb', - 'serviceFullName': 'fake-rb', - 'serviceVersion': '', - 'appName': 'fake', - 'appVersion': '', - 'serviceType': null, - 'id': 25, - 'type': 'string', - 'name': 'fakeProperty', - 'createTime': 1556112661342, - 'lastUpdatedTime': 1556112661342, - 'executionId': null, - 'value': 0, - 'markedAsDeleted': false, - 'processInstanceId': '18e16bc7-6694-11e9-9c1b-0a586460028a', - 'taskId': '18e192da-6694-11e9-9c1b-0a586460028a', - 'taskVariable': true + entry: { + serviceName: 'fake-rb', + serviceFullName: 'fake-rb', + serviceVersion: '', + appName: 'fake', + appVersion: '', + serviceType: null, + id: 25, + type: 'string', + name: 'fakeProperty', + createTime: 1556112661342, + lastUpdatedTime: 1556112661342, + executionId: null, + value: 0, + markedAsDeleted: false, + processInstanceId: '18e16bc7-6694-11e9-9c1b-0a586460028a', + taskId: '18e192da-6694-11e9-9c1b-0a586460028a', + taskVariable: true } } ], - 'pagination': { - 'skipCount': 0, - 'maxItems': 100, - 'count': 1, - 'hasMoreItems': false, - 'totalItems': 1 + pagination: { + skipCount: 0, + maxItems: 100, + count: 1, + hasMoreItems: false, + totalItems: 1 } } })); diff --git a/lib/process-services-cloud/src/lib/form/services/form-cloud.service.ts b/lib/process-services-cloud/src/lib/form/services/form-cloud.service.ts index 6134ac46f10..aaf934a73dd 100644 --- a/lib/process-services-cloud/src/lib/form/services/form-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/form/services/form-cloud.service.ts @@ -53,6 +53,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi /** * Gets the form definition of a task. + * * @param appName Name of the app * @param taskId ID of the target task * @param version Version of the form @@ -60,27 +61,26 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi */ getTaskForm(appName: string, taskId: string, version?: number): Observable { return this.getTask(appName, taskId).pipe( - switchMap(task => { - return this.getForm(appName, task.formKey, version).pipe( - map((form: FormContent) => { - const flattenForm = { - ...form.formRepresentation, - ...form.formRepresentation.formDefinition, - taskId: task.id, - taskName: task.name, - processDefinitionId: task.processDefinitionId, - processInstanceId: task.processInstanceId - }; - delete flattenForm.formDefinition; - return flattenForm; - }) - ); - }) + switchMap(task => this.getForm(appName, task.formKey, version).pipe( + map((form: FormContent) => { + const flattenForm = { + ...form.formRepresentation, + ...form.formRepresentation.formDefinition, + taskId: task.id, + taskName: task.name, + processDefinitionId: task.processDefinitionId, + processInstanceId: task.processInstanceId + }; + delete flattenForm.formDefinition; + return flattenForm; + }) + )) ); } /** * Saves a task form. + * * @param appName Name of the app * @param taskId ID of the target task * @param processInstanceId ID of processInstance @@ -120,6 +120,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi /** * Completes a task form. + * * @param appName Name of the app * @param taskId ID of the target task * @param processInstanceId ID of processInstance @@ -131,11 +132,12 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi */ completeTaskForm(appName: string, taskId: string, processInstanceId: string, formId: string, formValues: FormValues, outcome: string, version: number): Observable { const apiUrl = `${this.getBasePath(appName)}/form/v1/forms/${formId}/submit/versions/${version}`; - const completeFormRepresentation = { + const completeFormRepresentation = { values: formValues, - taskId: taskId, - processInstanceId: processInstanceId - }; + taskId, + processInstanceId + } as CompleteFormRepresentation; + if (outcome) { completeFormRepresentation.outcome = outcome; } @@ -147,6 +149,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi /** * Gets details of a task + * * @param appName Name of the app * @param taskId ID of the target task * @returns Details of the task @@ -161,6 +164,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi /** * Gets the variables of a task. + * * @param appName Name of the app * @param taskId ID of the target task * @returns Task variables @@ -169,14 +173,13 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi const apiUrl = `${this.getBasePath(appName)}/query/v1/tasks/${taskId}/variables`; return this.get(apiUrl).pipe( - map((res: any) => { - return res.list.entries.map((variable) => new TaskVariableCloud(variable.entry)); - }) + map((res: any) => res.list.entries.map((variable) => new TaskVariableCloud(variable.entry))) ); } /** * Gets a form definition. + * * @param appName Name of the app * @param formKey key of the target task * @param version Version of the form @@ -200,6 +203,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi /** * Parses JSON data to create a corresponding form. + * * @param json JSON data to create the form * @param data Values for the form's fields * @param readOnly Toggles whether or not the form should be read-only @@ -221,7 +225,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi const form = new FormModel(flattenForm, formValues, readOnly); if (!json.fields) { form.outcomes = [ - new FormOutcomeModel( form, { + new FormOutcomeModel(form, { id: '$save', name: FormOutcomeModel.SAVE_ACTION, isSystem: true diff --git a/lib/process-services-cloud/src/lib/form/services/form-definition-selector-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/form/services/form-definition-selector-cloud.service.spec.ts index c38b0b5ad9d..f1e4b3b6bc1 100644 --- a/lib/process-services-cloud/src/lib/form/services/form-definition-selector-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/form/services/form-definition-selector-cloud.service.spec.ts @@ -43,10 +43,8 @@ describe('Form Definition Selector Cloud Service', () => { service = TestBed.inject(FormDefinitionSelectorCloudService); apiService = TestBed.inject(AlfrescoApiService); spyOn(apiService, 'getInstance').and.returnValue({ - oauth2Auth: oauth2Auth, - isEcmLoggedIn() { - return false; - }, + oauth2Auth, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') } as any); }); diff --git a/lib/process-services-cloud/src/lib/form/services/form-definition-selector-cloud.service.ts b/lib/process-services-cloud/src/lib/form/services/form-definition-selector-cloud.service.ts index 9bc010f6da1..d37ad736bd5 100644 --- a/lib/process-services-cloud/src/lib/form/services/form-definition-selector-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/form/services/form-definition-selector-cloud.service.ts @@ -35,6 +35,7 @@ export class FormDefinitionSelectorCloudService extends BaseCloudService impleme /** * Get all forms of an app. + * * @param appName Name of the application * @returns Details of the forms */ @@ -42,24 +43,19 @@ export class FormDefinitionSelectorCloudService extends BaseCloudService impleme const url = `${this.getBasePath(appName)}/form/v1/forms`; return this.get(url).pipe( - map((data: any) => { - return data.map((formData: any) => { - return formData.formRepresentation; - }); - }) + map((data: any) => data.map((formData: any) => formData.formRepresentation)) ); } /** * Get all forms of an app. + * * @param appName Name of the application * @returns Details of the forms */ getStandAloneTaskForms(appName: string): Observable { return from(this.getForms(appName)).pipe( - map((data: any) => { - return data.filter((formData: any) => formData.standalone || formData.standalone === undefined); - }) + map((data: any) => data.filter((formData: any) => formData.standalone || formData.standalone === undefined)) ); } } diff --git a/lib/process-services-cloud/src/lib/form/services/process-cloud-content.service.ts b/lib/process-services-cloud/src/lib/form/services/process-cloud-content.service.ts index 307efd3480e..b931de71c90 100644 --- a/lib/process-services-cloud/src/lib/form/services/process-cloud-content.service.ts +++ b/lib/process-services-cloud/src/lib/form/services/process-cloud-content.service.ts @@ -59,12 +59,10 @@ export class ProcessCloudContentService { return from( this.uploadApi.uploadFile(file, '', nodeId, '', { overwrite: true }) ).pipe( - map((res: any) => { - return { - ...res.entry, - nodeId: res.entry.id - }; - }), + map((res: any) => ({ + ...res.entry, + nodeId: res.entry.id + })), catchError(err => this.handleError(err)) ); } diff --git a/lib/process-services-cloud/src/lib/group/components/group-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/group/components/group-cloud.component.spec.ts index 5010fe30e12..c0130f6795b 100644 --- a/lib/process-services-cloud/src/lib/group/components/group-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/group/components/group-cloud.component.spec.ts @@ -44,14 +44,13 @@ describe('GroupCloudComponent', () => { oauth2Auth: { callCustomApi: () => Promise.resolve(mockIdentityGroups) }, - isEcmLoggedIn() { - return false; - }, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') }; + // eslint-disable-next-line prefer-arrow/prefer-arrow-functions function getElement(selector: string): T { - return fixture.nativeElement.querySelector(selector); + return fixture.nativeElement.querySelector(selector); } setupTestBed({ @@ -110,10 +109,10 @@ describe('GroupCloudComponent', () => { it('should not be able to search for a group that its name matches one of the preselected groups name', (done) => { component.preSelectGroups = [{ name: mockIdentityGroups[0].name }]; const changes = new SimpleChange(null, [{ name: mockIdentityGroups[0].name }], false); - component.ngOnChanges({ 'preSelectGroups': changes }); + component.ngOnChanges({ preSelectGroups: changes }); fixture.detectChanges(); - const inputHTMLElement: HTMLInputElement = element.querySelector('input'); + const inputHTMLElement = element.querySelector('input'); inputHTMLElement.focus(); inputHTMLElement.value = 'mock-group'; inputHTMLElement.dispatchEvent(new Event('keyup')); @@ -242,7 +241,7 @@ describe('GroupCloudComponent', () => { component.appName = 'mock-app-name'; const change = new SimpleChange(null, 'mock-app-name', false); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -486,8 +485,8 @@ describe('GroupCloudComponent', () => { beforeEach(() => { component.mode = 'single'; - component.preSelectGroups = mockIdentityGroups; - component.ngOnChanges({ 'preSelectGroups': changes }); + component.preSelectGroups = mockIdentityGroups; + component.ngOnChanges({ preSelectGroups: changes }); fixture.detectChanges(); }); @@ -503,15 +502,15 @@ describe('GroupCloudComponent', () => { beforeEach(() => { component.mode = 'multiple'; - component.preSelectGroups = mockIdentityGroups; - component.ngOnChanges({ 'preSelectGroups': change }); + component.preSelectGroups = mockIdentityGroups; + component.ngOnChanges({ preSelectGroups: change }); fixture.detectChanges(); }); it('should render all preselected groups', () => { component.mode = 'multiple'; fixture.detectChanges(); - component.ngOnChanges({ 'preSelectGroups': change }); + component.ngOnChanges({ preSelectGroups: change }); fixture.detectChanges(); const chips = fixture.debugElement.queryAll(By.css('mat-chip')); expect(chips.length).toBe(5); @@ -551,7 +550,7 @@ describe('GroupCloudComponent', () => { ]; const change = new SimpleChange(null, component.preSelectGroups, false); component.mode = 'multiple'; - component.ngOnChanges({ 'preSelectGroups': change }); + component.ngOnChanges({ preSelectGroups: change }); fixture.detectChanges(); fixture.whenStable().then(() => { @@ -579,7 +578,7 @@ describe('GroupCloudComponent', () => { const change = new SimpleChange(null, component.preSelectGroups, false); component.mode = 'multiple'; - component.ngOnChanges({ 'preSelectGroups': change }); + component.ngOnChanges({ preSelectGroups: change }); const removeGroupSpy = spyOn(component.removeGroup, 'emit'); fixture.detectChanges(); @@ -610,8 +609,8 @@ describe('GroupCloudComponent', () => { it('should chip list be disabled and show one single chip - single mode', () => { component.mode = 'single'; component.readOnly = true; - component.preSelectGroups = mockIdentityGroups; - component.ngOnChanges({ 'preSelectGroups': change }); + component.preSelectGroups = mockIdentityGroups; + component.ngOnChanges({ preSelectGroups: change }); fixture.detectChanges(); @@ -627,8 +626,8 @@ describe('GroupCloudComponent', () => { it('should chip list be disabled and show all the chips - multiple mode', () => { component.mode = 'multiple'; component.readOnly = true; - component.preSelectGroups = mockIdentityGroups; - component.ngOnChanges({ 'preSelectGroups': change }); + component.preSelectGroups = mockIdentityGroups; + component.ngOnChanges({ preSelectGroups: change }); fixture.detectChanges(); @@ -663,8 +662,8 @@ describe('GroupCloudComponent', () => { component.mode = 'single'; component.validate = true; - component.preSelectGroups = [mockIdentityGroups[0], mockIdentityGroups[1]]; - component.ngOnChanges({ 'preSelectGroups': new SimpleChange(null, [mockIdentityGroups[0], mockIdentityGroups[1]], false) }); + component.preSelectGroups = [mockIdentityGroups[0], mockIdentityGroups[1]]; + component.ngOnChanges({ preSelectGroups: new SimpleChange(null, [mockIdentityGroups[0], mockIdentityGroups[1]], false) }); }); it('should check validation for all the groups and emit warning - multiple mode', (done) => { @@ -694,9 +693,9 @@ describe('GroupCloudComponent', () => { component.mode = 'multiple'; component.validate = true; - component.preSelectGroups = [mockIdentityGroups[0], mockIdentityGroups[1]]; + component.preSelectGroups = [mockIdentityGroups[0], mockIdentityGroups[1]]; component.ngOnChanges({ - 'preSelectGroups': new SimpleChange(null, [mockIdentityGroups[0], mockIdentityGroups[1]], false) + preSelectGroups: new SimpleChange(null, [mockIdentityGroups[0], mockIdentityGroups[1]], false) }); }); }); diff --git a/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts b/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts index 70e46baa3f1..bb99b0b5988 100644 --- a/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts @@ -235,9 +235,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy { private isGroupAlreadySelected(group: IdentityGroupModel): boolean { if (this.selectedGroups && this.selectedGroups.length > 0) { - const result = this.selectedGroups.find((selectedGroup: IdentityGroupModel) => { - return selectedGroup.name === group.name; - }); + const result = this.selectedGroups.find((selectedGroup: IdentityGroupModel) => selectedGroup.name === group.name); return !!result; } @@ -317,7 +315,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy { filterGroupsByRoles(group: IdentityGroupModel): Observable { return this.identityGroupService.checkGroupHasRole(group.id, this.roles).pipe( - map((hasRole: boolean) => ({ hasRole: hasRole, group: group })), + map((hasRole: boolean) => ({ hasRole, group })), filter((filteredGroup: { hasRole: boolean; group: IdentityGroupModel }) => filteredGroup.hasRole), map((filteredGroup: { hasRole: boolean; group: IdentityGroupModel }) => filteredGroup.group)); } @@ -370,9 +368,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy { } private removeGroupFromSelected({ id, name }: IdentityGroupModel): void { - const indexToRemove = this.selectedGroups.findIndex(group => { - return group.id === id && group.name === name; - }); + const indexToRemove = this.selectedGroups.findIndex(group => group.id === id && group.name === name); if (indexToRemove !== -1) { this.selectedGroups.splice(indexToRemove, 1); @@ -380,9 +376,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy { } private removeGroupFromValidation({ id, name }: IdentityGroupModel): void { - const indexToRemove = this.invalidGroups.findIndex(group => { - return group.id === id && group.name === name; - }); + const indexToRemove = this.invalidGroups.findIndex(group => group.id === id && group.name === name); if (indexToRemove !== -1) { this.invalidGroups.splice(indexToRemove, 1); @@ -428,9 +422,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy { removeDuplicatedGroups(groups: IdentityGroupModel[]): IdentityGroupModel[] { return groups.filter((group, index, self) => - index === self.findIndex((auxGroup) => { - return group.id === auxGroup.id && group.name === auxGroup.name; - })); + index === self.findIndex((auxGroup) => group.id === auxGroup.id && group.name === auxGroup.name)); } private hasPreSelectGroups(): boolean { diff --git a/lib/process-services-cloud/src/lib/group/pipe/group-initial.pipe.spec.ts b/lib/process-services-cloud/src/lib/group/pipe/group-initial.pipe.spec.ts index 139710ab21d..c30dac66934 100644 --- a/lib/process-services-cloud/src/lib/group/pipe/group-initial.pipe.spec.ts +++ b/lib/process-services-cloud/src/lib/group/pipe/group-initial.pipe.spec.ts @@ -25,7 +25,7 @@ describe('InitialGroupNamePipe', () => { beforeEach(() => { pipe = new InitialGroupNamePipe(); - fakeGroup = {name: 'mock'}; + fakeGroup = {name: 'mock'}; }); it('should return with the group initial', () => { diff --git a/lib/process-services-cloud/src/lib/models/date-cloud-filter.model.ts b/lib/process-services-cloud/src/lib/models/date-cloud-filter.model.ts index 228a802a923..ee31843f1e8 100644 --- a/lib/process-services-cloud/src/lib/models/date-cloud-filter.model.ts +++ b/lib/process-services-cloud/src/lib/models/date-cloud-filter.model.ts @@ -15,6 +15,9 @@ * limitations under the License. */ +/* eslint-disable @typescript-eslint/naming-convention */ + +// eslint-disable-next-line no-shadow export enum DateCloudFilterType { NO_DATE = 'NO_DATE', TODAY = 'TODAY', diff --git a/lib/process-services-cloud/src/lib/people/components/people-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/people/components/people-cloud.component.spec.ts index 45432250d15..f3701baa600 100644 --- a/lib/process-services-cloud/src/lib/people/components/people-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/people/components/people-cloud.component.spec.ts @@ -44,9 +44,7 @@ describe('PeopleCloudComponent', () => { oauth2Auth: { callCustomApi: () => Promise.resolve(mockUsers) }, - isEcmLoggedIn() { - return false; - }, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') }; @@ -55,8 +53,9 @@ describe('PeopleCloudComponent', () => { { id: mockUsers[2].id, username: mockUsers[2].username } ]; + // eslint-disable-next-line prefer-arrow/prefer-arrow-functions function getElement(selector: string): T { - return fixture.nativeElement.querySelector(selector); + return fixture.nativeElement.querySelector(selector); } setupTestBed({ @@ -125,10 +124,10 @@ describe('PeopleCloudComponent', () => { it('should not be able to search for a user that his username matches one of the preselected users username', (done) => { component.preSelectUsers = [{ username: mockUsers[0].username }]; const changes = new SimpleChange(null, [{ username: mockUsers[0].username }], false); - component.ngOnChanges({ 'preSelectUsers': changes }); + component.ngOnChanges({ preSelectUsers: changes }); fixture.detectChanges(); - const inputHTMLElement: HTMLInputElement = element.querySelector('input'); + const inputHTMLElement = element.querySelector('input'); inputHTMLElement.focus(); inputHTMLElement.value = 'first-name'; inputHTMLElement.dispatchEvent(new Event('keyup')); @@ -145,10 +144,10 @@ describe('PeopleCloudComponent', () => { it('should not be able to search for a user that his id matches one of the preselected users id', (done) => { component.preSelectUsers = [{ id: mockUsers[0].id }]; const changes = new SimpleChange(null, [{ id: mockUsers[0].id }], false); - component.ngOnChanges({ 'preSelectUsers': changes }); + component.ngOnChanges({ preSelectUsers: changes }); fixture.detectChanges(); - const inputHTMLElement: HTMLInputElement = element.querySelector('input'); + const inputHTMLElement = element.querySelector('input'); inputHTMLElement.focus(); inputHTMLElement.value = 'first-name'; inputHTMLElement.dispatchEvent(new Event('keyup')); @@ -165,10 +164,10 @@ describe('PeopleCloudComponent', () => { it('should not be able to search for a user that his email matches one of the preselected users email', (done) => { component.preSelectUsers = [{ email: mockUsers[0].email }]; const changes = new SimpleChange(null, [{ email: mockUsers[0].email }], false); - component.ngOnChanges({ 'preSelectUsers': changes }); + component.ngOnChanges({ preSelectUsers: changes }); fixture.detectChanges(); - const inputHTMLElement: HTMLInputElement = element.querySelector('input'); + const inputHTMLElement = element.querySelector('input'); inputHTMLElement.focus(); inputHTMLElement.value = 'first-name'; inputHTMLElement.dispatchEvent(new Event('keyup')); @@ -186,7 +185,7 @@ describe('PeopleCloudComponent', () => { component.excludedUsers = [{ email: mockUsers[0].email }]; fixture.detectChanges(); - const inputHTMLElement: HTMLInputElement = element.querySelector('input'); + const inputHTMLElement = element.querySelector('input'); inputHTMLElement.focus(); inputHTMLElement.value = 'first-name'; inputHTMLElement.dispatchEvent(new Event('keyup')); @@ -204,7 +203,7 @@ describe('PeopleCloudComponent', () => { component.excludedUsers = [{ email: mockUsers[0].email }]; fixture.detectChanges(); - const inputHTMLElement: HTMLInputElement = element.querySelector('input'); + const inputHTMLElement = element.querySelector('input'); inputHTMLElement.focus(); inputHTMLElement.value = 'first-name'; inputHTMLElement.dispatchEvent(new Event('keyup')); @@ -222,7 +221,7 @@ describe('PeopleCloudComponent', () => { component.excludedUsers = [{ email: mockUsers[0].email }]; fixture.detectChanges(); - const inputHTMLElement: HTMLInputElement = element.querySelector('input'); + const inputHTMLElement = element.querySelector('input'); inputHTMLElement.focus(); inputHTMLElement.value = 'first-name'; inputHTMLElement.dispatchEvent(new Event('keyup')); @@ -350,7 +349,7 @@ describe('PeopleCloudComponent', () => { component.appName = 'mock-app-name'; const change = new SimpleChange(null, 'mock-app-name', false); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -592,8 +591,8 @@ describe('PeopleCloudComponent', () => { beforeEach(() => { component.mode = 'single'; - component.preSelectUsers = mockPreselectedUsers; - component.ngOnChanges({ 'preSelectUsers': changes }); + component.preSelectUsers = mockPreselectedUsers; + component.ngOnChanges({ preSelectUsers: changes }); fixture.detectChanges(); element = fixture.nativeElement; @@ -620,8 +619,8 @@ describe('PeopleCloudComponent', () => { const changes = new SimpleChange(null, mockPreselectedUsers, false); - component.preSelectUsers = mockPreselectedUsers; - component.ngOnChanges({ 'preSelectUsers': changes }); + component.preSelectUsers = mockPreselectedUsers; + component.ngOnChanges({ preSelectUsers: changes }); fixture.detectChanges(); fixture.whenStable().then(() => { @@ -644,7 +643,7 @@ describe('PeopleCloudComponent', () => { ]; const change = new SimpleChange(null, component.preSelectUsers, false); - component.ngOnChanges({ 'preSelectUsers': change }); + component.ngOnChanges({ preSelectUsers: change }); fixture.detectChanges(); fixture.whenStable().then(() => { @@ -669,7 +668,7 @@ describe('PeopleCloudComponent', () => { ]; const change = new SimpleChange(null, component.preSelectUsers, false); - component.ngOnChanges({ 'preSelectUsers': change }); + component.ngOnChanges({ preSelectUsers: change }); const removeUserSpy = spyOn(component.removeUser, 'emit'); @@ -700,8 +699,8 @@ describe('PeopleCloudComponent', () => { it('should chip list be disabled and show one single chip - single mode', () => { component.mode = 'single'; component.readOnly = true; - component.preSelectUsers = mockPreselectedUsers; - component.ngOnChanges({ 'preSelectUsers': change }); + component.preSelectUsers = mockPreselectedUsers; + component.ngOnChanges({ preSelectUsers: change }); fixture.detectChanges(); @@ -717,8 +716,8 @@ describe('PeopleCloudComponent', () => { it('should chip list be disabled and show mat chips for all the preselected users - multiple mode', () => { component.mode = 'multiple'; component.readOnly = true; - component.preSelectUsers = mockPreselectedUsers; - component.ngOnChanges({ 'preSelectUsers': change }); + component.preSelectUsers = mockPreselectedUsers; + component.ngOnChanges({ preSelectUsers: change }); fixture.detectChanges(); @@ -751,9 +750,9 @@ describe('PeopleCloudComponent', () => { component.mode = 'single'; component.validate = true; - component.preSelectUsers = [mockPreselectedUsers[0], mockPreselectedUsers[1]]; + component.preSelectUsers = [mockPreselectedUsers[0], mockPreselectedUsers[1]]; component.ngOnChanges({ - 'preSelectUsers': new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false) + preSelectUsers: new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false) }); }); @@ -766,9 +765,9 @@ describe('PeopleCloudComponent', () => { component.warning.subscribe(() => warnings++); component.mode = 'single'; component.validate = false; - component.preSelectUsers = [mockPreselectedUsers[0], mockPreselectedUsers[1]]; + component.preSelectUsers = [mockPreselectedUsers[0], mockPreselectedUsers[1]]; component.ngOnChanges({ - 'preSelectUsers': new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false) + preSelectUsers: new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false) }); expect(warnings).toBe(0); @@ -798,9 +797,9 @@ describe('PeopleCloudComponent', () => { component.mode = 'multiple'; component.validate = true; - component.preSelectUsers = [mockPreselectedUsers[0], mockPreselectedUsers[1]]; + component.preSelectUsers = [mockPreselectedUsers[0], mockPreselectedUsers[1]]; component.ngOnChanges({ - 'preSelectUsers': new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false) + preSelectUsers: new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false) }); }); }); diff --git a/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts b/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts index 7a1ceded8c6..b56b96dc320 100644 --- a/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts @@ -264,16 +264,14 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy { filterUsersByRoles(user: IdentityUserModel): Observable { return this.identityUserService.checkUserHasRole(user.id, this.roles).pipe( - map((hasRole: boolean) => ({ hasRole: hasRole, user: user })), + map((hasRole: boolean) => ({ hasRole, user })), filter((filteredUser: { hasRole: boolean; user: IdentityUserModel }) => filteredUser.hasRole), map((filteredUser: { hasRole: boolean; user: IdentityUserModel }) => filteredUser.user)); } private isUserAlreadySelected(searchUser: IdentityUserModel): boolean { if (this.selectedUsers && this.selectedUsers.length > 0) { - const result = this.selectedUsers.find((selectedUser) => { - return this.compare(selectedUser, searchUser); - }); + const result = this.selectedUsers.find((selectedUser) => this.compare(selectedUser, searchUser)); return !!result; } @@ -442,11 +440,9 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy { } private removeUserFromSelected({ id, username, email }: IdentityUserModel): void { - const indexToRemove = this.selectedUsers.findIndex(user => { - return user.id === id + const indexToRemove = this.selectedUsers.findIndex(user => user.id === id && user.username === username - && user.email === email; - }); + && user.email === email); if (indexToRemove !== -1) { this.selectedUsers.splice(indexToRemove, 1); @@ -454,11 +450,9 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy { } private removeUserFromValidation({ id, username, email }: IdentityUserModel): void { - const indexToRemove = this.invalidUsers.findIndex(user => { - return user.id === id + const indexToRemove = this.invalidUsers.findIndex(user => user.id === id && user.username === username - && user.email === email; - }); + && user.email === email); if (indexToRemove !== -1) { this.invalidUsers.splice(indexToRemove, 1); diff --git a/lib/process-services-cloud/src/lib/pipes/process-name-cloud.pipe.ts b/lib/process-services-cloud/src/lib/pipes/process-name-cloud.pipe.ts index 5a4a54ae796..1a1a4da0064 100644 --- a/lib/process-services-cloud/src/lib/pipes/process-name-cloud.pipe.ts +++ b/lib/process-services-cloud/src/lib/pipes/process-name-cloud.pipe.ts @@ -20,28 +20,28 @@ import moment from 'moment-es6'; import { LocalizedDatePipe } from '@alfresco/adf-core'; import { ProcessInstanceCloud } from '../process/start-process/models/process-instance-cloud.model'; +export const DATE_TIME_IDENTIFIER_REG_EXP = new RegExp('%{datetime}', 'i'); +export const PROCESS_DEFINITION_IDENTIFIER_REG_EXP = new RegExp('%{processdefinition}', 'i'); + @Pipe({ name: 'processNameCloud' }) export class ProcessNameCloudPipe implements PipeTransform { - static DATE_TIME_IDENTIFIER_REG_EXP = new RegExp('%{datetime}', 'i'); - static PROCESS_DEFINITION_IDENTIFIER_REG_EXP = new RegExp('%{processdefinition}', 'i'); - constructor(private localizedDatePipe: LocalizedDatePipe) { } transform(processNameFormat: string, processInstance?: ProcessInstanceCloud): string { let processName = processNameFormat; - if (processName.match(ProcessNameCloudPipe.DATE_TIME_IDENTIFIER_REG_EXP)) { + if (processName.match(DATE_TIME_IDENTIFIER_REG_EXP)) { const presentDateTime = moment.now(); processName = processName.replace( - ProcessNameCloudPipe.DATE_TIME_IDENTIFIER_REG_EXP, + DATE_TIME_IDENTIFIER_REG_EXP, this.localizedDatePipe.transform(presentDateTime, 'medium') ); } - if (processName.match(ProcessNameCloudPipe.PROCESS_DEFINITION_IDENTIFIER_REG_EXP)) { + if (processName.match(PROCESS_DEFINITION_IDENTIFIER_REG_EXP)) { const selectedProcessDefinitionName = processInstance ? processInstance.processDefinitionName : ''; processName = processName.replace( - ProcessNameCloudPipe.PROCESS_DEFINITION_IDENTIFIER_REG_EXP, + PROCESS_DEFINITION_IDENTIFIER_REG_EXP, selectedProcessDefinitionName ); } diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.spec.ts index aee31a13c69..c841f813774 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.spec.ts @@ -69,9 +69,7 @@ describe('EditProcessFilterCloudComponent', () => { oauth2Auth: { callCustomApi: () => Promise.resolve(fakeApplicationInstance) }, - isEcmLoggedIn() { - return false; - }, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') }; @@ -97,13 +95,11 @@ describe('EditProcessFilterCloudComponent', () => { alfrescoApiService = TestBed.inject(AlfrescoApiService); dialog = TestBed.inject(MatDialog); spyOn(dialog, 'open').and.returnValue({ - afterClosed() { - return of({ - action: ProcessFilterDialogCloudComponent.ACTION_SAVE, - icon: 'icon', - name: 'fake-name' - }); - } + afterClosed: () => of({ + action: ProcessFilterDialogCloudComponent.ACTION_SAVE, + icon: 'icon', + name: 'fake-name' + }) } as any); getProcessFilterByIdSpy = spyOn(service, 'getFilterById').and.returnValue(of(fakeFilter)); getRunningApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance)); @@ -128,7 +124,7 @@ describe('EditProcessFilterCloudComponent', () => { it('should fetch process instance filter by id', async () => { const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -144,7 +140,7 @@ describe('EditProcessFilterCloudComponent', () => { it('should display filter name as title', async () => { const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); component.showProcessFilterName = true; - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -161,7 +157,7 @@ describe('EditProcessFilterCloudComponent', () => { it('should not display filter name as title if the flag is false', async () => { const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); component.showProcessFilterName = false; - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -172,7 +168,7 @@ describe('EditProcessFilterCloudComponent', () => { it('should not display mat-spinner if isloading set to false', async () => { const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -191,7 +187,7 @@ describe('EditProcessFilterCloudComponent', () => { it('should display mat-spinner if isloading set to true', async () => { component.isLoading = true; const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -204,7 +200,7 @@ describe('EditProcessFilterCloudComponent', () => { beforeEach(() => { const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); }); @@ -288,7 +284,7 @@ describe('EditProcessFilterCloudComponent', () => { })); const processFilterIdChange = new SimpleChange(null, 'filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -324,7 +320,7 @@ describe('EditProcessFilterCloudComponent', () => { })); const processFilterIdChange = new SimpleChange(null, 'filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -466,7 +462,7 @@ describe('EditProcessFilterCloudComponent', () => { await fixture.whenStable(); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -476,7 +472,7 @@ describe('EditProcessFilterCloudComponent', () => { expect(component.processFilterProperties[1].key).toEqual('processName'); }); - it('should get form attributes', async() => { + it('should get form attributes', async () => { fixture.detectChanges(); await fixture.whenStable(); @@ -485,7 +481,7 @@ describe('EditProcessFilterCloudComponent', () => { await fixture.whenStable(); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -495,7 +491,7 @@ describe('EditProcessFilterCloudComponent', () => { expect(component.editProcessFilterForm.get('completedDateType')).toBeDefined(); }); - it('should get form attributes for suspendedData', async() => { + it('should get form attributes for suspendedData', async () => { const filter = new ProcessFilterCloudModel({ id: 'filter-id', name: 'ADF_CLOUD_PROCESS_FILTERS.RUNNING_PROCESSES', @@ -517,7 +513,7 @@ describe('EditProcessFilterCloudComponent', () => { await fixture.whenStable(); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -535,7 +531,7 @@ describe('EditProcessFilterCloudComponent', () => { await fixture.whenStable(); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -569,7 +565,7 @@ describe('EditProcessFilterCloudComponent', () => { await fixture.whenStable(); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -587,7 +583,7 @@ describe('EditProcessFilterCloudComponent', () => { await fixture.whenStable(); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -611,7 +607,7 @@ describe('EditProcessFilterCloudComponent', () => { fixture.detectChanges(); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); const controller = component.editProcessFilterForm.get('appVersionMultiple'); @@ -638,7 +634,7 @@ describe('EditProcessFilterCloudComponent', () => { await fixture.whenStable(); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -659,7 +655,7 @@ describe('EditProcessFilterCloudComponent', () => { it('should display default sort properties', async () => { const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -697,7 +693,7 @@ describe('EditProcessFilterCloudComponent', () => { await fixture.whenStable(); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -733,7 +729,7 @@ describe('EditProcessFilterCloudComponent', () => { })); component.sortProperties = ['name']; const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -760,7 +756,7 @@ describe('EditProcessFilterCloudComponent', () => { const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); getProcessFilterByIdSpy.and.returnValue(of(fakeFilter)); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); }); @@ -882,7 +878,7 @@ describe('EditProcessFilterCloudComponent', () => { await fixture.whenStable(); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -920,7 +916,7 @@ describe('EditProcessFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'lastModified']; const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); const date = moment(); @@ -943,7 +939,7 @@ describe('EditProcessFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange']; const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); component.filterChange.subscribe(() => { @@ -977,7 +973,7 @@ describe('EditProcessFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange']; const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); component.filterChange.subscribe(() => { @@ -998,7 +994,7 @@ describe('EditProcessFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange']; const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); const dateFilter = { @@ -1088,7 +1084,7 @@ describe('EditProcessFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'initiator']; const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': processFilterIdChange }); + component.ngOnChanges({ id: processFilterIdChange }); fixture.detectChanges(); expect(component.initiatorOptions).toEqual([ { username: 'user1' }, { username: 'user2'} ]); diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts index 734e7a2bb52..98ce3a2b5e2 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter-cloud.component.ts @@ -31,6 +31,13 @@ import { ProcessFilterDialogCloudComponent } from './process-filter-dialog-cloud import { ProcessCloudService } from '../../services/process-cloud.service'; import { DateCloudFilterType, DateRangeFilter } from '../../../models/date-cloud-filter.model'; +export const PROCESS_FILTER_ACTION_SAVE = 'save'; +export const PROCESS_FILTER_ACTION_SAVE_AS = 'saveAs'; +export const PROCESS_FILTER_ACTION_DELETE = 'delete'; +const DEFAULT_PROCESS_FILTER_PROPERTIES = ['status', 'sort', 'order', 'lastModified']; +const DEFAULT_SORT_PROPERTIES = ['id', 'name', 'status', 'startDate']; +const DEFAULT_ACTIONS = ['save', 'saveAs', 'delete']; + export interface DropdownOption { value: string; label: string; @@ -43,15 +50,6 @@ export interface DropdownOption { encapsulation: ViewEncapsulation.None }) export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDestroy { - - public static ACTION_SAVE = 'save'; - public static ACTION_SAVE_AS = 'saveAs'; - public static ACTION_DELETE = 'delete'; - public static DEFAULT_PROCESS_FILTER_PROPERTIES = ['status', 'sort', 'order', 'lastModified']; - public static DEFAULT_SORT_PROPERTIES = ['id', 'name', 'status', 'startDate']; - public static DEFAULT_ACTIONS = ['save', 'saveAs', 'delete']; - public DATE_FORMAT: string = 'DD/MM/YYYY'; - /** The name of the application. */ @Input() appName: string = ''; @@ -66,15 +64,15 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes /** List of process filter properties to display */ @Input() - filterProperties = EditProcessFilterCloudComponent.DEFAULT_PROCESS_FILTER_PROPERTIES; + filterProperties = DEFAULT_PROCESS_FILTER_PROPERTIES; /** List of sort properties to display. */ @Input() - sortProperties = EditProcessFilterCloudComponent.DEFAULT_SORT_PROPERTIES; + sortProperties = DEFAULT_SORT_PROPERTIES; /** List of sort actions. */ @Input() - actions = EditProcessFilterCloudComponent.DEFAULT_ACTIONS; + actions = DEFAULT_ACTIONS; /** Toggles editing of process filter actions. */ @Input() @@ -139,8 +137,8 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes { value: 'DESC', label: 'ADF_CLOUD_PROCESS_FILTERS.DIRECTION.DESCENDING' } ]; actionDisabledForDefault = [ - EditProcessFilterCloudComponent.ACTION_SAVE, - EditProcessFilterCloudComponent.ACTION_DELETE + PROCESS_FILTER_ACTION_SAVE, + PROCESS_FILTER_ACTION_DELETE ]; applicationNames: any[] = []; allProcessDefinitionNamesOption: DropdownOption = { @@ -274,7 +272,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes if (this.filterProperties.includes('initiator')) { this.initiatorOptions = !!this.processFilter.initiator - ? this.processFilter.initiator.split(',').map( username => Object.assign({}, { username: username })) + ? this.processFilter.initiator.split(',').map( username => Object.assign({}, { username })) : []; } @@ -297,7 +295,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes checkMandatoryFilterProperties() { if (this.filterProperties === undefined || this.filterProperties.length === 0) { - this.filterProperties = EditProcessFilterCloudComponent.DEFAULT_PROCESS_FILTER_PROPERTIES; + this.filterProperties = DEFAULT_PROCESS_FILTER_PROPERTIES; } } @@ -323,7 +321,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes checkMandatorySortProperties() { if (this.sortProperties === undefined || this.sortProperties.length === 0) { - this.sortProperties = EditProcessFilterCloudComponent.DEFAULT_SORT_PROPERTIES; + this.sortProperties = DEFAULT_SORT_PROPERTIES; } } @@ -335,7 +333,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes checkMandatoryActions() { if (this.actions === undefined || this.actions.length === 0) { - this.actions = EditProcessFilterCloudComponent.DEFAULT_ACTIONS; + this.actions = DEFAULT_ACTIONS; } } @@ -419,11 +417,11 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes } executeFilterActions(action: ProcessFilterAction): void { - if (action.actionType === EditProcessFilterCloudComponent.ACTION_SAVE) { + if (action.actionType === PROCESS_FILTER_ACTION_SAVE) { this.save(action); - } else if (action.actionType === EditProcessFilterCloudComponent.ACTION_SAVE_AS) { + } else if (action.actionType === PROCESS_FILTER_ACTION_SAVE_AS) { this.saveAs(action); - } else if (action.actionType === EditProcessFilterCloudComponent.ACTION_DELETE) { + } else if (action.actionType === PROCESS_FILTER_ACTION_DELETE) { this.delete(action); } } @@ -489,6 +487,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes /** * Return filter name + * * @param filterName */ getSanitizeFilterName(filterName: string): string { @@ -498,6 +497,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes /** * Return name with hyphen + * * @param name */ replaceSpaceWithHyphen(name: string): string { @@ -525,8 +525,8 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes } hasFilterChanged(action: ProcessFilterAction): boolean { - return action.actionType === EditProcessFilterCloudComponent.ACTION_SAVE || - action.actionType === EditProcessFilterCloudComponent.ACTION_SAVE_AS ? + return action.actionType === PROCESS_FILTER_ACTION_SAVE || + action.actionType === PROCESS_FILTER_ACTION_SAVE_AS ? !this.filterHasBeenChanged : false; } @@ -545,17 +545,17 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes private createFilterActions(): ProcessFilterAction[] { return [ { - actionType: EditProcessFilterCloudComponent.ACTION_SAVE, + actionType: PROCESS_FILTER_ACTION_SAVE, icon: 'adf:save', tooltip: 'ADF_CLOUD_EDIT_PROCESS_FILTER.TOOL_TIP.SAVE' }, { - actionType: EditProcessFilterCloudComponent.ACTION_SAVE_AS, + actionType: PROCESS_FILTER_ACTION_SAVE_AS, icon: 'adf:save-as', tooltip: 'ADF_CLOUD_EDIT_PROCESS_FILTER.TOOL_TIP.SAVE_AS' }, { - actionType: EditProcessFilterCloudComponent.ACTION_DELETE, + actionType: PROCESS_FILTER_ACTION_DELETE, icon: 'delete', tooltip: 'ADF_CLOUD_EDIT_PROCESS_FILTER.TOOL_TIP.DELETE' } diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filter-dialog-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filter-dialog-cloud.component.ts index c9fd8abd5d0..924610c75cc 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filter-dialog-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filter-dialog-cloud.component.ts @@ -26,6 +26,7 @@ import { FormBuilder, FormGroup, AbstractControl, Validators } from '@angular/fo }) export class ProcessFilterDialogCloudComponent implements OnInit { + // eslint-disable-next-line @typescript-eslint/naming-convention public static ACTION_SAVE = 'SAVE'; defaultIcon = 'inbox'; diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts index e70deefd0cf..57ef0dac46d 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.spec.ts @@ -60,7 +60,7 @@ describe('ProcessFiltersCloudComponent', () => { it('should attach specific icon for each filter if hasIcon is true', async () => { const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({'appName': change}); + component.ngOnChanges({appName: change}); fixture.detectChanges(); await fixture.whenStable(); @@ -81,7 +81,7 @@ describe('ProcessFiltersCloudComponent', () => { it('should not attach icons for each filter if hasIcon is false', async () => { component.showIcons = false; const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -92,7 +92,7 @@ describe('ProcessFiltersCloudComponent', () => { it('should display the filters', async () => { const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({'appName': change}); + component.ngOnChanges({appName: change}); fixture.detectChanges(); await fixture.whenStable(); @@ -124,7 +124,7 @@ describe('ProcessFiltersCloudComponent', () => { done(); }); - component.ngOnChanges({'appName': change}); + component.ngOnChanges({appName: change}); fixture.detectChanges(); }); @@ -133,7 +133,7 @@ describe('ProcessFiltersCloudComponent', () => { const appName = 'my-app-1'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -148,7 +148,7 @@ describe('ProcessFiltersCloudComponent', () => { const appName = 'my-app-1'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -159,7 +159,7 @@ describe('ProcessFiltersCloudComponent', () => { const change = new SimpleChange(null, { name: 'nonexistentFilter' }, true); fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toBeUndefined(); }); @@ -170,7 +170,7 @@ describe('ProcessFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(mockProcessFilters[1]); expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[1]); @@ -182,7 +182,7 @@ describe('ProcessFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(mockProcessFilters[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[2]); @@ -194,7 +194,7 @@ describe('ProcessFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(mockProcessFilters[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[2]); @@ -206,7 +206,7 @@ describe('ProcessFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(mockProcessFilters[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[2]); @@ -216,7 +216,7 @@ describe('ProcessFiltersCloudComponent', () => { const filterClickedSpy = spyOn(component.filterClicked, 'emit'); const appName = 'my-app-1'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -234,7 +234,7 @@ describe('ProcessFiltersCloudComponent', () => { it('should reset the filter when the param is undefined', () => { const change = new SimpleChange(mockProcessFilters[0], undefined, false); component.currentFilter = mockProcessFilters[0]; - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(undefined); }); @@ -245,7 +245,7 @@ describe('ProcessFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toBe(mockProcessFilters[0]); expect(filterClickedSpy).not.toHaveBeenCalled(); @@ -256,7 +256,7 @@ describe('ProcessFiltersCloudComponent', () => { const appName = 'my-app-1'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); expect(component.getFilters).toHaveBeenCalledWith(appName); }); @@ -266,7 +266,7 @@ describe('ProcessFiltersCloudComponent', () => { const appName = null; const change = new SimpleChange(undefined, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); expect(component.getFilters).not.toHaveBeenCalledWith(appName); }); @@ -276,7 +276,7 @@ describe('ProcessFiltersCloudComponent', () => { const appName = 'fake-app-name'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); expect(component.getFilters).toHaveBeenCalledWith(appName); }); @@ -296,21 +296,21 @@ describe('ProcessFiltersCloudComponent', () => { const runningProcessesFilterKey = mockProcessFilters[1].key; const completedProcessesFilterKey = mockProcessFilters[2].key; - function getActiveFilterElement(filterKey: string): Element { + const getActiveFilterElement = (filterKey: string): Element => { const activeFilter = fixture.debugElement.query(By.css(`.adf-active`)); return activeFilter.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`); - } + }; - async function clickOnFilter(filterKey: string) { + const clickOnFilter = async (filterKey: string) => { fixture.debugElement.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`).click(); fixture.detectChanges(); await fixture.whenStable(); - } + }; it('should apply active CSS class on filter click', async () => { component.appName = 'mock-app-name'; const appNameChange = new SimpleChange(null, 'mock-app-name', true); - component.ngOnChanges({ 'appName': appNameChange }); + component.ngOnChanges({ appName: appNameChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -335,7 +335,7 @@ describe('ProcessFiltersCloudComponent', () => { it('Should apply active CSS class when filterParam input changed', async () => { fixture.detectChanges(); - component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: allProcessesFilterKey }, true) }); + component.ngOnChanges({ filterParam: new SimpleChange(null, { key: allProcessesFilterKey }, true) }); fixture.detectChanges(); await fixture.whenStable(); @@ -343,7 +343,7 @@ describe('ProcessFiltersCloudComponent', () => { expect(getActiveFilterElement(runningProcessesFilterKey)).toBeNull(); expect(getActiveFilterElement(completedProcessesFilterKey)).toBeNull(); - component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: runningProcessesFilterKey }, true) }); + component.ngOnChanges({ filterParam: new SimpleChange(null, { key: runningProcessesFilterKey }, true) }); fixture.detectChanges(); await fixture.whenStable(); @@ -351,7 +351,7 @@ describe('ProcessFiltersCloudComponent', () => { expect(getActiveFilterElement(runningProcessesFilterKey)).toBeDefined(); expect(getActiveFilterElement(completedProcessesFilterKey)).toBeNull(); - component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: completedProcessesFilterKey }, true) }); + component.ngOnChanges({ filterParam: new SimpleChange(null, { key: completedProcessesFilterKey }, true) }); fixture.detectChanges(); await fixture.whenStable(); diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts index 119511127a1..9d661abd232 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/process-filters-cloud.component.ts @@ -111,12 +111,10 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro */ public selectFilter(paramFilter: FilterParamsModel) { if (paramFilter) { - this.currentFilter = this.filters.find((filter, index) => { - return paramFilter.id === filter.id || + this.currentFilter = this.filters.find((filter, index) => paramFilter.id === filter.id || (paramFilter.name && this.checkFilterNamesEquality(paramFilter.name, filter.name)) || (paramFilter.key && (paramFilter.key === filter.key)) || - paramFilter.index === index; - }); + paramFilter.index === index); } } @@ -146,7 +144,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro * Select filter with the id */ public selectFilterById(id: string) { - this.selectFilterAndEmit( {id: id}); + this.selectFilterAndEmit({id}); } /** diff --git a/lib/process-services-cloud/src/lib/process/process-filters/models/process-filter-cloud.model.ts b/lib/process-services-cloud/src/lib/process/process-filters/models/process-filter-cloud.model.ts index 145ff1e6059..e55fb6747df 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/models/process-filter-cloud.model.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/models/process-filter-cloud.model.ts @@ -14,14 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/* eslint-disable no-underscore-dangle */ + import { DateCloudFilterType } from '../../../models/date-cloud-filter.model'; import { DateRangeFilterService } from '../../../common/date-range-filter/date-range-filter.service'; import { ComponentSelectionMode } from '../../../types'; export class ProcessFilterCloudModel { - - private dateRangeFilterService = new DateRangeFilterService(); - id: string; name: string; key: string; @@ -47,6 +47,7 @@ export class ProcessFilterCloudModel { suspendedDateType: DateCloudFilterType; completedDate: Date; + private dateRangeFilterService = new DateRangeFilterService(); private _completedFrom: string; private _completedTo: string; private _startFrom: string; diff --git a/lib/process-services-cloud/src/lib/process/process-filters/services/process-filter-cloud.service.ts b/lib/process-services-cloud/src/lib/process/process-filters/services/process-filter-cloud.service.ts index a49eae27e78..fa81bf3986b 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/services/process-filter-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/services/process-filter-cloud.service.ts @@ -90,6 +90,7 @@ export class ProcessFilterCloudService { /** * Creates and returns the default process instance filters for a app. + * * @param appName Name of the target app * @returns Observable of default process instance filters just created or created filters */ @@ -114,6 +115,7 @@ export class ProcessFilterCloudService { /** * Gets all process instance filters for a process app. + * * @param appName Name of the target app * @returns Observable of process filters details */ @@ -124,6 +126,7 @@ export class ProcessFilterCloudService { /** * Get process instance filter for given filter id + * * @param appName Name of the target app * @param id Id of the target process instance filter * @returns Observable of process instance filter details @@ -138,17 +141,14 @@ export class ProcessFilterCloudService { return of(filters); } }), - map((filters: ProcessFilterCloudModel[]) => { - return filters.filter((filter: ProcessFilterCloudModel) => { - return filter.id === id; - })[0]; - }), + map((filters: ProcessFilterCloudModel[]) => filters.filter((filter: ProcessFilterCloudModel) => filter.id === id)[0]), catchError((err) => this.handleProcessError(err)) ); } /** * Adds a new process instance filter + * * @param filter The new filter to add * @returns Observable of process instance filters with newly added filter */ @@ -180,6 +180,7 @@ export class ProcessFilterCloudService { /** * Update process instance filter + * * @param filter The new filter to update * @returns Observable of process instance filters with updated filter */ @@ -205,6 +206,7 @@ export class ProcessFilterCloudService { /** * Delete process instance filter + * * @param filter The new filter to delete * @returns Observable of process instance filters without deleted filter */ @@ -230,6 +232,7 @@ export class ProcessFilterCloudService { /** * Checks if given filter is a default filter + * * @param filterName Name of the target process filter * @returns Boolean value for whether the filter is a default filter */ @@ -240,6 +243,7 @@ export class ProcessFilterCloudService { /** * Checks user preference are empty or not + * * @param preferences User preferences of the target app * @returns Boolean value if the preferences are not empty */ @@ -249,6 +253,7 @@ export class ProcessFilterCloudService { /** * Checks for process instance filters in given user preferences + * * @param preferences User preferences of the target app * @param key Key of the process instance filters * @param filters Details of create filter @@ -261,6 +266,7 @@ export class ProcessFilterCloudService { /** * Calls create preference api to create process instance filters + * * @param appName Name of the target app * @param key Key of the process instance filters * @param filters Details of new process instance filter @@ -272,6 +278,7 @@ export class ProcessFilterCloudService { /** * Calls get preference api to get process instance filter by preference key + * * @param appName Name of the target app * @param key Key of the process instance filters * @returns Observable of process instance filters @@ -282,6 +289,7 @@ export class ProcessFilterCloudService { /** * Calls update preference api to update process instance filter + * * @param appName Name of the target app * @param key Key of the process instance filters * @param filters Details of update filter @@ -293,6 +301,7 @@ export class ProcessFilterCloudService { /** * Creates a uniq key with appName and username + * * @param appName Name of the target app * @returns String of process instance filters preference key */ @@ -303,6 +312,7 @@ export class ProcessFilterCloudService { /** * Finds and returns the process instance filters from preferences + * * @returns Array of ProcessFilterCloudModel * @param preferences * @param key @@ -322,6 +332,7 @@ export class ProcessFilterCloudService { /** * Creates and returns the default filters for a process app. + * * @param appName Name of the target app * @returns Array of ProcessFilterCloudModel */ diff --git a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts index ce878368c76..f4873635ed1 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts @@ -84,19 +84,19 @@ describe('ProcessListCloudComponent', () => { component = fixture.componentInstance; appConfig.config = Object.assign(appConfig.config, { 'adf-cloud-process-list': { - 'presets': { - 'fakeCustomSchema': [ + presets: { + fakeCustomSchema: [ { - 'key': 'fakeName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', - 'sortable': true + key: 'fakeName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', + sortable: true }, { - 'key': 'fakeTaskName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', - 'sortable': true + key: 'fakeTaskName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', + sortable: true } ] } @@ -219,7 +219,7 @@ describe('ProcessListCloudComponent', () => { done(); }); component.appName = appName.currentValue; - component.ngOnChanges({ 'appName': appName }); + component.ngOnChanges({ appName }); fixture.detectChanges(); }); @@ -263,9 +263,9 @@ describe('ProcessListCloudComponent', () => { const initiatorChange = new SimpleChange(undefined, 'mock-initiator', true); component.ngOnChanges({ - 'appName': appNameChange, - 'assignee': initiatorChange, - 'status': statusChange + appName: appNameChange, + assignee: initiatorChange, + status: statusChange }); fixture.detectChanges(); expect(component.isListEmpty()).toBeFalsy(); @@ -285,7 +285,7 @@ describe('ProcessListCloudComponent', () => { ]; const sortChange = new SimpleChange(undefined, mockSort, true); component.ngOnChanges({ - 'sorting': sortChange + sorting: sortChange }); fixture.detectChanges(); expect(component.formatSorting).toHaveBeenCalledWith(mockSort); diff --git a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts index feb30039f03..0c8fab23ccf 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.ts @@ -26,6 +26,8 @@ import { processCloudPresetsDefaultModel } from '../models/process-cloud-preset. import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model'; import { ProcessListCloudSortingModel } from '../models/process-list-sorting.model'; +const PRESET_KEY = 'adf-cloud-process-list.presets'; + @Component({ selector: 'adf-cloud-process-list', templateUrl: './process-list-cloud.component.html', @@ -33,9 +35,6 @@ import { ProcessListCloudSortingModel } from '../models/process-list-sorting.mod encapsulation: ViewEncapsulation.None }) export class ProcessListCloudComponent extends DataTableSchema implements OnChanges, AfterContentInit, PaginatedComponent { - - static PRESET_KEY = 'adf-cloud-process-list.presets'; - @ViewChild(DataTableComponent) dataTable: DataTableComponent; @@ -198,12 +197,12 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan constructor(private processListCloudService: ProcessListCloudService, appConfigService: AppConfigService, private userPreferences: UserPreferencesService) { - super(appConfigService, ProcessListCloudComponent.PRESET_KEY, processCloudPresetsDefaultModel); + super(appConfigService, PRESET_KEY, processCloudPresetsDefaultModel); this.size = userPreferences.paginationSize; this.userPreferences.select(UserPreferenceValues.PaginationSize).subscribe((pageSize) => { this.size = pageSize; }); - this.pagination = new BehaviorSubject( { + this.pagination = new BehaviorSubject({ maxItems: this.size, skipCount: 0, totalItems: 0 @@ -282,6 +281,7 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan /** * Resets the pagination values and * Reloads the process list + * * @param pagination Pagination values to be set */ updatePagination(pagination: PaginationModel) { diff --git a/lib/process-services-cloud/src/lib/process/process-list/mock/process-list-service.mock.ts b/lib/process-services-cloud/src/lib/process/process-list/mock/process-list-service.mock.ts index 1f030899329..c175aa4cdfc 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/mock/process-list-service.mock.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/mock/process-list-service.mock.ts @@ -82,85 +82,85 @@ export const fakeProcessCloudList = { } }; -export let fakeCustomSchema = +export const fakeCustomSchema = [ new ObjectDataColumn({ - 'key': 'fakeName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', - 'sortable': true + key: 'fakeName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', + sortable: true }), new ObjectDataColumn({ - 'key': 'fakeTaskName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', - 'sortable': true + key: 'fakeTaskName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', + sortable: true }) ]; export const processListSchemaMock = { - 'presets': { - 'default': [ + presets: { + default: [ { - 'key': 'id', - 'type': 'text', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.ID', - 'sortable': true + key: 'id', + type: 'text', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.ID', + sortable: true }, { - 'key': 'name', - 'type': 'text', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.NAME', - 'sortable': true + key: 'name', + type: 'text', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.NAME', + sortable: true }, { - 'key': 'status', - 'type': 'text', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.STATUS', - 'sortable': true + key: 'status', + type: 'text', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.STATUS', + sortable: true }, { - 'key': 'startDate', - 'type': 'date', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.START_DATE', - 'sortable': true, - 'format': 'timeAgo' + key: 'startDate', + type: 'date', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.START_DATE', + sortable: true, + format: 'timeAgo' }, { - 'key': 'appName', - 'type': 'text', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.APP_NAME', - 'sortable': true + key: 'appName', + type: 'text', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.APP_NAME', + sortable: true }, { - 'key': 'businessKey', - 'type': 'text', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.BUSINESS_KEY', - 'sortable': true + key: 'businessKey', + type: 'text', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.BUSINESS_KEY', + sortable: true }, { - 'key': 'initiator', - 'type': 'text', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.INITIATOR', - 'sortable': true + key: 'initiator', + type: 'text', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.INITIATOR', + sortable: true }, { - 'key': 'lastModified', - 'type': 'date', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.LAST_MODIFIED', - 'sortable': true + key: 'lastModified', + type: 'date', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.LAST_MODIFIED', + sortable: true }, { - 'key': 'processDefinitionId', - 'type': 'text', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_ID', - 'sortable': true + key: 'processDefinitionId', + type: 'text', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_ID', + sortable: true }, { - 'key': 'processDefinitionKey', - 'type': 'text', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_KEY', - 'sortable': true + key: 'processDefinitionKey', + type: 'text', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_KEY', + sortable: true } ] } diff --git a/lib/process-services-cloud/src/lib/process/process-list/models/process-cloud-preset.model.ts b/lib/process-services-cloud/src/lib/process/process-list/models/process-cloud-preset.model.ts index 416a735cc83..ae3f1d72b50 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/models/process-cloud-preset.model.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/models/process-cloud-preset.model.ts @@ -15,21 +15,21 @@ * limitations under the License. */ -export let processCloudPresetsDefaultModel = { - 'default': [ +export const processCloudPresetsDefaultModel = { + default: [ { - 'key': 'name', - 'type': 'text', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.NAME', - 'sortable': true + key: 'name', + type: 'text', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.NAME', + sortable: true }, { - 'key': 'startDate', - 'type': 'date', - 'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.START_DATE', - 'cssClass': 'hidden', - 'sortable': true, - 'format': 'timeAgo' + key: 'startDate', + type: 'date', + title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.START_DATE', + cssClass: 'hidden', + sortable: true, + format: 'timeAgo' } ] }; diff --git a/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.spec.ts index 78c3c9f13cf..b34613ba72e 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.spec.ts @@ -24,31 +24,19 @@ describe('ProcessListCloudService', () => { let service: ProcessListCloudService; let alfrescoApiService: AlfrescoApiService; - function returnCallQueryParameters(): any { - return { - oauth2Auth: { - callCustomApi: (_queryUrl, _operation, _context, queryParams) => { - return Promise.resolve(queryParams); - } - }, - isEcmLoggedIn() { - return false; - } - }; - } + const returnCallQueryParameters = (): any => ({ + oauth2Auth: { + callCustomApi: (_queryUrl, _operation, _context, queryParams) => Promise.resolve(queryParams) + }, + isEcmLoggedIn: () => false + }); - function returnCallUrl(): any { - return { - oauth2Auth: { - callCustomApi: (queryUrl) => { - return Promise.resolve(queryUrl); - } - }, - isEcmLoggedIn() { - return false; - } - }; - } + const returnCallUrl = (): any => ({ + oauth2Auth: { + callCustomApi: (queryUrl) => Promise.resolve(queryUrl) + }, + isEcmLoggedIn: () => false + }); setupTestBed({ imports: [ diff --git a/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts b/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts index 5620089d979..c22873f250f 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/services/process-list-cloud.service.ts @@ -33,6 +33,7 @@ export class ProcessListCloudService extends BaseCloudService { /** * Finds a process using an object with optional query properties. + * * @param requestNode Query object * @param queryUrl Query url * @returns Process information @@ -50,9 +51,7 @@ export class ProcessListCloudService extends BaseCloudService { map((response: any) => { const entries = response.list && response.list.entries; if (entries) { - response.list.entries = entries.map((entryData) => { - return entryData.entry; - }); + response.list.entries = entries.map((entryData) => entryData.entry); } return response; }) diff --git a/lib/process-services-cloud/src/lib/process/services/process-cloud.service.ts b/lib/process-services-cloud/src/lib/process/services/process-cloud.service.ts index f4451327f5b..5a9fc0a4da7 100644 --- a/lib/process-services-cloud/src/lib/process/services/process-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/process/services/process-cloud.service.ts @@ -40,6 +40,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou /** * Gets details of a process instance. + * * @param appName Name of the app * @param processInstanceId ID of the process instance whose details you want * @returns Process instance details @@ -62,6 +63,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou /** * Gets the process definitions associated with an app. + * * @param appName Name of the target app * @returns Array of process definitions */ @@ -70,9 +72,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`; return this.get(url).pipe( - map((res: any) => { - return res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry)); - }) + map((res: any) => res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry))) ); } else { this.logService.error('AppName is mandatory for querying task'); @@ -82,6 +82,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou /** * Gets the application versions associated with an app. + * * @param appName Name of the target app * @returns Array of Application Version Models */ @@ -90,9 +91,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou const url = `${this.getBasePath(appName)}/query/v1/applications`; return this.get(url).pipe( - map((appEntities: ApplicationVersionResponseModel) => { - return appEntities.list.entries; - }), + map((appEntities: ApplicationVersionResponseModel) => appEntities.list.entries), catchError((err) => this.handleError(err)) ); } else { @@ -103,6 +102,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou /** * Cancels a process. + * * @param appName Name of the app * @param processInstanceId Id of the process to cancel * @returns Operation Information diff --git a/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.spec.ts index 0b8212196d3..fa1c822deac 100755 --- a/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.spec.ts @@ -72,11 +72,11 @@ describe('StartProcessCloudComponent', () => { } }; - function typeValueInto(selector: any, value: string) { + const typeValueInto = (selector: any, value: string) => { const inputElement = fixture.debugElement.query(By.css(`${selector}`)); inputElement.nativeElement.value = value; inputElement.nativeElement.dispatchEvent(new Event('input')); - } + }; setupTestBed({ imports: [ @@ -120,7 +120,7 @@ describe('StartProcessCloudComponent', () => { component.appName = 'myApp'; fixture.detectChanges(); const change = new SimpleChange(null, 'MyApp', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); }); @@ -131,7 +131,7 @@ describe('StartProcessCloudComponent', () => { fixture.detectChanges(); const change = new SimpleChange(null, 'MyApp', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); tick(550); @@ -162,7 +162,7 @@ describe('StartProcessCloudComponent', () => { const change = new SimpleChange(null, 'MyApp', false); fixture.detectChanges(); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); tick(); typeValueInto('#processName', 'OLE'); @@ -209,24 +209,24 @@ describe('StartProcessCloudComponent', () => { beforeEach(() => { component.name = 'My new process with form'; component.values = [{ - 'id': '1', - 'type': 'string', - 'name': 'firstName', - 'value': 'FakeName', - get 'hasValue'() { + id: '1', + type: 'string', + name: 'firstName', + value: 'FakeName', + get hasValue() { return this['value']; }, - set 'hasValue'(value) { + set hasValue(value) { this['value'] = value; } }, { - 'id': '1', 'type': 'string', - 'name': 'lastName', - 'value': 'FakeLastName', - get 'hasValue'() { + id: '1', type: 'string', + name: 'lastName', + value: 'FakeLastName', + get hasValue() { return this['value']; }, - set 'hasValue'(value) { + set hasValue(value) { this['value'] = value; } }]; @@ -239,7 +239,7 @@ describe('StartProcessCloudComponent', () => { formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm)); const change = new SimpleChange(null, 'MyApp', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); tick(); typeValueInto('#processName', 'My new process with form'); @@ -265,7 +265,7 @@ describe('StartProcessCloudComponent', () => { formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartFormNotValid)); const change = new SimpleChange(null, 'MyApp', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); tick(); @@ -293,7 +293,7 @@ describe('StartProcessCloudComponent', () => { formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm)); const change = new SimpleChange(null, 'MyApp', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); tick(); @@ -323,7 +323,7 @@ describe('StartProcessCloudComponent', () => { formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartFormNotValid)); const change = new SimpleChange(null, 'MyApp', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); tick(); @@ -355,7 +355,7 @@ describe('StartProcessCloudComponent', () => { formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm)); const change = new SimpleChange(null, 'MyApp', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); tick(550); @@ -382,7 +382,7 @@ describe('StartProcessCloudComponent', () => { formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm)); const change = new SimpleChange(null, 'MyApp', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); tick(550); @@ -401,7 +401,7 @@ describe('StartProcessCloudComponent', () => { component.appName = 'myApp'; fixture.detectChanges(); const change = new SimpleChange(null, 'MyApp', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); }); @@ -853,11 +853,11 @@ describe('StartProcessCloudComponent', () => { component.processDefinitionName = 'fake-name'; const change = new SimpleChange(null, 'MyApp', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); }); it('should cancel bubbling a keydown event ()', () => { - const escapeKeyboardEvent = new KeyboardEvent('keydown', { 'keyCode': ESCAPE } as any); + const escapeKeyboardEvent = new KeyboardEvent('keydown', { keyCode: ESCAPE } as any); fixture.debugElement.triggerEventHandler('keydown', escapeKeyboardEvent); expect(escapeKeyboardEvent.cancelBubble).toBe(true); diff --git a/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.ts b/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.ts index c948fc99a0b..daf4398449b 100755 --- a/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/process/start-process/components/start-process-cloud.component.ts @@ -31,6 +31,11 @@ import { ProcessDefinitionCloud } from '../../../models/process-definition-cloud import { Subject, Observable } from 'rxjs'; import { TaskVariableCloud } from '../../../form/models/task-variable-cloud.model'; import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe'; + +const MAX_NAME_LENGTH: number = 255; +const PROCESS_DEFINITION_DEBOUNCE: number = 300; +const PROCESS_FORM_DEBOUNCE: number = 400; + @Component({ selector: 'adf-cloud-start-process', templateUrl: './start-process-cloud.component.html', @@ -38,11 +43,6 @@ import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe'; encapsulation: ViewEncapsulation.None }) export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy { - - static MAX_NAME_LENGTH: number = 255; - static PROCESS_DEFINITION_DEBOUNCE: number = 300; - static PROCESS_FORM_DEBOUNCE: number = 400; - @ViewChild(MatAutocompleteTrigger) inputAutocomplete: MatAutocompleteTrigger; @@ -52,7 +52,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy /** Maximum length of the process name. */ @Input() - maxNameLength: number = StartProcessCloudComponent.MAX_NAME_LENGTH; + maxNameLength: number = MAX_NAME_LENGTH; /** Name of the process. */ @Input() @@ -121,15 +121,15 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy }); this.processDefinition.valueChanges - .pipe(debounceTime(StartProcessCloudComponent.PROCESS_DEFINITION_DEBOUNCE)) + .pipe(debounceTime(PROCESS_DEFINITION_DEBOUNCE)) .pipe(takeUntil(this.onDestroy$)) .subscribe((processDefinitionName) => { - this.selectProcessDefinitionByProcesDefinitionName(processDefinitionName); + this.selectProcessDefinitionByProcessDefinitionName(processDefinitionName); }); this.processForm.valueChanges .pipe( - debounceTime(StartProcessCloudComponent.PROCESS_FORM_DEBOUNCE), + debounceTime(PROCESS_FORM_DEBOUNCE), tap(() => this.disableStartButton = true), distinctUntilChanged(), filter(() => this.isProcessSelectionValid()), @@ -170,8 +170,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy } private getMaxNameLength(): number { - return this.maxNameLength > StartProcessCloudComponent.MAX_NAME_LENGTH ? - StartProcessCloudComponent.MAX_NAME_LENGTH : this.maxNameLength; + return this.maxNameLength > MAX_NAME_LENGTH ? MAX_NAME_LENGTH : this.maxNameLength; } private generateProcessInstance(): Observable { @@ -187,7 +186,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy } } - private selectProcessDefinitionByProcesDefinitionName(processDefinitionName: string): void { + private selectProcessDefinitionByProcessDefinitionName(processDefinitionName: string): void { this.filteredProcesses = this.getProcessDefinitionListByNameOrKey(processDefinitionName); if (this.isProcessFormValid() && @@ -205,9 +204,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy } private getProcessDefinitionListByNameOrKey(processDefinitionName: string): ProcessDefinitionCloud[] { - return this.processDefinitionList.filter((processDefinitionCloud) => { - return !processDefinitionName || this.getProcessDefinition(processDefinitionCloud, processDefinitionName); - }); + return this.processDefinitionList.filter((processDefinitionCloud) => !processDefinitionName || this.getProcessDefinition(processDefinitionCloud, processDefinitionName)); } private getProcessIfExists(processDefinition: string): ProcessDefinitionCloud { diff --git a/lib/process-services-cloud/src/lib/process/start-process/mock/start-process.component.mock.ts b/lib/process-services-cloud/src/lib/process/start-process/mock/start-process.component.mock.ts index 2fa3307a4d6..4e2a0f84dd6 100755 --- a/lib/process-services-cloud/src/lib/process/start-process/mock/start-process.component.mock.ts +++ b/lib/process-services-cloud/src/lib/process/start-process/mock/start-process.component.mock.ts @@ -74,29 +74,25 @@ export const fakeProcessDefinitions: ProcessDefinitionCloud[] = [ }) ]; -export function fakeSingleProcessDefinition(name: string): ProcessDefinitionCloud[] { - return [ - new ProcessDefinitionCloud({ - appName: 'startformwithoutupload', - formKey: 'form-a5d50817-5183-4850-802d-17af54b2632f', - id: 'd00c0237-8772-11e9-859a-428f83d5904f', - key: 'process-5151ad1d-f992-4ee6-9742-3a04617469fe', - name: name - }) - ]; -} +export const fakeSingleProcessDefinition = (name: string): ProcessDefinitionCloud[] => [ + new ProcessDefinitionCloud({ + appName: 'startformwithoutupload', + formKey: 'form-a5d50817-5183-4850-802d-17af54b2632f', + id: 'd00c0237-8772-11e9-859a-428f83d5904f', + key: 'process-5151ad1d-f992-4ee6-9742-3a04617469fe', + name + }) +]; -export function fakeSingleProcessDefinitionWithoutForm(name: string): ProcessDefinitionCloud[] { - return [ - new ProcessDefinitionCloud({ - appName: 'startformwithoutupload', - formKey: '', - id: 'd00c0237-8772-11e9-859a-428f83d5904f', - key: 'process-5151ad1d-f992-4ee6-9742-3a04617469fe', - name: name - }) - ]; -} +export const fakeSingleProcessDefinitionWithoutForm = (name: string): ProcessDefinitionCloud[] => [ + new ProcessDefinitionCloud({ + appName: 'startformwithoutupload', + formKey: '', + id: 'd00c0237-8772-11e9-859a-428f83d5904f', + key: 'process-5151ad1d-f992-4ee6-9742-3a04617469fe', + name + }) +]; export const fakeNoNameProcessDefinitions: ProcessDefinitionCloud[] = [ new ProcessDefinitionCloud({ @@ -122,129 +118,129 @@ export const fakeProcessPayload = new ProcessPayloadCloud({ }); export const fakeStartForm = { - 'formRepresentation': { - 'id': 'form-de8895be-d0d7-4434-beef-559b15305d72', - 'name': 'StartEventForm', - 'description': '', - 'version': 0, - 'formDefinition': { - 'tabs': [], - 'fields': [ + formRepresentation: { + id: 'form-de8895be-d0d7-4434-beef-559b15305d72', + name: 'StartEventForm', + description: '', + version: 0, + formDefinition: { + tabs: [], + fields: [ { - 'type': 'container', - 'id': '5a6b24c1-db2b-45e9-9aff-142395433d23', - 'name': 'Label', - 'tab': null, - 'fields': { - '1': [ + type: 'container', + id: '5a6b24c1-db2b-45e9-9aff-142395433d23', + name: 'Label', + tab: null, + fields: { + 1: [ { - 'type': 'text', - 'id': 'firstName', - 'name': 'firstName', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'text', + id: 'firstName', + name: 'firstName', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': false, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: false, + minLength: 0, + maxLength: 0, + regexPattern: null } ], - '2': [ + 2: [ { - 'type': 'text', - 'id': 'lastName', - 'name': 'lastName', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'text', + id: 'lastName', + name: 'lastName', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': false, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: false, + minLength: 0, + maxLength: 0, + regexPattern: null } ] }, - 'numberOfColumns': 2 + numberOfColumns: 2 } ], - 'outcomes': [], - 'metadata': {}, - 'variables': [] + outcomes: [], + metadata: {}, + variables: [] } } }; export const fakeStartFormNotValid = { - 'formRepresentation': { - 'id': 'form-a5d50817-5183-4850-802d-17af54b2632f', - 'name': 'simpleform', - 'description': '', - 'version': 0, - 'formDefinition': { - 'tabs': [], - 'fields': [ + formRepresentation: { + id: 'form-a5d50817-5183-4850-802d-17af54b2632f', + name: 'simpleform', + description: '', + version: 0, + formDefinition: { + tabs: [], + fields: [ { - 'type': 'container', - 'id': '5a6b24c1-db2b-45e9-9aff-142395433d23', - 'name': 'Label', - 'tab': null, - 'fields': { - '1': [ + type: 'container', + id: '5a6b24c1-db2b-45e9-9aff-142395433d23', + name: 'Label', + tab: null, + fields: { + 1: [ { - 'type': 'text', - 'id': 'firstName', - 'name': 'firstName', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'text', + id: 'firstName', + name: 'firstName', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': true, - 'minLength': 15, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: true, + minLength: 15, + maxLength: 0, + regexPattern: null } ], - '2': [ + 2: [ { - 'type': 'text', - 'id': 'lastName', - 'name': 'lastName', - 'colspan': 1, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + type: 'text', + id: 'lastName', + name: 'lastName', + colspan: 1, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'visibilityCondition': null, - 'placeholder': null, - 'value': null, - 'required': false, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null + visibilityCondition: null, + placeholder: null, + value: null, + required: false, + minLength: 0, + maxLength: 0, + regexPattern: null } ] }, - 'numberOfColumns': 2 + numberOfColumns: 2 } ], - 'outcomes': [], - 'metadata': {}, - 'variables': [] + outcomes: [], + metadata: {}, + variables: [] } } }; diff --git a/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.spec.ts index 482f38e0a90..688ab0b73bb 100755 --- a/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.spec.ts @@ -38,9 +38,7 @@ describe('StartProcessCloudService', () => { } }) }, - isEcmLoggedIn() { - return false; - } + isEcmLoggedIn: () => false }; setupTestBed({ diff --git a/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.ts b/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.ts index 0e8e1b37ccc..834ac5c6cd4 100755 --- a/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/process/start-process/services/start-process-cloud.service.ts @@ -37,6 +37,7 @@ export class StartProcessCloudService extends BaseCloudService { /** * Gets the process definitions associated with an app. + * * @param appName Name of the target app * @returns Array of process definitions */ @@ -45,9 +46,7 @@ export class StartProcessCloudService extends BaseCloudService { const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`; return this.get(url).pipe( - map((res: any) => { - return res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry)); - }) + map((res: any) => res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry))) ); } else { this.logService.error('AppName is mandatory for querying task'); @@ -57,6 +56,7 @@ export class StartProcessCloudService extends BaseCloudService { /** * Create a process based on a process definition, name, form values or variables. + * * @param appName name of the Application * @param payload Details of the process (definition key, name, variables, etc) * @returns Details of the process instance just created @@ -72,6 +72,7 @@ export class StartProcessCloudService extends BaseCloudService { /** * Starts an already created process using the process instance id. + * * @param createdProcessInstanceId process instance id of the process previously created * @returns Details of the process instance just started */ @@ -85,6 +86,7 @@ export class StartProcessCloudService extends BaseCloudService { /** * Starts a process based on a process definition, name, form values or variables. + * * @param appName name of the Application * @param payload Details of the process (definition key, name, variables, etc) * @returns Details of the process instance just started @@ -98,6 +100,7 @@ export class StartProcessCloudService extends BaseCloudService { /** * Update an existing process instance + * * @param appName name of the Application * @param processInstanceId process instance to update * @param payload Details of the process (definition key, name, variables, etc) @@ -114,6 +117,7 @@ export class StartProcessCloudService extends BaseCloudService { /** * Delete an existing process instance + * * @param appName name of the Application * @param processInstanceId process instance to update */ diff --git a/lib/process-services-cloud/src/lib/services/form-fields.interfaces.ts b/lib/process-services-cloud/src/lib/services/form-fields.interfaces.ts index e8fe4291822..361acd7e312 100644 --- a/lib/process-services-cloud/src/lib/services/form-fields.interfaces.ts +++ b/lib/process-services-cloud/src/lib/services/form-fields.interfaces.ts @@ -200,6 +200,7 @@ export interface TextField extends FormField { placeholder: string | null; } +// eslint-disable-next-line no-shadow export enum PeopleModeOptions { single = 'single', multiple = 'multiple' @@ -210,6 +211,7 @@ export interface PeopleField extends FormField { optionType: PeopleModeOptions; } +// eslint-disable-next-line no-shadow export enum FormFieldType { text = 'text', multiline = 'multi-line-text', diff --git a/lib/process-services-cloud/src/lib/services/local-preference-cloud.service.ts b/lib/process-services-cloud/src/lib/services/local-preference-cloud.service.ts index 6135c874752..a969d64a34c 100644 --- a/lib/process-services-cloud/src/lib/services/local-preference-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/services/local-preference-cloud.service.ts @@ -27,6 +27,7 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf /** * Gets local preferences + * * @param _ Name of the target app * @param key Key of the target preference * @returns List of local preferences @@ -37,8 +38,8 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf } return of( { - 'list': { - 'entries': [] + list: { + entries: [] } } ); @@ -46,6 +47,7 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf /** * Gets local preference. + * * @param _ Name of the target app * @param key Key of the target preference * @returns Observable of local preference @@ -56,6 +58,7 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf /** * Creates local preference. + * * @param _ Name of the target app * @param key Key of the target preference * @param newPreference Details of new local preference @@ -70,6 +73,7 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf /** * Updates local preference. + * * @param _ Name of the target app * @param key Key of the target preference * @param updatedPreference Details of updated preference @@ -84,6 +88,7 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf /** * Deletes local preference by given preference key. + * * @param key Key of the target preference * @param preferences Details of updated preferences * @returns Observable of preferences without deleted preference @@ -97,12 +102,12 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf prepareLocalPreferenceResponse(key: string): any { return { - 'list': { - 'entries': [ + list: { + entries: [ { - 'entry': { - 'key': key, - 'value': this.storage.getItem(key) || '[]' + entry: { + key, + value: this.storage.getItem(key) || '[]' } } ] diff --git a/lib/process-services-cloud/src/lib/services/notification-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/services/notification-cloud.service.spec.ts index 59e0af96e29..20dc1072df9 100644 --- a/lib/process-services-cloud/src/lib/services/notification-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/services/notification-cloud.service.spec.ts @@ -29,7 +29,7 @@ describe('NotificationCloudService', () => { let apolloSubscribeSpy: jasmine.Spy; let apiService: AlfrescoApiService; const useMock: any = { - subscribe() {} + subscribe: () => {} }; const queryMock = ` @@ -47,9 +47,7 @@ describe('NotificationCloudService', () => { oauth2Auth: { token: '1234567' }, - isEcmLoggedIn() { - return false; - }, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') }; diff --git a/lib/process-services-cloud/src/lib/services/notification-cloud.service.ts b/lib/process-services-cloud/src/lib/services/notification-cloud.service.ts index 2ccdca9b919..de1ea29237a 100644 --- a/lib/process-services-cloud/src/lib/services/notification-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/services/notification-cloud.service.ts @@ -61,6 +61,7 @@ export class NotificationCloudService extends BaseCloudService { lazy: true, connectionParams: { kaInterval: 2000, + // eslint-disable-next-line @typescript-eslint/naming-convention 'X-Authorization': 'Bearer ' + this.apiService.getInstance().oauth2Auth.token } } @@ -84,6 +85,7 @@ export class NotificationCloudService extends BaseCloudService { operation.setContext({ headers: { ...oldHeaders, + // eslint-disable-next-line @typescript-eslint/naming-convention 'X-Authorization': 'Bearer ' + this.apiService.getInstance().oauth2Auth.token } }); diff --git a/lib/process-services-cloud/src/lib/services/user-preference-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/services/user-preference-cloud.service.spec.ts index fe147ceee92..80546ea7c06 100644 --- a/lib/process-services-cloud/src/lib/services/user-preference-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/services/user-preference-cloud.service.spec.ts @@ -32,27 +32,19 @@ describe('PreferenceService', () => { state: 404, stateText: 'Not Found' }; - function apiMock(mockResponse): any { - return { - oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(mockResponse); - } - }, - isEcmLoggedIn() { - return false; - }, - reply: jasmine.createSpy('reply') - }; - } + const apiMock = (mockResponse): any => ({ + oauth2Auth: { + callCustomApi: () => Promise.resolve(mockResponse) + }, + isEcmLoggedIn: () => false, + reply: jasmine.createSpy('reply') + }); const apiErrorMock: any = { oauth2Auth: { callCustomApi: () => Promise.reject(errorResponse) }, - isEcmLoggedIn() { - return false; - } + isEcmLoggedIn:() => false }; setupTestBed({ diff --git a/lib/process-services-cloud/src/lib/services/user-preference-cloud.service.ts b/lib/process-services-cloud/src/lib/services/user-preference-cloud.service.ts index ec32a1800ee..ec633d52b5c 100644 --- a/lib/process-services-cloud/src/lib/services/user-preference-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/services/user-preference-cloud.service.ts @@ -33,6 +33,7 @@ export class UserPreferenceCloudService extends BaseCloudService implements Pref /** * Gets user preferences + * * @param appName Name of the target app * @returns List of user preferences */ @@ -48,6 +49,7 @@ export class UserPreferenceCloudService extends BaseCloudService implements Pref /** * Gets user preference. + * * @param appName Name of the target app * @param key Key of the target preference * @returns Observable of user preference @@ -64,6 +66,7 @@ export class UserPreferenceCloudService extends BaseCloudService implements Pref /** * Creates user preference. + * * @param appName Name of the target app * @param key Key of the target preference * @newPreference Details of new user preference @@ -83,6 +86,7 @@ export class UserPreferenceCloudService extends BaseCloudService implements Pref /** * Updates user preference. + * * @param appName Name of the target app * @param key Key of the target preference * @param updatedPreference Details of updated preference @@ -94,6 +98,7 @@ export class UserPreferenceCloudService extends BaseCloudService implements Pref /** * Deletes user preference by given preference key. + * * @param appName Name of the target app * @param key Key of the target preference * @returns Observable of delete operation status diff --git a/lib/process-services-cloud/src/lib/task/directives/claim-task-cloud.directive.spec.ts b/lib/process-services-cloud/src/lib/task/directives/claim-task-cloud.directive.spec.ts index 62b3914c27b..15c499d1f89 100644 --- a/lib/process-services-cloud/src/lib/task/directives/claim-task-cloud.directive.spec.ts +++ b/lib/process-services-cloud/src/lib/task/directives/claim-task-cloud.directive.spec.ts @@ -113,7 +113,7 @@ describe('Claim Task Directive validation errors', () => { selector: 'adf-cloud-claim-undefined-appname-component', template: '' }) - class ClaimTestInvalidAppNameUndefineddDirectiveComponent { + class ClaimTestInvalidAppNameUndefinedDirectiveComponent { appNameUndefined = undefined; taskMock = 'test1234'; @@ -126,7 +126,7 @@ describe('Claim Task Directive validation errors', () => { selector: 'adf-cloud-claim-null-appname-component', template: '' }) - class ClaimTestInvalidAppNameNulldDirectiveComponent { + class ClaimTestInvalidAppNameNullDirectiveComponent { appNameNull = null; taskMock = 'test1234'; @@ -144,8 +144,8 @@ describe('Claim Task Directive validation errors', () => { ], declarations: [ ClaimTestMissingTaskIdDirectiveComponent, - ClaimTestInvalidAppNameUndefineddDirectiveComponent, - ClaimTestInvalidAppNameNulldDirectiveComponent, + ClaimTestInvalidAppNameUndefinedDirectiveComponent, + ClaimTestInvalidAppNameNullDirectiveComponent, ClaimTestMissingInputDirectiveComponent ] }); @@ -165,12 +165,12 @@ describe('Claim Task Directive validation errors', () => { }); it('should throw error when appName is undefined', () => { - fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefineddDirectiveComponent); + fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefinedDirectiveComponent); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); }); it('should throw error when appName is null', () => { - fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefineddDirectiveComponent); + fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefinedDirectiveComponent); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); }); }); diff --git a/lib/process-services-cloud/src/lib/task/directives/complete-task.directive.spec.ts b/lib/process-services-cloud/src/lib/task/directives/complete-task.directive.spec.ts index 79bd37e4287..9a01aa75281 100644 --- a/lib/process-services-cloud/src/lib/task/directives/complete-task.directive.spec.ts +++ b/lib/process-services-cloud/src/lib/task/directives/complete-task.directive.spec.ts @@ -125,7 +125,7 @@ describe('Complete Task Directive validation errors', () => { selector: 'adf-cloud-undefined-appname-component', template: '' }) - class TestInvalidAppNameUndefineddDirectiveComponent { + class TestInvalidAppNameUndefinedDirectiveComponent { appName = 'simple-app'; taskMock = 'test1234'; @@ -142,7 +142,7 @@ describe('Complete Task Directive validation errors', () => { selector: 'adf-cloud-null-appname-component', template: '' }) - class TestInvalidAppNameNulldDirectiveComponent { + class TestInvalidAppNameNullDirectiveComponent { appName = 'simple-app'; taskMock = 'test1234'; @@ -164,8 +164,8 @@ describe('Complete Task Directive validation errors', () => { ], declarations: [ TestMissingTaskIdDirectiveComponent, - TestInvalidAppNameUndefineddDirectiveComponent, - TestInvalidAppNameNulldDirectiveComponent, + TestInvalidAppNameUndefinedDirectiveComponent, + TestInvalidAppNameNullDirectiveComponent, TestMissingInputDirectiveComponent ] }); @@ -184,12 +184,12 @@ describe('Complete Task Directive validation errors', () => { }); it('should throw error when appName is undefined', () => { - fixture = TestBed.createComponent(TestInvalidAppNameUndefineddDirectiveComponent); + fixture = TestBed.createComponent(TestInvalidAppNameUndefinedDirectiveComponent); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); }); it('should throw error when appName is null', () => { - fixture = TestBed.createComponent(TestInvalidAppNameUndefineddDirectiveComponent); + fixture = TestBed.createComponent(TestInvalidAppNameUndefinedDirectiveComponent); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); }); }); diff --git a/lib/process-services-cloud/src/lib/task/directives/unclaim-task-cloud.directive.spec.ts b/lib/process-services-cloud/src/lib/task/directives/unclaim-task-cloud.directive.spec.ts index 20bc645d6e9..a8b60d8e9d8 100644 --- a/lib/process-services-cloud/src/lib/task/directives/unclaim-task-cloud.directive.spec.ts +++ b/lib/process-services-cloud/src/lib/task/directives/unclaim-task-cloud.directive.spec.ts @@ -113,7 +113,7 @@ describe('UnClaim Task Directive validation errors', () => { selector: 'adf-cloud-claim-undefined-appname-component', template: '' }) - class ClaimTestInvalidAppNameUndefineddDirectiveComponent { + class ClaimTestInvalidAppNameUndefinedDirectiveComponent { appNameUndefined = undefined; taskMock = 'test1234'; @@ -126,7 +126,7 @@ describe('UnClaim Task Directive validation errors', () => { selector: 'adf-cloud-claim-null-appname-component', template: '' }) - class ClaimTestInvalidAppNameNulldDirectiveComponent { + class ClaimTestInvalidAppNameNullDirectiveComponent { appNameNull = null; taskMock = 'test1234'; @@ -144,8 +144,8 @@ describe('UnClaim Task Directive validation errors', () => { ], declarations: [ ClaimTestMissingTaskIdDirectiveComponent, - ClaimTestInvalidAppNameUndefineddDirectiveComponent, - ClaimTestInvalidAppNameNulldDirectiveComponent, + ClaimTestInvalidAppNameUndefinedDirectiveComponent, + ClaimTestInvalidAppNameNullDirectiveComponent, ClaimTestMissingInputDirectiveComponent ] }); @@ -165,12 +165,12 @@ describe('UnClaim Task Directive validation errors', () => { }); it('should throw error when appName is undefined', () => { - fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefineddDirectiveComponent); + fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefinedDirectiveComponent); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); }); it('should throw error when appName is null', () => { - fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefineddDirectiveComponent); + fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefinedDirectiveComponent); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); }); }); diff --git a/lib/process-services-cloud/src/lib/task/models/task.model.ts b/lib/process-services-cloud/src/lib/task/models/task.model.ts index 772d6c74781..c6a26afe81c 100644 --- a/lib/process-services-cloud/src/lib/task/models/task.model.ts +++ b/lib/process-services-cloud/src/lib/task/models/task.model.ts @@ -15,6 +15,7 @@ * limitations under the License. */ +// eslint-disable-next-line no-shadow export enum ClaimTaskEnum { claim = 'claim', unclaim = 'unclaim' diff --git a/lib/process-services-cloud/src/lib/task/services/task-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/task/services/task-cloud.service.spec.ts index c09a549087a..762ae7f9c6d 100644 --- a/lib/process-services-cloud/src/lib/task/services/task-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/task/services/task-cloud.service.spec.ts @@ -32,75 +32,45 @@ describe('Task Cloud Service', () => { let identityUserService: IdentityUserService; let translateService: TranslationService; - function returnFakeTaskCompleteResults(): any { - return { - reply: () => {}, - oauth2Auth: { - callCustomApi : () => { - return Promise.resolve(taskCompleteCloudMock); - } - }, - isEcmLoggedIn() { - return false; - } - }; - } - - function returnFakeTaskCompleteResultsError(): any { - return { - reply: () => {}, - oauth2Auth: { - callCustomApi : () => { - return Promise.reject(taskCompleteCloudMock); - } - }, - isEcmLoggedIn() { - return false; - } - }; - } - - function returnFakeTaskDetailsResults(): any { - return { - reply: () => {}, - oauth2Auth: { - callCustomApi : () => { - return Promise.resolve(fakeTaskDetailsCloud); - } - }, - isEcmLoggedIn() { - return false; - } - }; - } - - function returnFakeCandidateUsersResults(): any { - return { - reply: () => {}, - oauth2Auth: { - callCustomApi : () => { - return Promise.resolve(['mockuser1', 'mockuser2', 'mockuser3']); - } - }, - isEcmLoggedIn() { - return false; - } - }; - } - - function returnFakeCandidateGroupResults(): any { - return { - reply: () => {}, - oauth2Auth: { - callCustomApi : () => { - return Promise.resolve(['mockgroup1', 'mockgroup2', 'mockgroup3']); - } - }, - isEcmLoggedIn() { - return false; - } - }; - } + const returnFakeTaskCompleteResults = (): any => ({ + reply: () => {}, + oauth2Auth: { + callCustomApi : () => Promise.resolve(taskCompleteCloudMock) + }, + isEcmLoggedIn: () => false + }); + + const returnFakeTaskCompleteResultsError = (): any => ({ + reply: () => {}, + oauth2Auth: { + callCustomApi : () => Promise.reject(taskCompleteCloudMock) + }, + isEcmLoggedIn: () => false + }); + + const returnFakeTaskDetailsResults = (): any => ({ + reply: () => {}, + oauth2Auth: { + callCustomApi : () => Promise.resolve(fakeTaskDetailsCloud) + }, + isEcmLoggedIn: () => false + }); + + const returnFakeCandidateUsersResults = (): any => ({ + reply: () => {}, + oauth2Auth: { + callCustomApi : () => Promise.resolve(['mockuser1', 'mockuser2', 'mockuser3']) + }, + isEcmLoggedIn: () => false + }); + + const returnFakeCandidateGroupResults = (): any => ({ + reply: () => {}, + oauth2Auth: { + callCustomApi : () => Promise.resolve(['mockgroup1', 'mockgroup2', 'mockgroup3']) + }, + isEcmLoggedIn: () => false + }); setupTestBed({ imports: [ diff --git a/lib/process-services-cloud/src/lib/task/services/task-cloud.service.ts b/lib/process-services-cloud/src/lib/task/services/task-cloud.service.ts index b032887764c..9e29acf80fe 100644 --- a/lib/process-services-cloud/src/lib/task/services/task-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/task/services/task-cloud.service.ts @@ -45,6 +45,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Complete a task. + * * @param appName Name of the app * @param taskId ID of the task to complete * @returns Details of the task that was completed @@ -52,7 +53,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi completeTask(appName: string, taskId: string): Observable { if ((appName || appName === '') && taskId) { const url = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/complete`; - const payload = { 'payloadType': 'CompleteTaskPayload' }; + const payload = { payloadType: 'CompleteTaskPayload' }; return this.post(url, payload); } else { @@ -63,6 +64,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Validate if a task can be completed. + * * @param taskDetails task details object * @returns Boolean value if the task can be completed */ @@ -72,6 +74,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Validate if a task is editable. + * * @param taskDetails task details object * @returns Boolean value if the task is editable */ @@ -90,6 +93,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Validate if a task can be claimed. + * * @param taskDetails task details object * @returns Boolean value if the task can be completed */ @@ -99,6 +103,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Validate if a task can be unclaimed. + * * @param taskDetails task details object * @returns Boolean value if the task can be completed */ @@ -109,6 +114,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Claims a task for an assignee. + * * @param appName Name of the app * @param taskId ID of the task to claim * @param assignee User to assign the task to @@ -132,6 +138,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Un-claims a task. + * * @param appName Name of the app * @param taskId ID of the task to unclaim * @returns Details of the task that was unclaimed @@ -154,6 +161,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Gets details of a task. + * * @param appName Name of the app * @param taskId ID of the task whose details you want * @returns Task details @@ -173,6 +181,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Creates a new standalone task. + * * @param taskDetails Details of the task to create * @returns Details of the newly created task */ @@ -188,6 +197,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Updates the details (name, description, due date) for a task. + * * @param appName Name of the app * @param taskId ID of the task to update * @param payload Data to update the task @@ -209,6 +219,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Gets candidate users of the task. + * * @param appName Name of the app * @param taskId ID of the task * @returns Candidate users @@ -225,6 +236,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Gets candidate groups of the task. + * * @param appName Name of the app * @param taskId ID of the task * @returns Candidate groups @@ -241,6 +253,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Gets the process definitions associated with an app. + * * @param appName Name of the target app * @returns Array of process definitions */ @@ -249,9 +262,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`; return this.get(url).pipe( - map((res: any) => { - return res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry)); - }) + map((res: any) => res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry))) ); } else { this.logService.error('AppName is mandatory for querying task'); @@ -261,6 +272,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi /** * Updates the task assignee. + * * @param appName Name of the app * @param taskId ID of the task to update assignee * @param assignee assignee to update current user task assignee @@ -268,13 +280,11 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi */ assign(appName: string, taskId: string, assignee: string): Observable { if (appName && taskId) { - const payLoad = { 'assignee': assignee, 'taskId': taskId, 'payloadType': 'AssignTaskPayload' }; + const payLoad = { assignee, taskId, payloadType: 'AssignTaskPayload' }; const url = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/assign`; return this.post(url, payLoad).pipe( - map((res: any) => { - return res.entry; - }) + map((res: any) => res.entry) ); } else { this.logService.error('AppName and TaskId are mandatory to change/update the task assignee'); diff --git a/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.spec.ts index ed39ca5e469..c2e7e4a7f3e 100644 --- a/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.spec.ts @@ -42,9 +42,7 @@ describe('StartTaskCloudComponent', () => { oauth2Auth: { callCustomApi: () => Promise.resolve(taskDetailsMock) }, - isEcmLoggedIn() { - return false; - }, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') }; diff --git a/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.ts b/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.ts index dddce8c71da..97cb692cd20 100644 --- a/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/start-task/components/start-task-cloud.component.ts @@ -35,6 +35,9 @@ import { StartTaskCloudRequestModel } from '../models/start-task-cloud-request.m import { takeUntil } from 'rxjs/operators'; import { TaskPriorityOption } from '../../models/task.model'; +const MAX_NAME_LENGTH = 255; +const DATE_FORMAT: string = 'DD/MM/YYYY'; + @Component({ selector: 'adf-cloud-start-task', templateUrl: './start-task-cloud.component.html', @@ -44,20 +47,14 @@ import { TaskPriorityOption } from '../../models/task.model'; { provide: MAT_DATE_FORMATS, useValue: MOMENT_DATE_FORMATS }], encapsulation: ViewEncapsulation.None }) - export class StartTaskCloudComponent implements OnInit, OnDestroy { - - static MAX_NAME_LENGTH = 255; - - public DATE_FORMAT: string = 'DD/MM/YYYY'; - /** (required) Name of the app. */ @Input() appName: string = ''; /** Maximum length of the task name. */ @Input() - maxNameLength: number = StartTaskCloudComponent.MAX_NAME_LENGTH; + maxNameLength: number = MAX_NAME_LENGTH; /** Name of the task. */ @Input() @@ -140,8 +137,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy { } private getMaxNameLength(): number { - return this.maxNameLength > StartTaskCloudComponent.MAX_NAME_LENGTH ? - StartTaskCloudComponent.MAX_NAME_LENGTH : this.maxNameLength; + return this.maxNameLength > MAX_NAME_LENGTH ? MAX_NAME_LENGTH : this.maxNameLength; } private loadCurrentUser() { @@ -186,7 +182,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy { this.dateError = false; if (newDateValue) { - const momentDate = moment(newDateValue, this.DATE_FORMAT, true); + const momentDate = moment(newDateValue, DATE_FORMAT, true); if (!momentDate.isValid()) { this.dateError = true; } @@ -209,9 +205,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy { onCandidateGroupRemove(candidateGroup: any) { if (candidateGroup.name) { - this.candidateGroupNames = this.candidateGroupNames.filter((name: string) => { - return name !== candidateGroup.name; - }); + this.candidateGroupNames = this.candidateGroupNames.filter((name: string) => name !== candidateGroup.name); } } @@ -226,7 +220,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy { public whitespaceValidator(control: FormControl) { const isWhitespace = (control.value || '').trim().length === 0; const isValid = control.value.length === 0 || !isWhitespace; - return isValid ? null : { 'whitespace': true }; + return isValid ? null : { whitespace: true }; } get nameController(): FormControl { diff --git a/lib/process-services-cloud/src/lib/task/start-task/mock/task-details.mock.ts b/lib/process-services-cloud/src/lib/task/start-task/mock/task-details.mock.ts index 3efe74af757..74529e9ecfb 100644 --- a/lib/process-services-cloud/src/lib/task/start-task/mock/task-details.mock.ts +++ b/lib/process-services-cloud/src/lib/task/start-task/mock/task-details.mock.ts @@ -17,4 +17,4 @@ import { StartTaskCloudRequestModel } from '../models/start-task-cloud-request.model'; -export let taskDetailsMock = new StartTaskCloudRequestModel({ assignee: 'fake-assigne', name: 'fake-name' }); +export const taskDetailsMock = new StartTaskCloudRequestModel({ assignee: 'fake-assigne', name: 'fake-name' }); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/base-edit-task-filter-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/base-edit-task-filter-cloud.component.ts index bfec4385179..ed11a84ca03 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/base-edit-task-filter-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/base-edit-task-filter-cloud.component.ts @@ -29,6 +29,8 @@ import { IdentityGroupModel, IdentityUserModel, TranslationService, UserPreferen import { TaskFilterDialogCloudComponent } from '../task-filter-dialog/task-filter-dialog-cloud.component'; import { MatDialog } from '@angular/material/dialog'; +/* eslint-disable @typescript-eslint/naming-convention */ + export interface DropdownOption { value: string; label: string; @@ -202,6 +204,7 @@ export abstract class BaseEditTaskFilterCloudComponent implements OnInit, OnC /** * Return filter name + * * @param filterName */ getSanitizeFilterName(filterName: string): string { @@ -322,9 +325,7 @@ export abstract class BaseEditTaskFilterCloudComponent implements OnInit, OnC get createSortProperties(): FilterOptions[] { this.checkMandatorySortProperties(); - return this.sortProperties.map((property: string) => { - return { label: property, value: property }; - }); + return this.sortProperties.map((property: string) => ({ label: property, value: property })); } createAndFilterActions(): TaskFilterAction[] { diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-service-task-filter-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-service-task-filter-cloud.component.spec.ts index 334eea84889..5f27f377413 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-service-task-filter-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-service-task-filter-cloud.component.spec.ts @@ -82,7 +82,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should fetch task filter by taskId', () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); fixture.whenStable().then(() => { expect(getTaskFilterSpy).toHaveBeenCalled(); @@ -102,7 +102,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { component.filterProperties = ['processDefinitionName']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const controller = component.editTaskFilterForm.get('processDefinitionName'); @@ -115,7 +115,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should display filter name as title', async () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -129,7 +129,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should not display filter name if showFilterName is false', async () => { const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); component.showTaskFilterName = false; - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -140,7 +140,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should not display mat-spinner if isloading set to false', async () => { const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -157,7 +157,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should display mat-spinner if isloading set to true', async () => { component.isLoading = true; const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -170,7 +170,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { beforeEach(() => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); }); @@ -204,7 +204,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { })); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -222,7 +222,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should enable delete button for custom task filters', async () => { const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -240,7 +240,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should enable save button if the filter is changed for custom task filters', (done) => { const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -291,7 +291,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { })); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -329,7 +329,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { })); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -474,7 +474,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should able to build a editTaskFilter form with default properties if input is empty', async () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); component.filterProperties = []; fixture.detectChanges(); @@ -497,7 +497,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { component.filterProperties = ['appName', 'processInstanceId', 'priority']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); const appController = component.editTaskFilterForm.get('appName'); fixture.detectChanges(); @@ -513,7 +513,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should display default sort properties', async () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -539,7 +539,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { })); fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -559,7 +559,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should display default sort properties if input is empty', async () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.sortProperties = []; fixture.detectChanges(); @@ -584,7 +584,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { it('should display default filter actions', async () => { component.toggleFilterActions = true; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -606,7 +606,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { component.actions = ['save']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; fixture.detectChanges(); @@ -631,7 +631,7 @@ describe('EditServiceTaskFilterCloudComponent', () => { beforeEach(() => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); spyOn(component.action, 'emit').and.callThrough(); }); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts index 0c4ee060201..43c4dae48dd 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/edit-task-filters/edit-task-filter-cloud.component.spec.ts @@ -57,9 +57,7 @@ describe('EditTaskFilterCloudComponent', () => { oauth2Auth: { callCustomApi: () => Promise.resolve(fakeApplicationInstance) }, - isEcmLoggedIn() { - return false; - }, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') }; @@ -102,7 +100,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should fetch task filter by taskId', () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); fixture.whenStable().then(() => { expect(getTaskFilterSpy).toHaveBeenCalled(); @@ -120,7 +118,7 @@ describe('EditTaskFilterCloudComponent', () => { component.filterProperties = ['processDefinitionName']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const controller = component.editTaskFilterForm.get('processDefinitionName'); @@ -133,7 +131,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should display filter name as title', async () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -147,7 +145,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should not display filter name if showFilterName is false', async () => { const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); component.showTaskFilterName = false; - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -158,7 +156,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should not display mat-spinner if isloading set to false', async () => { const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -175,7 +173,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should display mat-spinner if isloading set to true', async () => { component.isLoading = true; const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -188,7 +186,7 @@ describe('EditTaskFilterCloudComponent', () => { beforeEach(() => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); }); @@ -221,7 +219,7 @@ describe('EditTaskFilterCloudComponent', () => { })); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -239,7 +237,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should enable delete button for custom task filters', async () => { const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -257,7 +255,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should enable save button if the filter is changed for custom task filters', (done) => { const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -308,7 +306,7 @@ describe('EditTaskFilterCloudComponent', () => { })); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -346,7 +344,7 @@ describe('EditTaskFilterCloudComponent', () => { })); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; @@ -469,7 +467,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should able to build a editTaskFilter form with default properties if input is empty', async () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); component.filterProperties = []; fixture.detectChanges(); const stateController = component.editTaskFilterForm.get('status'); @@ -489,7 +487,7 @@ describe('EditTaskFilterCloudComponent', () => { component.filterProperties = ['appName', 'processInstanceId', 'priority']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); const appController = component.editTaskFilterForm.get('appName'); fixture.detectChanges(); @@ -504,7 +502,7 @@ describe('EditTaskFilterCloudComponent', () => { component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); const appController = component.editTaskFilterForm.get('completedBy'); fixture.detectChanges(); @@ -521,7 +519,7 @@ describe('EditTaskFilterCloudComponent', () => { component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -534,7 +532,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const mockUser: IdentityUserModel[] = [{ @@ -565,7 +563,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'dueDateRange']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('dueDateType'); @@ -587,7 +585,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'dueDateRange']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-dueDateRange"] .mat-select-trigger'); @@ -606,7 +604,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'dueDateRange']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const dateFilter = { @@ -643,7 +641,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('completedDateType'); @@ -665,7 +663,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const dateFilter = { @@ -701,7 +699,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'createdDateRange']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('createdDateType'); @@ -724,7 +722,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['assignment']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const assignmentComponent = fixture.debugElement.nativeElement.querySelector('adf-cloud-task-assignment-filter'); expect(assignmentComponent).toBeTruthy(); @@ -735,7 +733,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['assignment']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); component.onAssignedChange(identityUserMock); component.filterChange.subscribe(() => { @@ -749,7 +747,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'createdDateRange']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const dateFilter = { @@ -790,7 +788,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['assignment']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.onAssignedGroupsChange(identityGroupsMock); @@ -806,7 +804,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should display default sort properties', async () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -832,7 +830,7 @@ describe('EditTaskFilterCloudComponent', () => { })); fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -852,7 +850,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should display default sort properties if input is empty', async () => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.sortProperties = []; fixture.detectChanges(); @@ -877,7 +875,7 @@ describe('EditTaskFilterCloudComponent', () => { it('should display default filter actions', async () => { component.toggleFilterActions = true; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); expansionPanel.click(); @@ -899,7 +897,7 @@ describe('EditTaskFilterCloudComponent', () => { component.actions = ['save']; fixture.detectChanges(); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); component.toggleFilterActions = true; fixture.detectChanges(); @@ -923,7 +921,7 @@ describe('EditTaskFilterCloudComponent', () => { component.appName = 'fake'; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'lastModified']; const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); const lastModifiedToControl: AbstractControl = component.editTaskFilterForm.get('lastModifiedTo'); @@ -949,7 +947,7 @@ describe('EditTaskFilterCloudComponent', () => { beforeEach(() => { const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); - component.ngOnChanges({ 'id': taskFilterIdChange }); + component.ngOnChanges({ id: taskFilterIdChange }); fixture.detectChanges(); spyOn(component.action, 'emit').and.callThrough(); }); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/service-task-filters-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/service-task-filters-cloud.component.spec.ts index a068cb56ddb..16537d6d751 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/service-task-filters-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/service-task-filters-cloud.component.spec.ts @@ -62,7 +62,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { it('should attach specific icon for each filter if hasIcon is true', async () => { const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({'appName': change}); + component.ngOnChanges({appName: change}); fixture.detectChanges(); await fixture.whenStable(); @@ -84,7 +84,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { it('should not attach icons for each filter if hasIcon is false', async () => { component.showIcons = false; const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({'appName': change}); + component.ngOnChanges({appName: change}); fixture.detectChanges(); await fixture.whenStable(); @@ -96,7 +96,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { it('should display the filters', async () => { const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({'appName': change}); + component.ngOnChanges({appName: change}); fixture.detectChanges(); await fixture.whenStable(); @@ -128,7 +128,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { done(); }); - component.ngOnChanges({'appName': change}); + component.ngOnChanges({appName: change}); fixture.detectChanges(); }); @@ -136,7 +136,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { const appName = 'my-app-1'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -150,7 +150,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(fakeGlobalServiceFilters[1]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalServiceFilters[1]); @@ -160,7 +160,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { const change = new SimpleChange(null, { name: 'nonexistentFilter' }, true); fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toBeUndefined(); }); @@ -171,7 +171,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -186,7 +186,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(fakeGlobalServiceFilters[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalServiceFilters[2]); @@ -198,7 +198,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(fakeGlobalServiceFilters[0]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalServiceFilters[0]); @@ -225,7 +225,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toBe(fakeGlobalServiceFilters[0]); expect(filterClickedSpy).not.toHaveBeenCalled(); @@ -234,7 +234,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { it('should reset the filter when the param is undefined', () => { const change = new SimpleChange(null, undefined, false); component.currentFilter = fakeGlobalServiceFilters[0]; - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toBe(undefined); }); @@ -244,7 +244,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { const appName = 'my-app-1'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); expect(component.getFilters).toHaveBeenCalledWith(appName); }); @@ -254,7 +254,7 @@ describe('ServiceTaskFiltersCloudComponent', () => { const appName = 'fake-app-name'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); expect(component.getFilters).toHaveBeenCalledWith(appName); }); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filter-dialog/task-filter-dialog-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filter-dialog/task-filter-dialog-cloud.component.ts index bb4efd23231..18773eb1222 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filter-dialog/task-filter-dialog-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filter-dialog/task-filter-dialog-cloud.component.ts @@ -26,6 +26,7 @@ import { FormBuilder, FormGroup, AbstractControl, Validators } from '@angular/fo }) export class TaskFilterDialogCloudComponent implements OnInit { + // eslint-disable-next-line @typescript-eslint/naming-convention public static ACTION_SAVE = 'SAVE'; defaultIcon = 'inbox'; diff --git a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts index e0e72975d9a..fd701a77ecb 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/components/task-filters-cloud.component.spec.ts @@ -67,7 +67,7 @@ describe('TaskFiltersCloudComponent', () => { it('should attach specific icon for each filter if hasIcon is true', async () => { const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -89,7 +89,7 @@ describe('TaskFiltersCloudComponent', () => { it('should not attach icons for each filter if hasIcon is false', async () => { component.showIcons = false; const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -100,7 +100,7 @@ describe('TaskFiltersCloudComponent', () => { it('should display the filters', async () => { const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -133,14 +133,14 @@ describe('TaskFiltersCloudComponent', () => { done(); }); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); }); it('should display the task filters', async () => { const appName = 'my-app-1'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -157,7 +157,7 @@ describe('TaskFiltersCloudComponent', () => { const appName = 'my-app-1'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -170,7 +170,7 @@ describe('TaskFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(fakeGlobalFilter[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]); @@ -180,7 +180,7 @@ describe('TaskFiltersCloudComponent', () => { const change = new SimpleChange(null, { name: 'nonexistentFilter' }, true); fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toBeUndefined(); }); @@ -191,7 +191,7 @@ describe('TaskFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(fakeGlobalFilter[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]); @@ -203,7 +203,7 @@ describe('TaskFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(fakeGlobalFilter[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]); @@ -215,7 +215,7 @@ describe('TaskFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(fakeGlobalFilter[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]); @@ -242,7 +242,7 @@ describe('TaskFiltersCloudComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toBe(fakeGlobalFilter[0]); expect(filterClickedSpy).not.toHaveBeenCalled(); @@ -251,7 +251,7 @@ describe('TaskFiltersCloudComponent', () => { it('should reset the filter when the param is undefined', () => { const change = new SimpleChange(fakeGlobalFilter[0], undefined, false); component.currentFilter = fakeGlobalFilter[0]; - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); expect(component.currentFilter).toEqual(undefined); }); @@ -261,14 +261,14 @@ describe('TaskFiltersCloudComponent', () => { const appName = 'my-app-1'; const change = new SimpleChange(null, appName, true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); expect(component.getFilters).toHaveBeenCalledWith(appName); }); it('should display filter counter if property set to true', async () => { const change = new SimpleChange(undefined, 'my-app-1', true); - component.ngOnChanges({ 'appName': change }); + component.ngOnChanges({ appName: change }); fixture.detectChanges(); await fixture.whenStable(); @@ -331,7 +331,7 @@ describe('TaskFiltersCloudComponent', () => { component.currentFilter = null; change = new SimpleChange(null, { key: fakeGlobalFilter[0].key }, true); - component.ngOnChanges({ 'filterParam': change }); + component.ngOnChanges({ filterParam: change }); fixture.detectChanges(); fixture.whenStable().then(() => { fixture.detectChanges(); @@ -363,22 +363,22 @@ describe('TaskFiltersCloudComponent', () => { const queuedTasksFilterKey = defaultTaskFiltersMock[0].key; const completedTasksFilterKey = defaultTaskFiltersMock[2].key; - function getActiveFilterElement(filterKey: string): Element { + const getActiveFilterElement = (filterKey: string): Element => { const activeFilter = fixture.debugElement.query(By.css(`.adf-active`)); return activeFilter.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`); - } + }; - async function clickOnFilter(filterKey: string) { + const clickOnFilter = async (filterKey: string) => { fixture.debugElement.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`).click(); fixture.detectChanges(); await fixture.whenStable(); - } + }; it('Should highlight task filter on filter click', async () => { getTaskListFiltersSpy.and.returnValue(of(defaultTaskFiltersMock)); component.appName = 'mock-app-name'; const appNameChange = new SimpleChange(null, 'mock-app-name', true); - component.ngOnChanges({ 'appName': appNameChange }); + component.ngOnChanges({ appName: appNameChange }); fixture.detectChanges(); await fixture.whenStable(); @@ -405,7 +405,7 @@ describe('TaskFiltersCloudComponent', () => { getTaskListFiltersSpy.and.returnValue(of(defaultTaskFiltersMock)); fixture.detectChanges(); - component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: assignedTasksFilterKey }, true) }); + component.ngOnChanges({ filterParam: new SimpleChange(null, { key: assignedTasksFilterKey }, true) }); fixture.detectChanges(); await fixture.whenStable(); @@ -413,7 +413,7 @@ describe('TaskFiltersCloudComponent', () => { expect(getActiveFilterElement(queuedTasksFilterKey)).toBeNull(); expect(getActiveFilterElement(completedTasksFilterKey)).toBeNull(); - component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: queuedTasksFilterKey }, true) }); + component.ngOnChanges({ filterParam: new SimpleChange(null, { key: queuedTasksFilterKey }, true) }); fixture.detectChanges(); await fixture.whenStable(); @@ -421,7 +421,7 @@ describe('TaskFiltersCloudComponent', () => { expect(getActiveFilterElement(queuedTasksFilterKey)).toBeDefined(); expect(getActiveFilterElement(completedTasksFilterKey)).toBeNull(); - component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: completedTasksFilterKey }, true) }); + component.ngOnChanges({ filterParam: new SimpleChange(null, { key: completedTasksFilterKey }, true) }); fixture.detectChanges(); await fixture.whenStable(); diff --git a/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts b/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts index 12431a843e7..871558f5c38 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/models/filter-cloud.model.ts @@ -15,6 +15,10 @@ * limitations under the License. */ +/* eslint-disable no-underscore-dangle */ +/* eslint-disable no-shadow */ +/* eslint-disable @typescript-eslint/naming-convention */ + import { DateCloudFilterType } from '../../../models/date-cloud-filter.model'; import { DateRangeFilterService } from '../../../common/date-range-filter/date-range-filter.service'; import { ComponentSelectionMode } from '../../../types'; diff --git a/lib/process-services-cloud/src/lib/task/task-filters/services/service-task-filter-cloud.service.ts b/lib/process-services-cloud/src/lib/task/task-filters/services/service-task-filter-cloud.service.ts index a2dbca818e8..efaf8f49a90 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/services/service-task-filter-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/services/service-task-filter-cloud.service.ts @@ -41,6 +41,7 @@ export class ServiceTaskFilterCloudService { /** * Creates and returns the default task filters for an app. + * * @param appName Name of the target app * @returns Observable of default filters task filters just created or created filters */ @@ -62,6 +63,7 @@ export class ServiceTaskFilterCloudService { /** * Checks user preference are empty or not + * * @param preferences User preferences of the target app * @returns Boolean value if the preferences are not empty */ @@ -71,6 +73,7 @@ export class ServiceTaskFilterCloudService { /** * Checks for task filters in given user preferences + * * @param preferences User preferences of the target app * @param key Key of the task filters * @param filters Details of create filter @@ -83,6 +86,7 @@ export class ServiceTaskFilterCloudService { /** * Calls create preference api to create task filters + * * @param appName Name of the target app * @param key Key of the task instance filters * @param filters Details of new task filter @@ -94,6 +98,7 @@ export class ServiceTaskFilterCloudService { /** * Calls get preference api to get task filter by preference key + * * @param appName Name of the target app * @param key Key of the task filters * @returns Observable of task filters @@ -104,6 +109,7 @@ export class ServiceTaskFilterCloudService { /** * Gets all task filters for a task app. + * * @param appName Name of the target app * @returns Observable of task filter details */ @@ -114,6 +120,7 @@ export class ServiceTaskFilterCloudService { /** * Gets a task filter. + * * @param appName Name of the target app * @param id ID of the task * @returns Details of the task filter @@ -128,16 +135,13 @@ export class ServiceTaskFilterCloudService { return of(filters); } }), - map((filters: any) => { - return filters.filter((filter: ServiceTaskFilterCloudModel) => { - return filter.id === id; - })[0]; - }) + map((filters: any) => filters.filter((filter: ServiceTaskFilterCloudModel) => filter.id === id)[0]) ); } /** * Adds a new task filter. + * * @param filter The new filter to add * @returns Observable of task instance filters with newly added filter */ @@ -146,7 +150,7 @@ export class ServiceTaskFilterCloudService { return this.getTaskFiltersByKey(newFilter.appName, key).pipe( switchMap((filters: ServiceTaskFilterCloudModel[]) => { if (filters && filters.length === 0) { - return this.createTaskFilters(newFilter.appName, key, [newFilter]); + return this.createTaskFilters(newFilter.appName, key, [newFilter]); } else { filters.push(newFilter); return this.preferenceService.updatePreference(newFilter.appName, key, filters); @@ -165,6 +169,7 @@ export class ServiceTaskFilterCloudService { /** * Updates a task filter. + * * @param filter The filter to update * @returns Observable of task instance filters with updated filter */ @@ -173,7 +178,7 @@ export class ServiceTaskFilterCloudService { return this.getTaskFiltersByKey(updatedFilter.appName, key).pipe( switchMap((filters: ServiceTaskFilterCloudModel[]) => { if (filters && filters.length === 0) { - return this.createTaskFilters(updatedFilter.appName, key, [updatedFilter]); + return this.createTaskFilters(updatedFilter.appName, key, [updatedFilter]); } else { const itemIndex = filters.findIndex((filter: ServiceTaskFilterCloudModel) => filter.id === updatedFilter.id); filters[itemIndex] = updatedFilter; @@ -189,6 +194,7 @@ export class ServiceTaskFilterCloudService { /** * Deletes a task filter + * * @param filter The filter to delete * @returns Observable of task instance filters without deleted filter */ @@ -211,6 +217,7 @@ export class ServiceTaskFilterCloudService { /** * Checks if given filter is a default filter + * * @param filterName Name of the target task filter * @returns Boolean value for whether the filter is a default filter */ @@ -221,6 +228,7 @@ export class ServiceTaskFilterCloudService { /** * Calls update preference api to update task filter + * * @param appName Name of the target app * @param key Key of the task filters * @param filters Details of update filter @@ -232,6 +240,7 @@ export class ServiceTaskFilterCloudService { /** * Creates a uniq key with appName and username + * * @param appName Name of the target app * @returns String of task filters preference key */ @@ -241,6 +250,7 @@ export class ServiceTaskFilterCloudService { /** * Finds and returns the task filters from preferences + * * @param appName Name of the target app * @returns Array of TaskFilterCloudModel */ @@ -251,6 +261,7 @@ export class ServiceTaskFilterCloudService { /** * Creates and returns the default filters for a task app. + * * @param appName Name of the target app * @returns Array of TaskFilterCloudModel */ diff --git a/lib/process-services-cloud/src/lib/task/task-filters/services/task-filter-cloud.service.ts b/lib/process-services-cloud/src/lib/task/task-filters/services/task-filter-cloud.service.ts index f96ccc0836f..855577c2ba9 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/services/task-filter-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/services/task-filter-cloud.service.ts @@ -64,6 +64,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Creates and returns the default task filters for an app. + * * @param appName Name of the target app * @returns Observable of default filters task filters just created or created filters */ @@ -85,6 +86,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Checks user preference are empty or not + * * @param preferences User preferences of the target app * @returns Boolean value if the preferences are not empty */ @@ -94,6 +96,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Checks for task filters in given user preferences + * * @param preferences User preferences of the target app * @param key Key of the task filters * @param filters Details of create filter @@ -106,6 +109,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Calls create preference api to create task filters + * * @param appName Name of the target app * @param key Key of the task instance filters * @param filters Details of new task filter @@ -117,6 +121,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Calls get preference api to get task filter by preference key + * * @param appName Name of the target app * @param key Key of the task filters * @returns Observable of task filters @@ -127,6 +132,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Gets all task filters for a task app. + * * @param appName Name of the target app * @returns Observable of task filter details */ @@ -137,6 +143,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Gets a task filter. + * * @param appName Name of the target app * @param id ID of the task * @returns Details of the task filter @@ -151,16 +158,13 @@ export class TaskFilterCloudService extends BaseCloudService { return of(filters); } }), - map((filters: any) => { - return filters.filter((filter: TaskFilterCloudModel) => { - return filter.id === id; - })[0]; - }) + map((filters: any) => filters.filter((filter: TaskFilterCloudModel) => filter.id === id)[0]) ); } /** * Adds a new task filter. + * * @param filter The new filter to add * @returns Observable of task instance filters with newly added filter */ @@ -169,7 +173,7 @@ export class TaskFilterCloudService extends BaseCloudService { return this.getTaskFiltersByKey(newFilter.appName, key).pipe( switchMap((filters: any) => { if (filters && filters.length === 0) { - return this.createTaskFilters(newFilter.appName, key, [newFilter]); + return this.createTaskFilters(newFilter.appName, key, [newFilter]); } else { filters.push(newFilter); return this.preferenceService.updatePreference(newFilter.appName, key, filters); @@ -188,6 +192,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Updates a task filter. + * * @param filter The filter to update * @returns Observable of task instance filters with updated filter */ @@ -196,7 +201,7 @@ export class TaskFilterCloudService extends BaseCloudService { return this.getTaskFiltersByKey(updatedFilter.appName, key).pipe( switchMap((filters: TaskFilterCloudModel[]) => { if (filters && filters.length === 0) { - return this.createTaskFilters(updatedFilter.appName, key, [updatedFilter]); + return this.createTaskFilters(updatedFilter.appName, key, [updatedFilter]); } else { const itemIndex = filters.findIndex((filter: TaskFilterCloudModel) => filter.id === updatedFilter.id); filters[itemIndex] = updatedFilter; @@ -212,6 +217,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Deletes a task filter + * * @param filter The filter to delete * @returns Observable of task instance filters without deleted filter */ @@ -234,6 +240,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Checks if given filter is a default filter + * * @param filterName Name of the target task filter * @returns Boolean value for whether the filter is a default filter */ @@ -244,6 +251,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Finds a task using an object with optional query properties. + * * @param requestNode Query object * @returns Task information */ @@ -266,6 +274,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Calls update preference api to update task filter + * * @param appName Name of the target app * @param key Key of the task filters * @param filters Details of update filter @@ -277,6 +286,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Creates a uniq key with appName and username + * * @param appName Name of the target app * @returns String of task filters preference key */ @@ -286,6 +296,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Finds and returns the task filters from preferences + * * @param appName Name of the target app * @returns Array of TaskFilterCloudModel */ @@ -296,6 +307,7 @@ export class TaskFilterCloudService extends BaseCloudService { /** * Creates and returns the default filters for a task app. + * * @param appName Name of the target app * @returns Array of TaskFilterCloudModel */ diff --git a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts index 120a06039fc..9e57795325e 100644 --- a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts @@ -19,7 +19,7 @@ import { TaskHeaderCloudComponent } from './task-header-cloud.component'; import { of, throwError } from 'rxjs'; import { By } from '@angular/platform-browser'; import { ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing'; -import { setupTestBed, AppConfigService, AlfrescoApiService, CardViewArrayItem } from '@alfresco/adf-core'; +import { setupTestBed, AppConfigService, AlfrescoApiService } from '@alfresco/adf-core'; import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module'; import { TaskCloudService } from '../../services/task-cloud.service'; import { TaskHeaderCloudModule } from '../task-header-cloud.module'; @@ -53,9 +53,7 @@ describe('TaskHeaderCloudComponent', () => { oauth2Auth: { callCustomApi: () => Promise.resolve({}) }, - isEcmLoggedIn() { - return false; - }, + isEcmLoggedIn: () => false, reply: jasmine.createSpy('reply') }; @@ -292,7 +290,7 @@ describe('TaskHeaderCloudComponent', () => { }); it('should not render defined edit icon for assignee property if the task in assigned state and shared among candidate groups', async () => { - component.candidateGroups = [{ value: 'mock-group-1', icon: 'edit' }, { value: 'mock-group-2', icon: 'edit' }]; + component.candidateGroups = [{ value: 'mock-group-1', icon: 'edit' }, { value: 'mock-group-2', icon: 'edit' }]; component.candidateUsers = []; fixture.detectChanges(); await fixture.whenStable(); @@ -303,7 +301,7 @@ describe('TaskHeaderCloudComponent', () => { it('should not render defined edit icon for assignee property if the task in created state and shared among condidate groups', async () => { getTaskByIdSpy.and.returnValue(of(createdTaskDetailsCloudMock)); - component.candidateGroups = [{ value: 'mock-group-1', icon: 'edit' }, { value: 'mock-group-2', icon: 'edit' }]; + component.candidateGroups = [{ value: 'mock-group-1', icon: 'edit' }, { value: 'mock-group-2', icon: 'edit' }]; component.candidateUsers = []; component.ngOnChanges(); fixture.detectChanges(); diff --git a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts index 057bf4c8fd8..57d81a00700 100644 --- a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.ts @@ -127,8 +127,8 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges { finalize(() => (this.isLoading = false)) ).subscribe(([taskDetails, candidateUsers, candidateGroups]) => { this.taskDetails = taskDetails; - this.candidateGroups = candidateGroups.map((user) => { icon: 'group', value: user }); - this.candidateUsers = candidateUsers.map((group) => { icon: 'person', value: group }); + this.candidateGroups = candidateGroups.map((user) => ({ icon: 'group', value: user } as CardViewArrayItem)); + this.candidateUsers = candidateUsers.map((group) => ({ icon: 'person', value: group } as CardViewArrayItem)); if (this.taskDetails.parentTaskId) { this.loadParentName(`${this.taskDetails.parentTaskId}`); } else { diff --git a/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-claim-task.mock.ts b/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-claim-task.mock.ts index 955cb0402f3..008b2daec19 100644 --- a/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-claim-task.mock.ts +++ b/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-claim-task.mock.ts @@ -16,16 +16,16 @@ */ export const taskClaimCloudMock: any = { - 'entry': { - 'appName': 'simple-app', - 'appVersion': '', - 'serviceName': 'simple-app', - 'serviceFullName': 'simple-app', - 'serviceType': 'runtime-bundle', - 'serviceVersion': '', - 'id': '68d54a8f', - 'name': 'NXltAGmT', - 'priority': 0, - 'status': 'COMPLETED' + entry: { + appName: 'simple-app', + appVersion: '', + serviceName: 'simple-app', + serviceFullName: 'simple-app', + serviceType: 'runtime-bundle', + serviceVersion: '', + id: '68d54a8f', + name: 'NXltAGmT', + priority: 0, + status: 'COMPLETED' } }; diff --git a/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-complete-task.mock.ts b/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-complete-task.mock.ts index 7b757496598..d2ca7df2017 100644 --- a/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-complete-task.mock.ts +++ b/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-complete-task.mock.ts @@ -16,16 +16,16 @@ */ export const taskCompleteCloudMock: any = { - 'entry': { - 'appName': 'simple-app', - 'appVersion': '', - 'serviceName': 'simple-app', - 'serviceFullName': 'simple-app', - 'serviceType': 'runtime-bundle', - 'serviceVersion': '', - 'id': '68d54a8f', - 'name': 'NXltAGmT', - 'priority': 0, - 'status': 'COMPLETED' + entry: { + appName: 'simple-app', + appVersion: '', + serviceName: 'simple-app', + serviceFullName: 'simple-app', + serviceType: 'runtime-bundle', + serviceVersion: '', + id: '68d54a8f', + name: 'NXltAGmT', + priority: 0, + status: 'COMPLETED' } }; diff --git a/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-task-details-response.mock.ts b/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-task-details-response.mock.ts index d1b25664996..6f61403512a 100644 --- a/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-task-details-response.mock.ts +++ b/lib/process-services-cloud/src/lib/task/task-header/mocks/fake-task-details-response.mock.ts @@ -16,27 +16,27 @@ */ export const fakeTaskDetailsCloud = { - 'entry': { - 'appName': 'task-app', - 'appVersion': '', - 'id': '68d54a8f', - 'assignee': 'Phil Woods', - 'name': 'This is a new task', - 'description': 'This is the description ', - 'createdDate': 1545048055900, - 'dueDate': 1545091200000, - 'claimedDate': 1545140162601, - 'priority': 0, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'ASSIGNED', - 'owner': 'Phil Woods', - 'parentTaskId': null, - 'formKey': null, - 'lastModified': 1545140162601, - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': true + entry: { + appName: 'task-app', + appVersion: '', + id: '68d54a8f', + assignee: 'Phil Woods', + name: 'This is a new task', + description: 'This is the description ', + createdDate: 1545048055900, + dueDate: 1545091200000, + claimedDate: 1545140162601, + priority: 0, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'ASSIGNED', + owner: 'Phil Woods', + parentTaskId: null, + formKey: null, + lastModified: 1545140162601, + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: true } }; diff --git a/lib/process-services-cloud/src/lib/task/task-header/mocks/task-details-cloud.mock.ts b/lib/process-services-cloud/src/lib/task/task-header/mocks/task-details-cloud.mock.ts index 39702cce786..09b86ba5dd7 100644 --- a/lib/process-services-cloud/src/lib/task/task-header/mocks/task-details-cloud.mock.ts +++ b/lib/process-services-cloud/src/lib/task/task-header/mocks/task-details-cloud.mock.ts @@ -18,263 +18,263 @@ import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model'; export const taskDetailsWithParentTaskIdMock: TaskDetailsCloudModel = { - 'appName': 'task-app', - 'appVersion': 1, - 'id': '68d54a8f-01f3-11e9-8e36-0a58646002ad', - 'assignee': 'AssignedTaskUser', - 'name': 'This is a parent task name ', - 'description': 'This is the description ', - 'createdDate': new Date(1545048055900), - 'dueDate': new Date(), - 'claimedDate': null, - 'priority': 5, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'ASSIGNED', - 'owner': 'ownerUser', - 'parentTaskId': 'mock-parent-task-id', - 'formKey': null, - 'lastModified': new Date(1545048055900), - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': true + appName: 'task-app', + appVersion: 1, + id: '68d54a8f-01f3-11e9-8e36-0a58646002ad', + assignee: 'AssignedTaskUser', + name: 'This is a parent task name ', + description: 'This is the description ', + createdDate: new Date(1545048055900), + dueDate: new Date(), + claimedDate: null, + priority: 5, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'ASSIGNED', + owner: 'ownerUser', + parentTaskId: 'mock-parent-task-id', + formKey: null, + lastModified: new Date(1545048055900), + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: true }; export const assignedTaskDetailsCloudMock: TaskDetailsCloudModel = { - 'appName': 'task-app', - 'appVersion': 1, - 'id': '68d54a8f-01f3-11e9-8e36-0a58646002ad', - 'assignee': 'AssignedTaskUser', - 'name': 'This is a new task', - 'description': 'This is the description ', - 'createdDate': new Date(1545048055900), - 'dueDate': new Date(), - 'claimedDate': null, - 'priority': 1, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'ASSIGNED', - 'owner': 'ownerUser', - 'parentTaskId': null, - 'formKey': null, - 'lastModified': new Date(1545048055900), - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': true + appName: 'task-app', + appVersion: 1, + id: '68d54a8f-01f3-11e9-8e36-0a58646002ad', + assignee: 'AssignedTaskUser', + name: 'This is a new task', + description: 'This is the description ', + createdDate: new Date(1545048055900), + dueDate: new Date(), + claimedDate: null, + priority: 1, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'ASSIGNED', + owner: 'ownerUser', + parentTaskId: null, + formKey: null, + lastModified: new Date(1545048055900), + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: true }; export const createdTaskDetailsCloudMock: TaskDetailsCloudModel = { - 'appName': 'task-app', - 'appVersion': 1, - 'id': '68d54a8f-01f3-11e9-8e36-0a58646002ad', - 'assignee': 'CreatedTaskUser', - 'name': 'This is a new task', - 'description': 'This is the description ', - 'createdDate': new Date(1545048055900), - 'dueDate': new Date(1545091200000), - 'claimedDate': null, - 'priority': 5, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'CREATED', - 'owner': 'ownerUser', - 'parentTaskId': null, - 'formKey': null, - 'lastModified': new Date(1545048055900), - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': true + appName: 'task-app', + appVersion: 1, + id: '68d54a8f-01f3-11e9-8e36-0a58646002ad', + assignee: 'CreatedTaskUser', + name: 'This is a new task', + description: 'This is the description ', + createdDate: new Date(1545048055900), + dueDate: new Date(1545091200000), + claimedDate: null, + priority: 5, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'CREATED', + owner: 'ownerUser', + parentTaskId: null, + formKey: null, + lastModified: new Date(1545048055900), + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: true }; export const emptyOwnerTaskDetailsCloudMock: TaskDetailsCloudModel = { - 'appName': 'task-app', - 'appVersion': 1, - 'id': '68d54a8f-01f3-11e9-8e36-0a58646002ad', - 'assignee': 'AssignedTaskUser', - 'name': 'This is a new task', - 'description': 'This is the description ', - 'createdDate': new Date(1545048055900), - 'dueDate': new Date(1545091200000), - 'claimedDate': null, - 'priority': 5, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'ASSIGNED', - 'owner': null, - 'parentTaskId': null, - 'formKey': null, - 'lastModified': new Date(1545048055900), - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': true + appName: 'task-app', + appVersion: 1, + id: '68d54a8f-01f3-11e9-8e36-0a58646002ad', + assignee: 'AssignedTaskUser', + name: 'This is a new task', + description: 'This is the description ', + createdDate: new Date(1545048055900), + dueDate: new Date(1545091200000), + claimedDate: null, + priority: 5, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'ASSIGNED', + owner: null, + parentTaskId: null, + formKey: null, + lastModified: new Date(1545048055900), + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: true }; export const createdStateTaskDetailsCloudMock: TaskDetailsCloudModel = { - 'appName': 'mock-app-name', - 'appVersion': 1, - 'id': 'mock-task-id', - 'assignee': '', - 'name': 'This is a new task', - 'description': 'This is the description ', - 'createdDate': new Date(1545048055900), - 'dueDate': new Date(1545091200000), - 'claimedDate': null, - 'priority': 5, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'CREATED', - 'owner': 'ownerUser', - 'parentTaskId': null, - 'formKey': null, - 'lastModified': new Date(1545048055900), - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': false + appName: 'mock-app-name', + appVersion: 1, + id: 'mock-task-id', + assignee: '', + name: 'This is a new task', + description: 'This is the description ', + createdDate: new Date(1545048055900), + dueDate: new Date(1545091200000), + claimedDate: null, + priority: 5, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'CREATED', + owner: 'ownerUser', + parentTaskId: null, + formKey: null, + lastModified: new Date(1545048055900), + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: false }; export const completedTaskDetailsCloudMock: TaskDetailsCloudModel = { - 'appName': 'mock-app-name', - 'appVersion': 1, - 'id': 'mock-task-id', - 'assignee': 'CompletedTaskAssignee', - 'name': 'This is a new task', - 'description': 'This is the description ', - 'createdDate': new Date(1545048055900), - 'dueDate': new Date(1545091200000), - 'completedDate': new Date(1546091200000), - 'claimedDate': null, - 'priority': 5, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'COMPLETED', - 'owner': 'ownerUser', - 'parentTaskId': null, - 'formKey': null, - 'lastModified': new Date(1545048055900), - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': false + appName: 'mock-app-name', + appVersion: 1, + id: 'mock-task-id', + assignee: 'CompletedTaskAssignee', + name: 'This is a new task', + description: 'This is the description ', + createdDate: new Date(1545048055900), + dueDate: new Date(1545091200000), + completedDate: new Date(1546091200000), + claimedDate: null, + priority: 5, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'COMPLETED', + owner: 'ownerUser', + parentTaskId: null, + formKey: null, + lastModified: new Date(1545048055900), + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: false }; export const cancelledTaskDetailsCloudMock: TaskDetailsCloudModel = { - 'appName': 'mock-app-name', - 'appVersion': 1, - 'id': 'mock-task-id', - 'assignee': 'CancelledTaskAssignee', - 'name': 'This is a new task', - 'description': 'This is the description ', - 'createdDate': new Date(1545048055900), - 'dueDate': new Date(1545091200000), - 'claimedDate': null, - 'priority': 5, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'CANCELLED', - 'owner': 'ownerUser', - 'parentTaskId': null, - 'formKey': null, - 'lastModified': new Date(1545048055900), - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': true + appName: 'mock-app-name', + appVersion: 1, + id: 'mock-task-id', + assignee: 'CancelledTaskAssignee', + name: 'This is a new task', + description: 'This is the description ', + createdDate: new Date(1545048055900), + dueDate: new Date(1545091200000), + claimedDate: null, + priority: 5, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'CANCELLED', + owner: 'ownerUser', + parentTaskId: null, + formKey: null, + lastModified: new Date(1545048055900), + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: true }; export const suspendedTaskDetailsCloudMock: TaskDetailsCloudModel = { - 'appName': 'mock-app-name', - 'appVersion': 1, - 'id': 'mock-task-id', - 'assignee': 'SuspendedTaskAssignee', - 'name': 'This is a new task', - 'description': 'This is the description ', - 'createdDate': new Date(1545048055900), - 'dueDate': new Date(1545091200000), - 'claimedDate': null, - 'priority': 5, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'SUSPENDED', - 'owner': 'ownerUser', - 'parentTaskId': null, - 'formKey': null, - 'lastModified': new Date(1545048055900), - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': true + appName: 'mock-app-name', + appVersion: 1, + id: 'mock-task-id', + assignee: 'SuspendedTaskAssignee', + name: 'This is a new task', + description: 'This is the description ', + createdDate: new Date(1545048055900), + dueDate: new Date(1545091200000), + claimedDate: null, + priority: 5, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'SUSPENDED', + owner: 'ownerUser', + parentTaskId: null, + formKey: null, + lastModified: new Date(1545048055900), + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: true }; export const noCandidateUsersTaskDetailsCloudMock: TaskDetailsCloudModel = { - 'appName': 'mock-app-name', - 'appVersion': 1, - 'id': 'mock-task-id', - 'assignee': '', - 'name': 'This is a new task', - 'description': 'This is the description ', - 'createdDate': new Date(1545048055900), - 'dueDate': new Date(1545091200000), - 'claimedDate': null, - 'priority': 5, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'CREATED', - 'owner': 'ownerUser', - 'candidateUsers': null, - 'parentTaskId': null, - 'formKey': null, - 'lastModified': new Date(1545048055900), - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': false + appName: 'mock-app-name', + appVersion: 1, + id: 'mock-task-id', + assignee: '', + name: 'This is a new task', + description: 'This is the description ', + createdDate: new Date(1545048055900), + dueDate: new Date(1545091200000), + claimedDate: null, + priority: 5, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'CREATED', + owner: 'ownerUser', + candidateUsers: null, + parentTaskId: null, + formKey: null, + lastModified: new Date(1545048055900), + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: false }; export const noCandidateGroupsTaskDetailsCloudMock: TaskDetailsCloudModel = { - 'appName': 'mock-app-name', - 'appVersion': 1, - 'id': 'mock-task-id', - 'assignee': '', - 'name': 'This is a new task', - 'description': 'This is the description ', - 'createdDate': new Date(1545048055900), - 'dueDate': new Date(1545091200000), - 'claimedDate': null, - 'priority': 5, - 'category': null, - 'processDefinitionId': null, - 'processInstanceId': null, - 'status': 'CREATED', - 'owner': 'ownerUser', - 'candidateGroups': null, - 'parentTaskId': null, - 'formKey': null, - 'lastModified': new Date(1545048055900), - 'lastModifiedTo': null, - 'lastModifiedFrom': null, - 'standalone': false + appName: 'mock-app-name', + appVersion: 1, + id: 'mock-task-id', + assignee: '', + name: 'This is a new task', + description: 'This is the description ', + createdDate: new Date(1545048055900), + dueDate: new Date(1545091200000), + claimedDate: null, + priority: 5, + category: null, + processDefinitionId: null, + processInstanceId: null, + status: 'CREATED', + owner: 'ownerUser', + candidateGroups: null, + parentTaskId: null, + formKey: null, + lastModified: new Date(1545048055900), + lastModifiedTo: null, + lastModifiedFrom: null, + standalone: false }; export const taskWithFormDetailsMock: TaskDetailsCloudModel = { - 'appName': 'mock-app-name', - 'assignee': 'AssignedTaskUser', - 'completedDate': null, - 'createdDate': new Date(1555419255340), - 'dueDate': new Date(1558419255340), - 'description': null, - 'formKey': '4', - 'priority': 1, - 'parentTaskId': 'bd6b1741-6046-11e9-80f0-0a586460040d', - 'id': 'bd6b1741-6046-11e9-80f0-0a586460040d', - 'name': 'Task1', - 'owner': 'fakeAdmin', - 'standalone': true, - 'status': 'ASSIGNED' + appName: 'mock-app-name', + assignee: 'AssignedTaskUser', + completedDate: null, + createdDate: new Date(1555419255340), + dueDate: new Date(1558419255340), + description: null, + formKey: '4', + priority: 1, + parentTaskId: 'bd6b1741-6046-11e9-80f0-0a586460040d', + id: 'bd6b1741-6046-11e9-80f0-0a586460040d', + name: 'Task1', + owner: 'fakeAdmin', + standalone: true, + status: 'ASSIGNED' }; export const taskDetailsContainer = { diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/base-task-list-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-list/components/base-task-list-cloud.component.ts index db1d8b08a01..a45421bdd46 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/base-task-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/base-task-list-cloud.component.ts @@ -124,7 +124,7 @@ export abstract class BaseTaskListCloudComponent extends DataTableSchema impleme super(appConfigService, presetKey, taskPresetsCloudDefaultModel); this.size = userPreferences.paginationSize; - this.pagination = new BehaviorSubject( { + this.pagination = new BehaviorSubject({ maxItems: this.size, skipCount: 0, totalItems: 0 @@ -184,6 +184,7 @@ export abstract class BaseTaskListCloudComponent extends DataTableSchema impleme /** * Resets the pagination values and * Reloads the task list + * * @param pagination Pagination values to be set */ updatePagination(pagination: PaginationModel) { diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts index b76e15e6567..ab9ce821c95 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.spec.ts @@ -93,19 +93,19 @@ describe('ServiceTaskListCloudComponent', () => { component = fixture.componentInstance; appConfig.config = Object.assign(appConfig.config, { 'adf-cloud-service-task-list': { - 'presets': { - 'fakeCustomSchema': [ + presets: { + fakeCustomSchema: [ { - 'key': 'fakeName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', - 'sortable': true + key: 'fakeName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', + sortable: true }, { - 'key': 'fakeTaskName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', - 'sortable': true + key: 'fakeTaskName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', + sortable: true } ] } @@ -209,7 +209,7 @@ describe('ServiceTaskListCloudComponent', () => { done(); }); component.appName = appName.currentValue; - component.ngOnChanges({ 'appName': appName }); + component.ngOnChanges({ appName }); fixture.detectChanges(); }); @@ -257,7 +257,7 @@ describe('ServiceTaskListCloudComponent', () => { component.queryParams.status = 'mock-status'; const queryParams = new SimpleChange(undefined, { status: 'mock-status' }, true); component.ngOnChanges({ - 'queryParams': queryParams + queryParams }); fixture.detectChanges(); expect(component.isListEmpty()).toBeFalsy(); @@ -277,7 +277,7 @@ describe('ServiceTaskListCloudComponent', () => { ]; const sortChange = new SimpleChange(undefined, mockSort, true); component.ngOnChanges({ - 'sorting': sortChange + sorting: sortChange }); fixture.detectChanges(); expect(component.formatSorting).toHaveBeenCalledWith(mockSort); @@ -404,13 +404,13 @@ describe('ServiceTaskListCloudComponent', () => { const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); copyFixture.whenStable().then(() => { copyFixture.detectChanges(); - const spanHTMLElement = element.querySelector('span[title="04fdf69f-4ddd-48ab-9563-da776c9b163c"]'); + const spanHTMLElement = element.querySelector('span[title="04fdf69f-4ddd-48ab-9563-da776c9b163c"]'); spanHTMLElement.dispatchEvent(new Event('mouseenter')); copyFixture.detectChanges(); expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull(); }); customCopyComponent.taskList.appName = appName.currentValue; - customCopyComponent.taskList.ngOnChanges({ 'appName': appName }); + customCopyComponent.taskList.ngOnChanges({ appName }); copyFixture.detectChanges(); })); @@ -419,7 +419,7 @@ describe('ServiceTaskListCloudComponent', () => { customCopyComponent.taskList.success.subscribe(() => { copyFixture.whenStable().then(() => { copyFixture.detectChanges(); - const spanHTMLElement: HTMLInputElement = element.querySelector('span[title="serviceTaskName"]'); + const spanHTMLElement = element.querySelector('span[title="serviceTaskName"]'); spanHTMLElement.dispatchEvent(new Event('mouseenter')); copyFixture.detectChanges(); expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).toBeNull(); @@ -427,7 +427,7 @@ describe('ServiceTaskListCloudComponent', () => { }); }); customCopyComponent.taskList.appName = appName.currentValue; - customCopyComponent.taskList.ngOnChanges({ 'appName': appName }); + customCopyComponent.taskList.ngOnChanges({ appName }); copyFixture.detectChanges(); }); }); @@ -449,20 +449,20 @@ describe('ServiceTaskListCloudComponent', () => { serviceTaskListCloudService = TestBed.inject(ServiceTaskListCloudService); appConfig.config = Object.assign(appConfig.config, { 'adf-cloud-service-task-list': { - 'presets': { - 'fakeCustomSchema': [ + presets: { + fakeCustomSchema: [ { - 'key': 'id', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', - 'sortable': true, - 'copyContent': true + key: 'id', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', + sortable: true, + copyContent: true }, { - 'key': 'activityName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', - 'sortable': true + key: 'activityName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', + sortable: true } ] } @@ -494,7 +494,7 @@ describe('ServiceTaskListCloudComponent', () => { component.presetColumn = 'fakeCustomSchema'; component.appName = appName.currentValue; - component.ngOnChanges({ 'appName': appName }); + component.ngOnChanges({ appName }); component.ngAfterContentInit(); })); @@ -512,7 +512,7 @@ describe('ServiceTaskListCloudComponent', () => { }); component.presetColumn = 'fakeCustomSchema'; component.appName = appName.currentValue; - component.ngOnChanges({ 'appName': appName }); + component.ngOnChanges({ appName }); component.ngAfterContentInit(); })); }); diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.ts index 9abee66b9b9..f14e7c0295d 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/service-task-list-cloud.component.ts @@ -24,6 +24,8 @@ import { BaseTaskListCloudComponent } from './base-task-list-cloud.component'; import { ServiceTaskListCloudService } from '../services/service-task-list-cloud.service'; import { TaskCloudService } from '../../services/task-cloud.service'; +const PRESET_KEY = 'adf-cloud-service-task-list.presets'; + @Component({ selector: 'adf-cloud-service-task-list', templateUrl: './base-task-list-cloud.component.html', @@ -31,9 +33,6 @@ import { TaskCloudService } from '../../services/task-cloud.service'; encapsulation: ViewEncapsulation.None }) export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent { - - static PRESET_KEY = 'adf-cloud-service-task-list.presets'; - @Input() queryParams: { [key: string]: any } = {}; @@ -41,7 +40,7 @@ export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent { appConfigService: AppConfigService, taskCloudService: TaskCloudService, userPreferences: UserPreferencesService) { - super(appConfigService, taskCloudService, userPreferences, ServiceTaskListCloudComponent.PRESET_KEY); + super(appConfigService, taskCloudService, userPreferences, PRESET_KEY); } load(requestNode: ServiceTaskQueryCloudRequestModel) { diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts index 696710d0d87..2e3a3c7005a 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.spec.ts @@ -98,19 +98,19 @@ describe('TaskListCloudComponent', () => { component = fixture.componentInstance; appConfig.config = Object.assign(appConfig.config, { 'adf-cloud-task-list': { - 'presets': { - 'fakeCustomSchema': [ + presets: { + fakeCustomSchema: [ { - 'key': 'fakeName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', - 'sortable': true + key: 'fakeName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', + sortable: true }, { - 'key': 'fakeTaskName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', - 'sortable': true + key: 'fakeTaskName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', + sortable: true } ] } @@ -221,7 +221,7 @@ describe('TaskListCloudComponent', () => { done(); }); component.appName = appName.currentValue; - component.ngOnChanges({ 'appName': appName }); + component.ngOnChanges({ appName }); fixture.detectChanges(); }); @@ -275,10 +275,10 @@ describe('TaskListCloudComponent', () => { const lastModifiedFromChange = new SimpleChange(undefined, 'mock-lastmodified-date', true); const ownerChange = new SimpleChange(undefined, 'mock-owner-name', true); component.ngOnChanges({ - 'priority': priorityChange, - 'status': statusChange, - 'lastModifiedFrom': lastModifiedFromChange, - 'owner': ownerChange + priority: priorityChange, + status: statusChange, + lastModifiedFrom: lastModifiedFromChange, + owner: ownerChange }); fixture.detectChanges(); expect(component.isListEmpty()).toBeFalsy(); @@ -298,7 +298,7 @@ describe('TaskListCloudComponent', () => { ]; const sortChange = new SimpleChange(undefined, mockSort, true); component.ngOnChanges({ - 'sorting': sortChange + sorting: sortChange }); fixture.detectChanges(); expect(component.formatSorting).toHaveBeenCalledWith(mockSort); @@ -383,7 +383,7 @@ describe('TaskListCloudComponent', () => { let fixtureCustom: ComponentFixture; let componentCustom: CustomTaskListComponent; let customCopyComponent: CustomCopyContentTaskListComponent; - let element: any; + let element: HTMLElement; let copyFixture: ComponentFixture; setupTestBed({ @@ -425,13 +425,13 @@ describe('TaskListCloudComponent', () => { const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); copyFixture.whenStable().then(() => { copyFixture.detectChanges(); - const spanHTMLElement: HTMLInputElement = element.querySelector('span[title="11fe013d-c263-11e8-b75b-0a5864600540"]'); + const spanHTMLElement = element.querySelector('span[title="11fe013d-c263-11e8-b75b-0a5864600540"]'); spanHTMLElement.dispatchEvent(new Event('mouseenter')); copyFixture.detectChanges(); expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull(); }); customCopyComponent.taskList.appName = appName.currentValue; - customCopyComponent.taskList.ngOnChanges({ 'appName': appName }); + customCopyComponent.taskList.ngOnChanges({ appName }); copyFixture.detectChanges(); })); @@ -440,7 +440,7 @@ describe('TaskListCloudComponent', () => { customCopyComponent.taskList.success.subscribe(() => { copyFixture.whenStable().then(() => { copyFixture.detectChanges(); - const spanHTMLElement: HTMLInputElement = element.querySelector('span[title="standalone-subtask"]'); + const spanHTMLElement = element.querySelector('span[title="standalone-subtask"]'); spanHTMLElement.dispatchEvent(new Event('mouseenter')); copyFixture.detectChanges(); expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).toBeNull(); @@ -448,7 +448,7 @@ describe('TaskListCloudComponent', () => { }); }); customCopyComponent.taskList.appName = appName.currentValue; - customCopyComponent.taskList.ngOnChanges({ 'appName': appName }); + customCopyComponent.taskList.ngOnChanges({ appName }); copyFixture.detectChanges(); }); }); @@ -483,7 +483,7 @@ describe('TaskListCloudComponent', () => { describe('Copy cell content directive from app.config specifications', () => { - let element: any; + let element: HTMLElement; let taskSpy: jasmine.Spy; setupTestBed({ @@ -498,26 +498,26 @@ describe('TaskListCloudComponent', () => { taskListCloudService = TestBed.inject(TaskListCloudService); appConfig.config = Object.assign(appConfig.config, { 'adf-cloud-task-list': { - 'presets': { - 'fakeCustomSchema': [ + presets: { + fakeCustomSchema: [ { - 'key': 'id', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', - 'sortable': true, - 'copyContent': true + key: 'id', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', + sortable: true, + copyContent: true }, { - 'key': 'name', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', - 'sortable': true + key: 'name', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', + sortable: true }, { - 'key': 'entry.priority', - 'type': 'text', - 'title': 'ADF_TASK_LIST.PROPERTIES.PRIORITY', - 'sortable': true + key: 'entry.priority', + type: 'text', + title: 'ADF_TASK_LIST.PROPERTIES.PRIORITY', + sortable: true } ] } @@ -542,7 +542,7 @@ describe('TaskListCloudComponent', () => { component.success.subscribe(() => { fixture.whenStable().then(() => { fixture.detectChanges(); - const spanHTMLElement: HTMLInputElement = element.querySelector('span[title="11fe013d-c263-11e8-b75b-0a5864600540"]'); + const spanHTMLElement = element.querySelector('span[title="11fe013d-c263-11e8-b75b-0a5864600540"]'); spanHTMLElement.dispatchEvent(new Event('mouseenter')); fixture.detectChanges(); expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull(); @@ -551,7 +551,7 @@ describe('TaskListCloudComponent', () => { component.presetColumn = 'fakeCustomSchema'; component.appName = appName.currentValue; - component.ngOnChanges({ 'appName': appName }); + component.ngOnChanges({ appName }); component.ngAfterContentInit(); })); diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts index a9b594ec3d0..4cacec9a29e 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/task-list-cloud.component.ts @@ -22,6 +22,8 @@ import { TaskListCloudService } from '../services/task-list-cloud.service'; import { BaseTaskListCloudComponent } from './base-task-list-cloud.component'; import { TaskCloudService } from '../../services/task-cloud.service'; +const PRESET_KEY = 'adf-cloud-task-list.presets'; + @Component({ selector: 'adf-cloud-task-list', templateUrl: './base-task-list-cloud.component.html', @@ -29,9 +31,6 @@ import { TaskCloudService } from '../../services/task-cloud.service'; encapsulation: ViewEncapsulation.None }) export class TaskListCloudComponent extends BaseTaskListCloudComponent { - - static PRESET_KEY = 'adf-cloud-task-list.presets'; - /** * The assignee of the process. Possible values are: "assignee" (the current user is the assignee), * "candidate" (the current user is a task candidate", "group_x" (the task is assigned to a group @@ -136,7 +135,7 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent { appConfigService: AppConfigService, taskCloudService: TaskCloudService, userPreferences: UserPreferencesService) { - super(appConfigService, taskCloudService, userPreferences, TaskListCloudComponent.PRESET_KEY); + super(appConfigService, taskCloudService, userPreferences, PRESET_KEY); } load(requestNode: TaskQueryCloudRequestModel) { diff --git a/lib/process-services-cloud/src/lib/task/task-list/mock/fake-task-response.mock.ts b/lib/process-services-cloud/src/lib/task/task-list/mock/fake-task-response.mock.ts index d79cc75d129..4842b11879e 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/mock/fake-task-response.mock.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/mock/fake-task-response.mock.ts @@ -88,15 +88,15 @@ export const fakeServiceTask = { export const fakeCustomSchema = [ new ObjectDataColumn({ - 'key': 'fakeName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', - 'sortable': true + key: 'fakeName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', + sortable: true }), new ObjectDataColumn({ - 'key': 'fakeTaskName', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', - 'sortable': true + key: 'fakeTaskName', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', + sortable: true }) ]; diff --git a/lib/process-services-cloud/src/lib/task/task-list/models/task-preset-cloud.model.ts b/lib/process-services-cloud/src/lib/task/task-list/models/task-preset-cloud.model.ts index e0f27e85928..40881830b8a 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/models/task-preset-cloud.model.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/models/task-preset-cloud.model.ts @@ -16,57 +16,57 @@ */ export const taskPresetsCloudDefaultModel = { - 'default': [ + default: [ { - 'key': 'name', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.NAME', - 'sortable': true + key: 'name', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.NAME', + sortable: true }, { - 'key': 'created', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.CREATED', - 'cssClass': 'hidden', - 'sortable': true + key: 'created', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.CREATED', + cssClass: 'hidden', + sortable: true }, { - 'key': 'assignee', - 'type': 'text', - 'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.ASSIGNEE', - 'cssClass': 'hidden', - 'sortable': true + key: 'assignee', + type: 'text', + title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.ASSIGNEE', + cssClass: 'hidden', + sortable: true } ] }; export const serviceTaskPresetsCloudDefaultModel = { - 'default': [ + default: [ { - 'key': 'activityName', - 'type': 'text', - 'title': 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.ACTIVITY_NAME', - 'sortable': true + key: 'activityName', + type: 'text', + title: 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.ACTIVITY_NAME', + sortable: true }, { - 'key': 'status', - 'type': 'text', - 'title': 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.STATUS', - 'sortable': true + key: 'status', + type: 'text', + title: 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.STATUS', + sortable: true }, { - 'key': 'startedDate', - 'type': 'text', - 'title': 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.STARTED_DATE', - 'cssClass': 'hidden', - 'sortable': true + key: 'startedDate', + type: 'text', + title: 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.STARTED_DATE', + cssClass: 'hidden', + sortable: true }, { - 'key': 'completedDate', - 'type': 'text', - 'title': 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.COMPLETED_DATE', - 'cssClass': 'hidden', - 'sortable': true + key: 'completedDate', + type: 'text', + title: 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.COMPLETED_DATE', + cssClass: 'hidden', + sortable: true } ] }; diff --git a/lib/process-services-cloud/src/lib/task/task-list/services/service-task-list-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/task/task-list/services/service-task-list-cloud.service.spec.ts index 89f563ded1e..ea217bb9374 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/services/service-task-list-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/services/service-task-list-cloud.service.spec.ts @@ -26,32 +26,20 @@ describe('Activiti ServiceTaskList Cloud Service', () => { let service: ServiceTaskListCloudService; let alfrescoApiService: AlfrescoApiService; - function returnCallQueryParameters(): any { - return { - oauth2Auth: { - callCustomApi: (_queryUrl, _operation, _context, queryParams) => { - return Promise.resolve(queryParams); - } - }, - isEcmLoggedIn() { - return false; - }, - reply: jasmine.createSpy('reply') - }; - } + const returnCallQueryParameters = (): any => ({ + oauth2Auth: { + callCustomApi: (_queryUrl, _operation, _context, queryParams) => Promise.resolve(queryParams) + }, + isEcmLoggedIn: () => false, + reply: jasmine.createSpy('reply') + }); - function returnCallUrl(): any { - return { - oauth2Auth: { - callCustomApi: (queryUrl) => { - return Promise.resolve(queryUrl); - } - }, - isEcmLoggedIn() { - return false; - } - }; - } + const returnCallUrl = (): any => ({ + oauth2Auth: { + callCustomApi: (queryUrl) => Promise.resolve(queryUrl) + }, + isEcmLoggedIn: () => false + }); setupTestBed({ imports: [ @@ -65,7 +53,7 @@ describe('Activiti ServiceTaskList Cloud Service', () => { }); it('should append to the call all the parameters', (done) => { - const taskRequest: ServiceTaskQueryCloudRequestModel = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; + const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as ServiceTaskQueryCloudRequestModel; spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters); service.getServiceTaskByRequest(taskRequest).subscribe((res) => { expect(res).toBeDefined(); @@ -78,7 +66,7 @@ describe('Activiti ServiceTaskList Cloud Service', () => { }); it('should concat the app name to the request url', (done) => { - const taskRequest: ServiceTaskQueryCloudRequestModel = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; + const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as ServiceTaskQueryCloudRequestModel; spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl); service.getServiceTaskByRequest(taskRequest).subscribe((requestUrl) => { expect(requestUrl).toBeDefined(); @@ -89,10 +77,10 @@ describe('Activiti ServiceTaskList Cloud Service', () => { }); it('should concat the sorting to append as parameters', (done) => { - const taskRequest: ServiceTaskQueryCloudRequestModel = { + const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service', sorting: [{ orderBy: 'NAME', direction: 'DESC' }, { orderBy: 'TITLE', direction: 'ASC' }] - }; + } as ServiceTaskQueryCloudRequestModel; spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters); service.getServiceTaskByRequest(taskRequest).subscribe((res) => { expect(res).toBeDefined(); @@ -103,7 +91,7 @@ describe('Activiti ServiceTaskList Cloud Service', () => { }); it('should return an error when app name is not specified', (done) => { - const taskRequest: ServiceTaskQueryCloudRequestModel = { appName: null }; + const taskRequest = { appName: null } as ServiceTaskQueryCloudRequestModel; spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl); service.getServiceTaskByRequest(taskRequest).subscribe( () => { }, diff --git a/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.spec.ts b/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.spec.ts index fa4120a1d49..2a4e5fc9426 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/services/task-list-cloud.service.spec.ts @@ -27,32 +27,20 @@ describe('TaskListCloudService', () => { let service: TaskListCloudService; let alfrescoApiService: AlfrescoApiService; - function returnCallQueryParameters(): any { - return { - oauth2Auth: { - callCustomApi : (_queryUrl, _operation, _context, queryParams) => { - return Promise.resolve(queryParams); - } - }, - isEcmLoggedIn() { - return false; - }, - reply: jasmine.createSpy('reply') - }; - } + const returnCallQueryParameters = (): any => ({ + oauth2Auth: { + callCustomApi : (_queryUrl, _operation, _context, queryParams) => Promise.resolve(queryParams) + }, + isEcmLoggedIn: () => false, + reply: jasmine.createSpy('reply') + }); - function returnCallUrl(): any { - return { - oauth2Auth: { - callCustomApi : (queryUrl) => { - return Promise.resolve(queryUrl); - } - }, - isEcmLoggedIn() { - return false; - } - }; - } + const returnCallUrl = (): any => ({ + oauth2Auth: { + callCustomApi : (queryUrl) => Promise.resolve(queryUrl) + }, + isEcmLoggedIn: () => false + }); setupTestBed({ imports: [ @@ -67,7 +55,7 @@ describe('TaskListCloudService', () => { }); it('should append to the call all the parameters', (done) => { - const taskRequest: TaskQueryCloudRequestModel = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; + const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as TaskQueryCloudRequestModel; spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters); service.getTaskByRequest(taskRequest).subscribe((res) => { expect(res).toBeDefined(); @@ -80,7 +68,7 @@ describe('TaskListCloudService', () => { }); it('should concat the app name to the request url', (done) => { - const taskRequest: TaskQueryCloudRequestModel = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; + const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as TaskQueryCloudRequestModel; spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl); service.getTaskByRequest(taskRequest).subscribe((requestUrl) => { expect(requestUrl).toBeDefined(); @@ -91,8 +79,8 @@ describe('TaskListCloudService', () => { }); it('should concat the sorting to append as parameters', (done) => { - const taskRequest: TaskQueryCloudRequestModel = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service', - sorting: [{ orderBy: 'NAME', direction: 'DESC'}, { orderBy: 'TITLE', direction: 'ASC'}] }; + const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service', + sorting: [{ orderBy: 'NAME', direction: 'DESC'}, { orderBy: 'TITLE', direction: 'ASC'}] } as TaskQueryCloudRequestModel; spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters); service.getTaskByRequest(taskRequest).subscribe((res) => { expect(res).toBeDefined(); @@ -103,7 +91,7 @@ describe('TaskListCloudService', () => { }); it('should return an error when app name is not specified', (done) => { - const taskRequest: TaskQueryCloudRequestModel = { appName: null }; + const taskRequest = { appName: null } as TaskQueryCloudRequestModel; spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl); service.getTaskByRequest(taskRequest).subscribe( () => { },