diff --git a/lib/core/.eslintrc.json b/lib/core/.eslintrc.json index ed6272b132..7bab0d4376 100644 --- a/lib/core/.eslintrc.json +++ b/lib/core/.eslintrc.json @@ -21,16 +21,17 @@ ], "rules": { "jsdoc/newline-after-description": "warn", - "@typescript-eslint/naming-convention": "warn", + "@typescript-eslint/naming-convention": "off", "@typescript-eslint/consistent-type-assertions": "warn", - "@typescript-eslint/prefer-for-of": "warn", - "no-underscore-dangle": ["warn", { "allowAfterThis": true }], + "@typescript-eslint/prefer-for-of": "off", + "@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": [ @@ -105,7 +106,7 @@ "@angular-eslint/template/no-autofocus": "error", "@angular-eslint/template/no-positive-tabindex": "error", - "@angular-eslint/template/no-negated-async": "warn" + "@angular-eslint/template/no-negated-async": "off" } } ] diff --git a/lib/core/about/about-github-link/about-github-link.component.spec.ts b/lib/core/about/about-github-link/about-github-link.component.spec.ts index 85057fad79..19f56aec83 100644 --- a/lib/core/about/about-github-link/about-github-link.component.spec.ts +++ b/lib/core/about/about-github-link/about-github-link.component.spec.ts @@ -52,7 +52,7 @@ describe('AboutGithubLinkComponent', () => { expect(titleElement.innerText).toEqual('mock-application-name'); }); - it('should display version', async() => { + it('should display version', async () => { component.version = aboutGithubDetails.version; fixture.detectChanges(); await fixture.whenStable(); @@ -60,14 +60,14 @@ describe('AboutGithubLinkComponent', () => { expect(version.innerText).toEqual('ABOUT.VERSION: 0.0.7'); }); - it('should display adf github link as default if url is not specified', async() => { + it('should display adf github link as default if url is not specified', async () => { fixture.detectChanges(); await fixture.whenStable(); const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]'); expect(githubUrl.innerText).toEqual(aboutGithubDetails.defualrUrl); }); - it('should display the github link', async() => { + it('should display the github link', async () => { component.url = aboutGithubDetails.url; fixture.detectChanges(); await fixture.whenStable(); diff --git a/lib/core/about/about-server-settings/about-server-settings.component.spec.ts b/lib/core/about/about-server-settings/about-server-settings.component.spec.ts index 4367f64361..452c8e37c8 100644 --- a/lib/core/about/about-server-settings/about-server-settings.component.spec.ts +++ b/lib/core/about/about-server-settings/about-server-settings.component.spec.ts @@ -40,8 +40,8 @@ describe('AboutServerSettingsComponent', () => { component = fixture.componentInstance; appConfigService = TestBed.inject(AppConfigService); appConfigService.config = Object.assign(appConfigService.config, { - 'ecmHost': aboutGithubDetails.ecmHost, - 'bpmHost': aboutGithubDetails.bpmHost + ecmHost: aboutGithubDetails.ecmHost, + bpmHost: aboutGithubDetails.bpmHost }); fixture.detectChanges(); }); @@ -50,7 +50,7 @@ describe('AboutServerSettingsComponent', () => { fixture.destroy(); }); - it('should fetch process and content hosts from the app.config.json file', async() => { + it('should fetch process and content hosts from the app.config.json file', async () => { await fixture.whenStable(); expect(component.bpmHost).toEqual(aboutGithubDetails.bpmHost); expect(component.ecmHost).toEqual(aboutGithubDetails.ecmHost); diff --git a/lib/core/about/about.component.ts b/lib/core/about/about.component.ts index 766ae82721..9227764704 100644 --- a/lib/core/about/about.component.ts +++ b/lib/core/about/about.component.ts @@ -73,9 +73,7 @@ export class AboutComponent implements OnInit { this.dependencies = this.pkg?.dependencies; if (this.dependencies) { - const alfrescoPackages = Object.keys(this.dependencies).filter((val) => { - return new RegExp(this.regexp).test(val); - }); + const alfrescoPackages = Object.keys(this.dependencies).filter((val) => new RegExp(this.regexp).test(val)); alfrescoPackages.forEach((val) => { this.dependencyEntries.push({ @@ -97,20 +95,16 @@ export class AboutComponent implements OnInit { this.discovery.getEcmProductInfo().subscribe((repository) => { this.repository = repository; - this.statusEntries = Object.keys(repository.status).map((key) => { - return { - property: key, - value: repository.status[key] - }; - }); + this.statusEntries = Object.keys(repository.status).map((key) => ({ + property: key, + value: repository.status[key] + })); if (repository.license) { - this.licenseEntries = Object.keys(repository.license).map((key) => { - return { - property: key, - value: repository.license[key] - }; - }); + this.licenseEntries = Object.keys(repository.license).map((key) => ({ + property: key, + value: repository.license[key] + })); } }); } diff --git a/lib/core/about/about.mock.ts b/lib/core/about/about.mock.ts index 913b56273f..6daf8c1369 100644 --- a/lib/core/about/about.mock.ts +++ b/lib/core/about/about.mock.ts @@ -22,7 +22,7 @@ export const mockDependencies = { '@angular/mock-services': '8.0.0' }; -export const mockPlugins = [ +export const mockPlugins = [ { $name: 'plugin1', $version: '1.0.0', diff --git a/lib/core/app-config/app-config.service.spec.ts b/lib/core/app-config/app-config.service.spec.ts index 9458ddf5fe..c0f1ae26cf 100644 --- a/lib/core/app-config/app-config.service.spec.ts +++ b/lib/core/app-config/app-config.service.spec.ts @@ -44,7 +44,7 @@ describe('AppConfigService', () => { name: 'Custom Name' }, files: { - 'excluded': ['excluded'] + excluded: ['excluded'] }, logLevel: 'silent', alfrescoRepositoryName: 'alfresco-1' diff --git a/lib/core/app-config/app-config.service.ts b/lib/core/app-config/app-config.service.ts index 3b160d4c2c..11bd711c17 100644 --- a/lib/core/app-config/app-config.service.ts +++ b/lib/core/app-config/app-config.service.ts @@ -23,6 +23,7 @@ import { map, distinctUntilChanged, take } from 'rxjs/operators'; import { ExtensionConfig, ExtensionService, mergeObjects } from '@alfresco/adf-extensions'; /* spellchecker: disable */ +// eslint-disable-next-line no-shadow export enum AppConfigValues { APP_CONFIG_LANGUAGES_KEY = 'languages', PROVIDERS = 'providers', @@ -44,6 +45,7 @@ export enum AppConfigValues { NOTIFY_DURATION = 'notificationDefaultDuration' } +// eslint-disable-next-line no-shadow export enum Status { INIT = 'init', LOADING = 'loading', @@ -81,6 +83,7 @@ export class AppConfigService { /** * Requests notification of a property value when it is loaded. + * * @param property The desired property value * @returns Property value, when loaded */ @@ -94,6 +97,7 @@ export class AppConfigService { /** * Gets the value of a named property. + * * @param key Name of the property * @param defaultValue Value to return if the key is not found * @returns Value of the property @@ -119,11 +123,12 @@ export class AppConfigService { return defaultValue; } - return result; + return result; } /** * Gets the location.protocol value. + * * @returns The location.protocol string */ getLocationProtocol(): string { @@ -132,6 +137,7 @@ export class AppConfigService { /** * Gets the location.hostname property. + * * @returns Value of the property */ getLocationHostname(): string { @@ -140,6 +146,7 @@ export class AppConfigService { /** * Gets the location.port property. + * * @param prefix Text added before port value * @returns Port with prefix */ @@ -172,6 +179,7 @@ export class AppConfigService { /** * Loads the config file. + * * @returns Notification when loading is complete */ load(): Promise { diff --git a/lib/core/app-config/debug-app-config.service.ts b/lib/core/app-config/debug-app-config.service.ts index c05d6ab8c6..e33da8a597 100644 --- a/lib/core/app-config/debug-app-config.service.ts +++ b/lib/core/app-config/debug-app-config.service.ts @@ -30,11 +30,11 @@ export class DebugAppConfigService extends AppConfigService { /** @override */ get(key: string, defaultValue?: T): T { if (key === AppConfigValues.OAUTHCONFIG) { - return (JSON.parse(this.storage.getItem(key)) || super.get(key, defaultValue)); + return (JSON.parse(this.storage.getItem(key)) || super.get(key, defaultValue)); } else if (key === AppConfigValues.APPLICATION) { return undefined; } else { - return ( this.storage.getItem(key) || super.get(key, defaultValue)); + return (this.storage.getItem(key) as any || super.get(key, defaultValue)); } } } diff --git a/lib/core/card-view/components/card-view-arrayitem/card-view-arrayitem.component.spec.ts b/lib/core/card-view/components/card-view-arrayitem/card-view-arrayitem.component.spec.ts index 4f26ec62c0..45267ed7fd 100644 --- a/lib/core/card-view/components/card-view-arrayitem/card-view-arrayitem.component.spec.ts +++ b/lib/core/card-view/components/card-view-arrayitem/card-view-arrayitem.component.spec.ts @@ -28,11 +28,12 @@ describe('CardViewArrayItemComponent', () => { let component: CardViewArrayItemComponent; let fixture: ComponentFixture; - const mockData = [ + const mockData = [ { icon: 'person', value: 'Zlatan' }, { icon: 'group', value: 'Lionel Messi' }, { icon: 'person', value: 'Mohamed' }, - { icon: 'person', value: 'Ronaldo' }]; + { icon: 'person', value: 'Ronaldo' } + ] as CardViewArrayItem[]; const mockDefaultProps = { label: 'Array of items', diff --git a/lib/core/card-view/components/card-view-boolitem/card-view-boolitem.component.spec.ts b/lib/core/card-view/components/card-view-boolitem/card-view-boolitem.component.spec.ts index f873ae9ed8..58e2741ee6 100644 --- a/lib/core/card-view/components/card-view-boolitem/card-view-boolitem.component.spec.ts +++ b/lib/core/card-view/components/card-view-boolitem/card-view-boolitem.component.spec.ts @@ -184,7 +184,7 @@ describe('CardViewBoolItemComponent', () => { spyOn(cardViewUpdateService, 'update'); const property = { ... component.property }; - component.changed( { checked: true }); + component.changed({ checked: true } as MatCheckboxChange); expect(cardViewUpdateService.update).toHaveBeenCalledWith(property, true); }); @@ -192,7 +192,7 @@ describe('CardViewBoolItemComponent', () => { it('should update the property value after a changed', async () => { component.property.value = true; - component.changed( { checked: false }); + component.changed({ checked: false } as MatCheckboxChange); fixture.detectChanges(); await fixture.whenStable(); diff --git a/lib/core/card-view/components/card-view-boolitem/card-view-boolitem.component.ts b/lib/core/card-view/components/card-view-boolitem/card-view-boolitem.component.ts index d802320771..8992de97e4 100644 --- a/lib/core/card-view/components/card-view-boolitem/card-view-boolitem.component.ts +++ b/lib/core/card-view/components/card-view-boolitem/card-view-boolitem.component.ts @@ -40,7 +40,7 @@ export class CardViewBoolItemComponent extends BaseCardView { ...this.property }, change.checked ); + this.cardViewUpdateService.update({ ...this.property } as CardViewBoolItemModel, change.checked ); this.property.value = change.checked; } } diff --git a/lib/core/card-view/components/card-view-dateitem/card-view-dateitem.component.ts b/lib/core/card-view/components/card-view-dateitem/card-view-dateitem.component.ts index e95c5bc205..2ea33cf062 100644 --- a/lib/core/card-view/components/card-view-dateitem/card-view-dateitem.component.ts +++ b/lib/core/card-view/components/card-view-dateitem/card-view-dateitem.component.ts @@ -86,7 +86,7 @@ export class CardViewDateItemComponent extends BaseCardView this.dateAdapter).overrideDisplayFormat = 'MMM DD'; + (this.dateAdapter as MomentDateAdapter).overrideDisplayFormat = 'MMM DD'; if (this.property.value) { this.valueDate = moment(this.property.value, this.dateFormat); @@ -129,7 +129,7 @@ export class CardViewDateItemComponent extends BaseCardView { ...this.property }, null); + this.cardViewUpdateService.update({ ...this.property } as CardViewDateItemModel, null); this.property.value = null; this.property.default = null; } @@ -155,6 +155,6 @@ export class CardViewDateItemComponent extends BaseCardView { ...this.property }, this.property.value); + this.cardViewUpdateService.update({ ...this.property } as CardViewDateItemModel, this.property.value); } } diff --git a/lib/core/card-view/components/card-view-item-dispatcher/card-view-item-dispatcher.component.spec.ts b/lib/core/card-view/components/card-view-item-dispatcher/card-view-item-dispatcher.component.spec.ts index a7cb01d0a2..fe7d0c47ee 100644 --- a/lib/core/card-view/components/card-view-item-dispatcher/card-view-item-dispatcher.component.spec.ts +++ b/lib/core/card-view/components/card-view-item-dispatcher/card-view-item-dispatcher.component.spec.ts @@ -59,7 +59,7 @@ describe('CardViewItemDispatcherComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(CardViewItemDispatcherComponent); component = fixture.componentInstance; - component.property = { + component.property = { type: 'shiny-custom-element', label: 'Shiny custom element', value: null, @@ -111,7 +111,7 @@ describe('CardViewItemDispatcherComponent', () => { it('should update the subcomponent\'s input parameters', () => { const expectedEditable = false; const expectedDisplayEmpty = true; - const expectedProperty = {}; + const expectedProperty = {}; const expectedCustomInput = 1; const expectedDisplayNoneOption = false; const expectedDisplayClearAction = false; diff --git a/lib/core/card-view/components/card-view-keyvaluepairsitem/card-view-keyvaluepairsitem.component.ts b/lib/core/card-view/components/card-view-keyvaluepairsitem/card-view-keyvaluepairsitem.component.ts index 39ba357eb9..1913c9949c 100644 --- a/lib/core/card-view/components/card-view-keyvaluepairsitem/card-view-keyvaluepairsitem.component.ts +++ b/lib/core/card-view/components/card-view-keyvaluepairsitem/card-view-keyvaluepairsitem.component.ts @@ -69,7 +69,7 @@ export class CardViewKeyValuePairsItemComponent extends BaseCardView i.name.length && i.value.length); if (remove || validValues.length) { - this.cardViewUpdateService.update( { ...this.property }, validValues); + this.cardViewUpdateService.update({ ...this.property } as CardViewKeyValuePairsItemModel, validValues); this.property.value = validValues; } } diff --git a/lib/core/card-view/components/card-view-selectitem/card-view-selectitem.component.ts b/lib/core/card-view/components/card-view-selectitem/card-view-selectitem.component.ts index eb2e1461be..675fd9c98c 100644 --- a/lib/core/card-view/components/card-view-selectitem/card-view-selectitem.component.ts +++ b/lib/core/card-view/components/card-view-selectitem/card-view-selectitem.component.ts @@ -93,7 +93,7 @@ export class CardViewSelectItemComponent extends BaseCardView> { ...this.property }, selectedOption); + this.cardViewUpdateService.update({ ...this.property } as CardViewSelectItemModel, selectedOption); this.property.value = selectedOption; } diff --git a/lib/core/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.spec.ts b/lib/core/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.spec.ts index d6d05df6ea..5042d3b6c2 100644 --- a/lib/core/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.spec.ts +++ b/lib/core/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.spec.ts @@ -44,9 +44,9 @@ export class TestComponent { showInputFilter = true; multiple = false; standardOptions = [ - { 'id': '1', 'name': 'one' }, - { 'id': '2', 'name': 'two' }, - { 'id': '3', 'name': 'three' } + { id: '1', name: 'one' }, + { id: '2', name: 'two' }, + { id: '3', name: 'three' } ]; options = this.standardOptions; @@ -136,7 +136,7 @@ describe('SelectFilterInputComponent', () => { component.onModelChange('some-search-term'); expect(component.term).toBe('some-search-term'); - component.selectFilterInput.nativeElement.dispatchEvent(new KeyboardEvent('keydown', {'keyCode': ESCAPE} as any)); + component.selectFilterInput.nativeElement.dispatchEvent(new KeyboardEvent('keydown', {keyCode: ESCAPE} as any)); fixture.detectChanges(); expect(component.term).toBe(''); }); @@ -152,10 +152,10 @@ describe('SelectFilterInputComponent', () => { afterEach(() => testFixture.destroy()); it('should preserve the values for multiple search', async () => { - const userSelection = [{ 'id': '3', 'name': 'three' }]; + const userSelection = [{ id: '3', name: 'three' }]; const preSelected = [ - { 'id': '1', 'name': 'one' }, - { 'id': '2', 'name': 'two' } + { id: '1', name: 'one' }, + { id: '2', name: 'two' } ]; testComponent.field.value = preSelected; testComponent.multiple = true; diff --git a/lib/core/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.ts b/lib/core/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.ts index 96060e497e..339f0975bd 100644 --- a/lib/core/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.ts +++ b/lib/core/card-view/components/card-view-selectitem/select-filter-input/select-filter-input.component.ts @@ -25,7 +25,7 @@ import { takeUntil } from 'rxjs/operators'; selector: 'adf-select-filter-input', templateUrl: './select-filter-input.component.html', styleUrls: ['./select-filter-input.component.scss'], - host: { 'class': 'adf-select-filter-input' }, + host: { class: 'adf-select-filter-input' }, encapsulation: ViewEncapsulation.None }) export class SelectFilterInputComponent implements OnInit, OnDestroy { @@ -79,6 +79,7 @@ export class SelectFilterInputComponent implements OnInit, OnDestroy { this.previousSelected = values; if (restoreSelection) { + // eslint-disable-next-line no-underscore-dangle this.matSelect._onChange(values); } }); diff --git a/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts b/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts index 77739e086b..3cef68f4f7 100644 --- a/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts +++ b/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts @@ -904,28 +904,28 @@ describe('CardViewTextItemComponent', () => { }); }); - function updateTextField(key, value) { + const updateTextField = (key, value) => { const editInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`)); editInput.nativeElement.value = value; editInput.nativeElement.dispatchEvent(new Event('input')); fixture.detectChanges(); - } + }; - function getTextFieldValue(key): string { + const getTextFieldValue = (key): string => { const textItemInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`)); expect(textItemInput).not.toBeNull(); return textItemInput.nativeElement.value; - } + }; - function getTextField(key): DebugElement { + const getTextField = (key): DebugElement => { const textItemInput = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${key}"]`)); expect(textItemInput).not.toBeNull(); return textItemInput; - } + }; - function getTextFieldError(key): string { + const getTextFieldError = (key): string => { const textItemInputError = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-error-${key}"] li`)); expect(textItemInputError).not.toBeNull(); return textItemInputError.nativeElement.innerText; - } + }; }); diff --git a/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.ts b/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.ts index 4618ea3c2a..ba751b7d9d 100644 --- a/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.ts +++ b/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.ts @@ -132,7 +132,7 @@ export class CardViewTextItemComponent extends BaseCardView { ...this.property }, this.property.value); + this.cardViewUpdateService.update({ ...this.property } as CardViewTextItemModel, this.property.value); this.resetErrorMessages(); } else { this.errors = this.property.getValidationErrors(this.editedValue); diff --git a/lib/core/card-view/components/card-view/card-view.component.spec.ts b/lib/core/card-view/components/card-view/card-view.component.spec.ts index a84fbd8ba8..cea66df22f 100644 --- a/lib/core/card-view/components/card-view/card-view.component.spec.ts +++ b/lib/core/card-view/components/card-view/card-view.component.spec.ts @@ -145,7 +145,7 @@ describe('CardViewComponent', () => { }); it('should render the select element with the None option when not set in the properties', async () => { - const options: CardViewSelectItemOption[] = [{'label' : 'Option 1', 'key': '1'}, {'label' : 'Option 2', 'key': '2'}]; + const options: CardViewSelectItemOption[] = [{label : 'Option 1', key: '1'}, {label : 'Option 2', key: '2'}]; component.properties = [new CardViewSelectItemModel({ label: 'My default label', value: '1', @@ -173,7 +173,7 @@ describe('CardViewComponent', () => { }); it('should render the select element with the None option when set true in the properties', async () => { - const options: CardViewSelectItemOption[] = [{'label' : 'Option 1', 'key': '1'}, {'label' : 'Option 2', 'key': '2'}]; + const options: CardViewSelectItemOption[] = [{label : 'Option 1', key: '1'}, {label : 'Option 2', key: '2'}]; component.properties = [new CardViewSelectItemModel({ label: 'My default label', value: '1', @@ -202,7 +202,7 @@ describe('CardViewComponent', () => { }); it('should not render the select element with the None option when set false in the properties', async () => { - const options: CardViewSelectItemOption[] = [{'label' : 'Option 1', 'key': '1'}, {'label' : 'Option 2', 'key': '2'}]; + const options: CardViewSelectItemOption[] = [{label : 'Option 1', key: '1'}, {label : 'Option 2', key: '2'}]; component.properties = [new CardViewSelectItemModel({ label: 'My default label', value: '1', diff --git a/lib/core/card-view/models/card-view-textitem.model.ts b/lib/core/card-view/models/card-view-textitem.model.ts index 05a4d67340..195e9c96b2 100644 --- a/lib/core/card-view/models/card-view-textitem.model.ts +++ b/lib/core/card-view/models/card-view-textitem.model.ts @@ -44,9 +44,7 @@ export class CardViewTextItemModel extends CardViewBaseItemModel implements Card applyPipes(displayValue) { if (this.pipes.length) { - displayValue = this.pipes.reduce((accumulator, { pipe, params = [] }) => { - return pipe.transform(accumulator, ...params); - }, displayValue); + displayValue = this.pipes.reduce((accumulator, { pipe, params = [] }) => pipe.transform(accumulator, ...params), displayValue); } return displayValue; diff --git a/lib/core/card-view/services/card-item-types.service.ts b/lib/core/card-view/services/card-item-types.service.ts index 8d9c907a68..c154cec11c 100644 --- a/lib/core/card-view/services/card-item-types.service.ts +++ b/lib/core/card-view/services/card-item-types.service.ts @@ -33,15 +33,15 @@ export class CardItemTypeService extends DynamicComponentMapper { protected defaultValue: Type = CardViewTextItemComponent; protected types: { [key: string]: DynamicComponentResolveFunction } = { - 'text': DynamicComponentResolver.fromType(CardViewTextItemComponent), - 'select': DynamicComponentResolver.fromType(CardViewSelectItemComponent), - 'int': DynamicComponentResolver.fromType(CardViewTextItemComponent), - 'float': DynamicComponentResolver.fromType(CardViewTextItemComponent), - 'date': DynamicComponentResolver.fromType(CardViewDateItemComponent), - 'datetime': DynamicComponentResolver.fromType(CardViewDateItemComponent), - 'bool': DynamicComponentResolver.fromType(CardViewBoolItemComponent), - 'map': DynamicComponentResolver.fromType(CardViewMapItemComponent), - 'keyvaluepairs': DynamicComponentResolver.fromType(CardViewKeyValuePairsItemComponent), - 'array': DynamicComponentResolver.fromType(CardViewArrayItemComponent) + text: DynamicComponentResolver.fromType(CardViewTextItemComponent), + select: DynamicComponentResolver.fromType(CardViewSelectItemComponent), + int: DynamicComponentResolver.fromType(CardViewTextItemComponent), + float: DynamicComponentResolver.fromType(CardViewTextItemComponent), + date: DynamicComponentResolver.fromType(CardViewDateItemComponent), + datetime: DynamicComponentResolver.fromType(CardViewDateItemComponent), + bool: DynamicComponentResolver.fromType(CardViewBoolItemComponent), + map: DynamicComponentResolver.fromType(CardViewMapItemComponent), + keyvaluepairs: DynamicComponentResolver.fromType(CardViewKeyValuePairsItemComponent), + array: DynamicComponentResolver.fromType(CardViewArrayItemComponent) }; } diff --git a/lib/core/card-view/services/card-view-update.service.spec.ts b/lib/core/card-view/services/card-view-update.service.spec.ts index e1755224bf..a338b37984 100644 --- a/lib/core/card-view/services/card-view-update.service.spec.ts +++ b/lib/core/card-view/services/card-view-update.service.spec.ts @@ -50,14 +50,14 @@ describe('CardViewUpdateService', () => { describe('Service', () => { let cardViewUpdateService: CardViewUpdateService; - const property: CardViewBaseItemModel = { + const property: CardViewBaseItemModel = { label: 'property-label', value: 'property-value', key: 'property-key', default: 'property-default', editable: false, clickable: false - }; + } as CardViewBaseItemModel; beforeEach(() => { cardViewUpdateService = TestBed.inject(CardViewUpdateService); @@ -85,7 +85,7 @@ describe('CardViewUpdateService', () => { })); it('should send updated node when aspect changed', fakeAsync(() => { - const fakeNode: MinimalNode = { id: 'Bigfoot'}; + const fakeNode: MinimalNode = { id: 'Bigfoot'} as MinimalNode; cardViewUpdateService.updatedAspect$.subscribe((node: MinimalNode) => { expect(node.id).toBe('Bigfoot'); }); diff --git a/lib/core/card-view/services/card-view-update.service.ts b/lib/core/card-view/services/card-view-update.service.ts index ed6c8c9967..e0b577e1f4 100644 --- a/lib/core/card-view/services/card-view-update.service.ts +++ b/lib/core/card-view/services/card-view-update.service.ts @@ -29,13 +29,11 @@ export interface ClickNotification { target: any; } -export function transformKeyToObject(key: string, value): any { +export const transformKeyToObject = (key: string, value): any => { const objectLevels: string[] = key.split('.').reverse(); - return objectLevels.reduce((previousValue, currentValue) => { - return { [currentValue]: previousValue}; - }, value); -} + return objectLevels.reduce((previousValue, currentValue) => ({ [currentValue]: previousValue}), value); +}; @Injectable({ providedIn: 'root' @@ -62,6 +60,7 @@ export class CardViewUpdateService { /** * Updates the cardview items property + * * @param notification */ updateElement(notification: CardViewBaseItemModel) { diff --git a/lib/core/clipboard/clipboard.directive.spec.ts b/lib/core/clipboard/clipboard.directive.spec.ts index 19c626f958..36700a148a 100644 --- a/lib/core/clipboard/clipboard.directive.spec.ts +++ b/lib/core/clipboard/clipboard.directive.spec.ts @@ -101,14 +101,14 @@ describe('CopyClipboardDirective', () => { }); it('should show tooltip when hover element', (() => { - const spanHTMLElement: HTMLInputElement = element.querySelector('span'); + const spanHTMLElement = element.querySelector('span'); spanHTMLElement.dispatchEvent(new Event('mouseenter')); fixture.detectChanges(); expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull(); })); it('should not show tooltip when element it is not hovered', (() => { - const spanHTMLElement: HTMLInputElement = element.querySelector('span'); + const spanHTMLElement = element.querySelector('span'); spanHTMLElement.dispatchEvent(new Event('mouseenter')); fixture.detectChanges(); expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull(); @@ -119,7 +119,7 @@ describe('CopyClipboardDirective', () => { })); it('should copy the content of element when click it', fakeAsync(() => { - const spanHTMLElement: HTMLInputElement = element.querySelector('span'); + const spanHTMLElement = element.querySelector('span'); fixture.detectChanges(); spyOn(document, 'execCommand'); spanHTMLElement.dispatchEvent(new Event('click')); @@ -129,7 +129,7 @@ describe('CopyClipboardDirective', () => { })); it('should not copy the content of element when click it', fakeAsync(() => { - const spanHTMLElement: HTMLInputElement = element.querySelector('span'); + const spanHTMLElement = element.querySelector('span'); fixture.detectChanges(); spyOn(document, 'execCommand'); spanHTMLElement.dispatchEvent(new Event('mouseleave')); diff --git a/lib/core/clipboard/clipboard.service.ts b/lib/core/clipboard/clipboard.service.ts index 05ece99b6c..54f50c75b2 100644 --- a/lib/core/clipboard/clipboard.service.ts +++ b/lib/core/clipboard/clipboard.service.ts @@ -30,6 +30,7 @@ export class ClipboardService { /** * Checks if the target element can have its text copied. + * * @param target Target HTML element * @returns True if the text can be copied, false otherwise */ @@ -42,6 +43,7 @@ export class ClipboardService { /** * Copies text from an HTML element to the clipboard. + * * @param target HTML element to be copied * @param message Snackbar message to alert when copying happens */ @@ -60,6 +62,7 @@ export class ClipboardService { /** * Copies a text string to the clipboard. + * * @param content Text to copy * @param message Snackbar message to alert when copying happens */ diff --git a/lib/core/comments/comments.component.spec.ts b/lib/core/comments/comments.component.spec.ts index 71fe0ea2e1..fcce854f96 100644 --- a/lib/core/comments/comments.component.spec.ts +++ b/lib/core/comments/comments.component.spec.ts @@ -81,14 +81,14 @@ describe('CommentsComponent', () => { it('should load comments when taskId specified', () => { const change = new SimpleChange(null, '123', true); - component.ngOnChanges({'taskId': change}); + component.ngOnChanges({taskId: change}); expect(getProcessCommentsSpy).toHaveBeenCalled(); }); it('should load comments when nodeId specified', () => { const change = new SimpleChange(null, '123', true); - component.ngOnChanges({'nodeId': change}); + component.ngOnChanges({nodeId: change}); expect(getContentCommentsSpy).toHaveBeenCalled(); }); @@ -98,7 +98,7 @@ describe('CommentsComponent', () => { getProcessCommentsSpy.and.returnValue(throwError({})); const change = new SimpleChange(null, '123', true); - component.ngOnChanges({'taskId': change}); + component.ngOnChanges({taskId: change}); expect(emitSpy).toHaveBeenCalled(); }); @@ -110,7 +110,7 @@ describe('CommentsComponent', () => { it('should display comments when the task has comments', async () => { const change = new SimpleChange(null, '123', true); - component.ngOnChanges({'taskId': change}); + component.ngOnChanges({taskId: change}); fixture.detectChanges(); await fixture.whenStable(); @@ -121,7 +121,7 @@ describe('CommentsComponent', () => { it('should display comments count when the task has comments', async () => { const change = new SimpleChange(null, '123', true); - component.ngOnChanges({'taskId': change}); + component.ngOnChanges({taskId: change}); fixture.detectChanges(); await fixture.whenStable(); @@ -142,7 +142,7 @@ describe('CommentsComponent', () => { it('should display comments input by default', async () => { const change = new SimpleChange(null, '123', true); - component.ngOnChanges({'taskId': change}); + component.ngOnChanges({taskId: change}); fixture.detectChanges(); await fixture.whenStable(); @@ -169,7 +169,7 @@ describe('CommentsComponent', () => { }); it('should fetch new comments when taskId changed', () => { - component.ngOnChanges({'taskId': change}); + component.ngOnChanges({taskId: change}); expect(getProcessCommentsSpy).toHaveBeenCalledWith('456'); }); @@ -179,7 +179,7 @@ describe('CommentsComponent', () => { }); it('should not fetch new comments when taskId changed to null', () => { - component.ngOnChanges({'taskId': nullChange}); + component.ngOnChanges({taskId: nullChange}); expect(getProcessCommentsSpy).not.toHaveBeenCalled(); }); }); @@ -194,7 +194,7 @@ describe('CommentsComponent', () => { }); it('should fetch new comments when nodeId changed', () => { - component.ngOnChanges({'nodeId': change}); + component.ngOnChanges({nodeId: change}); expect(getContentCommentsSpy).toHaveBeenCalledWith('456'); }); @@ -204,7 +204,7 @@ describe('CommentsComponent', () => { }); it('should not fetch new comments when nodeId changed to null', () => { - component.ngOnChanges({'nodeId': nullChange}); + component.ngOnChanges({nodeId: nullChange}); expect(getContentCommentsSpy).not.toHaveBeenCalled(); }); }); @@ -276,7 +276,7 @@ describe('CommentsComponent', () => { }); it('should clear comment when escape key is pressed', async () => { - const event = new KeyboardEvent('keydown', {'key': 'Escape'}); + const event = new KeyboardEvent('keydown', {key: 'Escape'}); let element = fixture.nativeElement.querySelector('#comment-input'); element.dispatchEvent(event); @@ -363,7 +363,7 @@ describe('CommentsComponent', () => { }); it('should clear comment when escape key is pressed', async () => { - const event = new KeyboardEvent('keydown', {'key': 'Escape'}); + const event = new KeyboardEvent('keydown', {key: 'Escape'}); let element = fixture.nativeElement.querySelector('#comment-input'); element.dispatchEvent(event); diff --git a/lib/core/context-menu/context-menu-overlay.service.spec.ts b/lib/core/context-menu/context-menu-overlay.service.spec.ts index 7d6f16eefb..815425d56b 100644 --- a/lib/core/context-menu/context-menu-overlay.service.spec.ts +++ b/lib/core/context-menu/context-menu-overlay.service.spec.ts @@ -29,10 +29,10 @@ describe('ContextMenuOverlayService', () => { let injector: Injector; const overlayConfig = { panelClass: 'test-panel', - source: { + source: { clientY: 1, clientX: 1 - } + } as MouseEvent }; setupTestBed({ diff --git a/lib/core/context-menu/context-menu-overlay.service.ts b/lib/core/context-menu/context-menu-overlay.service.ts index bf92b4d51a..b05ff40b73 100644 --- a/lib/core/context-menu/context-menu-overlay.service.ts +++ b/lib/core/context-menu/context-menu-overlay.service.ts @@ -52,10 +52,12 @@ export class ContextMenuOverlayService { // prevent native contextmenu on overlay element if config.hasBackdrop is true if (overlayConfig.hasBackdrop) { - ( overlay)._backdropElement + // eslint-disable-next-line no-underscore-dangle + (overlay as any)._backdropElement .addEventListener('contextmenu', (event) => { event.preventDefault(); - ( overlay)._backdropClick.next(null); + // eslint-disable-next-line no-underscore-dangle + (overlay as any)._backdropClick.next(null); }, true); } @@ -96,7 +98,7 @@ export class ContextMenuOverlayService { right: clientX, top: clientY, width: 0 - }) + } as any) }; const positionStrategy = this.overlay.position() diff --git a/lib/core/datatable/components/datatable-cell/datatable-cell.component.spec.ts b/lib/core/datatable/components/datatable-cell/datatable-cell.component.spec.ts index 6d68b43e48..4336020941 100644 --- a/lib/core/datatable/components/datatable-cell/datatable-cell.component.spec.ts +++ b/lib/core/datatable/components/datatable-cell/datatable-cell.component.spec.ts @@ -47,9 +47,9 @@ describe('DataTableCellComponent', () => { }); it('should use column format', () => { - const component = new DateCellComponent(null, { + const component = new DateCellComponent(null, { nodeUpdated: new Subject() - }, appConfigService); + } as any, appConfigService); component.column = { key: 'created', type: 'date', @@ -72,7 +72,7 @@ describe('DataTableCellComponent', () => { type: 'text' }; - component.row = { + component.row = { cache: { name: 'some-name' }, @@ -82,14 +82,14 @@ describe('DataTableCellComponent', () => { name: 'test-name' } } - }; + } as any; component.ngOnInit(); - alfrescoApiService.nodeUpdated.next( { + alfrescoApiService.nodeUpdated.next({ id: 'id', name: 'updated-name' - }); + } as Node); expect(component.row['node'].entry.name).toBe('updated-name'); expect(component.row['cache'].name).toBe('updated-name'); @@ -107,7 +107,7 @@ describe('DataTableCellComponent', () => { type: 'text' }; - component.row = { + component.row = { cache: { name: 'some-name' }, @@ -117,14 +117,14 @@ describe('DataTableCellComponent', () => { name: 'test-name' } } - }; + } as any; component.ngOnInit(); - alfrescoApiService.nodeUpdated.next( { + alfrescoApiService.nodeUpdated.next({ id: 'id', name: 'updated-name' - }); + } as Node); expect(component.row['node'].entry.name).not.toBe('updated-name'); expect(component.row['cache'].name).not.toBe('updated-name'); @@ -142,7 +142,7 @@ describe('DataTableCellComponent', () => { type: 'text' }; - component.row = { + component.row = { cache: { name: 'some-name' }, @@ -155,7 +155,7 @@ describe('DataTableCellComponent', () => { } } } - }; + } as any; component.ngOnInit(); diff --git a/lib/core/datatable/components/datatable/datatable.component.spec.ts b/lib/core/datatable/components/datatable/datatable.component.spec.ts index 4981621e8b..ad46bf4191 100644 --- a/lib/core/datatable/components/datatable/datatable.component.spec.ts +++ b/lib/core/datatable/components/datatable/datatable.component.spec.ts @@ -66,13 +66,13 @@ class FakeDataRow implements DataRow { } } -export function resolverFn(row: DataRow, col: DataColumn) { +export const resolverFn = (row: DataRow, col: DataColumn) => { const value = row.getValue(col.key); if (col.key === 'name') { return `${row.getValue('firstName')} - ${row.getValue('lastName')}`; } return value; -} +}; describe('DataTable', () => { @@ -599,10 +599,10 @@ describe('DataTable', () => { done(); }); - dataTable.onRowClick(rows[0], { - metaKey: true, preventDefault() { - } - }); + dataTable.onRowClick(rows[0], { + metaKey: true, + preventDefault: () => {} + } as any); }); it('should unselect the row searching it by row id, when row id is defined', () => { @@ -724,7 +724,7 @@ describe('DataTable', () => { it('should initialize default adapter', () => { const table = new DataTableComponent(null, null); expect(table.data).toBeUndefined(); - table.ngOnChanges({ 'data': new SimpleChange('123', {}, true) }); + table.ngOnChanges({ data: new SimpleChange('123', {}, true) }); expect(table.data).toEqual(jasmine.any(ObjectDataTableAdapter)); }); @@ -736,7 +736,7 @@ describe('DataTable', () => { }); it('should emit row click event', (done) => { - const row = {}; + const row = {} as DataRow; dataTable.data = new ObjectDataTableAdapter([], []); dataTable.rowClick.subscribe((e) => { @@ -751,7 +751,7 @@ describe('DataTable', () => { it('should emit double click if there are two single click in 250ms', (done) => { - const row = {}; + const row = {} as DataRow; dataTable.data = new ObjectDataTableAdapter([], []); dataTable.ngOnChanges({}); fixture.detectChanges(); @@ -768,8 +768,7 @@ describe('DataTable', () => { }); it('should emit double click if there are more than two single click in 250ms', (done) => { - - const row = {}; + const row = {} as DataRow; dataTable.data = new ObjectDataTableAdapter([], []); dataTable.ngOnChanges({}); fixture.detectChanges(); @@ -788,8 +787,7 @@ describe('DataTable', () => { }); it('should emit single click if there are two single click in more than 250ms', (done) => { - - const row = {}; + const row = {} as DataRow; let clickCount = 0; dataTable.data = new ObjectDataTableAdapter([], []); @@ -811,7 +809,7 @@ describe('DataTable', () => { }); it('should emit row-click dom event', (done) => { - const row = {}; + const row = {} as DataRow; dataTable.data = new ObjectDataTableAdapter([], []); fixture.nativeElement.addEventListener('row-click', (e) => { @@ -825,7 +823,7 @@ describe('DataTable', () => { }); it('should emit row-dblclick dom event', (done) => { - const row = {}; + const row = {} as DataRow; dataTable.data = new ObjectDataTableAdapter([], []); fixture.nativeElement.addEventListener('row-dblclick', (e) => { @@ -854,7 +852,7 @@ describe('DataTable', () => { }); it('should not sort if column is missing', () => { - dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) }); + dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) }); fixture.detectChanges(); dataTable.ngAfterViewInit(); const adapter = dataTable.data; @@ -864,7 +862,7 @@ describe('DataTable', () => { }); it('should not sort upon clicking non-sortable column header', () => { - dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) }); + dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) }); fixture.detectChanges(); dataTable.ngAfterViewInit(); const adapter = dataTable.data; @@ -879,7 +877,7 @@ describe('DataTable', () => { }); it('should set sorting upon column header clicked', () => { - dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) }); + dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) }); fixture.detectChanges(); dataTable.ngAfterViewInit(); const adapter = dataTable.data; @@ -900,7 +898,7 @@ describe('DataTable', () => { }); it('should invert sorting upon column header clicked', () => { - dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) }); + dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) }); fixture.detectChanges(); dataTable.ngAfterViewInit(); @@ -970,9 +968,9 @@ describe('DataTable', () => { it('should invert "select all" status', () => { expect(dataTable.isSelectAllChecked).toBeFalsy(); - dataTable.onSelectAllClick( { checked: true }); + dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange); expect(dataTable.isSelectAllChecked).toBeTruthy(); - dataTable.onSelectAllClick( { checked: false }); + dataTable.onSelectAllClick({ checked: false } as MatCheckboxChange); expect(dataTable.isSelectAllChecked).toBeFalsy(); }); @@ -982,7 +980,7 @@ describe('DataTable', () => { dataTable.data = data; dataTable.multiselect = true; dataTable.ngAfterContentInit(); - dataTable.onSelectAllClick( { checked: true }); + dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange); expect(dataTable.selection.every((entry) => entry.isSelected)); @@ -1000,13 +998,13 @@ describe('DataTable', () => { dataTable.multiselect = true; dataTable.ngAfterContentInit(); - dataTable.onSelectAllClick( { checked: true }); + dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange); expect(dataTable.isSelectAllChecked).toBe(true); for (let i = 0; i < rows.length; i++) { expect(rows[i].isSelected).toBe(true); } - dataTable.onSelectAllClick( { checked: false }); + dataTable.onSelectAllClick({ checked: false } as MatCheckboxChange); expect(dataTable.isSelectAllChecked).toBe(false); for (let i = 0; i < rows.length; i++) { expect(rows[i].isSelected).toBe(false); @@ -1015,9 +1013,9 @@ describe('DataTable', () => { it('should allow "select all" calls with no rows', () => { dataTable.multiselect = true; - dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) }); + dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) }); - dataTable.onSelectAllClick( { checked: true }); + dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange); expect(dataTable.isSelectAllChecked).toBe(true); }); @@ -1032,16 +1030,16 @@ describe('DataTable', () => { const rows = dataTable.data.getRows(); dataTable.multiselect = true; - dataTable.onCheckboxChange(rows[0], { checked: true }); + dataTable.onCheckboxChange(rows[0], { checked: true } as MatCheckboxChange); expect(dataTable.isSelectAllIndeterminate).toBe(true); expect(dataTable.isSelectAllChecked).toBe(false); - dataTable.onCheckboxChange(rows[1], { checked: true }); + dataTable.onCheckboxChange(rows[1], { checked: true } as MatCheckboxChange); expect(dataTable.isSelectAllIndeterminate).toBe(false); expect(dataTable.isSelectAllChecked).toBe(true); - dataTable.onCheckboxChange(rows[0], { checked: false }); - dataTable.onCheckboxChange(rows[1], { checked: false }); + dataTable.onCheckboxChange(rows[0], { checked: false } as MatCheckboxChange); + dataTable.onCheckboxChange(rows[1], { checked: false } as MatCheckboxChange); expect(dataTable.isSelectAllIndeterminate).toBe(false); expect(dataTable.isSelectAllChecked).toBe(false); }); @@ -1051,16 +1049,16 @@ describe('DataTable', () => { const rows = data.getRows(); dataTable.multiselect = true; - dataTable.ngOnChanges({ 'data': new SimpleChange('123', data, true) }); + dataTable.ngOnChanges({ data: new SimpleChange('123', data, true) }); expect(rows[0].isSelected).toBe(false); expect(rows[1].isSelected).toBe(false); - dataTable.onCheckboxChange(rows[1], { checked: true }); + dataTable.onCheckboxChange(rows[1], { checked: true } as MatCheckboxChange); expect(rows[0].isSelected).toBe(false); expect(rows[1].isSelected).toBe(true); - dataTable.onCheckboxChange(rows[0], { checked: true }); + dataTable.onCheckboxChange(rows[0], { checked: true } as MatCheckboxChange); expect(rows[0].isSelected).toBe(true); expect(rows[1].isSelected).toBe(true); }); @@ -1073,7 +1071,7 @@ describe('DataTable', () => { dataTable.multiselect = false; dataTable.ngAfterContentInit(); - dataTable.onSelectAllClick( { checked: true }); + dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange); expect(dataTable.isSelectAllChecked).toBe(true); for (let i = 0; i < rows.length; i++) { expect(rows[i].isSelected).toBe(false); @@ -1082,53 +1080,45 @@ describe('DataTable', () => { it('should require row and column for icon value check', () => { expect(dataTable.isIconValue(null, null)).toBeFalsy(); - expect(dataTable.isIconValue( {}, null)).toBeFalsy(); - expect(dataTable.isIconValue(null, {})).toBeFalsy(); + expect(dataTable.isIconValue({} as DataRow, null)).toBeFalsy(); + expect(dataTable.isIconValue(null, {} as DataColumn)).toBeFalsy(); }); it('should use special material url scheme', () => { - const column = {}; + const column = {} as DataColumn; const row: any = { - getValue: function() { - return 'material-icons://android'; - } + getValue: () => 'material-icons://android' }; expect(dataTable.isIconValue(row, column)).toBeTruthy(); }); it('should not use special material url scheme', () => { - const column = {}; + const column = {} as DataColumn; const row: any = { - getValue: function() { - return 'http://www.google.com'; - } + getValue: () => 'http://www.google.com' }; expect(dataTable.isIconValue(row, column)).toBeFalsy(); }); it('should parse icon value', () => { - const column = {}; + const column = {} as DataColumn; const row: any = { - getValue: function() { - return 'material-icons://android'; - } + getValue: () => 'material-icons://android' }; expect(dataTable.asIconValue(row, column)).toBe('android'); }); it('should not parse icon value', () => { - const column = {}; + const column = {} as DataColumn; const row: any = { - getValue: function() { - return 'http://www.google.com'; - } + getValue: () => 'http://www.google.com' }; expect(dataTable.asIconValue(row, column)).toBe(null); @@ -1142,29 +1132,29 @@ describe('DataTable', () => { it('should require column and direction to evaluate sorting state', () => { expect(dataTable.isColumnSorted(null, null)).toBeFalsy(); - expect(dataTable.isColumnSorted( {}, null)).toBeFalsy(); + expect(dataTable.isColumnSorted({} as DataColumn, null)).toBeFalsy(); expect(dataTable.isColumnSorted(null, 'asc')).toBeFalsy(); }); it('should require adapter sorting to evaluate sorting state', () => { - dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) }); + dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) }); spyOn(dataTable.data, 'getSorting').and.returnValue(null); - expect(dataTable.isColumnSorted( {}, 'asc')).toBeFalsy(); + expect(dataTable.isColumnSorted({} as DataColumn, 'asc')).toBeFalsy(); }); it('should evaluate column sorting state', () => { - dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) }); + dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) }); spyOn(dataTable.data, 'getSorting').and.returnValue(new DataSorting('column_1', 'asc')); - expect(dataTable.isColumnSorted( { key: 'column_1' }, 'asc')).toBeTruthy(); - expect(dataTable.isColumnSorted( { key: 'column_2' }, 'desc')).toBeFalsy(); + expect(dataTable.isColumnSorted({ key: 'column_1' } as DataColumn, 'asc')).toBeTruthy(); + expect(dataTable.isColumnSorted({ key: 'column_2' } as DataColumn, 'desc')).toBeFalsy(); }); it('should replace image source with fallback thumbnail on error', () => { - const event = { + const event = { target: { src: 'missing-image' } - }; + } as any; const row = new FakeDataRow(); dataTable.fallbackThumbnail = ''; dataTable.onImageLoadingError(event, row); @@ -1173,11 +1163,11 @@ describe('DataTable', () => { it('should replace image source with miscellaneous icon when fallback is not available', () => { const originalSrc = 'missing-image'; - const event = { + const event = { target: { src: originalSrc } - }; + } as any; const row = new FakeDataRow(); dataTable.fallbackThumbnail = null; dataTable.onImageLoadingError(event, row); @@ -1185,39 +1175,39 @@ describe('DataTable', () => { }); it('should not get cell tooltip when row is not provided', () => { - const col = { key: 'name', type: 'text' }; + const col = { key: 'name', type: 'text' } as DataColumn; expect(dataTable.getCellTooltip(null, col)).toBeNull(); }); it('should not get cell tooltip when column is not provided', () => { - const row = {}; + const row = {} as DataRow; expect(dataTable.getCellTooltip(row, null)).toBeNull(); }); it('should not get cell tooltip when formatter is not provided', () => { - const col = { key: 'name', type: 'text' }; - const row = {}; + const col = { key: 'name', type: 'text' } as DataColumn; + const row = {} as DataRow; expect(dataTable.getCellTooltip(row, col)).toBeNull(); }); it('should use formatter function to generate tooltip', () => { const tooltip = 'tooltip value'; - const col = { + const col = { key: 'name', type: 'text', formatTooltip: () => tooltip - }; - const row = {}; + } as DataColumn; + const row = {} as DataRow; expect(dataTable.getCellTooltip(row, col)).toBe(tooltip); }); it('should return null value from the tooltip formatter', () => { - const col = { + const col = { key: 'name', type: 'text', formatTooltip: () => null - }; - const row = {}; + } as DataColumn; + const row = {} as DataRow; expect(dataTable.getCellTooltip(row, col)).toBeNull(); }); @@ -1227,15 +1217,13 @@ describe('DataTable', () => { emitted++; }); - const column = {}; + const column = {} as any; const row: any = { - getValue: function() { - return 'id'; - } + getValue: () => 'id' }; dataTable.getRowActions(row, column); - dataTable.ngOnChanges({ 'data': new SimpleChange('123', {}, true) }); + dataTable.ngOnChanges({ data: new SimpleChange('123', {}, true) }); dataTable.getRowActions(row, column); expect(emitted).toBe(2); @@ -1340,7 +1328,7 @@ describe('DataTable', () => { const newDataColumnsSchema = { key: 'new-column'}; const columnsChange = new SimpleChange(null, [newDataColumnsSchema], false); - dataTable.ngOnChanges({ 'columns': columnsChange }); + dataTable.ngOnChanges({ columns: columnsChange }); const expectedNewDataColumns = [new ObjectDataColumn(newDataColumnsSchema)]; expect(dataTable.data.getColumns()).toEqual(expectedNewDataColumns); }); diff --git a/lib/core/datatable/components/datatable/datatable.component.ts b/lib/core/datatable/components/datatable/datatable.component.ts index b269453ef2..ecb168e36b 100644 --- a/lib/core/datatable/components/datatable/datatable.component.ts +++ b/lib/core/datatable/components/datatable/datatable.component.ts @@ -41,11 +41,13 @@ import { DataCellEvent } from '../data-cell.event'; import { DataRowActionEvent } from '../data-row-action.event'; import { share, buffer, map, filter, debounceTime } from 'rxjs/operators'; +// eslint-disable-next-line no-shadow export enum DisplayMode { List = 'list', Gallery = 'gallery' } +// eslint-disable-next-line no-shadow export enum ShowHeaderMode { Never = 'never', Always = 'always', @@ -330,7 +332,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck, this.singleClickStreamSub = singleClickStream.subscribe((dataRowEvents: DataRowEvent[]) => { const event: DataRowEvent = dataRowEvents[0]; - this.handleRowSelection(event.value, event.event); + this.handleRowSelection(event.value, event.event as any); this.rowClick.emit(event); if (!event.defaultPrevented) { this.elementRef.nativeElement.dispatchEvent( @@ -431,7 +433,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck, public getSchemaFromHtml(): any { let schema = []; if (this.columnList && this.columnList.columns && this.columnList.columns.length > 0) { - schema = this.columnList.columns.map((c) => c); + schema = this.columnList.columns.map((c) => c as DataColumn); } return schema; } @@ -515,8 +517,8 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck, onRowKeyUp(row: DataRow, keyboardEvent: KeyboardEvent) { const event = new CustomEvent('row-keyup', { detail: { - row: row, - keyboardEvent: keyboardEvent, + row, + keyboardEvent, sender: this }, bubbles: true @@ -613,7 +615,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck, onImageLoadingError(event: Event, row: DataRow) { if (event) { - const element = event.target; + const element = event.target as any; if (this.fallbackThumbnail) { element.src = this.fallbackThumbnail; @@ -749,9 +751,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck, } getSortableColumns() { - return this.data.getColumns().filter((column) => { - return column.sortable === true; - }); + return this.data.getColumns().filter((column) => column.sortable === true); } isEmpty() { @@ -778,7 +778,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck, private emitRowSelectionEvent(name: string, row: DataRow) { const domEvent = new CustomEvent(name, { detail: { - row: row, + row, selection: this.selection }, bubbles: true @@ -823,9 +823,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck, } getNameColumnValue() { - return this.data.getColumns().find( (el: any) => { - return el.key.includes('name'); - }); + return this.data.getColumns().find( (el: any) => el.key.includes('name')); } getAutomationValue(row: DataRow): any { diff --git a/lib/core/datatable/components/json-cell/json-cell.component.spec.ts b/lib/core/datatable/components/json-cell/json-cell.component.spec.ts index 3c6cd4efa4..0b35a2cd9f 100644 --- a/lib/core/datatable/components/json-cell/json-cell.component.spec.ts +++ b/lib/core/datatable/components/json-cell/json-cell.component.spec.ts @@ -47,9 +47,9 @@ describe('JsonCellComponent', () => { rowData = { name: '1', entity: { - 'name': 'test', - 'description': 'this is a test', - 'version': 1 + name: 'test', + description: 'this is a test', + version: 1 } }; diff --git a/lib/core/datatable/data/data-table.schema.ts b/lib/core/datatable/data/data-table.schema.ts index 98501c64f5..8abbc6858b 100644 --- a/lib/core/datatable/data/data-table.schema.ts +++ b/lib/core/datatable/data/data-table.schema.ts @@ -67,7 +67,7 @@ export abstract class DataTableSchema { public getSchemaFromHtml(columnList: DataColumnListComponent): any { let schema = []; if (columnList && columnList.columns && columnList.columns.length > 0) { - schema = columnList.columns.map((c) => c); + schema = columnList.columns.map((c) => c as DataColumn); } return schema; } diff --git a/lib/core/datatable/data/datatable-adapter.ts b/lib/core/datatable/data/datatable-adapter.ts index b1719baac7..49400b8add 100644 --- a/lib/core/datatable/data/datatable-adapter.ts +++ b/lib/core/datatable/data/datatable-adapter.ts @@ -28,7 +28,7 @@ export interface DataTableAdapter { setRows(rows: Array): void; getColumns(): Array; setColumns(columns: Array): void; - getValue(row: DataRow, col: DataColumn, resolverFn?: (row: DataRow, col: DataColumn) => any): any; + getValue(row: DataRow, col: DataColumn, resolverFn?: (_row: DataRow, _col: DataColumn) => any): any; getSorting(): DataSorting; setSorting(sorting: DataSorting): void; sort(key?: string, direction?: string): void; diff --git a/lib/core/datatable/data/object-datatable-adapter.spec.ts b/lib/core/datatable/data/object-datatable-adapter.spec.ts index db74d57944..6bdc010f26 100644 --- a/lib/core/datatable/data/object-datatable-adapter.spec.ts +++ b/lib/core/datatable/data/object-datatable-adapter.spec.ts @@ -47,8 +47,8 @@ describe('ObjectDataTableAdapter', () => { it('should map columns without rows', () => { const adapter = new ObjectDataTableAdapter(null, [ - {}, - {} + {} as DataColumn, + {} as DataColumn ]); const columns = adapter.getColumns(); @@ -64,10 +64,7 @@ describe('ObjectDataTableAdapter', () => { it('should apply new rows array', () => { const adapter = new ObjectDataTableAdapter([], []); - const newRows = [ - {}, - {} - ]; + const newRows = [{}, {}] as DataRow[]; adapter.setRows(newRows); expect(adapter.getRows()).toBe(newRows); @@ -102,10 +99,7 @@ describe('ObjectDataTableAdapter', () => { it('should apply new columns array', () => { const adapter = new ObjectDataTableAdapter([], []); - const columns = [ - {}, - {} - ]; + const columns = [{},{}] as DataColumn[]; adapter.setColumns(columns); expect(adapter.getColumns()).toBe(columns); @@ -123,8 +117,8 @@ describe('ObjectDataTableAdapter', () => { it('should reset columns by null value', () => { const adapter = new ObjectDataTableAdapter([], [ - {}, - {} + {} as DataColumn, + {} as DataColumn ]); expect(adapter.getColumns()).toBeDefined(); expect(adapter.getColumns().length).toBe(2); @@ -144,7 +138,7 @@ describe('ObjectDataTableAdapter', () => { it('should fail getting value with column not defined', () => { const adapter = new ObjectDataTableAdapter([], []); expect(() => { - adapter.getValue( {}, null); + adapter.getValue({} as DataRow, null); }).toThrowError('Column not found'); }); @@ -155,7 +149,7 @@ describe('ObjectDataTableAdapter', () => { row.getValue.and.returnValue(value); const adapter = new ObjectDataTableAdapter([], []); - const result = adapter.getValue(row, { key: 'col1' }); + const result = adapter.getValue(row, { key: 'col1' } as DataColumn); expect(row.getValue).toHaveBeenCalledWith('col1'); expect(result).toBe(value); @@ -206,7 +200,7 @@ describe('ObjectDataTableAdapter', () => { it('should take first sortable column by default', () => { const adapter = new ObjectDataTableAdapter([], [ - { key: 'icon' }, + { key: 'icon' } as DataColumn, new ObjectDataColumn({ key: 'id', sortable: true }) ]); @@ -225,8 +219,8 @@ describe('ObjectDataTableAdapter', () => { { id: 2, created: new Date(2016, 7, 6, 15, 7, 1) } ], [ - { key: 'id' }, - { key: 'created' } + { key: 'id' } as DataColumn, + { key: 'created' } as DataColumn ] ); @@ -304,9 +298,7 @@ describe('ObjectDataTableAdapter', () => { describe('ObjectDataRow', () => { it('should require object source', () => { - expect(() => { - return new ObjectDataRow(null); - }).toThrowError('Object source not found'); + expect(() => new ObjectDataRow(null)).toThrowError('Object source not found'); }); it('should get top level property value', () => { diff --git a/lib/core/datatable/data/object-datatable-adapter.ts b/lib/core/datatable/data/object-datatable-adapter.ts index 7c0e036d80..e9b1af41fc 100644 --- a/lib/core/datatable/data/object-datatable-adapter.ts +++ b/lib/core/datatable/data/object-datatable-adapter.ts @@ -44,7 +44,7 @@ export class ObjectDataTableAdapter implements DataTableAdapter { if (rowToExaminate.hasOwnProperty(key)) { schema.push({ type: 'text', - key: key, + key, title: key, sortable: false }); @@ -61,15 +61,11 @@ export class ObjectDataTableAdapter implements DataTableAdapter { this._columns = []; if (data && data.length > 0) { - this._rows = data.map((item) => { - return new ObjectDataRow(item); - }); + this._rows = data.map((item) => new ObjectDataRow(item)); } if (schema && schema.length > 0) { - this._columns = schema.map((item) => { - return new ObjectDataColumn(item); - }); + this._columns = schema.map((item) => new ObjectDataColumn(item)); // Sort by first sortable or just first column const sortable = this._columns.filter((column) => column.sortable); @@ -99,7 +95,7 @@ export class ObjectDataTableAdapter implements DataTableAdapter { this._columns = columns || []; } - getValue(row: DataRow, col: DataColumn, resolver?: (row: DataRow, col: DataColumn) => any ): any { + getValue(row: DataRow, col: DataColumn, resolver?: (_row: DataRow, _col: DataColumn) => any ): any { if (!row) { throw new Error('Row not found'); } diff --git a/lib/core/dialogs/download-zip/download-zip.dialog.spec.ts b/lib/core/dialogs/download-zip/download-zip.dialog.spec.ts index e47c465514..9e340ce314 100755 --- a/lib/core/dialogs/download-zip/download-zip.dialog.spec.ts +++ b/lib/core/dialogs/download-zip/download-zip.dialog.spec.ts @@ -93,41 +93,35 @@ describe('DownloadZipDialogComponent', () => { }); it('should call cancelDownload when CANCEL button is clicked', () => { - spyOn(downloadZipService, 'createDownload').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(downloadZipService, 'createDownload').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); fixture.detectChanges(); spyOn(component, 'cancelDownload'); - const cancelButton: HTMLButtonElement = element.querySelector('#cancel-button'); + const cancelButton = element.querySelector('#cancel-button'); cancelButton.click(); expect(component.cancelDownload).toHaveBeenCalled(); }); it('should call createDownload when component is initialize', () => { - const createDownloadSpy = spyOn(downloadZipService, 'createDownload').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + const createDownloadSpy = spyOn(downloadZipService, 'createDownload').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); fixture.detectChanges(); expect(createDownloadSpy).toHaveBeenCalled(); }); it('should close dialog when download is completed', () => { - spyOn(downloadZipService, 'createDownload').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(downloadZipService, 'createDownload').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); component.download('fakeUrl', 'fileName'); spyOn(component, 'cancelDownload'); @@ -136,12 +130,10 @@ describe('DownloadZipDialogComponent', () => { }); it('should close dialog when download is cancelled', () => { - spyOn(downloadZipService, 'createDownload').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(downloadZipService, 'createDownload').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); fixture.detectChanges(); component.download('url', 'filename'); @@ -159,7 +151,7 @@ describe('DownloadZipDialogComponent', () => { expect(component.downloadZip).toHaveBeenCalled(); - const cancelButton: HTMLButtonElement = element.querySelector('#cancel-button'); + const cancelButton = element.querySelector('#cancel-button'); cancelButton.click(); expect(component.cancelDownload).toHaveBeenCalled(); diff --git a/lib/core/dialogs/download-zip/download-zip.dialog.ts b/lib/core/dialogs/download-zip/download-zip.dialog.ts index 05e2258fe1..e0f91d2802 100755 --- a/lib/core/dialogs/download-zip/download-zip.dialog.ts +++ b/lib/core/dialogs/download-zip/download-zip.dialog.ts @@ -27,7 +27,7 @@ import { NodesApiService } from '../../services/nodes-api.service'; selector: 'adf-download-zip-dialog', templateUrl: './download-zip.dialog.html', styleUrls: ['./download-zip.dialog.scss'], - host: { 'class': 'adf-download-zip-dialog' }, + host: { class: 'adf-download-zip-dialog' }, encapsulation: ViewEncapsulation.None }) export class DownloadZipDialogComponent implements OnInit { diff --git a/lib/core/directives/check-allowable-operation.directive.spec.ts b/lib/core/directives/check-allowable-operation.directive.spec.ts index 2ff7428263..c8eee0dbee 100644 --- a/lib/core/directives/check-allowable-operation.directive.spec.ts +++ b/lib/core/directives/check-allowable-operation.directive.spec.ts @@ -43,7 +43,7 @@ describe('CheckAllowableOperationDirective', () => { }); beforeEach(() => { - changeDetectorMock = { detectChanges: () => {} }; + changeDetectorMock = { detectChanges: () => {} } as ChangeDetectorRef; }); describe('HTML nativeElement as subject', () => { @@ -107,7 +107,7 @@ describe('CheckAllowableOperationDirective', () => { const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock); spyOn(directive, 'enableElement').and.stub(); - directive.nodes = [{}, {}]; + directive.nodes = [{}, {}] as any[]; expect(directive.updateElement()).toBeTruthy(); expect(directive.enableElement).toHaveBeenCalled(); @@ -120,7 +120,7 @@ describe('CheckAllowableOperationDirective', () => { const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock); spyOn(directive, 'disableElement').and.stub(); - directive.nodes = [{}, {}]; + directive.nodes = [{}, {}] as any[]; expect(directive.updateElement()).toBeFalsy(); expect(directive.disableElement).toHaveBeenCalled(); @@ -137,7 +137,7 @@ describe('CheckAllowableOperationDirective', () => { const testComponent = new TestComponent(); testComponent.disabled = false; const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock, testComponent); - directive.nodes = [{}, {}]; + directive.nodes = [{}, {}] as any[]; directive.updateElement(); @@ -153,7 +153,7 @@ describe('CheckAllowableOperationDirective', () => { const testComponent = new TestComponent(); testComponent.disabled = true; const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock, testComponent); - directive.nodes = [{}, {}]; + directive.nodes = [{}, {}] as any[]; directive.updateElement(); diff --git a/lib/core/directives/highlight.directive.spec.ts b/lib/core/directives/highlight.directive.spec.ts index 95c6ccd603..f8b09d8c65 100644 --- a/lib/core/directives/highlight.directive.spec.ts +++ b/lib/core/directives/highlight.directive.spec.ts @@ -116,7 +116,7 @@ describe('HighlightDirective', () => { const highlighter = TestBed.inject(HighlightTransformService); spyOn(highlighter, 'highlight').and.callThrough(); - const callback = function() { + const callback = () => { component.highlightDirectives.first.highlight('raddish', ''); fixture.detectChanges(); }; diff --git a/lib/core/directives/logout.directive.ts b/lib/core/directives/logout.directive.ts index 83bfb3bdbf..abab05470c 100644 --- a/lib/core/directives/logout.directive.ts +++ b/lib/core/directives/logout.directive.ts @@ -50,7 +50,7 @@ export class LogoutDirective implements OnInit { } } - getRedirectUri () { + getRedirectUri() { if (this.redirectUri === undefined ) { return this.appConfig.get('loginRoute', '/login'); } diff --git a/lib/core/directives/node-delete.directive.spec.ts b/lib/core/directives/node-delete.directive.spec.ts index 94a92d481d..769218d89c 100644 --- a/lib/core/directives/node-delete.directive.spec.ts +++ b/lib/core/directives/node-delete.directive.spec.ts @@ -137,7 +137,7 @@ describe('NodeDeleteDirective', () => { }); it('should process node successfully', (done) => { - component.selection = [{ entry: { id: '1', name: 'name1' } }]; + component.selection = [{ entry: { id: '1', name: 'name1' } }]; disposableDelete = component.deleteDirective.delete.subscribe((message) => { expect(message).toBe( @@ -272,7 +272,7 @@ describe('NodeDeleteDirective', () => { }); it('should emit event when delete is done', (done) => { - component.selection = [{ entry: { id: '1', name: 'name1' } }]; + component.selection = [{ entry: { id: '1', name: 'name1' } }]; fixture.detectChanges(); element.nativeElement.click(); diff --git a/lib/core/directives/node-delete.directive.ts b/lib/core/directives/node-delete.directive.ts index 27cf49bb38..2902765eff 100644 --- a/lib/core/directives/node-delete.directive.ts +++ b/lib/core/directives/node-delete.directive.ts @@ -120,7 +120,7 @@ export class NodeDeleteDirective implements OnChanges { } private deleteNode(node: NodeEntry | DeletedNodeEntity): Observable { - const id = ( node.entry).nodeId || node.entry.id; + const id = (node.entry as any).nodeId || node.entry.id; let promise: Promise; diff --git a/lib/core/directives/node-download.directive.ts b/lib/core/directives/node-download.directive.ts index 73d103eb2f..981fef5508 100755 --- a/lib/core/directives/node-download.directive.ts +++ b/lib/core/directives/node-download.directive.ts @@ -59,6 +59,7 @@ export class NodeDownloadDirective { /** * Downloads multiple selected nodes. * Packs result into a .ZIP archive if there is more than one node selected. + * * @param selection Multiple selected nodes to download */ downloadNodes(selection: NodeEntry | Array) { @@ -80,6 +81,7 @@ export class NodeDownloadDirective { /** * Downloads a single node. * Packs result into a .ZIP archive is the node is a Folder. + * * @param node Node to download */ downloadNode(node: NodeEntry) { @@ -95,7 +97,7 @@ export class NodeDownloadDirective { } // Check if there's nodeId for Shared Files - if (!entry.isFile && !entry.isFolder && ( entry).nodeId) { + if (!entry.isFile && !entry.isFolder && (entry as any).nodeId) { this.downloadFile(node); } } @@ -108,7 +110,7 @@ export class NodeDownloadDirective { private downloadFile(node: NodeEntry) { if (node && node.entry) { // nodeId for Shared node - const id = ( node.entry).nodeId || node.entry.id; + const id = (node.entry as any).nodeId || node.entry.id; let url; let fileName; diff --git a/lib/core/directives/node-favorite.directive.spec.ts b/lib/core/directives/node-favorite.directive.spec.ts index d9707961ae..8a7b179133 100644 --- a/lib/core/directives/node-favorite.directive.spec.ts +++ b/lib/core/directives/node-favorite.directive.spec.ts @@ -45,7 +45,7 @@ describe('NodeFavoriteDirective', () => { spyOn(directive, 'markFavoritesNodes'); const change = new SimpleChange(null, [], true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); expect(directive.markFavoritesNodes).not.toHaveBeenCalledWith(); }); @@ -56,7 +56,7 @@ describe('NodeFavoriteDirective', () => { let selection = [{ entry: { id: '1', name: 'name1' } }]; let change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); expect(directive.markFavoritesNodes).toHaveBeenCalledWith(selection); @@ -66,7 +66,7 @@ describe('NodeFavoriteDirective', () => { ]; change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); expect(directive.markFavoritesNodes).toHaveBeenCalledWith(selection); }); @@ -79,13 +79,13 @@ describe('NodeFavoriteDirective', () => { ]; let change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); expect(directive.hasFavorites()).toBe(true); change = new SimpleChange(null, [], true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); expect(directive.hasFavorites()).toBe(false); @@ -107,7 +107,7 @@ describe('NodeFavoriteDirective', () => { ]; const change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); expect(favoritesApiSpy.calls.count()).toBe(2); @@ -121,7 +121,7 @@ describe('NodeFavoriteDirective', () => { ]; let change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); expect(directive.favorites.length).toBe(2); @@ -134,7 +134,7 @@ describe('NodeFavoriteDirective', () => { ]; change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); expect(directive.favorites.length).toBe(1); @@ -148,7 +148,7 @@ describe('NodeFavoriteDirective', () => { ]; let change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); @@ -164,7 +164,7 @@ describe('NodeFavoriteDirective', () => { ]; change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); expect(directive.favorites.length).toBe(3); @@ -188,7 +188,7 @@ describe('NodeFavoriteDirective', () => { it('should not perform action if favorites collection is empty', fakeAsync(() => { const change = new SimpleChange(null, [], true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); directive.toggleFavorite(); @@ -333,7 +333,7 @@ describe('NodeFavoriteDirective', () => { ]; const change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); expect(directive.favorites[0].entry.isFavorite).toBe(true); @@ -348,7 +348,7 @@ describe('NodeFavoriteDirective', () => { ]; const change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); expect(directive.favorites[0].entry.isFavorite).toBe(true); @@ -362,7 +362,7 @@ describe('NodeFavoriteDirective', () => { ]; const change = new SimpleChange(null, selection, true); - directive.ngOnChanges({'selection': change}); + directive.ngOnChanges({selection: change}); tick(); expect(directive.favorites[0].entry.isFavorite).toBe(false); diff --git a/lib/core/directives/node-favorite.directive.ts b/lib/core/directives/node-favorite.directive.ts index 48cf78f5b4..6b2cbf669b 100644 --- a/lib/core/directives/node-favorite.directive.ts +++ b/lib/core/directives/node-favorite.directive.ts @@ -74,7 +74,7 @@ export class NodeFavoriteDirective implements OnChanges { if (every) { const batch = this.favorites.map((selected: NodeEntry | SharedLinkEntry) => { // shared files have nodeId - const id = ( selected).entry.nodeId || selected.entry.id; + const id = (selected as SharedLinkEntry).entry.nodeId || selected.entry.id; return from(this.favoritesApi.deleteFavorite('-me-', id)); }); @@ -92,7 +92,7 @@ export class NodeFavoriteDirective implements OnChanges { const notFavorite = this.favorites.filter((node) => !node.entry.isFavorite); const body: FavoriteBody[] = notFavorite.map((node) => this.createFavoriteBody(node)); - from(this.favoritesApi.createFavorite('-me-', body)) + from(this.favoritesApi.createFavorite('-me-', body as any)) .subscribe( () => { notFavorite.map((selected) => selected.entry.isFavorite = true); @@ -138,8 +138,8 @@ export class NodeFavoriteDirective implements OnChanges { } // ACS 5.x and 6.x without 'isFavorite' include - const { name, isFile, isFolder } = node; - const id = ( node).nodeId || node.id; + const { name, isFile, isFolder } = node as Node; + const id = (node as SharedLink).nodeId || node.id; const promise = this.favoritesApi.getFavorite('-me-', id); @@ -153,17 +153,15 @@ export class NodeFavoriteDirective implements OnChanges { isFavorite: true } })), - catchError(() => { - return of({ - entry: { - id, - isFolder, - isFile, - name, - isFavorite: false - } - }); - }) + catchError(() => of({ + entry: { + id, + isFolder, + isFile, + name, + isFavorite: false + } + })) ); } diff --git a/lib/core/directives/node-restore.directive.spec.ts b/lib/core/directives/node-restore.directive.spec.ts index 5e4da1c62c..2a6329726f 100644 --- a/lib/core/directives/node-restore.directive.spec.ts +++ b/lib/core/directives/node-restore.directive.spec.ts @@ -69,9 +69,7 @@ describe('NodeRestoreDirective', () => { })); translationService = TestBed.inject(TranslationService); - spyOn(translationService, 'instant').and.callFake((key) => { - return key; - }); + spyOn(translationService, 'instant').and.callFake((key) => key); }); it('should not restore when selection is empty', () => { @@ -240,9 +238,7 @@ describe('NodeRestoreDirective', () => { done(); }); - restoreNodeSpy.and.callFake(() => { - return Promise.resolve(); - }); + restoreNodeSpy.and.callFake(() => Promise.resolve()); component.selection = [ { entry: { id: '1', name: 'name1', path: ['somewhere-over-the-rainbow'] } }, diff --git a/lib/core/directives/node-restore.directive.ts b/lib/core/directives/node-restore.directive.ts index f920714e74..7008b51d62 100644 --- a/lib/core/directives/node-restore.directive.ts +++ b/lib/core/directives/node-restore.directive.ts @@ -256,9 +256,9 @@ export class NodeRestoreDirective { path = status.success[0].entry.path; } this.restore.emit({ - message: message, - action: action, - path: path + message, + action, + path }); } diff --git a/lib/core/directives/upload.directive.spec.ts b/lib/core/directives/upload.directive.spec.ts index 4d7743dbe2..d9a50a0140 100644 --- a/lib/core/directives/upload.directive.spec.ts +++ b/lib/core/directives/upload.directive.spec.ts @@ -16,7 +16,6 @@ */ import { ElementRef } from '@angular/core'; -import { FileInfo } from './../utils/file-utils'; import { UploadDirective } from './upload.directive'; describe('UploadDirective', () => { @@ -89,21 +88,21 @@ describe('UploadDirective', () => { it('should prevent default event on drop', () => { directive.enabled = true; const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']); - directive.onDrop( event); + directive.onDrop(event); expect(event.preventDefault).toHaveBeenCalled(); }); it('should stop default event propagation on drop', () => { directive.enabled = true; const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']); - directive.onDrop( event); + directive.onDrop(event); expect(event.stopPropagation).toHaveBeenCalled(); }); it('should not prevent default event on drop when disabled', () => { directive.enabled = false; const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']); - directive.onDrop( event); + directive.onDrop(event); expect(event.preventDefault).not.toHaveBeenCalled(); }); @@ -111,10 +110,7 @@ describe('UploadDirective', () => { directive.enabled = true; const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']); spyOn(directive, 'getDataTransfer').and.returnValue({} as any); - spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve([ - {}, - {} - ])); + spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve([{}, {}])); spyOn(nativeElement, 'dispatchEvent').and.callFake((_) => { done(); }); @@ -123,9 +119,7 @@ describe('UploadDirective', () => { it('should provide dropped files in upload-files event', (done) => { directive.enabled = true; - const files = [ - {} - ]; + const files = [{}]; const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']); spyOn(directive, 'getDataTransfer').and.returnValue({} as any); spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve(files)); @@ -141,10 +135,8 @@ describe('UploadDirective', () => { it('should reset input value after file upload', () => { directive.enabled = true; directive.mode = ['click']; - const files = [ - {} - ]; - const event = {'currentTarget': {'files': files}, 'target': {'value': '/testpath/document.pdf'}}; + const files = [{}]; + const event = {currentTarget: {files}, target: {value: '/testpath/document.pdf'}}; directive.onSelectFiles(event); expect(event.target.value).toBe(''); diff --git a/lib/core/directives/upload.directive.ts b/lib/core/directives/upload.directive.ts index 796297a0df..30cb834cee 100644 --- a/lib/core/directives/upload.directive.ts +++ b/lib/core/directives/upload.directive.ts @@ -159,7 +159,7 @@ export class UploadDirective implements OnInit, OnDestroy { detail: { sender: this, data: this.data, - files: files + files }, bubbles: true }); @@ -192,6 +192,7 @@ export class UploadDirective implements OnInit, OnDestroy { /** * Extract files from the DataTransfer object used to hold the data that is being dragged during a drag and drop operation. + * * @param dataTransfer DataTransfer object */ getFilesDropped(dataTransfer: DataTransfer): Promise { @@ -206,7 +207,7 @@ export class UploadDirective implements OnInit, OnDestroy { const item = items[i].webkitGetAsEntry(); if (item) { if (item.isFile) { - iterations.push(Promise.resolve( { + iterations.push(Promise.resolve({ entry: item, file: items[i].getAsFile(), relativeFolder: '/' @@ -218,7 +219,7 @@ export class UploadDirective implements OnInit, OnDestroy { } } } else { - iterations.push(Promise.resolve( { + iterations.push(Promise.resolve({ entry: null, file: items[i].getAsFile(), relativeFolder: '/' @@ -229,11 +230,11 @@ export class UploadDirective implements OnInit, OnDestroy { // safari or FF const files = FileUtils .toFileArray(dataTransfer.files) - .map((file) => { + .map((file) => ({ entry: null, - file: file, + file, relativeFolder: '/' - }); + })); iterations.push(Promise.resolve(files)); } @@ -247,17 +248,18 @@ export class UploadDirective implements OnInit, OnDestroy { /** * Invoked when user selects files or folders by means of File Dialog + * * @param event DOM event */ onSelectFiles(event: any): void { if (this.isClickMode()) { - const input = ( event.currentTarget); + const input = event.currentTarget; const files = FileUtils.toFileArray(input.files); - this.onUploadFiles(files.map((file) => { + this.onUploadFiles(files.map((file) => ({ entry: null, - file: file, + file, relativeFolder: '/' - })); + }))); event.target.value = ''; } } diff --git a/lib/core/form/components/form-base.component.ts b/lib/core/form/components/form-base.component.ts index 3df64b85d1..8bdfa9450a 100644 --- a/lib/core/form/components/form-base.component.ts +++ b/lib/core/form/components/form-base.component.ts @@ -157,6 +157,7 @@ export abstract class FormBaseComponent { /** * Invoked when user clicks outcome button. + * * @param outcome Form outcome model */ onOutcomeClicked(outcome: FormOutcomeModel): boolean { diff --git a/lib/core/form/components/form-field/form-field.component.ts b/lib/core/form/components/form-field/form-field.component.ts index 597ebd1dba..49ef7bc62b 100644 --- a/lib/core/form/components/form-field/form-field.component.ts +++ b/lib/core/form/components/form-field/form-field.component.ts @@ -33,7 +33,6 @@ import { import { FormRenderingService } from './../../services/form-rendering.service'; import { WidgetVisibilityService } from './../../services/widget-visibility.service'; import { FormFieldModel } from './../widgets/core/form-field.model'; -import { WidgetComponent } from './../widgets/widget.component'; declare const adf: any; @@ -93,7 +92,7 @@ export class FormFieldComponent implements OnInit, OnDestroy { if (componentType) { const factory = this.componentFactoryResolver.resolveComponentFactory(componentType); this.componentRef = this.container.createComponent(factory); - const instance = this.componentRef.instance; + const instance = this.componentRef.instance; instance.field = this.field; instance.fieldChanged.subscribe((field) => { if (field && this.field.form) { @@ -136,7 +135,7 @@ export class FormFieldComponent implements OnInit, OnDestroy { const metadata = { selector: `runtime-component-${type}`, - template: template + template }; const factory = this.createComponentFactorySync(this.compiler, metadata, componentInfo.class); diff --git a/lib/core/form/components/form-renderer.component.spec.ts b/lib/core/form/components/form-renderer.component.spec.ts index 76483679f8..9f349b407f 100644 --- a/lib/core/form/components/form-renderer.component.spec.ts +++ b/lib/core/form/components/form-renderer.component.spec.ts @@ -44,45 +44,45 @@ import { TextWidgetComponent } from './widgets'; import { By } from '@angular/platform-browser'; import { DebugElement } from '@angular/core'; -function typeIntoInput(targetInput: HTMLInputElement, message: string) { +const typeIntoInput = (targetInput: HTMLInputElement, message: string) => { expect(targetInput).not.toBeNull('Expected input to set to be valid and not null'); targetInput.value = message; targetInput.dispatchEvent(new Event('input')); -} +}; -function typeIntoDate(targetInput: DebugElement, date: { srcElement: { value: string } }) { +const typeIntoDate = (targetInput: DebugElement, date: { srcElement: { value: string } }) => { expect(targetInput).not.toBeNull('Expected input to set to be valid and not null'); targetInput.triggerEventHandler('change', date); -} +}; -function expectElementToBeHidden(targetElement: HTMLElement): void { +const expectElementToBeHidden = (targetElement: HTMLElement): void => { expect(targetElement).not.toBeNull(); expect(targetElement).toBeDefined(); expect(targetElement.hidden).toBe(true, `${targetElement.id} should be hidden but it is not`); -} +}; -function expectElementToBeVisible(targetElement: HTMLElement): void { +const expectElementToBeVisible = (targetElement: HTMLElement): void => { expect(targetElement).not.toBeNull(); expect(targetElement).toBeDefined(); expect(targetElement.hidden).toBe(false, `${targetElement.id} should be visibile but it is not`); -} +}; -function expectInputElementValueIs(targetElement: HTMLInputElement, value: string): void { +const expectInputElementValueIs = (targetElement: HTMLInputElement, value: string): void => { expect(targetElement).not.toBeNull(); expect(targetElement).toBeDefined(); expect(targetElement.value).toBe(value, `invalid value for ${targetElement.name}`); -} +}; -function expectElementToBeInvalid(fieldId: string, fixture: ComponentFixture): void { +const expectElementToBeInvalid = (fieldId: string, fixture: ComponentFixture): void => { const invalidElementContainer = fixture.nativeElement.querySelector(`#field-${fieldId}-container .adf-invalid`); expect(invalidElementContainer).not.toBeNull(); expect(invalidElementContainer).toBeDefined(); -} +}; -function expectElementToBeValid(fieldId: string, fixture: ComponentFixture): void { +const expectElementToBeValid = (fieldId: string, fixture: ComponentFixture): void => { const invalidElementContainer = fixture.nativeElement.querySelector(`#field-${fieldId}-container .adf-invalid`); expect(invalidElementContainer).toBeNull(); -} +}; describe('Form Renderer Component', () => { @@ -630,7 +630,7 @@ describe('Form Renderer Component', () => { describe('Custom Widget', () => { it('Should be able to correctly display a custom process cloud widget', async () => { - formRenderingService.register({ 'bananaforevah': () => TextWidgetComponent }, true); + formRenderingService.register({ bananaforevah: () => TextWidgetComponent }, true); formRendererComponent.formDefinition = formService.parseForm(customWidgetForm.formRepresentation.formDefinition); fixture.detectChanges(); await fixture.whenStable(); @@ -641,7 +641,7 @@ describe('Form Renderer Component', () => { }); it('Should be able to correctly use visibility in a custom process cloud widget ', async () => { - formRenderingService.register({ 'bananaforevah': () => TextWidgetComponent }, true); + formRenderingService.register({ bananaforevah: () => TextWidgetComponent }, true); formRendererComponent.formDefinition = formService.parseForm(customWidgetFormWithVisibility.formRepresentation.formDefinition); fixture.detectChanges(); await fixture.whenStable(); diff --git a/lib/core/form/components/mock/form-renderer.component.mock.ts b/lib/core/form/components/mock/form-renderer.component.mock.ts index 0ac3af0b2d..ffcdb9874e 100644 --- a/lib/core/form/components/mock/form-renderer.component.mock.ts +++ b/lib/core/form/components/mock/form-renderer.component.mock.ts @@ -32,7 +32,7 @@ export const formDisplayValueVisibility = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Text0bq3ar', name: 'Text', @@ -47,7 +47,7 @@ export const formDisplayValueVisibility = { params: { existingColspan: 1, maxColspan: 2 } } ], - '2': [ + 2: [ { id: 'Displayvalue0g6092', name: 'Display value', @@ -101,7 +101,7 @@ export const formDisplayValueForm = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'DisplayValueColspan', name: 'DisplayValueColspan', @@ -240,7 +240,7 @@ export const formDisplayValueForm = { } } ], - '2': [ + 2: [ { id: 'Text0howrc', name: 'Text', @@ -342,7 +342,7 @@ export const formDisplayValueCombinedVisibility = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Text0bq3ar', name: 'Text', @@ -357,7 +357,7 @@ export const formDisplayValueCombinedVisibility = { params: { existingColspan: 1, maxColspan: 2 } } ], - '2': [ + 2: [ { id: 'Displayvalue0g6092', name: 'Display value', @@ -402,7 +402,7 @@ export const formDisplayValueCombinedVisibility = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'TextTwo', name: 'TextTwo', @@ -417,7 +417,7 @@ export const formDisplayValueCombinedVisibility = { params: { existingColspan: 1, maxColspan: 2 } } ], - '2': [] + 2: [] } } ], @@ -445,7 +445,7 @@ export const formNumberWidgetVisibility = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Number1', name: 'Number1', @@ -462,7 +462,7 @@ export const formNumberWidgetVisibility = { } } ], - '2': [ + 2: [ { id: 'Number2', name: 'Number2', @@ -520,7 +520,7 @@ export const formNumberTextJson = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'NumberColspan', name: 'NumberColspan', @@ -582,7 +582,7 @@ export const formNumberTextJson = { } } ], - '2': [ + 2: [ { id: 'Text', name: 'Text', @@ -763,7 +763,7 @@ export const formRequiredNumberWidget = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Number1', name: 'Number1', @@ -780,7 +780,7 @@ export const formRequiredNumberWidget = { } } ], - '2': [ + 2: [ { id: 'Number2', name: 'Number2', @@ -839,7 +839,7 @@ export const colspanForm = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Number0u0kiv', name: 'NumberColspan', @@ -866,7 +866,7 @@ export const colspanForm = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Number00fuuk', name: 'Number', @@ -884,7 +884,7 @@ export const colspanForm = { } } ], - '2': [ + 2: [ { id: 'Number03u9d4', name: 'Number', @@ -911,7 +911,7 @@ export const colspanForm = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Text04sjhr', name: 'Text', @@ -957,7 +957,7 @@ export const numberNotRequiredForm = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Number0x8cbv', name: 'Number', @@ -971,7 +971,7 @@ export const numberNotRequiredForm = { params: { existingColspan: 1, maxColspan: 2 } } ], - '2': [] + 2: [] } } ], @@ -999,7 +999,7 @@ export const numberMinMaxForm = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Number0him2z', name: 'Number', @@ -1016,7 +1016,7 @@ export const numberMinMaxForm = { } } ], - '2': [] + 2: [] } } ], @@ -1043,7 +1043,7 @@ export const textWidgetVisibility = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'textOne', name: 'textOne', @@ -1058,7 +1058,7 @@ export const textWidgetVisibility = { params: { existingColspan: 1, maxColspan: 2 } } ], - '2': [ + 2: [ { id: 'textTwo', name: 'textTwo', @@ -1091,7 +1091,7 @@ export const textWidgetVisibility = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'textThree', name: 'textThree', @@ -1125,7 +1125,7 @@ export const textWidgetVisibility = { params: { existingColspan: 1, maxColspan: 2 } } ], - '2': [ + 2: [ { id: 'textFour', name: 'textFour', @@ -1187,7 +1187,7 @@ export const numberWidgetVisibilityForm = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Text0hs0gt', name: 'TextOne', @@ -1236,7 +1236,7 @@ export const numberWidgetVisibilityForm = { } } ], - '2': [ + 2: [ { id: 'Text0cuqet', name: 'TextTwo', @@ -1280,7 +1280,7 @@ export const radioWidgetVisibiltyForm = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Text0cee7g', name: 'Text', @@ -1295,7 +1295,7 @@ export const radioWidgetVisibiltyForm = { params: { existingColspan: 1, maxColspan: 2 } } ], - '2': [ + 2: [ { id: 'Radiobuttons03rkbo', name: 'Radio buttons', @@ -1352,7 +1352,7 @@ export const customWidgetForm = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Text0vdi18', name: 'herejustoshowstandardones', @@ -1371,7 +1371,7 @@ export const customWidgetForm = { } } ], - '2': [ + 2: [ { id: 'bananaforevah0k8gui', name: 'bananaforevah', @@ -1416,7 +1416,7 @@ export const customWidgetFormWithVisibility = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Text0vdi18', name: 'herejustoshowstandardones', @@ -1435,7 +1435,7 @@ export const customWidgetFormWithVisibility = { } } ], - '2': [ + 2: [ { id: 'bananaforevah0k8gui', name: 'bananaforevah', @@ -1488,7 +1488,7 @@ export const formDateVisibility = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Date0hwq20', name: 'Date', @@ -1508,7 +1508,7 @@ export const formDateVisibility = { dateDisplayFormat: 'YYYY-MM-DD' } ], - '2': [ + 2: [ { id: 'Text0pqd1u', name: 'Text', @@ -1545,7 +1545,7 @@ export const formDateVisibility = { tab: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { id: 'Text0uyqd3', name: 'Text', @@ -1573,7 +1573,7 @@ export const formDateVisibility = { } } ], - '2': [] + 2: [] } } ], diff --git a/lib/core/form/components/widgets/amount/amount.widget.spec.ts b/lib/core/form/components/widgets/amount/amount.widget.spec.ts index bec94b295b..a6a6707e61 100644 --- a/lib/core/form/components/widgets/amount/amount.widget.spec.ts +++ b/lib/core/form/components/widgets/amount/amount.widget.spec.ts @@ -46,7 +46,7 @@ describe('AmountWidgetComponent', () => { it('should setup currency from field', () => { const currency = 'UAH'; widget.field = new FormFieldModel(null, { - currency: currency + currency }); widget.ngOnInit(); diff --git a/lib/core/form/components/widgets/container/container.widget.model.ts b/lib/core/form/components/widgets/container/container.widget.model.ts index 16192aec31..0bd7587dd7 100644 --- a/lib/core/form/components/widgets/container/container.widget.model.ts +++ b/lib/core/form/components/widgets/container/container.widget.model.ts @@ -37,7 +37,7 @@ export class ContainerWidgetComponentModel extends ContainerModel { let allowCollapse = false; if (this.isGroup() && this.field.params['allowCollapse']) { - allowCollapse = this.field.params['allowCollapse']; + allowCollapse = this.field.params['allowCollapse']; } return allowCollapse; @@ -47,7 +47,7 @@ export class ContainerWidgetComponentModel extends ContainerModel { let collapseByDefault = false; if (this.isCollapsible() && this.field.params['collapseByDefault']) { - collapseByDefault = this.field.params['collapseByDefault']; + collapseByDefault = this.field.params['collapseByDefault']; } return collapseByDefault; diff --git a/lib/core/form/components/widgets/container/container.widget.spec.ts b/lib/core/form/components/widgets/container/container.widget.spec.ts index 7680f0cb72..db4e352260 100644 --- a/lib/core/form/components/widgets/container/container.widget.spec.ts +++ b/lib/core/form/components/widgets/container/container.widget.spec.ts @@ -123,9 +123,9 @@ describe('ContainerWidgetComponent', () => { type: 'container', tab: null, fields: { - '1' : [{ id: '1' }, { id: '2' }, { id: '3' }], - '2' : [{ id: '4' }, { id: '5' }], - '3' : [{ id: '6' }] + 1 : [{ id: '1' }, { id: '2' }, { id: '3' }], + 2 : [{ id: '4' }, { id: '5' }], + 3 : [{ id: '6' }] } }; @@ -150,7 +150,7 @@ describe('ContainerWidgetComponent', () => { type: 'container', tab: null, fields: { - '1': [ + 1: [ { id: 'a', colspan: 2, @@ -192,7 +192,7 @@ describe('ContainerWidgetComponent', () => { rowspan: 1 } ], - '2': [ + 2: [ { id: '1', rowspan: 3, @@ -208,7 +208,7 @@ describe('ContainerWidgetComponent', () => { colspan: 2 } ], - '3': [ + 3: [ { id: 'white' }, @@ -265,8 +265,8 @@ describe('ContainerWidgetComponent', () => { widget.content = container; expect(widget.getColumnWith(undefined)).toBe('25'); - expect(widget.getColumnWith( { colspan: 1 })).toBe('25'); - expect(widget.getColumnWith( { colspan: 3 })).toBe('75'); + expect(widget.getColumnWith({ colspan: 1 } as FormFieldModel)).toBe('25'); + expect(widget.getColumnWith({ colspan: 3 } as FormFieldModel)).toBe('75'); }); }); }); diff --git a/lib/core/form/components/widgets/container/container.widget.ts b/lib/core/form/components/widgets/container/container.widget.ts index 1d07925f31..894b1c3966 100644 --- a/lib/core/form/components/widgets/container/container.widget.ts +++ b/lib/core/form/components/widgets/container/container.widget.ts @@ -97,9 +97,8 @@ export class ContainerWidgetComponent extends WidgetComponent implements OnInit, private getMaxColumnFieldSize(): number { let maxFieldSize = 0; if (this.content?.columns?.length > 0) { - maxFieldSize = this.content?.columns?.reduce((prevColumn, currentColumn) => { - return currentColumn.fields.length > prevColumn?.fields?.length ? currentColumn : prevColumn; - })?.fields?.length; + maxFieldSize = this.content?.columns?.reduce((prevColumn, currentColumn) => + currentColumn.fields.length > prevColumn?.fields?.length ? currentColumn : prevColumn)?.fields?.length; } return maxFieldSize; } diff --git a/lib/core/form/components/widgets/content/content.widget.spec.ts b/lib/core/form/components/widgets/content/content.widget.spec.ts index 41ef62d14e..9515abbbcc 100644 --- a/lib/core/form/components/widgets/content/content.widget.spec.ts +++ b/lib/core/form/components/widgets/content/content.widget.spec.ts @@ -39,12 +39,12 @@ describe('ContentWidgetComponent', () => { let processContentService: ProcessContentService; let serviceContent: ContentService; - function createFakeImageBlob() { + const createFakeImageBlob = () => { const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='); return new Blob([data], { type: 'image/png' }); - } + }; - function createFakePdfBlob(): Blob { + const createFakePdfBlob = (): Blob => { const pdfData = atob( 'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' + 'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' + @@ -60,7 +60,7 @@ describe('ContentWidgetComponent', () => { 'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' + 'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G'); return new Blob([pdfData], { type: 'application/pdf' }); - } + }; setupTestBed({ imports: [ @@ -118,7 +118,7 @@ describe('ContentWidgetComponent', () => { const contentId = 1; const change = new SimpleChange(null, contentId, true); - component.ngOnChanges({ 'id': change }); + component.ngOnChanges({ id: change }); jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, @@ -129,7 +129,7 @@ describe('ContentWidgetComponent', () => { created: 1490354907883, createdBy: { id: 2, - firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com' + firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com' }, relatedContent: false, contentAvailable: true, @@ -161,7 +161,7 @@ describe('ContentWidgetComponent', () => { const contentId = 1; const change = new SimpleChange(null, contentId, true); - component.ngOnChanges({ 'id': change }); + component.ngOnChanges({ id: change }); jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, @@ -172,7 +172,7 @@ describe('ContentWidgetComponent', () => { created: 1490354907883, createdBy: { id: 2, - firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com' + firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com' }, relatedContent: false, contentAvailable: true, @@ -189,7 +189,7 @@ describe('ContentWidgetComponent', () => { const contentId = 1; const change = new SimpleChange(null, contentId, true); - component.ngOnChanges({ 'id': change }); + component.ngOnChanges({ id: change }); component.contentLoaded.subscribe(() => { fixture.detectChanges(); @@ -211,7 +211,7 @@ describe('ContentWidgetComponent', () => { created: 1490354907883, createdBy: { id: 2, - firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com' + firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com' }, relatedContent: false, contentAvailable: false, @@ -235,7 +235,7 @@ describe('ContentWidgetComponent', () => { created: 1490354907883, createdBy: { id: 2, - firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com' + firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com' }, relatedContent: false, contentAvailable: true, @@ -271,7 +271,7 @@ describe('ContentWidgetComponent', () => { created: 1490354907883, createdBy: { id: 2, - firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com' + firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com' }, relatedContent: false, contentAvailable: true, diff --git a/lib/core/form/components/widgets/core/form-field-validator.spec.ts b/lib/core/form/components/widgets/core/form-field-validator.spec.ts index 5d9c0cd711..a5dae7a66e 100644 --- a/lib/core/form/components/widgets/core/form-field-validator.spec.ts +++ b/lib/core/form/components/widgets/core/form-field-validator.spec.ts @@ -78,7 +78,7 @@ describe('FormFieldValidator', () => { required: true }); - field.emptyOption = { id: '' }; + field.emptyOption = { id: '' } as FormFieldOption; expect(validator.validate(field)).toBeFalsy(); field.value = ''; @@ -94,7 +94,7 @@ describe('FormFieldValidator', () => { selectionType: 'multiple' }); - field.emptyOption = { id: 'empty' }; + field.emptyOption = { id: 'empty' } as FormFieldOption; expect(validator.validate(field)).toBeFalsy(); field.value = []; diff --git a/lib/core/form/components/widgets/core/form-field.model.spec.ts b/lib/core/form/components/widgets/core/form-field.model.spec.ts index be14e2c465..99f884e590 100644 --- a/lib/core/form/components/widgets/core/form-field.model.spec.ts +++ b/lib/core/form/components/widgets/core/form-field.model.spec.ts @@ -816,31 +816,31 @@ describe('FormFieldModel', () => { form = new FormModel({ variables: [ { - 'id': 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', - 'name': 'name2', - 'type': 'string', - 'value': 'default hello' + id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', + name: 'name2', + type: 'string', + value: 'default hello' } ], processVariables: [ { - 'serviceName': 'denys-variable-mapping-rb', - 'serviceFullName': 'denys-variable-mapping-rb', - 'serviceVersion': '', - 'appName': 'denys-variable-mapping', - 'appVersion': '', - 'serviceType': null, - 'id': 3, - 'type': 'string', - 'name': 'variables.name1', - 'createTime': 1566989626284, - 'lastUpdatedTime': 1566989626284, - 'executionId': null, - 'value': 'hello', - 'markedAsDeleted': false, - 'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44', - 'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44', - 'taskVariable': true + serviceName: 'denys-variable-mapping-rb', + serviceFullName: 'denys-variable-mapping-rb', + serviceVersion: '', + appName: 'denys-variable-mapping', + appVersion: '', + serviceType: null, + id: 3, + type: 'string', + name: 'variables.name1', + createTime: 1566989626284, + lastUpdatedTime: 1566989626284, + executionId: null, + value: 'hello', + markedAsDeleted: false, + processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44', + taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44', + taskVariable: true } ] }); diff --git a/lib/core/form/components/widgets/core/form-field.model.ts b/lib/core/form/components/widgets/core/form-field.model.ts index 411a3f1018..65817c90ee 100644 --- a/lib/core/form/components/widgets/core/form-field.model.ts +++ b/lib/core/form/components/widgets/core/form-field.model.ts @@ -151,30 +151,30 @@ export class FormFieldModel extends FormWidgetModel { this.name = json.name; this.type = json.type; this.roles = json.roles; - this._required = json.required; - this._readOnly = json.readOnly || json.type === 'readonly'; - this.overrideId = json.overrideId; + this._required = json.required; + this._readOnly = json.readOnly || json.type === 'readonly'; + this.overrideId = json.overrideId; this.tab = json.tab; this.restUrl = json.restUrl; this.restResponsePath = json.restResponsePath; this.restIdProperty = json.restIdProperty; this.restLabelProperty = json.restLabelProperty; - this.colspan = json.colspan; - this.rowspan = json.rowspan; - this.minLength = json.minLength || 0; - this.maxLength = json.maxLength || 0; + this.colspan = json.colspan; + this.rowspan = json.rowspan; + this.minLength = json.minLength || 0; + this.maxLength = json.maxLength || 0; this.minValue = json.minValue; this.maxValue = json.maxValue; this.regexPattern = json.regexPattern; - this.options = json.options || []; - this.hasEmptyValue = json.hasEmptyValue; + this.options = json.options || []; + this.hasEmptyValue = json.hasEmptyValue; this.className = json.className; this.optionType = json.optionType; - this.params = json.params || {}; + this.params = json.params || {}; this.hyperlinkUrl = json.hyperlinkUrl; this.displayText = json.displayText; this.visibilityCondition = json.visibilityCondition ? new WidgetVisibilityModel(json.visibilityCondition) : undefined; - this.enableFractions = json.enableFractions; + this.enableFractions = json.enableFractions; this.currency = json.currency; this.dateDisplayFormat = json.dateDisplayFormat || this.getDefaultDateFormat(json); this._value = this.parseValue(json); @@ -256,7 +256,7 @@ export class FormFieldModel extends FormWidgetModel { } private containerFactory(json: any, form: any): void { - this.numberOfColumns = json.numberOfColumns || 1; + this.numberOfColumns = json.numberOfColumns || 1; this.fields = json.fields; @@ -453,6 +453,7 @@ export class FormFieldModel extends FormWidgetModel { /** * Skip the invalid field type + * * @param type */ isInvalidFieldType(type: string) { diff --git a/lib/core/form/components/widgets/core/form.model.spec.ts b/lib/core/form/components/widgets/core/form.model.spec.ts index 8ac15b8551..617db89bff 100644 --- a/lib/core/form/components/widgets/core/form.model.spec.ts +++ b/lib/core/form/components/widgets/core/form.model.spec.ts @@ -363,9 +363,7 @@ describe('FormModel', () => { }); const field: any = { - validate() { - return true; - } + validate: () => true }; form.validateField(field); @@ -409,14 +407,10 @@ describe('FormModel', () => { spyOn(form, 'getFormFields').and.returnValue([testField]); - const validator = { - isSupported(): boolean { - return true; - }, - validate(): boolean { - return true; - } - }; + const validator = { + isSupported: (): boolean => true, + validate: (): boolean => true + } as FormFieldValidator; spyOn(validator, 'validate').and.callThrough(); @@ -449,7 +443,7 @@ describe('FormModel', () => { const defaultLength = FORM_FIELD_VALIDATORS.length; expect(form.fieldValidators.length).toBe(defaultLength); - form.fieldValidators.push( {}); + form.fieldValidators.push({} as any); expect(form.fieldValidators.length).toBe(defaultLength + 1); expect(FORM_FIELD_VALIDATORS.length).toBe(defaultLength); @@ -461,63 +455,63 @@ describe('FormModel', () => { beforeEach(() => { const variables = [ { - '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': 'date', - 'value': '29.09.2019' + id: '3ed9f28a-dbae-463f-b991-47ef06658bb6', + name: 'name2', + type: 'date', + value: '29.09.2019' }, { - 'id': 'booleanVar', - 'name': 'bool', - 'type': 'boolean', - 'value': 'true' + id: 'booleanVar', + name: 'bool', + type: 'boolean', + value: 'true' } ]; const processVariables = [ { - 'serviceName': 'denys-variable-mapping-rb', - 'serviceFullName': 'denys-variable-mapping-rb', - 'serviceVersion': '', - 'appName': 'denys-variable-mapping', - 'appVersion': '', - 'serviceType': null, - 'id': 3, - 'type': 'string', - 'name': 'variables.name1', - 'createTime': 1566989626284, - 'lastUpdatedTime': 1566989626284, - 'executionId': null, - 'value': 'hello', - 'markedAsDeleted': false, - 'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44', - 'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44', - 'taskVariable': true + serviceName: 'denys-variable-mapping-rb', + serviceFullName: 'denys-variable-mapping-rb', + serviceVersion: '', + appName: 'denys-variable-mapping', + appVersion: '', + serviceType: null, + id: 3, + type: 'string', + name: 'variables.name1', + createTime: 1566989626284, + lastUpdatedTime: 1566989626284, + executionId: null, + value: 'hello', + markedAsDeleted: false, + processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44', + taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44', + taskVariable: true }, { - 'serviceName': 'denys-variable-mapping-rb', - 'serviceFullName': 'denys-variable-mapping-rb', - 'serviceVersion': '', - 'appName': 'denys-variable-mapping', - 'appVersion': '', - 'serviceType': null, - 'id': 1, - 'type': 'boolean', - 'name': 'booleanVar', - 'createTime': 1566989626283, - 'lastUpdatedTime': 1566989626283, - 'executionId': null, - 'value': 'true', - 'markedAsDeleted': false, - 'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44', - 'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44', - 'taskVariable': true + serviceName: 'denys-variable-mapping-rb', + serviceFullName: 'denys-variable-mapping-rb', + serviceVersion: '', + appName: 'denys-variable-mapping', + appVersion: '', + serviceType: null, + id: 1, + type: 'boolean', + name: 'booleanVar', + createTime: 1566989626283, + lastUpdatedTime: 1566989626283, + executionId: null, + value: 'true', + markedAsDeleted: false, + processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44', + taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44', + taskVariable: true } ]; @@ -624,7 +618,7 @@ describe('FormModel', () => { }); describe('setNodeIdValueForViewersLinkedToUploadWidget', () => { - const fakeNodeWithProperties: Node = { + const fakeNodeWithProperties: Node = { id: 'fake-properties', name: 'fake-properties-name', content: { @@ -634,7 +628,7 @@ describe('FormModel', () => { 'pfx:property_one': 'testValue', 'pfx:property_two': true } - }; + } as Node; let form: FormModel; it('should set the node id to the viewers linked to the upload widget in the event', () => { diff --git a/lib/core/form/components/widgets/core/form.model.ts b/lib/core/form/components/widgets/core/form.model.ts index c49e6382d3..4f63c5dc80 100644 --- a/lib/core/form/components/widgets/core/form.model.ts +++ b/lib/core/form/components/widgets/core/form.model.ts @@ -248,6 +248,7 @@ export class FormModel implements ProcessFormModel { /** * Returns a form variable that matches the identifier. + * * @param identifier The `name` or `id` value. */ getFormVariable(identifier: string): FormVariableModel { @@ -264,6 +265,7 @@ export class FormModel implements ProcessFormModel { /** * Returns a value of the form variable that matches the identifier. * Provides additional conversion of types (date, boolean). + * * @param identifier The `name` or `id` value */ getFormVariableValue(identifier: string): any { @@ -278,6 +280,7 @@ export class FormModel implements ProcessFormModel { /** * Returns a process variable value. + * * @param name Variable name */ getProcessVariableValue(name: string): any { @@ -338,7 +341,7 @@ export class FormModel implements ProcessFormModel { const field = this.fields[i]; if (field instanceof ContainerModel) { - const container = field; + const container = field; formFieldModel.push(container.field); container.field.columns.forEach((column) => { @@ -356,24 +359,24 @@ export class FormModel implements ProcessFormModel { protected parseOutcomes() { if (this.json.fields) { - const saveOutcome = new FormOutcomeModel( this, { + const saveOutcome = new FormOutcomeModel(this, { id: FormModel.SAVE_OUTCOME, name: 'SAVE', isSystem: true }); - const completeOutcome = new FormOutcomeModel( this, { + const completeOutcome = new FormOutcomeModel(this, { id: FormModel.COMPLETE_OUTCOME, name: 'COMPLETE', isSystem: true }); - const startProcessOutcome = new FormOutcomeModel( this, { + const startProcessOutcome = new FormOutcomeModel(this, { id: FormModel.START_PROCESS_OUTCOME, name: 'START PROCESS', isSystem: true }); const customOutcomes = (this.json.outcomes || []).map( - (obj) => new FormOutcomeModel( this, obj) + (obj) => new FormOutcomeModel(this, obj) ); this.outcomes = [saveOutcome].concat( diff --git a/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts b/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts index da1e14cfcc..f792d3aed5 100644 --- a/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts +++ b/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts @@ -57,7 +57,7 @@ describe('DateTimeWidgetComponent', () => { id: 'date-id', name: 'date-name', type: 'datetime', - minValue: minValue + minValue }); fixture.detectChanges(); @@ -81,7 +81,7 @@ describe('DateTimeWidgetComponent', () => { it('should setup max value for date picker', () => { const maxValue = '1982-03-13T10:00:000Z'; widget.field = new FormFieldModel(null, { - maxValue: maxValue + maxValue }); fixture.detectChanges(); @@ -157,14 +157,14 @@ describe('DateTimeWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - let dateButton = element.querySelector('button'); + let dateButton = element.querySelector('button'); expect(dateButton.disabled).toBeFalsy(); widget.field.readOnly = true; fixture.detectChanges(); await fixture.whenStable(); - dateButton = element.querySelector('button'); + dateButton = element.querySelector('button'); expect(dateButton.disabled).toBeTruthy(); }); diff --git a/lib/core/form/components/widgets/date-time/date-time.widget.ts b/lib/core/form/components/widgets/date-time/date-time.widget.ts index 56dc3d369b..d373a02541 100644 --- a/lib/core/form/components/widgets/date-time/date-time.widget.ts +++ b/lib/core/form/components/widgets/date-time/date-time.widget.ts @@ -62,7 +62,7 @@ export class DateTimeWidgetComponent 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) { diff --git a/lib/core/form/components/widgets/date/date.widget.spec.ts b/lib/core/form/components/widgets/date/date.widget.spec.ts index 3115721bed..88a6e38cbf 100644 --- a/lib/core/form/components/widgets/date/date.widget.spec.ts +++ b/lib/core/form/components/widgets/date/date.widget.spec.ts @@ -49,7 +49,7 @@ describe('DateWidgetComponent', () => { widget.field = new FormFieldModel(null, { id: 'date-id', name: 'date-name', - minValue: minValue + minValue }); widget.ngOnInit(); @@ -61,7 +61,7 @@ describe('DateWidgetComponent', () => { it('should date field be present', () => { const minValue = '13-03-1982'; widget.field = new FormFieldModel(null, { - minValue: minValue + minValue }); fixture.detectChanges(); @@ -73,7 +73,7 @@ describe('DateWidgetComponent', () => { it('should setup max value for date picker', () => { const maxValue = '31-03-1982'; widget.field = new FormFieldModel(null, { - maxValue: maxValue + maxValue }); widget.ngOnInit(); @@ -160,13 +160,13 @@ describe('DateWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - let dateButton = element.querySelector('button'); + let dateButton = element.querySelector('button'); expect(dateButton.disabled).toBeFalsy(); widget.field.readOnly = true; fixture.detectChanges(); - dateButton = element.querySelector('button'); + dateButton = element.querySelector('button'); expect(dateButton.disabled).toBeTruthy(); }); diff --git a/lib/core/form/components/widgets/date/date.widget.ts b/lib/core/form/components/widgets/date/date.widget.ts index 799987c610..0cd820ca7b 100644 --- a/lib/core/form/components/widgets/date/date.widget.ts +++ b/lib/core/form/components/widgets/date/date.widget.ts @@ -70,7 +70,7 @@ export class DateWidgetComponent extends WidgetComponent implements OnInit, OnDe .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) { diff --git a/lib/core/form/components/widgets/dropdown/dropdown.widget.spec.ts b/lib/core/form/components/widgets/dropdown/dropdown.widget.spec.ts index c5b6f4fb77..3f94b0a913 100644 --- a/lib/core/form/components/widgets/dropdown/dropdown.widget.spec.ts +++ b/lib/core/form/components/widgets/dropdown/dropdown.widget.spec.ts @@ -37,10 +37,10 @@ describe('DropdownWidgetComponent', () => { let fixture: ComponentFixture; let element: HTMLElement; - function openSelect() { + const openSelect = () => { const dropdown = fixture.debugElement.nativeElement.querySelector('.mat-select-trigger'); dropdown.click(); - } + }; const fakeOptionList: FormFieldOption[] = [ { id: 'opt_1', name: 'option_1' }, @@ -80,7 +80,7 @@ describe('DropdownWidgetComponent', () => { const fieldId = ''; const form = new FormModel({ - taskId: taskId + taskId }); widget.field = new FormFieldModel(form, { @@ -99,16 +99,14 @@ describe('DropdownWidgetComponent', () => { }); it('should preserve empty option when loading fields', () => { - const restFieldValue: FormFieldOption = { id: '1', name: 'Option1' }; - spyOn(formService, 'getRestFieldValues').and.callFake(() => { - return new Observable((observer) => { - observer.next([restFieldValue]); - observer.complete(); - }); - }); + const restFieldValue: FormFieldOption = { id: '1', name: 'Option1' } as FormFieldOption; + spyOn(formService, 'getRestFieldValues').and.callFake(() => new Observable((observer) => { + observer.next([restFieldValue]); + observer.complete(); + })); const form = new FormModel({ taskId: '' }); - const emptyOption: FormFieldOption = { id: 'empty', name: 'Empty' }; + const emptyOption: FormFieldOption = { id: 'empty', name: 'Empty' } as FormFieldOption; widget.field = new FormFieldModel(form, { id: '', restUrl: '/some/url/address', @@ -167,9 +165,7 @@ describe('DropdownWidgetComponent', () => { beforeEach(() => { spyOn(visibilityService, 'refreshVisibility').and.stub(); - 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', @@ -230,9 +226,7 @@ describe('DropdownWidgetComponent', () => { beforeEach(() => { spyOn(visibilityService, 'refreshVisibility').and.stub(); - spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => { - return of(fakeOptionList); - }); + spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => of(fakeOptionList)); widget.field = new FormFieldModel(new FormModel({ processDefinitionId: 'fake-process-id' }), { id: 'dropdown-id', name: 'date-name', @@ -300,7 +294,7 @@ describe('DropdownWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const dropDownElement: HTMLSelectElement = element.querySelector('#dropdown-id'); + const dropDownElement = element.querySelector('#dropdown-id'); expect(dropDownElement).not.toBeNull(); expect(dropDownElement.getAttribute('aria-disabled')).toBe('true'); }); diff --git a/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.model.ts b/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.model.ts index 2c7b249b95..73a06c39fd 100644 --- a/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.model.ts +++ b/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.model.ts @@ -72,7 +72,7 @@ export class DynamicTableModel extends FormWidgetModel { } if (field.json.value) { - this.rows = field.json.value.map((obj) => {selected: false, value: obj}); + this.rows = field.json.value.map((obj) => ({ selected: false, value: obj } as DynamicTableRow)); } } @@ -91,7 +91,7 @@ export class DynamicTableModel extends FormWidgetModel { } if (definitions) { - return definitions.map((obj) => obj); + return definitions.map((obj) => obj as DynamicTableColumn); } } return null; diff --git a/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.spec.ts b/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.spec.ts index 81fa128f5e..04a2358645 100644 --- a/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.spec.ts +++ b/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.spec.ts @@ -107,7 +107,7 @@ describe('DynamicTableWidgetComponent', () => { }); it('should select row on click', () => { - const row = {selected: false}; + const row = {selected: false} as DynamicTableRow; widget.onRowClicked(row); expect(row.selected).toBeTruthy(); @@ -115,7 +115,7 @@ describe('DynamicTableWidgetComponent', () => { }); it('should require table to select clicked row', () => { - const row = {selected: false}; + const row = {selected: false} as DynamicTableRow; widget.content = null; widget.onRowClicked(row); @@ -123,7 +123,7 @@ describe('DynamicTableWidgetComponent', () => { }); it('should reset selected row', () => { - const row = {selected: false}; + const row = {selected: false} as DynamicTableRow; widget.content.rows.push(row); widget.content.selectedRow = row; expect(widget.content.selectedRow).toBe(row); @@ -135,7 +135,7 @@ describe('DynamicTableWidgetComponent', () => { }); it('should check selection', () => { - const row = {selected: false}; + const row = {selected: false} as DynamicTableRow; widget.content.rows.push(row); widget.content.selectedRow = row; expect(widget.hasSelection()).toBeTruthy(); @@ -153,8 +153,8 @@ describe('DynamicTableWidgetComponent', () => { }); it('should move selection up', () => { - const row1 = {}; - const row2 = {}; + const row1 = {} as DynamicTableRow; + const row2 = {} as DynamicTableRow; widget.content.rows.push(...[row1, row2]); widget.content.selectedRow = row2; @@ -168,8 +168,8 @@ describe('DynamicTableWidgetComponent', () => { }); it('should move selection down', () => { - const row1 = {}; - const row2 = {}; + const row1 = {} as DynamicTableRow; + const row2 = {} as DynamicTableRow; widget.content.rows.push(...[row1, row2]); widget.content.selectedRow = row1; @@ -183,7 +183,7 @@ describe('DynamicTableWidgetComponent', () => { }); it('should delete selected row', () => { - const row = {}; + const row = {} as DynamicTableRow; widget.content.rows.push(row); widget.content.selectedRow = row; widget.deleteSelection(); @@ -213,7 +213,7 @@ describe('DynamicTableWidgetComponent', () => { expect(widget.editMode).toBeFalsy(); expect(widget.editRow).toBeFalsy(); - const row = {value: true}; + const row = {value: true} as DynamicTableRow; widget.content.selectedRow = row; expect(widget.editSelection()).toBeTruthy(); @@ -223,7 +223,7 @@ describe('DynamicTableWidgetComponent', () => { }); it('should copy row', () => { - const row = {value: {opt: {key: '1', value: 1}}}; + const row = {value: {opt: {key: '1', value: 1}}} as DynamicTableRow; const copy = widget.copyRow(row); expect(copy.value).toEqual(row.value); }); @@ -235,14 +235,14 @@ describe('DynamicTableWidgetComponent', () => { it('should retrieve cell value', () => { const value = ''; - const row = {value: {key: value}}; - const column = {id: 'key'}; + const row = {value: {key: value}} as DynamicTableRow; + const column = {id: 'key'} as DynamicTableColumn; expect(widget.getCellValue(row, column)).toBe(value); }); it('should save changes and add new row', () => { - const row = {isNew: true, value: {key: 'value'}}; + const row = {isNew: true, value: {key: 'value'}} as DynamicTableRow; widget.editMode = true; widget.editRow = row; @@ -255,7 +255,7 @@ describe('DynamicTableWidgetComponent', () => { }); it('should save changes and update row', () => { - const row = {isNew: false, value: {key: 'value'}}; + const row = {isNew: false, value: {key: 'value'}} as DynamicTableRow; widget.editMode = true; widget.editRow = row; widget.content.selectedRow = row; @@ -275,7 +275,7 @@ describe('DynamicTableWidgetComponent', () => { it('should cancel changes', () => { widget.editMode = true; - widget.editRow = {}; + widget.editRow = {} as DynamicTableRow; widget.onCancelChanges(); expect(widget.editMode).toBeFalsy(); @@ -311,15 +311,15 @@ describe('DynamicTableWidgetComponent', () => { }); it('should prepend default currency for amount columns', () => { - const row = {value: {key: '100'}}; - const column = {id: 'key', type: 'Amount'}; + const row = {value: {key: '100'}} as DynamicTableRow; + const column = {id: 'key', type: 'Amount'} as DynamicTableColumn; const actual = widget.getCellValue(row, column); expect(actual).toBe('$ 100'); }); it('should prepend custom currency for amount columns', () => { - const row = {value: {key: '100'}}; - const column = {id: 'key', type: 'Amount', amountCurrency: 'GBP'}; + const row = {value: {key: '100'}} as DynamicTableRow; + const column = {id: 'key', type: 'Amount', amountCurrency: 'GBP'} as DynamicTableColumn; const actual = widget.getCellValue(row, column); expect(actual).toBe('GBP 100'); }); @@ -357,7 +357,7 @@ describe('DynamicTableWidgetComponent', () => { }); it('should focus on add button when a new row is saved', async () => { - const addNewRowButton: HTMLButtonElement = element.querySelector('#fake-dynamic-table-add-row'); + const addNewRowButton = element.querySelector('#fake-dynamic-table-add-row'); expect(element.querySelector('#dynamic-table-fake-dynamic-table')).not.toBeNull(); expect(addNewRowButton).not.toBeNull(); diff --git a/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.ts b/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.ts index c2e18c3b62..bd89eba459 100644 --- a/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.ts +++ b/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.ts @@ -72,7 +72,7 @@ export class DynamicTableWidgetComponent extends WidgetComponent implements OnIn forceFocusOnAddButton() { if (this.content) { this.cd.detectChanges(); - const buttonAddRow = this.elementRef.nativeElement.querySelector('#' + this.content.id + '-add-row'); + const buttonAddRow = this.elementRef.nativeElement.querySelector('#' + this.content.id + '-add-row'); if (this.isDynamicTableReady(buttonAddRow)) { buttonAddRow.focus(); } @@ -139,7 +139,7 @@ export class DynamicTableWidgetComponent extends WidgetComponent implements OnIn addNewRow(): boolean { if (this.content && !this.readOnly) { - this.editRow = { + this.editRow = { isNew: true, selected: false, value: {} @@ -195,9 +195,7 @@ export class DynamicTableWidgetComponent extends WidgetComponent implements OnIn } copyRow(row: DynamicTableRow): DynamicTableRow { - return { - value: this.copyObject(row.value) - }; + return { value: this.copyObject(row.value) } as DynamicTableRow; } private copyObject(obj: any): any { diff --git a/lib/core/form/components/widgets/dynamic-table/editors/amount/amount.editor.spec.ts b/lib/core/form/components/widgets/dynamic-table/editors/amount/amount.editor.spec.ts index c3c0342fbd..55b44722a0 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/amount/amount.editor.spec.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/amount/amount.editor.spec.ts @@ -28,8 +28,8 @@ describe('AmountEditorComponent', () => { }); it('should update row value on change', () => { - const row = { value: {} }; - const column = { id: 'key' }; + const row = { value: {} } as DynamicTableRow; + const column = { id: 'key' } as DynamicTableColumn; const value = 100; const event = { target: { value } }; diff --git a/lib/core/form/components/widgets/dynamic-table/editors/amount/amount.editor.ts b/lib/core/form/components/widgets/dynamic-table/editors/amount/amount.editor.ts index e440d772f1..4f991f0a44 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/amount/amount.editor.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/amount/amount.editor.ts @@ -45,7 +45,7 @@ export class AmountEditorComponent implements OnInit { } onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) { - const value: number = Number(( event.target).value); + const value: number = Number(event.target.value); row.value[column.id] = value; } diff --git a/lib/core/form/components/widgets/dynamic-table/editors/boolean/boolean.editor.spec.ts b/lib/core/form/components/widgets/dynamic-table/editors/boolean/boolean.editor.spec.ts index 591bf405e1..2e7e75d2e4 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/boolean/boolean.editor.spec.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/boolean/boolean.editor.spec.ts @@ -29,8 +29,8 @@ describe('BooleanEditorComponent', () => { }); it('should update row value on change', () => { - const row = { value: {} }; - const column = { id: 'key' }; + const row = { value: {} } as DynamicTableRow; + const column = { id: 'key' } as DynamicTableColumn; const event = { checked: true } ; component.onValueChanged(row, column, event); diff --git a/lib/core/form/components/widgets/dynamic-table/editors/boolean/boolean.editor.ts b/lib/core/form/components/widgets/dynamic-table/editors/boolean/boolean.editor.ts index 6c9a9fb1db..8c65ef5c52 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/boolean/boolean.editor.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/boolean/boolean.editor.ts @@ -39,7 +39,7 @@ export class BooleanEditorComponent { column: DynamicTableColumn; onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) { - const value: boolean = ( event).checked; + const value: boolean = event.checked; row.value[column.id] = value; } diff --git a/lib/core/form/components/widgets/dynamic-table/editors/date/date.editor.spec.ts b/lib/core/form/components/widgets/dynamic-table/editors/date/date.editor.spec.ts index 4521d2d76c..3581dcc64c 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/date/date.editor.spec.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/date/date.editor.spec.ts @@ -45,8 +45,8 @@ describe('DateEditorComponent', () => { fixture = TestBed.createComponent(DateEditorComponent); component = fixture.componentInstance; - row = { value: { date: '1879-03-14T00:00:00.000Z' } }; - column = { id: 'date', type: 'Date' }; + row = { value: { date: '1879-03-14T00:00:00.000Z' } } as DynamicTableRow; + column = { id: 'date', type: 'Date' } as DynamicTableColumn; const field = new FormFieldModel(new FormModel()); table = new DynamicTableModel(field, null); table.rows.push(row); @@ -58,7 +58,7 @@ describe('DateEditorComponent', () => { describe('using Date Piker', () => { it('should update row value on change', () => { - const input = > {value: '14-03-2016' }; + const input = {value: '14-03-2016' } as MatDatepickerInputEvent; component.ngOnInit(); component.onDateChanged(input); @@ -69,7 +69,7 @@ describe('DateEditorComponent', () => { it('should flush value on user input', () => { spyOn(table, 'flushValue').and.callThrough(); - const input = > {value: '14-03-2016' }; + const input = {value: '14-03-2016' } as MatDatepickerInputEvent; component.ngOnInit(); component.onDateChanged(input); diff --git a/lib/core/form/components/widgets/dynamic-table/editors/date/date.editor.ts b/lib/core/form/components/widgets/dynamic-table/editors/date/date.editor.ts index 4dea65ab7b..2e7e5a5bd3 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/date/date.editor.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/date/date.editor.ts @@ -70,7 +70,7 @@ export class DateEditorComponent implements OnInit, OnDestroy { .pipe(takeUntil(this.onDestroy$)) .subscribe(locale => this.dateAdapter.setLocale(locale)); - const momentDateAdapter = this.dateAdapter; + const momentDateAdapter = this.dateAdapter as MomentDateAdapter; momentDateAdapter.overrideDisplayFormat = this.DATE_FORMAT; this.value = moment(this.table.getCellValue(this.row, this.column), this.DATE_FORMAT); diff --git a/lib/core/form/components/widgets/dynamic-table/editors/datetime/datetime.editor.spec.ts b/lib/core/form/components/widgets/dynamic-table/editors/datetime/datetime.editor.spec.ts index eda78a7b76..eac1b56c64 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/datetime/datetime.editor.spec.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/datetime/datetime.editor.spec.ts @@ -44,8 +44,8 @@ describe('DateTimeEditorComponent', () => { fixture = TestBed.createComponent(DateTimeEditorComponent); component = fixture.componentInstance; - row = { value: { date: '1879-03-14T00:00:00.000Z' } }; - column = { id: 'datetime', type: 'Datetime' }; + row = { value: { date: '1879-03-14T00:00:00.000Z' } } as DynamicTableRow; + column = { id: 'datetime', type: 'Datetime' } as DynamicTableColumn; const field = new FormFieldModel(new FormModel()); table = new DynamicTableModel(field, null); table.rows.push(row); diff --git a/lib/core/form/components/widgets/dynamic-table/editors/datetime/datetime.editor.ts b/lib/core/form/components/widgets/dynamic-table/editors/datetime/datetime.editor.ts index 8f234e9d3e..74a91c65c8 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/datetime/datetime.editor.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/datetime/datetime.editor.ts @@ -73,7 +73,7 @@ export class DateTimeEditorComponent implements OnInit, OnDestroy { .pipe(takeUntil(this.onDestroy$)) .subscribe(locale => this.dateAdapter.setLocale(locale)); - const momentDateAdapter = this.dateAdapter; + const momentDateAdapter = this.dateAdapter as MomentDateAdapter; momentDateAdapter.overrideDisplayFormat = this.DATE_TIME_FORMAT; this.value = moment(this.table.getCellValue(this.row, this.column), this.DATE_TIME_FORMAT); diff --git a/lib/core/form/components/widgets/dynamic-table/editors/dropdown/dropdown.editor.spec.ts b/lib/core/form/components/widgets/dynamic-table/editors/dropdown/dropdown.editor.spec.ts index b31834aac0..c09a6dd07c 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/dropdown/dropdown.editor.spec.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/dropdown/dropdown.editor.spec.ts @@ -51,14 +51,14 @@ describe('DropdownEditorComponent', () => { alfrescoApiService = TestBed.inject(AlfrescoApiService); formService = new FormService(null, alfrescoApiService, null); - row = {value: {dropdown: 'one'}}; - column = { + row = {value: {dropdown: 'one'}} as DynamicTableRow; + column = { id: 'dropdown', options: [ - {id: '1', name: 'one'}, - {id: '2', name: 'two'} + {id: '1', name: 'one'}, + {id: '2', name: 'two'} ] - }; + } as DynamicTableColumn; form = new FormModel({taskId: ''}); table = new DynamicTableModel(new FormFieldModel(form, {id: ''}), formService); @@ -95,9 +95,9 @@ describe('DropdownEditorComponent', () => { column.optionType = 'rest'; row.value[column.id] = 'twelve'; - const restResults = [ - {id: '11', name: 'eleven'}, - {id: '12', name: 'twelve'} + const restResults: DynamicTableColumnOption[] = [ + {id: '11', name: 'eleven'}, + {id: '12', name: 'twelve'} ]; spyOn(formService, 'getRestFieldValuesColumn').and.returnValue( @@ -192,11 +192,11 @@ describe('DropdownEditorComponent', () => { }, {id: 'opt_3', name: 'option_3'}]; let dynamicTable: DynamicTableModel; - function openSelect() { + const openSelect = () => { const dropdown = fixture.debugElement.query(By.css('.mat-select-trigger')); dropdown.triggerEventHandler('click', null); fixture.detectChanges(); - } + }; beforeEach(() => { fixture = TestBed.createComponent(DropdownEditorComponent); @@ -213,15 +213,15 @@ describe('DropdownEditorComponent', () => { beforeEach(() => { stubFormService = fixture.debugElement.injector.get(FormService); spyOn(stubFormService, 'getRestFieldValuesColumn').and.returnValue(of(fakeOptionList)); - row = {value: {dropdown: 'one'}}; - column = { + row = {value: {dropdown: 'one'}} as DynamicTableRow; + column = { id: 'column-id', optionType: 'rest', options: [ - {id: '1', name: 'one'}, - {id: '2', name: 'two'} + {id: '1', name: 'one'}, + {id: '2', name: 'two'} ] - }; + } as DynamicTableColumn; form = new FormModel({taskId: ''}); dynamicTable = new DynamicTableModel(new FormFieldModel(form, {id: ''}), formService); dynamicTable.rows.push(row); @@ -261,15 +261,15 @@ describe('DropdownEditorComponent', () => { beforeEach(() => { stubFormService = fixture.debugElement.injector.get(FormService); spyOn(stubFormService, 'getRestFieldValuesColumnByProcessId').and.returnValue(of(fakeOptionList)); - row = {value: {dropdown: 'one'}}; - column = { + row = {value: {dropdown: 'one'}} as DynamicTableRow; + column = { id: 'column-id', optionType: 'rest', options: [ - {id: '1', name: 'one'}, - {id: '2', name: 'two'} + {id: '1', name: 'one'}, + {id: '2', name: 'two'} ] - }; + } as DynamicTableColumn; form = new FormModel({processDefinitionId: ''}); dynamicTable = new DynamicTableModel(new FormFieldModel(form, {id: ''}), formService); dynamicTable.rows.push(row); diff --git a/lib/core/form/components/widgets/dynamic-table/editors/dropdown/dropdown.editor.ts b/lib/core/form/components/widgets/dynamic-table/editors/dropdown/dropdown.editor.ts index 99db2f7fbe..7d22d13a0c 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/dropdown/dropdown.editor.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/dropdown/dropdown.editor.ts @@ -99,7 +99,7 @@ export class DropdownEditorComponent implements OnInit { } onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) { - let value: any = ( event).value; + let value: any = event.value; value = column.options.find((opt) => opt.name === value); row.value[column.id] = value; } diff --git a/lib/core/form/components/widgets/dynamic-table/editors/row.editor.spec.ts b/lib/core/form/components/widgets/dynamic-table/editors/row.editor.spec.ts index 5bf69850bd..853054da5d 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/row.editor.spec.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/row.editor.spec.ts @@ -17,7 +17,6 @@ import { FormFieldModel, FormModel } from '../../core'; import { FormService } from './../../../../services/form.service'; -import { DynamicRowValidationSummary } from './../dynamic-row-validation-summary.model'; import { DynamicTableColumn } from './../dynamic-table-column.model'; import { DynamicTableRow } from './../dynamic-table-row.model'; import { DynamicTableModel } from './../dynamic-table.widget.model'; @@ -45,8 +44,8 @@ describe('RowEditorComponent', () => { component = new RowEditorComponent(); const field = new FormFieldModel(new FormModel()); component.table = new DynamicTableModel(field, new FormService(null, alfrescoApiService, null)); - component.row = {}; - component.column = {}; + component.row = {} as DynamicTableRow; + component.column = {} as DynamicTableColumn; }); it('should be valid upon init', () => { @@ -72,7 +71,7 @@ describe('RowEditorComponent', () => { it('should emit [save] event', (done) => { spyOn(component.table, 'validateRow').and.returnValue( - {isValid: true, message: null} + {isValid: true, message: null} ); component.save.subscribe((event) => { expect(event.table).toBe(component.table); @@ -85,7 +84,7 @@ describe('RowEditorComponent', () => { it('should not emit [save] event for invalid row', () => { spyOn(component.table, 'validateRow').and.returnValue( - {isValid: false, message: 'error'} + {isValid: false, message: 'error'} ); let raised = false; component.save.subscribe(() => raised = true); diff --git a/lib/core/form/components/widgets/dynamic-table/editors/text/text.editor.spec.ts b/lib/core/form/components/widgets/dynamic-table/editors/text/text.editor.spec.ts index d106447e72..4e6b25c190 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/text/text.editor.spec.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/text/text.editor.spec.ts @@ -28,8 +28,8 @@ describe('TextEditorComponent', () => { }); it('should update row value on change', () => { - const row = { value: {} }; - const column = { id: 'key' }; + const row = { value: {} } as DynamicTableRow; + const column = { id: 'key' } as DynamicTableColumn; const value = ''; const event = { target: { value } }; diff --git a/lib/core/form/components/widgets/dynamic-table/editors/text/text.editor.ts b/lib/core/form/components/widgets/dynamic-table/editors/text/text.editor.ts index d192884e7e..748bca817e 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/text/text.editor.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/text/text.editor.ts @@ -45,7 +45,7 @@ export class TextEditorComponent implements OnInit { } onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) { - const value: any = ( event.target).value; + const value: any = event.target.value; row.value[column.id] = value; } diff --git a/lib/core/form/components/widgets/functional-group/functional-group.widget.spec.ts b/lib/core/form/components/widgets/functional-group/functional-group.widget.spec.ts index 76c56b998d..ffa7b4338c 100644 --- a/lib/core/form/components/widgets/functional-group/functional-group.widget.spec.ts +++ b/lib/core/form/components/widgets/functional-group/functional-group.widget.spec.ts @@ -57,7 +57,7 @@ describe('FunctionalGroupWidgetComponent', () => { fixture.destroy(); }); - async function typeIntoInput(text: string) { + const typeIntoInput = async (text: string) => { component.searchTerm.setValue(text); fixture.detectChanges(); @@ -72,7 +72,7 @@ describe('FunctionalGroupWidgetComponent', () => { await fixture.whenStable(); fixture.detectChanges(); - } + }; it('should setup text from underlying field on init', async () => { const group: GroupModel = { name: 'group-1'}; diff --git a/lib/core/form/components/widgets/functional-group/functional-group.widget.ts b/lib/core/form/components/widgets/functional-group/functional-group.widget.ts index b7d9f052f5..079814c2d5 100644 --- a/lib/core/form/components/widgets/functional-group/functional-group.widget.ts +++ b/lib/core/form/components/widgets/functional-group/functional-group.widget.ts @@ -74,7 +74,7 @@ export class FunctionalGroupWidgetComponent extends WidgetComponent implements O const params = this.field.params; if (params && params.restrictWithGroup) { - const restrictWithGroup = params.restrictWithGroup; + const restrictWithGroup = params.restrictWithGroup; this.groupId = restrictWithGroup.id; } diff --git a/lib/core/form/components/widgets/hyperlink/hyperlink.widget.spec.ts b/lib/core/form/components/widgets/hyperlink/hyperlink.widget.spec.ts index a4c8c9c2a9..5622bb01e6 100644 --- a/lib/core/form/components/widgets/hyperlink/hyperlink.widget.spec.ts +++ b/lib/core/form/components/widgets/hyperlink/hyperlink.widget.spec.ts @@ -185,7 +185,7 @@ describe('HyperlinkWidgetComponent', () => { const url = 'https://www.alfresco.com/'; widget.field = new FormFieldModel(new FormModel(), { hyperlinkUrl: url, - displayText: displayText, + displayText, type: FormFieldTypes.HYPERLINK }); @@ -201,7 +201,7 @@ describe('HyperlinkWidgetComponent', () => { widget.field = new FormFieldModel(new FormModel(), { id: 'hyperlink', hyperlinkUrl: url, - displayText: displayText, + displayText, type: FormFieldTypes.HYPERLINK, tooltip: 'hyperlink widget' }); diff --git a/lib/core/form/components/widgets/people/people.widget.spec.ts b/lib/core/form/components/widgets/people/people.widget.spec.ts index 28c80c69b5..82649a9d25 100644 --- a/lib/core/form/components/widgets/people/people.widget.spec.ts +++ b/lib/core/form/components/widgets/people/people.widget.spec.ts @@ -48,12 +48,8 @@ describe('PeopleWidgetComponent', () => { formService = TestBed.inject(FormService); translationService = TestBed.inject(TranslateService); - spyOn(translationService, 'instant').and.callFake((key) => { - return key; - }); - spyOn(translationService, 'get').and.callFake((key) => { - return of(key); - }); + spyOn(translationService, 'instant').and.callFake((key) => key); + spyOn(translationService, 'get').and.callFake((key) => of(key)); element = fixture.nativeElement; widget = fixture.componentInstance; @@ -193,7 +189,7 @@ describe('PeopleWidgetComponent', () => { }); it('should show an error message if the user is invalid', async () => { - const peopleHTMLElement: HTMLInputElement = element.querySelector('input'); + const peopleHTMLElement = element.querySelector('input'); peopleHTMLElement.focus(); peopleHTMLElement.value = 'K'; peopleHTMLElement.dispatchEvent(new Event('keyup')); @@ -207,7 +203,7 @@ describe('PeopleWidgetComponent', () => { }); it('should show the people if the typed result match', async () => { - const peopleHTMLElement: HTMLInputElement = element.querySelector('input'); + const peopleHTMLElement = element.querySelector('input'); peopleHTMLElement.focus(); peopleHTMLElement.value = 'T'; peopleHTMLElement.dispatchEvent(new Event('keyup')); @@ -221,7 +217,7 @@ describe('PeopleWidgetComponent', () => { }); it('should hide result list if input is empty', async () => { - const peopleHTMLElement: HTMLInputElement = element.querySelector('input'); + const peopleHTMLElement = element.querySelector('input'); peopleHTMLElement.focus(); peopleHTMLElement.value = ''; peopleHTMLElement.dispatchEvent(new Event('keyup')); @@ -238,7 +234,7 @@ describe('PeopleWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const peopleHTMLElement: HTMLInputElement = element.querySelector('input'); + const peopleHTMLElement = element.querySelector('input'); peopleHTMLElement.focus(); peopleHTMLElement.value = 'T'; peopleHTMLElement.dispatchEvent(new Event('keyup')); @@ -253,7 +249,7 @@ describe('PeopleWidgetComponent', () => { it('should emit peopleSelected if option is valid', async () => { const selectEmitSpy = spyOn(widget.peopleSelected, 'emit'); - const peopleHTMLElement: HTMLInputElement = element.querySelector('input'); + const peopleHTMLElement = element.querySelector('input'); peopleHTMLElement.focus(); peopleHTMLElement.value = 'Test01 Test01'; peopleHTMLElement.dispatchEvent(new Event('keyup')); diff --git a/lib/core/form/components/widgets/people/people.widget.ts b/lib/core/form/components/widgets/people/people.widget.ts index 0078784dfc..4b06e778a8 100644 --- a/lib/core/form/components/widgets/people/people.widget.ts +++ b/lib/core/form/components/widgets/people/people.widget.ts @@ -21,7 +21,6 @@ import { PeopleProcessService } from '../../../../services/people-process.servic import { UserProcessModel } from '../../../../models'; import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core'; import { FormService } from '../../../services/form.service'; -import { GroupModel } from '../core/group.model'; import { WidgetComponent } from './../widget.component'; import { FormControl } from '@angular/forms'; import { Observable, of } from 'rxjs'; @@ -97,7 +96,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { } const params = this.field.params; if (params && params.restrictWithGroup) { - const restrictWithGroup = params.restrictWithGroup; + const restrictWithGroup = params.restrictWithGroup; this.groupId = restrictWithGroup.id; } } diff --git a/lib/core/form/components/widgets/radio-buttons/radio-buttons.widget.spec.ts b/lib/core/form/components/widgets/radio-buttons/radio-buttons.widget.spec.ts index 90de5eb87a..5c347c39e7 100644 --- a/lib/core/form/components/widgets/radio-buttons/radio-buttons.widget.spec.ts +++ b/lib/core/form/components/widgets/radio-buttons/radio-buttons.widget.spec.ts @@ -61,7 +61,7 @@ describe('RadioButtonsWidgetComponent', () => { const fieldId = ''; const form = new FormModel({ - taskId: taskId + taskId }); widget.field = new FormFieldModel(form, { @@ -82,7 +82,7 @@ describe('RadioButtonsWidgetComponent', () => { const fieldId = ''; const form = new FormModel({ - taskId: taskId + taskId }); widget.field = new FormFieldModel(form, { @@ -105,7 +105,7 @@ describe('RadioButtonsWidgetComponent', () => { const fieldId = ''; const form = new FormModel({ - taskId: taskId + taskId }); widget.field = new FormFieldModel(form, { @@ -204,13 +204,13 @@ describe('RadioButtonsWidgetComponent', () => { expect(widgetLabel.innerText).toBe('radio-name-label*'); expect(radioButtonWidget.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(radioButtonWidget.field.isValid).toBe(true); }); @@ -229,7 +229,7 @@ describe('RadioButtonsWidgetComponent', () => { }); 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(radioButtonWidget.field.isValid).toBe(true); }); @@ -281,7 +281,7 @@ describe('RadioButtonsWidgetComponent', () => { }); it('should trigger field changed event on click', fakeAsync(() => { - const option: HTMLElement = element.querySelector('#radio-id-opt-1-input'); + const option = element.querySelector('#radio-id-opt-1-input'); expect(element.querySelector('#radio-id')).not.toBeNull(); expect(option).not.toBeNull(); option.click(); diff --git a/lib/core/form/components/widgets/text/text-mask.component.ts b/lib/core/form/components/widgets/text/text-mask.component.ts index 37ea8c2f39..3b34748a9d 100644 --- a/lib/core/form/components/widgets/text/text-mask.component.ts +++ b/lib/core/form/components/widgets/text/text-mask.component.ts @@ -51,11 +51,11 @@ export class InputMaskDirective implements OnChanges, ControlValueAccessor { }; private translationMask = { - '0': { pattern: /\d/ }, - '9': { pattern: /\d/, optional: true }, + 0: { pattern: /\d/ }, + 9: { pattern: /\d/, optional: true }, '#': { pattern: /\d/, recursive: true }, - 'A': { pattern: /[a-zA-Z0-9]/ }, - 'S': { pattern: /[a-zA-Z]/ } + A: { pattern: /[a-zA-Z0-9]/ }, + S: { pattern: /[a-zA-Z]/ } }; private byPassKeys = [9, 16, 17, 18, 36, 37, 38, 39, 40, 91]; diff --git a/lib/core/form/components/widgets/typeahead/typeahead.widget.spec.ts b/lib/core/form/components/widgets/typeahead/typeahead.widget.spec.ts index d58a035fdf..597e893aa4 100644 --- a/lib/core/form/components/widgets/typeahead/typeahead.widget.spec.ts +++ b/lib/core/form/components/widgets/typeahead/typeahead.widget.spec.ts @@ -47,12 +47,8 @@ describe('TypeaheadWidgetComponent', () => { beforeEach(() => { alfrescoApiService = TestBed.inject(AlfrescoApiService); translationService = TestBed.inject(TranslateService); - spyOn(translationService, 'instant').and.callFake((key) => { - return key; - }); - spyOn(translationService, 'get').and.callFake((key) => { - return of(key); - }); + spyOn(translationService, 'instant').and.callFake((key) => key); + spyOn(translationService, 'get').and.callFake((key) => of(key)); formService = new FormService(null, alfrescoApiService, null); widget = new TypeaheadWidgetComponent(formService, null); @@ -65,7 +61,7 @@ describe('TypeaheadWidgetComponent', () => { const fieldId = ''; const form = new FormModel({ - taskId: taskId + taskId }); widget.field = new FormFieldModel(form, { @@ -86,7 +82,7 @@ describe('TypeaheadWidgetComponent', () => { const fieldId = ''; const form = new FormModel({ - taskId: taskId + taskId }); widget.field = new FormFieldModel(form, { @@ -103,7 +99,7 @@ describe('TypeaheadWidgetComponent', () => { const fieldId = ''; const form = new FormModel({ - taskId: taskId + taskId }); widget.field = new FormFieldModel(form, { @@ -125,7 +121,7 @@ describe('TypeaheadWidgetComponent', () => { const fieldId = ''; const form = new FormModel({ - processDefinitionId: processDefinitionId + processDefinitionId }); widget.field = new FormFieldModel(form, { @@ -301,7 +297,7 @@ describe('TypeaheadWidgetComponent', () => { it('should show typeahead options', async () => { const typeaheadElement = fixture.debugElement.query(By.css('#typeahead-id')); - const typeaheadHTMLElement = typeaheadElement.nativeElement; + const typeaheadHTMLElement = typeaheadElement.nativeElement as HTMLInputElement; typeaheadHTMLElement.focus(); typeaheadWidgetComponent.value = 'F'; typeaheadHTMLElement.value = 'F'; @@ -318,7 +314,7 @@ describe('TypeaheadWidgetComponent', () => { it('should hide the option when the value is empty', async () => { const typeaheadElement = fixture.debugElement.query(By.css('#typeahead-id')); - const typeaheadHTMLElement = typeaheadElement.nativeElement; + const typeaheadHTMLElement = typeaheadElement.nativeElement as HTMLInputElement; typeaheadHTMLElement.focus(); typeaheadWidgetComponent.value = 'F'; typeaheadHTMLElement.value = 'F'; diff --git a/lib/core/form/components/widgets/upload/upload.widget.spec.ts b/lib/core/form/components/widgets/upload/upload.widget.spec.ts index 9b35927bee..99712daee0 100644 --- a/lib/core/form/components/widgets/upload/upload.widget.spec.ts +++ b/lib/core/form/components/widgets/upload/upload.widget.spec.ts @@ -31,50 +31,48 @@ import { TranslateModule } from '@ngx-translate/core'; import { RelatedContentRepresentation } from '@alfresco/js-api'; const fakePngAnswer = new RelatedContentRepresentation({ - 'id': 1155, - 'name': 'a_png_file.png', - 'created': '2017-07-25T17:17:37.099Z', - 'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' }, - 'relatedContent': false, - 'contentAvailable': true, - 'link': false, - 'mimeType': 'image/png', - 'simpleType': 'image', - 'previewStatus': 'queued', - 'thumbnailStatus': 'queued' + id: 1155, + name: 'a_png_file.png', + created: '2017-07-25T17:17:37.099Z', + createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' }, + relatedContent: false, + contentAvailable: true, + link: false, + mimeType: 'image/png', + simpleType: 'image', + previewStatus: 'queued', + thumbnailStatus: 'queued' }); const fakeJpgAnswer = { - 'id': 1156, - 'name': 'a_jpg_file.jpg', - 'created': '2017-07-25T17:17:37.118Z', - 'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' }, - 'relatedContent': false, - 'contentAvailable': true, - 'link': false, - 'mimeType': 'image/jpeg', - 'simpleType': 'image', - 'previewStatus': 'queued', - 'thumbnailStatus': 'queued' + id: 1156, + name: 'a_jpg_file.jpg', + created: '2017-07-25T17:17:37.118Z', + createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' }, + relatedContent: false, + contentAvailable: true, + link: false, + mimeType: 'image/jpeg', + simpleType: 'image', + previewStatus: 'queued', + thumbnailStatus: 'queued' }; describe('UploadWidgetComponent', () => { - function fakeCreationFile (name: string, id: string | number) { - return { - 'id': id, - 'name': name, - 'created': '2017-07-25T17:17:37.118Z', - 'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' }, - 'relatedContent': false, - 'contentAvailable': true, - 'link': false, - 'mimeType': 'image/jpeg', - 'simpleType': 'image', - 'previewStatus': 'queued', - 'thumbnailStatus': 'queued' - }; - } + const fakeCreationFile = (name: string, id: string | number) => ({ + id, + name, + created: '2017-07-25T17:17:37.118Z', + createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' }, + relatedContent: false, + contentAvailable: true, + link: false, + mimeType: 'image/jpeg', + simpleType: 'image', + previewStatus: 'queued', + thumbnailStatus: 'queued' + }); let contentService: ProcessContentService; @@ -231,7 +229,7 @@ describe('UploadWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const deleteButton = element.querySelector('#file-1155-remove'); + const deleteButton = element.querySelector('#file-1155-remove'); deleteButton.click(); expect(uploadWidgetComponent.field.updateForm).toHaveBeenCalled(); @@ -261,7 +259,7 @@ describe('UploadWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - inputElement = element.querySelector('#upload-id'); + inputElement = element.querySelector('#upload-id'); expect(inputElement).toBeDefined(); expect(inputElement).not.toBeNull(); expect(uploadWidgetComponent.field.value).not.toBeNull(); @@ -379,7 +377,7 @@ describe('UploadWidgetComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const buttonElement = element.querySelector('#file-1156-remove'); + const buttonElement = element.querySelector('#file-1156-remove'); buttonElement.click(); fixture.detectChanges(); const jpegElement = element.querySelector('#file-1156'); diff --git a/lib/core/form/models/form-definition.model.ts b/lib/core/form/models/form-definition.model.ts index 3160458748..7d530be43a 100644 --- a/lib/core/form/models/form-definition.model.ts +++ b/lib/core/form/models/form-definition.model.ts @@ -26,13 +26,13 @@ export class FormDefinitionModel extends FormSaveRepresentation { constructor(id: string, name: any, lastUpdatedByFullName: string, lastUpdated: string, metadata: any) { super(); this.formRepresentation = { - id: id, - name: name, + id, + name, description: '', version: 1, lastUpdatedBy: 1, - lastUpdatedByFullName: lastUpdatedByFullName, - lastUpdated: lastUpdated, + lastUpdatedByFullName, + lastUpdated, stencilSetId: 0, referenceId: null, formDefinition: { @@ -47,7 +47,7 @@ export class FormDefinitionModel extends FormSaveRepresentation { sizeY: 1, row: -1, col: -1, - fields: {'1': this.metadataToFields(metadata)} + fields: {1: this.metadataToFields(metadata)} }], gridsterForm: false, javascriptEvents: [], @@ -64,7 +64,7 @@ export class FormDefinitionModel extends FormSaveRepresentation { private metadataToFields(metadata: any): any[] { const fields = []; if (metadata) { - metadata.forEach(function(property) { + metadata.forEach((property) => { if (property) { const field = { type: 'text', diff --git a/lib/core/form/models/widget-visibility.model.ts b/lib/core/form/models/widget-visibility.model.ts index 2612fa5ea9..64d25203d7 100644 --- a/lib/core/form/models/widget-visibility.model.ts +++ b/lib/core/form/models/widget-visibility.model.ts @@ -100,6 +100,7 @@ export class WidgetVisibilityModel { } } +// eslint-disable-next-line no-shadow export enum WidgetTypeEnum { field = 'field', variable = 'variable', diff --git a/lib/core/form/services/activiti-alfresco.service.ts b/lib/core/form/services/activiti-alfresco.service.ts index 63621429f9..5ea094b721 100644 --- a/lib/core/form/services/activiti-alfresco.service.ts +++ b/lib/core/form/services/activiti-alfresco.service.ts @@ -72,6 +72,7 @@ export class ActivitiContentService { /** * Returns a list of all the repositories configured + * * @param tenantId * @param includeAccount */ diff --git a/lib/core/form/services/ecm-model.service.spec.ts b/lib/core/form/services/ecm-model.service.spec.ts index 6b39979694..1d41a4cf4c 100644 --- a/lib/core/form/services/ecm-model.service.spec.ts +++ b/lib/core/form/services/ecm-model.service.spec.ts @@ -52,7 +52,7 @@ describe('EcmModelService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({}) }); @@ -68,7 +68,7 @@ describe('EcmModelService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({}) }); @@ -87,7 +87,7 @@ describe('EcmModelService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({}) }); @@ -107,7 +107,7 @@ describe('EcmModelService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({}) }); @@ -146,7 +146,7 @@ describe('EcmModelService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({}) }); @@ -186,7 +186,7 @@ describe('EcmModelService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({}) }); @@ -201,7 +201,7 @@ describe('EcmModelService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({}) }); @@ -216,26 +216,22 @@ describe('EcmModelService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({}) }); }); it('Should create an ECM type with properties', (done) => { - spyOn(service, 'createEcmType').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(service, 'createEcmType').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); - spyOn(service, 'addPropertyToAType').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(service, 'addPropertyToAType').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); service.createEcmTypeWithProperties('nameType', new FormModel()).subscribe(() => { expect(service.createEcmType).toHaveBeenCalled(); @@ -245,19 +241,15 @@ describe('EcmModelService', () => { }); it('Should return the already existing type', (done) => { - spyOn(service, 'searchEcmType').and.callFake(() => { - return new Observable((observer) => { - observer.next({test: 'I-EXIST'}); - observer.complete(); - }); - }); + spyOn(service, 'searchEcmType').and.callFake(() => new Observable((observer) => { + observer.next({test: 'I-EXIST'}); + observer.complete(); + })); - spyOn(service, 'createEcmTypeWithProperties').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(service, 'createEcmTypeWithProperties').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); service.saveFomType('nameType', new FormModel()).subscribe(() => { expect(service.searchEcmType).toHaveBeenCalled(); @@ -267,19 +259,15 @@ describe('EcmModelService', () => { }); it('Should create an ECM type with properties if the ecm Type is not defined already', (done) => { - spyOn(service, 'searchEcmType').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(service, 'searchEcmType').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); - spyOn(service, 'createEcmTypeWithProperties').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(service, 'createEcmTypeWithProperties').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); service.saveFomType('nameType', new FormModel()).subscribe(() => { expect(service.searchEcmType).toHaveBeenCalled(); @@ -289,19 +277,15 @@ describe('EcmModelService', () => { }); it('Should create an ECM model for the activiti if not defined already', (done) => { - spyOn(service, 'searchActivitiEcmModel').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(service, 'searchActivitiEcmModel').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); - spyOn(service, 'createActivitiEcmModel').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(service, 'createActivitiEcmModel').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); service.createEcmTypeForActivitiForm('nameType', new FormModel()).subscribe(() => { expect(service.searchActivitiEcmModel).toHaveBeenCalled(); @@ -311,19 +295,15 @@ describe('EcmModelService', () => { }); it('If a model for the activiti is already define has to save the new type', (done) => { - spyOn(service, 'searchActivitiEcmModel').and.callFake(() => { - return new Observable((observer) => { - observer.next({test: 'I-EXIST'}); - observer.complete(); - }); - }); + spyOn(service, 'searchActivitiEcmModel').and.callFake(() => new Observable((observer) => { + observer.next({test: 'I-EXIST'}); + observer.complete(); + })); - spyOn(service, 'saveFomType').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(service, 'saveFomType').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); service.createEcmTypeForActivitiForm('nameType', new FormModel()).subscribe(() => { expect(service.searchActivitiEcmModel).toHaveBeenCalled(); diff --git a/lib/core/form/services/ecm-model.service.ts b/lib/core/form/services/ecm-model.service.ts index 143c338605..7583c16760 100644 --- a/lib/core/form/services/ecm-model.service.ts +++ b/lib/core/form/services/ecm-model.service.ts @@ -65,9 +65,7 @@ export class EcmModelService { } searchActivitiEcmModel() { - return this.getEcmModels().pipe(map(function (ecmModels: any) { - return ecmModels.list.entries.find((model) => model.entry.name === EcmModelService.MODEL_NAME); - })); + return this.getEcmModels().pipe(map((ecmModels: any) => ecmModels.list.entries.find((model) => model.entry.name === EcmModelService.MODEL_NAME))); } createActivitiEcmModel(formName: string, form: FormModel): Observable { @@ -129,9 +127,8 @@ export class EcmModelService { } public searchEcmType(typeName: string, modelName: string): Observable { - return this.getEcmType(modelName).pipe(map(function (customTypes: any) { - return customTypes.list.entries.find((type) => type.entry.prefixedName === typeName || type.entry.title === typeName); - })); + return this.getEcmType(modelName).pipe(map((customTypes: any) => + customTypes.list.entries.find((type) => type.entry.prefixedName === typeName || type.entry.title === typeName))); } public activeEcmModel(modelName: string): Observable { diff --git a/lib/core/form/services/form-rendering.service.ts b/lib/core/form/services/form-rendering.service.ts index e9ae3e7b4e..31b2e294e4 100644 --- a/lib/core/form/services/form-rendering.service.ts +++ b/lib/core/form/services/form-rendering.service.ts @@ -19,6 +19,7 @@ import { DynamicComponentMapper, DynamicComponentResolveFunction, DynamicCompone import { Injectable, Type } from '@angular/core'; import * as widgets from './../components/widgets/index'; +/* eslint-disable id-blacklist */ @Injectable({ providedIn: 'root' }) @@ -26,28 +27,28 @@ export class FormRenderingService extends DynamicComponentMapper { protected defaultValue: Type = widgets.UnknownWidgetComponent; protected types: { [key: string]: DynamicComponentResolveFunction } = { - 'text': DynamicComponentResolver.fromType(widgets.TextWidgetComponent), - 'string': DynamicComponentResolver.fromType(widgets.TextWidgetComponent), - 'integer': DynamicComponentResolver.fromType(widgets.NumberWidgetComponent), + text: DynamicComponentResolver.fromType(widgets.TextWidgetComponent), + string: DynamicComponentResolver.fromType(widgets.TextWidgetComponent), + integer: DynamicComponentResolver.fromType(widgets.NumberWidgetComponent), 'multi-line-text': DynamicComponentResolver.fromType(widgets.MultilineTextWidgetComponentComponent), - 'boolean': DynamicComponentResolver.fromType(widgets.CheckboxWidgetComponent), - 'dropdown': DynamicComponentResolver.fromType(widgets.DropdownWidgetComponent), - 'date': DynamicComponentResolver.fromType(widgets.DateWidgetComponent), - 'amount': DynamicComponentResolver.fromType(widgets.AmountWidgetComponent), + boolean: DynamicComponentResolver.fromType(widgets.CheckboxWidgetComponent), + dropdown: DynamicComponentResolver.fromType(widgets.DropdownWidgetComponent), + date: DynamicComponentResolver.fromType(widgets.DateWidgetComponent), + amount: DynamicComponentResolver.fromType(widgets.AmountWidgetComponent), 'radio-buttons': DynamicComponentResolver.fromType(widgets.RadioButtonsWidgetComponent), - 'hyperlink': DynamicComponentResolver.fromType(widgets.HyperlinkWidgetComponent), + hyperlink: DynamicComponentResolver.fromType(widgets.HyperlinkWidgetComponent), 'readonly-text': DynamicComponentResolver.fromType(widgets.DisplayTextWidgetComponent), - 'json': DynamicComponentResolver.fromType(widgets.JsonWidgetComponent), - 'readonly': DynamicComponentResolver.fromType(widgets.TextWidgetComponent), - 'typeahead': DynamicComponentResolver.fromType(widgets.TypeaheadWidgetComponent), - 'people': DynamicComponentResolver.fromType(widgets.PeopleWidgetComponent), + json: DynamicComponentResolver.fromType(widgets.JsonWidgetComponent), + readonly: DynamicComponentResolver.fromType(widgets.TextWidgetComponent), + typeahead: DynamicComponentResolver.fromType(widgets.TypeaheadWidgetComponent), + people: DynamicComponentResolver.fromType(widgets.PeopleWidgetComponent), 'functional-group': DynamicComponentResolver.fromType(widgets.FunctionalGroupWidgetComponent), 'dynamic-table': DynamicComponentResolver.fromType(widgets.DynamicTableWidgetComponent), - 'container': DynamicComponentResolver.fromType(widgets.ContainerWidgetComponent), - 'group': DynamicComponentResolver.fromType(widgets.ContainerWidgetComponent), - 'document': DynamicComponentResolver.fromType(widgets.DocumentWidgetComponent), - 'upload': DynamicComponentResolver.fromType(widgets.UploadWidgetComponent), - 'datetime': DynamicComponentResolver.fromType(widgets.DateTimeWidgetComponent), + container: DynamicComponentResolver.fromType(widgets.ContainerWidgetComponent), + group: DynamicComponentResolver.fromType(widgets.ContainerWidgetComponent), + document: DynamicComponentResolver.fromType(widgets.DocumentWidgetComponent), + upload: DynamicComponentResolver.fromType(widgets.UploadWidgetComponent), + datetime: DynamicComponentResolver.fromType(widgets.DateTimeWidgetComponent), 'file-viewer': DynamicComponentResolver.fromType(widgets.FileViewerWidgetComponent) }; } diff --git a/lib/core/form/services/form.service.spec.ts b/lib/core/form/services/form.service.spec.ts index 0ff4b39eb7..22619ce32b 100644 --- a/lib/core/form/services/form.service.spec.ts +++ b/lib/core/form/services/form.service.spec.ts @@ -25,28 +25,28 @@ import { TranslateModule } from '@ngx-translate/core'; declare let jasmine: any; const fakeGroupResponse = { - 'size': 2, - 'total': 2, - 'start': 0, - 'data': [{ - 'id': '2004', - 'name': 'PEOPLE_GROUP', - 'externalId': null, - 'status': 'active', - 'groups': null - }, { 'id': 2005, 'name': 'PEOPLE_GROUP_2', 'externalId': null, 'status': 'active', 'groups': null }] + size: 2, + total: 2, + start: 0, + data: [{ + id: '2004', + name: 'PEOPLE_GROUP', + externalId: null, + status: 'active', + groups: null + }, { id: 2005, name: 'PEOPLE_GROUP_2', externalId: null, status: 'active', groups: null }] }; const fakePeopleResponse = { - 'size': 3, - 'total': 3, - 'start': 0, - 'data': [{ 'id': 2002, 'firstName': 'Peo', 'lastName': 'Ple', 'email': 'people' }, { - 'id': 2003, - 'firstName': 'Peo02', - 'lastName': 'Ple02', - 'email': 'people02' - }, { 'id': 2004, 'firstName': 'Peo03', 'lastName': 'Ple03', 'email': 'people03' }] + size: 3, + total: 3, + start: 0, + data: [{ id: 2002, firstName: 'Peo', lastName: 'Ple', email: 'people' }, { + id: 2003, + firstName: 'Peo02', + lastName: 'Ple02', + email: 'people02' + }, { id: 2004, firstName: 'Peo03', lastName: 'Ple03', email: 'people03' }] }; describe('Form service', () => { @@ -93,7 +93,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(responseBody) }); @@ -107,7 +107,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(responseBody) }); @@ -121,7 +121,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({ id: '1' }) }); @@ -136,7 +136,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(responseBody) }); @@ -151,7 +151,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(responseBody) }); @@ -167,7 +167,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(responseBody) }); @@ -181,7 +181,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({ id: 1 }) }); @@ -195,7 +195,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({ id: 1 }) }); @@ -217,7 +217,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(response) }); @@ -233,7 +233,7 @@ describe('Form service', () => { it('should handle error with error message', () => { const message = ''; - service.handleError({ message: message }).subscribe(() => { + service.handleError({ message }).subscribe(() => { }, (error) => { expect(error).toBe(message); }); @@ -266,7 +266,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({ data: [ @@ -288,7 +288,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(response) }); @@ -303,7 +303,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(simpleResponseBody) }); @@ -322,7 +322,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakePeopleResponse) }); @@ -340,7 +340,7 @@ describe('Form service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeGroupResponse) }); @@ -353,23 +353,10 @@ describe('Form service', () => { }); it('should create a Form form a Node', (done) => { - const nameForm = 'testNode'; - const formId = 100; - stubCreateForm(); - - stubGetEcmModel(); - - stubAddFieldsToAForm(); - - service.createFormFromANode(nameForm).subscribe((result) => { - expect(result.id).toEqual(formId); - done(); - }); - - function stubCreateForm() { + const stubCreateForm = () => { jasmine.Ajax.stubRequest( 'http://localhost:9876/bpm/activiti-app/api/enterprise/models' ).andReturn({ @@ -378,9 +365,9 @@ describe('Form service', () => { contentType: 'text/xml;charset=UTF-8', responseText: { id: formId, name: 'test', lastUpdatedByFullName: 'uset', lastUpdated: '12-12-2016' } }); - } + }; - function stubGetEcmModel() { + const stubGetEcmModel = () => { jasmine.Ajax.stubRequest( 'http://localhost:9876/ecm/alfresco/api/-default-/private/alfresco/versions/1/cmm/activitiFormsModel/types' ).andReturn({ @@ -399,9 +386,9 @@ describe('Form service', () => { } } }); - } + }; - function stubAddFieldsToAForm() { + const stubAddFieldsToAForm = () => { jasmine.Ajax.stubRequest( 'http://localhost:9876/bpm/activiti-app/api/enterprise/editor/form-models/' + formId ).andReturn({ @@ -410,7 +397,16 @@ describe('Form service', () => { contentType: 'text/xml;charset=UTF-8', responseText: { id: formId, name: 'test', lastUpdatedByFullName: 'user', lastUpdated: '12-12-2016' } }); - } + }; + + stubCreateForm(); + stubGetEcmModel(); + stubAddFieldsToAForm(); + + service.createFormFromANode(nameForm).subscribe((result) => { + expect(result.id).toEqual(formId); + done(); + }); }); }); }); diff --git a/lib/core/form/services/form.service.ts b/lib/core/form/services/form.service.ts index 2cb0eca73d..21be23cc9f 100644 --- a/lib/core/form/services/form.service.ts +++ b/lib/core/form/services/form.service.ts @@ -137,6 +137,7 @@ export class FormService implements FormValidationService { /** * Parses JSON data to create a corresponding Form model. + * * @param json JSON to create the form * @param data Values for the form fields * @param readOnly Should the form fields be read-only? @@ -148,7 +149,7 @@ export class FormService implements FormValidationService { const form = new FormModel(json, data, readOnly, this, fixedSpace); if (!json.fields) { form.outcomes = [ - new FormOutcomeModel( form, { + new FormOutcomeModel(form, { id: '$save', name: FormOutcomeModel.SAVE_ACTION, isSystem: true @@ -162,6 +163,7 @@ export class FormService implements FormValidationService { /** * Creates a Form with a field for each metadata property. + * * @param formName Name of the new form * @returns The new form */ @@ -187,6 +189,7 @@ export class FormService implements FormValidationService { /** * Create a Form. + * * @param formName Name of the new form * @returns The new form */ @@ -205,6 +208,7 @@ export class FormService implements FormValidationService { /** * Saves a form. + * * @param formId ID of the form to save * @param formModel Model data for the form * @returns Data for the saved form @@ -217,32 +221,32 @@ export class FormService implements FormValidationService { /** * Searches for a form by name. + * * @param name The form name to search for * @returns Form model(s) matching the search name */ searchFrom(name: string): Observable { const opts = { - 'modelType': 2 + modelType: 2 }; return from( this.modelsApi.getModels(opts) ) .pipe( - map(function (forms: any) { - return forms.data.find((formData) => formData.name === name); - }), + map((forms: any) => forms.data.find((formData) => formData.name === name)), catchError((err) => this.handleError(err)) ); } /** * Gets all the forms. + * * @returns List of form models */ getForms(): Observable { const opts = { - 'modelType': 2 + modelType: 2 }; return from(this.modelsApi.getModels(opts)) @@ -254,6 +258,7 @@ export class FormService implements FormValidationService { /** * Gets process definitions. + * * @returns List of process definitions */ getProcessDefinitions(): Observable { @@ -266,6 +271,7 @@ export class FormService implements FormValidationService { /** * Gets instance variables for a process. + * * @param processInstanceId ID of the target process * @returns List of instance variable information */ @@ -279,6 +285,7 @@ export class FormService implements FormValidationService { /** * Gets all the tasks. + * * @returns List of tasks */ getTasks(): Observable { @@ -291,6 +298,7 @@ export class FormService implements FormValidationService { /** * Gets a task. + * * @param taskId Task Id * @returns Task info */ @@ -304,12 +312,13 @@ export class FormService implements FormValidationService { /** * Saves a task form. + * * @param taskId Task Id * @param formValues Form Values * @returns Null response when the operation is complete */ saveTaskForm(taskId: string, formValues: FormValues): Observable { - const saveFormRepresentation = { values: formValues }; + const saveFormRepresentation = { values: formValues } as SaveFormRepresentation; return from(this.taskFormsApi.saveTaskForm(taskId, saveFormRepresentation)) .pipe( @@ -319,13 +328,14 @@ export class FormService implements FormValidationService { /** * Completes a Task Form. + * * @param taskId Task Id * @param formValues Form Values * @param outcome Form Outcome * @returns Null response when the operation is complete */ completeTaskForm(taskId: string, formValues: FormValues, outcome?: string): Observable { - const completeFormRepresentation: any = { values: formValues }; + const completeFormRepresentation = { values: formValues } as CompleteFormRepresentation; if (outcome) { completeFormRepresentation.outcome = outcome; } @@ -338,6 +348,7 @@ export class FormService implements FormValidationService { /** * Gets a form related to a task. + * * @param taskId ID of the target task * @returns Form definition */ @@ -351,6 +362,7 @@ export class FormService implements FormValidationService { /** * Gets a form definition. + * * @param formId ID of the target form * @returns Form definition */ @@ -364,14 +376,15 @@ export class FormService implements FormValidationService { /** * Gets the form definition with a given name. + * * @param name The form name * @returns Form definition */ getFormDefinitionByName(name: string): Observable { const opts = { - 'filter': 'myReusableForms', - 'filterText': name, - 'modelType': 2 + filter: 'myReusableForms', + filterText: name, + modelType: 2 }; return from(this.modelsApi.getModels(opts)) @@ -383,6 +396,7 @@ export class FormService implements FormValidationService { /** * Gets the start form instance for a given process. + * * @param processId Process definition ID * @returns Form definition */ @@ -396,6 +410,7 @@ export class FormService implements FormValidationService { /** * Gets a process instance. + * * @param processId ID of the process to get * @returns Process instance */ @@ -409,6 +424,7 @@ export class FormService implements FormValidationService { /** * Gets the start form definition for a given process. + * * @param processId Process definition ID * @returns Form definition */ @@ -422,6 +438,7 @@ export class FormService implements FormValidationService { /** * Gets values of fields populated by a REST backend. + * * @param taskId Task identifier * @param field Field identifier * @returns Field values @@ -435,6 +452,7 @@ export class FormService implements FormValidationService { /** * Gets values of fields populated by a REST backend using a process ID. + * * @param processDefinitionId Process identifier * @param field Field identifier * @returns Field values @@ -448,6 +466,7 @@ export class FormService implements FormValidationService { /** * Gets column values of fields populated by a REST backend using a process ID. + * * @param processDefinitionId Process identifier * @param field Field identifier * @param column Column identifier @@ -462,6 +481,7 @@ export class FormService implements FormValidationService { /** * Gets column values of fields populated by a REST backend. + * * @param taskId Task identifier * @param field Field identifier * @param column Column identifier @@ -476,6 +496,7 @@ export class FormService implements FormValidationService { /** * Returns a URL for the profile picture of a user. + * * @param userId ID of the target user * @returns URL string */ @@ -485,18 +506,19 @@ export class FormService implements FormValidationService { /** * Gets a list of workflow users. + * * @param filter Filter to select specific users * @param groupId Group ID for the search * @returns Array of users */ getWorkflowUsers(filter: string, groupId?: string): Observable { - const option: any = { filter: filter }; + const option: any = { filter }; if (groupId) { option.groupId = groupId; } return from(this.usersApi.getUsers(option)) .pipe( - switchMap(response => response.data || []), + switchMap(response => response.data as UserProcessModel[] || []), map((user) => { user.userImage = this.getUserProfileImageApi(user.id.toString()); return of(user); @@ -509,24 +531,26 @@ export class FormService implements FormValidationService { /** * Gets a list of groups in a workflow. + * * @param filter Filter to select specific groups * @param groupId Group ID for the search * @returns Array of groups */ getWorkflowGroups(filter: string, groupId?: string): Observable { - const option: any = { filter: filter }; + const option: any = { filter }; if (groupId) { option.groupId = groupId; } return from(this.groupsApi.getGroups(option)) .pipe( - map((response: any) => response.data || []), + map((response: any) => response.data || []), catchError((err) => this.handleError(err)) ); } /** * Gets the ID of a form. + * * @param form Object representing a form * @returns ID string */ @@ -542,6 +566,7 @@ export class FormService implements FormValidationService { /** * Creates a JSON representation of form data. + * * @param res Object representing form data * @returns JSON data */ @@ -554,6 +579,7 @@ export class FormService implements FormValidationService { /** * Creates a JSON array representation of form data. + * * @param res Object representing form data * @returns JSON data */ @@ -566,6 +592,7 @@ export class FormService implements FormValidationService { /** * Reports an error message. + * * @param error Data object with optional `message` and `status` fields for the error * @returns Error message */ diff --git a/lib/core/form/services/node.service.spec.ts b/lib/core/form/services/node.service.spec.ts index 2f2e9bedf6..8e8bd9788f 100644 --- a/lib/core/form/services/node.service.spec.ts +++ b/lib/core/form/services/node.service.spec.ts @@ -71,7 +71,7 @@ describe('NodeService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(responseBody) }); @@ -100,7 +100,7 @@ describe('NodeService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(responseBody) }); @@ -124,7 +124,7 @@ describe('NodeService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(responseBody) }); @@ -144,7 +144,7 @@ describe('NodeService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({}) }); @@ -163,7 +163,7 @@ describe('NodeService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({}) }); diff --git a/lib/core/form/services/process-content.service.spec.ts b/lib/core/form/services/process-content.service.spec.ts index 0893ff8dc0..90e0eb2c1a 100644 --- a/lib/core/form/services/process-content.service.spec.ts +++ b/lib/core/form/services/process-content.service.spec.ts @@ -28,7 +28,7 @@ const fileContentPdfResponseBody = { id: 999, name: 'fake-name.pdf', created: '2017-01-23T12:12:53.219+0000', - createdBy: { id: 2, firstName: 'fake-admin', lastName: 'fake-last', 'email': 'fake-admin' }, + createdBy: { id: 2, firstName: 'fake-admin', lastName: 'fake-last', email: 'fake-admin' }, relatedContent: false, contentAvailable: true, link: false, @@ -42,7 +42,7 @@ const fileContentJpgResponseBody = { id: 888, name: 'fake-name.jpg', created: '2017-01-23T12:12:53.219+0000', - createdBy: { id: 2, firstName: 'fake-admin', lastName: 'fake-last', 'email': 'fake-admin' }, + createdBy: { id: 2, firstName: 'fake-admin', lastName: 'fake-last', email: 'fake-admin' }, relatedContent: false, contentAvailable: true, link: false, @@ -52,7 +52,7 @@ const fileContentJpgResponseBody = { thumbnailStatus: 'unsupported' }; -function createFakeBlob() { +const createFakeBlob = () => { const data = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='; const bytes = new Uint8Array(data.length / 2); @@ -61,7 +61,7 @@ function createFakeBlob() { bytes[i / 2] = parseInt(data.substring(i, i + 2), /* base = */ 16); } return new Blob([bytes], { type: 'image/png' }); -} +}; describe('ProcessContentService', () => { @@ -100,7 +100,7 @@ describe('ProcessContentService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({ size: 2, @@ -150,7 +150,7 @@ describe('ProcessContentService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fileContentJpgResponseBody) }); @@ -168,7 +168,7 @@ describe('ProcessContentService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fileContentPdfResponseBody) }); diff --git a/lib/core/form/services/process-content.service.ts b/lib/core/form/services/process-content.service.ts index add5b78353..84c4ee6517 100644 --- a/lib/core/form/services/process-content.service.ts +++ b/lib/core/form/services/process-content.service.ts @@ -42,6 +42,7 @@ export class ProcessContentService { /** * Create temporary related content from an uploaded file. + * * @param file File to use for content * @returns The created content data */ @@ -52,6 +53,7 @@ export class ProcessContentService { /** * Gets the metadata for a related content item. + * * @param contentId ID of the content item * @returns Metadata for the content */ @@ -62,6 +64,7 @@ export class ProcessContentService { /** * Gets raw binary content data for a related content file. + * * @param contentId ID of the related content * @returns Binary data of the related content */ @@ -72,6 +75,7 @@ export class ProcessContentService { /** * Gets the preview for a related content file. + * * @param contentId ID of the related content * @returns Binary data of the content preview */ @@ -100,6 +104,7 @@ export class ProcessContentService { /** * Gets a URL for direct access to a related content file. + * * @param contentId ID of the related content * @returns URL to access the content */ @@ -109,6 +114,7 @@ export class ProcessContentService { /** * Gets the thumbnail for a related content file. + * * @param contentId ID of the related content * @returns Binary data of the thumbnail image */ @@ -119,6 +125,7 @@ export class ProcessContentService { /** * Gets related content items for a task instance. + * * @param taskId ID of the target task * @param opts Options supported by JS-API * @returns Metadata for the content @@ -130,6 +137,7 @@ export class ProcessContentService { /** * Gets related content items for a process instance. + * * @param processId ID of the target process * @param opts Options supported by JS-API * @returns Metadata for the content @@ -141,6 +149,7 @@ export class ProcessContentService { /** * Deletes related content. + * * @param contentId Identifier of the content to delete * @returns Null response that notifies when the deletion is complete */ @@ -151,6 +160,7 @@ export class ProcessContentService { /** * Associates an uploaded file with a process instance. + * * @param processInstanceId ID of the target process instance * @param content File to associate * @param opts Options supported by JS-API @@ -163,6 +173,7 @@ export class ProcessContentService { /** * Associates an uploaded file with a task instance. + * * @param taskId ID of the target task * @param file File to associate * @param opts Options supported by JS-API @@ -175,6 +186,7 @@ export class ProcessContentService { /** * Creates a JSON representation of data. + * * @param res Object representing data * @returns JSON object */ @@ -187,6 +199,7 @@ export class ProcessContentService { /** * Creates a JSON array representation of data. + * * @param res Object representing data * @returns JSON array object */ @@ -199,6 +212,7 @@ export class ProcessContentService { /** * Reports an error message. + * * @param error Data object with optional `message` and `status` fields for the error * @returns Callback when an error occurs */ diff --git a/lib/core/form/services/widget-visibility-cloud.service.spec.ts b/lib/core/form/services/widget-visibility-cloud.service.spec.ts index 6a6757888e..77991c1852 100644 --- a/lib/core/form/services/widget-visibility-cloud.service.spec.ts +++ b/lib/core/form/services/widget-visibility-cloud.service.spec.ts @@ -596,7 +596,7 @@ describe('WidgetVisibilityCloudService', () => { visibilityObjTest.rightType = 'field'; visibilityObjTest.rightValue = 'RIGHT_FORM_FIELD_ID'; - const container = fakeFormWithField.fields[0]; + const container = fakeFormWithField.fields[0]; const column0 = container.field.columns[0]; const column1 = container.field.columns[1]; @@ -989,12 +989,12 @@ describe('WidgetVisibilityCloudService', () => { type: 'radio-buttons', options: [ { - 'id': 'radioBoxYes', - 'name': 'Yes' + id: 'radioBoxYes', + name: 'Yes' }, { - 'id': 'radioBoxNo', - 'name': 'No' + id: 'radioBoxNo', + name: 'No' } ] }, { diff --git a/lib/core/form/services/widget-visibility.service.spec.ts b/lib/core/form/services/widget-visibility.service.spec.ts index 36b41cee19..64fa602880 100644 --- a/lib/core/form/services/widget-visibility.service.spec.ts +++ b/lib/core/form/services/widget-visibility.service.spec.ts @@ -622,7 +622,7 @@ describe('WidgetVisibilityService', () => { visibilityObjTest.operator = '!='; visibilityObjTest.rightFormFieldId = 'RIGHT_FORM_FIELD_ID'; - const container = fakeFormWithField.fields[0]; + const container = fakeFormWithField.fields[0]; const column0 = container.field.columns[0]; const column1 = container.field.columns[1]; @@ -943,12 +943,12 @@ describe('WidgetVisibilityService', () => { type: 'radio-buttons', options: [ { - 'id': 'radioBoxYes', - 'name': 'Yes' + id: 'radioBoxYes', + name: 'Yes' }, { - 'id': 'radioBoxNo', - 'name': 'No' + id: 'radioBoxNo', + name: 'No' } ] }, { diff --git a/lib/core/form/services/widget-visibility.service.ts b/lib/core/form/services/widget-visibility.service.ts index 0451d011b4..38fc6999d1 100644 --- a/lib/core/form/services/widget-visibility.service.ts +++ b/lib/core/form/services/widget-visibility.service.ts @@ -249,7 +249,7 @@ export class WidgetVisibilityService { private getFormTabContainers(form: FormModel): ContainerModel[] { if (!!form) { - return form.fields.filter(field => field.type === 'container' && field.tab); + return form.fields.filter(field => field.type === 'container' && field.tab) as ContainerModel[]; } return []; } @@ -345,7 +345,7 @@ export class WidgetVisibilityService { .pipe( map((res) => { const jsonRes = this.toJson(res); - this.processVarList = jsonRes; + this.processVarList = jsonRes; return jsonRes; }), catchError(() => this.handleError()) diff --git a/lib/core/info-drawer/info-drawer-layout.component.ts b/lib/core/info-drawer/info-drawer-layout.component.ts index bc897f0f30..77adad8cbf 100644 --- a/lib/core/info-drawer/info-drawer-layout.component.ts +++ b/lib/core/info-drawer/info-drawer-layout.component.ts @@ -22,7 +22,7 @@ import { Component, Directive, Input, ViewEncapsulation } from '@angular/core'; templateUrl: './info-drawer-layout.component.html', styleUrls: ['./info-drawer-layout.component.scss'], encapsulation: ViewEncapsulation.None, - host: { 'class': 'adf-info-drawer-layout' } + host: { class: 'adf-info-drawer-layout' } }) export class InfoDrawerLayoutComponent { /** The visibility of the header. */ diff --git a/lib/core/info-drawer/info-drawer.component.spec.ts b/lib/core/info-drawer/info-drawer.component.spec.ts index 5804d378d8..5dbd2c0b3d 100644 --- a/lib/core/info-drawer/info-drawer.component.spec.ts +++ b/lib/core/info-drawer/info-drawer.component.spec.ts @@ -52,8 +52,8 @@ describe('InfoDrawerComponent', () => { it('should emit when tab is changed', () => { const tabEmitSpy = spyOn(component.currentTab, 'emit'); - const event = {index: 1, tab: {textLabel: 'DETAILS'}}; - component.onTabChange( event); + const event = {index: 1, tab: {textLabel: 'DETAILS'}} as MatTabChangeEvent; + component.onTabChange(event); expect(tabEmitSpy).toHaveBeenCalledWith(1); }); diff --git a/lib/core/info-drawer/info-drawer.component.ts b/lib/core/info-drawer/info-drawer.component.ts index 4ab41aa7a6..169e3ea839 100644 --- a/lib/core/info-drawer/info-drawer.component.ts +++ b/lib/core/info-drawer/info-drawer.component.ts @@ -40,7 +40,7 @@ export class InfoDrawerTabComponent { templateUrl: './info-drawer.component.html', styleUrls: ['./info-drawer.component.scss'], encapsulation: ViewEncapsulation.None, - host: { 'class': 'adf-info-drawer' } + host: { class: 'adf-info-drawer' } }) export class InfoDrawerComponent { /** The title of the info drawer (string or translation key). */ diff --git a/lib/core/interface/search-configuration.interface.ts b/lib/core/interface/search-configuration.interface.ts index e237ad107e..fc08ae1b32 100644 --- a/lib/core/interface/search-configuration.interface.ts +++ b/lib/core/interface/search-configuration.interface.ts @@ -23,6 +23,7 @@ export interface SearchConfigurationInterface { /** * Generates a QueryBody object with custom search parameters. + * * @param searchTerm Term text to search for * @param maxResults Maximum number of search results to show in a page * @param skipCount The offset of the start of the page within the results list diff --git a/lib/core/language-menu/language-menu.component.spec.ts b/lib/core/language-menu/language-menu.component.spec.ts index 5c1a87c05a..57373fdb18 100644 --- a/lib/core/language-menu/language-menu.component.spec.ts +++ b/lib/core/language-menu/language-menu.component.spec.ts @@ -31,7 +31,7 @@ describe('LanguageMenuComponent', () => { let userPreferencesService: UserPreferencesService; let languageService: LanguageService; - const languages = [ + const languages = [ { key: 'fake-key-1', label: 'fake-label-1' @@ -45,7 +45,7 @@ describe('LanguageMenuComponent', () => { label: 'fake-label-3', direction: 'rtl' } - ]; + ] as any[]; beforeEach(() => { TestBed.configureTestingModule({ diff --git a/lib/core/layout/components/sidebar-action/sidebar-action-menu.component.ts b/lib/core/layout/components/sidebar-action/sidebar-action-menu.component.ts index 556e963ec0..40455b206f 100644 --- a/lib/core/layout/components/sidebar-action/sidebar-action-menu.component.ts +++ b/lib/core/layout/components/sidebar-action/sidebar-action-menu.component.ts @@ -23,7 +23,7 @@ import { ChangeDetectionStrategy, Component, Directive, Input, ViewEncapsulation styleUrls: ['./sidebar-action-menu.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, - host: { 'class': 'adf-sidebar-action-menu' } + host: { class: 'adf-sidebar-action-menu' } }) export class SidebarActionMenuComponent { diff --git a/lib/core/login/components/login-dialog-panel.component.spec.ts b/lib/core/login/components/login-dialog-panel.component.spec.ts index 599121c190..555ffa29f8 100644 --- a/lib/core/login/components/login-dialog-panel.component.spec.ts +++ b/lib/core/login/components/login-dialog-panel.component.spec.ts @@ -55,7 +55,7 @@ describe('LoginDialogPanelComponent', () => { fixture.destroy(); }); - function loginWithCredentials(username: string, password: string) { + const loginWithCredentials = (username: string, password: string) => { usernameInput.value = username; passwordInput.value = password; @@ -65,7 +65,7 @@ describe('LoginDialogPanelComponent', () => { component.submitForm(); fixture.detectChanges(); - } + }; it('should be created', () => { expect(element.querySelector('#adf-login-form')).not.toBeNull(); diff --git a/lib/core/login/components/login.component.spec.ts b/lib/core/login/components/login.component.spec.ts index dee8509805..12575f648d 100644 --- a/lib/core/login/components/login.component.spec.ts +++ b/lib/core/login/components/login.component.spec.ts @@ -26,7 +26,6 @@ import { LoginErrorEvent } from '../models/login-error.event'; import { LoginSuccessEvent } from '../models/login-success.event'; import { LoginComponent } from './login.component'; import { of, throwError } from 'rxjs'; -import { OauthConfigModel } from '../../models/oauth-config.model'; import { AlfrescoApiService } from '../../services/alfresco-api.service'; import { setupTestBed } from '../../testing/setup-test-bed'; @@ -46,9 +45,7 @@ describe('LoginComponent', () => { let usernameInput; let passwordInput; - const getLoginErrorElement = () => { - return element.querySelector('#login-error'); - }; + const getLoginErrorElement = () => element.querySelector('#login-error'); const getLoginErrorMessage = () => { const errorMessage = undefined; @@ -94,7 +91,7 @@ describe('LoginComponent', () => { fixture.destroy(); }); - function loginWithCredentials(username: string, password: string) { + const loginWithCredentials = (username: string, password: string) => { usernameInput.value = username; passwordInput.value = password; @@ -104,7 +101,7 @@ describe('LoginComponent', () => { element.querySelector('.adf-login-button').click(); fixture.detectChanges(); - } + }; it('should be autocomplete off', () => { expect( @@ -616,7 +613,7 @@ describe('LoginComponent', () => { describe('implicitFlow ', () => { beforeEach(() => { - appConfigService.config.oauth2 = { implicitFlow: true, silentLogin: false }; + appConfigService.config.oauth2 = { implicitFlow: true, silentLogin: false }; appConfigService.load(); alfrescoApiService.reset(); }); @@ -634,7 +631,7 @@ describe('LoginComponent', () => { it('should not render the implicitFlow button in case silentLogin is enabled', fakeAsync(() => { spyOn(authService, 'isOauth').and.returnValue(true); - appConfigService.config.oauth2 = { implicitFlow: true, silentLogin: true }; + appConfigService.config.oauth2 = { implicitFlow: true, silentLogin: true }; spyOn(component, 'redirectToImplicitLogin').and.stub(); diff --git a/lib/core/login/components/login.component.ts b/lib/core/login/components/login.component.ts index da5d25cf88..94d4d86a7f 100644 --- a/lib/core/login/components/login.component.ts +++ b/lib/core/login/components/login.component.ts @@ -39,6 +39,7 @@ import { DomSanitizer, SafeStyle } from '@angular/platform-browser'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; +// eslint-disable-next-line no-shadow enum LoginSteps { Landing = 0, Checking = 1, @@ -195,6 +196,7 @@ export class LoginComponent implements OnInit, OnDestroy { /** * Method called on submit form + * * @param values * @param event */ @@ -220,6 +222,7 @@ export class LoginComponent implements OnInit, OnDestroy { /** * The method check the error in the form and push the error in the formError object + * * @param data */ onValueChanged(data: any) { @@ -306,6 +309,7 @@ export class LoginComponent implements OnInit, OnDestroy { /** * Add a custom form error for a field + * * @param field * @param msg */ @@ -315,6 +319,7 @@ export class LoginComponent implements OnInit, OnDestroy { /** * Add a custom validation rule error for a field + * * @param field * @param ruleId - i.e. required | minlength | maxlength * @param msg @@ -341,6 +346,7 @@ export class LoginComponent implements OnInit, OnDestroy { /** * The method return if a field is valid or not + * * @param field */ isErrorStyle(field: AbstractControl) { diff --git a/lib/core/mock/apps-service.mock.ts b/lib/core/mock/apps-service.mock.ts index 17b37b5ea6..b3f4fa67cb 100644 --- a/lib/core/mock/apps-service.mock.ts +++ b/lib/core/mock/apps-service.mock.ts @@ -15,16 +15,16 @@ * limitations under the License. */ -export let fakeApps = { +export const fakeApps = { size: 2, total: 2, start: 0, data: [ { id: 1, defaultAppId: null, name: 'Sales-Fakes-App', description: 'desc-fake1', modelId: 22, - theme: 'theme-1-fake', icon: 'glyphicon-asterisk', 'deploymentId': '111', 'tenantId': null + theme: 'theme-1-fake', icon: 'glyphicon-asterisk', deploymentId: '111', tenantId: null }, { id: 2, defaultAppId: null, name: 'health-care-Fake', description: 'desc-fake2', modelId: 33, - theme: 'theme-2-fake', icon: 'glyphicon-asterisk', 'deploymentId': '444', 'tenantId': null + theme: 'theme-2-fake', icon: 'glyphicon-asterisk', deploymentId: '444', tenantId: null } ] }; diff --git a/lib/core/mock/bpm-user.service.mock.ts b/lib/core/mock/bpm-user.service.mock.ts index 52c8236a7f..bed069d8c8 100644 --- a/lib/core/mock/bpm-user.service.mock.ts +++ b/lib/core/mock/bpm-user.service.mock.ts @@ -17,7 +17,7 @@ import { BpmUserModel } from '../models'; -export let fakeBpmUserNoImage = { +export const fakeBpmUserNoImage = { apps: [], capabilities: 'fake-capability', company: 'fake-company', @@ -39,7 +39,7 @@ export let fakeBpmUserNoImage = { type: 'fake-type' }; -export let fakeBpmUser = new BpmUserModel({ +export const fakeBpmUser = new BpmUserModel({ apps: [], capabilities: null, company: 'fake-company', @@ -61,7 +61,7 @@ export let fakeBpmUser = new BpmUserModel({ type: 'fake-type' }); -export let fakeBpmEditedUser = { +export const fakeBpmEditedUser = { apps: [], capabilities: 'fake-capability', company: 'fake-company', diff --git a/lib/core/mock/comment-content-service.mock.ts b/lib/core/mock/comment-content-service.mock.ts index 5f03ae41e7..63050aab20 100644 --- a/lib/core/mock/comment-content-service.mock.ts +++ b/lib/core/mock/comment-content-service.mock.ts @@ -15,76 +15,76 @@ * limitations under the License. */ -export let fakeUser1 = { - 'enabled': true, - 'firstName': 'firstName', - 'lastName': 'lastName', - 'email': 'fake-email@dom.com', - 'emailNotificationsEnabled': true, - 'company': {}, - 'id': 'fake-email@dom.com', - 'avatarId': '123-123-123' +export const fakeUser1 = { + enabled: true, + firstName: 'firstName', + lastName: 'lastName', + email: 'fake-email@dom.com', + emailNotificationsEnabled: true, + company: {}, + id: 'fake-email@dom.com', + avatarId: '123-123-123' }; -export let fakeUser2 = { - 'enabled': true, - 'firstName': 'some', - 'lastName': 'one', - 'email': 'some-one@somegroup.com', - 'emailNotificationsEnabled': true, - 'company': {}, - 'id': 'fake-email@dom.com', - 'avatarId': '001-001-001' +export const fakeUser2 = { + enabled: true, + firstName: 'some', + lastName: 'one', + email: 'some-one@somegroup.com', + emailNotificationsEnabled: true, + company: {}, + id: 'fake-email@dom.com', + avatarId: '001-001-001' }; -export let fakeContentComments = { +export const fakeContentComments = { list: { - 'pagination': { - 'count': 4, - 'hasMoreItems': false, - 'totalItems': 4, - 'skipCount': 0, - 'maxItems': 100 + pagination: { + count: 4, + hasMoreItems: false, + totalItems: 4, + skipCount: 0, + maxItems: 100 }, entries: [{ - 'entry': { - 'createdAt': '2018-03-27T10:55:45.725+0000', - 'createdBy': fakeUser1, - 'edited': false, - 'modifiedAt': '2018-03-27T10:55:45.725+0000', - 'canEdit': true, - 'modifiedBy': fakeUser1, - 'canDelete': true, - 'id': '35a0cea7-b6d0-4abc-9030-f4e461dd1ac7', - 'content': 'fake-message-1' + entry: { + createdAt: '2018-03-27T10:55:45.725+0000', + createdBy: fakeUser1, + edited: false, + modifiedAt: '2018-03-27T10:55:45.725+0000', + canEdit: true, + modifiedBy: fakeUser1, + canDelete: true, + id: '35a0cea7-b6d0-4abc-9030-f4e461dd1ac7', + content: 'fake-message-1' } }, { - 'entry': { - 'createdAt': '2018-03-27T10:55:45.725+0000', - 'createdBy': fakeUser2, - 'edited': false, - 'modifiedAt': '2018-03-27T10:55:45.725+0000', - 'canEdit': true, - 'modifiedBy': fakeUser2, - 'canDelete': true, - 'id': '35a0cea7-b6d0-4abc-9030-f4e461dd1ac7', - 'content': 'fake-message-2' + entry: { + createdAt: '2018-03-27T10:55:45.725+0000', + createdBy: fakeUser2, + edited: false, + modifiedAt: '2018-03-27T10:55:45.725+0000', + canEdit: true, + modifiedBy: fakeUser2, + canDelete: true, + id: '35a0cea7-b6d0-4abc-9030-f4e461dd1ac7', + content: 'fake-message-2' } } ] } }; -export let fakeContentComment = { - 'entry': { - 'createdAt': '2018-03-29T11:49:51.735+0000', - 'createdBy': fakeUser1, - 'edited': false, - 'modifiedAt': '2018-03-29T11:49:51.735+0000', - 'canEdit': true, - 'modifiedBy': fakeUser1, - 'canDelete': true, - 'id': '4d07cdc5-f00c-4391-b39d-a842b12478b2', - 'content': 'fake-comment-message' +export const fakeContentComment = { + entry: { + createdAt: '2018-03-29T11:49:51.735+0000', + createdBy: fakeUser1, + edited: false, + modifiedAt: '2018-03-29T11:49:51.735+0000', + canEdit: true, + modifiedBy: fakeUser1, + canDelete: true, + id: '4d07cdc5-f00c-4391-b39d-a842b12478b2', + content: 'fake-comment-message' } }; diff --git a/lib/core/mock/comment-process-service.mock.ts b/lib/core/mock/comment-process-service.mock.ts index 68888351eb..0cf277426d 100644 --- a/lib/core/mock/comment-process-service.mock.ts +++ b/lib/core/mock/comment-process-service.mock.ts @@ -18,11 +18,11 @@ import { CommentModel } from '../models/comment.model'; import { UserProcessModel } from '../models/user-process.model'; -export let fakeUser1 = { id: 1, email: 'fake-email@dom.com', firstName: 'firstName', lastName: 'lastName' }; +export const fakeUser1 = { id: 1, email: 'fake-email@dom.com', firstName: 'firstName', lastName: 'lastName' }; -export let fakeUser2 = { id: 1001, email: 'some-one@somegroup.com', firstName: 'some', lastName: 'one' }; +export const fakeUser2 = { id: 1001, email: 'some-one@somegroup.com', firstName: 'some', lastName: 'one' }; -export let fakeTasksComment = { +export const fakeTasksComment = { size: 2, total: 2, start: 0, data: [ { @@ -34,7 +34,7 @@ export let fakeTasksComment = { ] }; -export let fakeProcessComment = new CommentModel({id: 1, message: 'Test', created: new Date('2016-11-10T03:37:30.010+0000'), createdBy: new UserProcessModel({ +export const fakeProcessComment = new CommentModel({id: 1, message: 'Test', created: new Date('2016-11-10T03:37:30.010+0000'), createdBy: new UserProcessModel({ id: 13, firstName: 'Wilbur', lastName: 'Adams', diff --git a/lib/core/mock/ecm-user.service.mock.ts b/lib/core/mock/ecm-user.service.mock.ts index deccb1ceee..a488716d62 100644 --- a/lib/core/mock/ecm-user.service.mock.ts +++ b/lib/core/mock/ecm-user.service.mock.ts @@ -133,7 +133,7 @@ export const createNewPersonMock = { email: 'fakeEcm@ecmUser.com' }; -export function getFakeUserWithContentAdminCapability(): PersonEntry { +export const getFakeUserWithContentAdminCapability = (): PersonEntry => { const fakeEcmUserWithAdminCapabilities = { ...fakeEcmUser, capabilities: { @@ -142,9 +142,9 @@ export function getFakeUserWithContentAdminCapability(): PersonEntry { }; const mockPerson = new Person(fakeEcmUserWithAdminCapabilities); return { entry: mockPerson }; -} +}; -export function getFakeUserWithContentUserCapability(): PersonEntry { +export const getFakeUserWithContentUserCapability = (): PersonEntry => { const fakeEcmUserWithAdminCapabilities = { ...fakeEcmUser, capabilities: { @@ -153,4 +153,4 @@ export function getFakeUserWithContentUserCapability(): PersonEntry { }; const mockPerson = new Person(fakeEcmUserWithAdminCapabilities); return { entry: mockPerson }; -} +}; diff --git a/lib/core/mock/form/demo-form.mock.ts b/lib/core/mock/form/demo-form.mock.ts index 43cb763464..870686f394 100644 --- a/lib/core/mock/form/demo-form.mock.ts +++ b/lib/core/mock/form/demo-form.mock.ts @@ -18,1833 +18,1833 @@ export class DemoForm { easyForm: any = { - 'formRepresentation': { - 'id': 1001, - 'name': 'ISSUE_FORM', - 'tabs': [], - 'fields': [ + formRepresentation: { + id: 1001, + name: 'ISSUE_FORM', + tabs: [], + fields: [ { - 'fieldType': 'ContainerRepresentation', - 'id': '1498212398417', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': false, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '1498212398417', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: false, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'RestFieldRepresentation', - 'id': 'label', - 'name': 'Label', - 'type': 'dropdown', - 'value': 'Choose one...', - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': true, - 'options': [ + fieldType: 'RestFieldRepresentation', + id: 'label', + name: 'Label', + type: 'dropdown', + value: 'Choose one...', + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: true, + options: [ { - 'id': 'empty', - 'name': 'Choose one...' + id: 'empty', + name: 'Choose one...' }, { - 'id': 'option_1', - 'name': 'test1' + id: 'option_1', + name: 'test1' }, { - 'id': 'option_2', - 'name': 'test2' + id: 'option_2', + name: 'test2' }, { - 'id': 'option_3', - 'name': 'test3' + id: 'option_3', + name: 'test3' } ], - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'endpoint': null, - 'requestHeaders': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + endpoint: null, + requestHeaders: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'Date', - 'name': 'Date', - 'type': 'date', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'Date', + name: 'Date', + type: 'date', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label5', - 'name': 'Label5', - 'type': 'boolean', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1 + fieldType: 'FormFieldRepresentation', + id: 'label5', + name: 'Label5', + type: 'boolean', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 1 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label6', - 'name': 'Label6', - 'type': 'boolean', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1 + fieldType: 'FormFieldRepresentation', + id: 'label6', + name: 'Label6', + type: 'boolean', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 1 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label4', - 'name': 'Label4', - 'type': 'integer', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'label4', + name: 'Label4', + type: 'integer', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'RestFieldRepresentation', - 'id': 'label12', - 'name': 'Label12', - 'type': 'radio-buttons', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': [ + fieldType: 'RestFieldRepresentation', + id: 'label12', + name: 'Label12', + type: 'radio-buttons', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + 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' } ], - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'endpoint': null, - 'requestHeaders': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + endpoint: null, + requestHeaders: null } ] } } ], - 'outcomes': [], - 'javascriptEvents': [], - 'className': '', - 'style': '', - 'customFieldTemplates': {}, - 'metadata': {}, - 'variables': [ + outcomes: [], + javascriptEvents: [], + className: '', + style: '', + customFieldTemplates: {}, + metadata: {}, + variables: [ { - 'id': 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', - 'name': 'name1', - 'type': 'string', - 'value': '' + id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', + name: 'name1', + type: 'string', + value: '' }, { - 'id': '3ed9f28a-dbae-463f-b991-47ef06658bb6', - 'name': 'name2', - 'type': 'string', - 'value': '' + id: '3ed9f28a-dbae-463f-b991-47ef06658bb6', + name: 'name2', + type: 'string', + value: '' }, { - 'id': 'a7710978-1e9c-4b54-a19c-c6267d2b19a2', - 'name': 'input02', - 'type': 'integer' + id: 'a7710978-1e9c-4b54-a19c-c6267d2b19a2', + name: 'input02', + type: 'integer' } ], - 'customFieldsValueInfo': {}, - 'gridsterForm': false, - 'globalDateFormat': 'D-M-YYYY' + customFieldsValueInfo: {}, + gridsterForm: false, + globalDateFormat: 'D-M-YYYY' } }; formDefinition: any = { - 'formRepresentation': { - 'id': 3003, - 'name': 'demo-01', - 'taskId': '7501', - 'taskName': 'Demo Form 01', - 'tabs': [ + formRepresentation: { + id: 3003, + name: 'demo-01', + taskId: '7501', + taskName: 'Demo Form 01', + tabs: [ { - 'id': 'tab1', - 'title': 'Text', - 'visibilityCondition': null + id: 'tab1', + title: 'Text', + visibilityCondition: null }, { - 'id': 'tab2', - 'title': 'Misc', - 'visibilityCondition': null + id: 'tab2', + title: 'Misc', + visibilityCondition: null } ], - 'fields': [ + fields: [ { - 'fieldType': 'ContainerRepresentation', - 'id': '1488274019966', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [], - '2': [] + fieldType: 'ContainerRepresentation', + id: '1488274019966', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [], + 2: [] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': 'section4', - 'name': 'Section 4', - 'type': 'group', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab2', - 'className': null, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 2 + fieldType: 'ContainerRepresentation', + id: 'section4', + name: 'Section 4', + type: 'group', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab2', + className: null, + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 2 }, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label8', - 'name': 'Label8', - 'type': 'people', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab2', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'label8', + name: 'Label8', + type: 'people', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab2', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label13', - 'name': 'Label13', - 'type': 'functional-group', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab2', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'label13', + name: 'Label13', + type: 'functional-group', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab2', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label18', - 'name': 'Label18', - 'type': 'readonly', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab2', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'label18', + name: 'Label18', + type: 'readonly', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab2', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label19', - 'name': 'Label19', - 'type': 'readonly-text', - 'value': 'Display text as part of the form', - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab2', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'label19', + name: 'Label19', + type: 'readonly-text', + value: 'Display text as part of the form', + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab2', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null } ], - '2': [ + 2: [ { - 'fieldType': 'HyperlinkRepresentation', - 'id': 'label15', - 'name': 'Label15', - 'type': 'hyperlink', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab2', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1 + fieldType: 'HyperlinkRepresentation', + id: 'label15', + name: 'Label15', + type: 'hyperlink', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab2', + className: null, + params: { + existingColspan: 1, + maxColspan: 1 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'hyperlinkUrl': 'www.google.com', - 'displayText': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + hyperlinkUrl: 'www.google.com', + displayText: null }, { - 'fieldType': 'AttachFileFieldRepresentation', - 'id': 'label16', - 'name': 'Label16', - 'type': 'upload', - 'value': [], - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab2', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1, - 'fileSource': { - 'serviceId': 'all-file-sources', - 'name': 'All file sources' + fieldType: 'AttachFileFieldRepresentation', + id: 'label16', + name: 'Label16', + type: 'upload', + value: [], + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab2', + className: null, + params: { + existingColspan: 1, + maxColspan: 1, + fileSource: { + serviceId: 'all-file-sources', + name: 'All file sources' } }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'metaDataColumnDefinitions': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + metaDataColumnDefinitions: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label17', - 'name': 'Label17', - 'type': 'select-folder', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab2', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1, - 'folderSource': { - 'serviceId': 'alfresco-1', - 'name': 'Alfresco 5.2 Local', - 'metaDataAllowed': true + fieldType: 'FormFieldRepresentation', + id: 'label17', + name: 'Label17', + type: 'select-folder', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab2', + className: null, + params: { + existingColspan: 1, + maxColspan: 1, + folderSource: { + serviceId: 'alfresco-1', + name: 'Alfresco 5.2 Local', + metaDataAllowed: true } }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null } ] } }, { - 'fieldType': 'DynamicTableRepresentation', - 'id': 'label14', - 'name': 'Label14', - 'type': 'dynamic-table', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab2', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1 + fieldType: 'DynamicTableRepresentation', + id: 'label14', + name: 'Label14', + type: 'dynamic-table', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab2', + className: null, + params: { + existingColspan: 1, + maxColspan: 1 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 2 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 2 }, - 'sizeX': 2, - 'sizeY': 2, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'columnDefinitions': [ + sizeX: 2, + sizeY: 2, + row: -1, + col: -1, + visibilityCondition: null, + columnDefinitions: [ { - 'id': 'id', - 'name': 'id', - 'type': 'String', - 'value': null, - 'optionType': null, - 'options': null, - 'restResponsePath': null, - 'restUrl': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'amountCurrency': null, - 'amountEnableFractions': false, - 'required': true, - 'editable': true, - 'sortable': true, - 'visible': true, - 'endpoint': null, - 'requestHeaders': null + id: 'id', + name: 'id', + type: 'String', + value: null, + optionType: null, + options: null, + restResponsePath: null, + restUrl: null, + restIdProperty: null, + restLabelProperty: null, + amountCurrency: null, + amountEnableFractions: false, + required: true, + editable: true, + sortable: true, + visible: true, + endpoint: null, + requestHeaders: null }, { - 'id': 'name', - 'name': 'name', - 'type': 'String', - 'value': null, - 'optionType': null, - 'options': null, - 'restResponsePath': null, - 'restUrl': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'amountCurrency': null, - 'amountEnableFractions': false, - 'required': true, - 'editable': true, - 'sortable': true, - 'visible': true, - 'endpoint': null, - 'requestHeaders': null + id: 'name', + name: 'name', + type: 'String', + value: null, + optionType: null, + options: null, + restResponsePath: null, + restUrl: null, + restIdProperty: null, + restLabelProperty: null, + amountCurrency: null, + amountEnableFractions: false, + required: true, + editable: true, + sortable: true, + visible: true, + endpoint: null, + requestHeaders: null } ] }, { - 'fieldType': 'ContainerRepresentation', - 'id': 'section1', - 'name': 'Section 1', - 'type': 'group', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 2 + fieldType: 'ContainerRepresentation', + id: 'section1', + name: 'Section 1', + type: 'group', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 2 }, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label1', - 'name': 'Label1', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'label1', + name: 'Label1', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label3', - 'name': 'Label3', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'label3', + name: 'Label3', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label2', - 'name': 'Label2', - 'type': 'multi-line-text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1 + fieldType: 'FormFieldRepresentation', + id: 'label2', + name: 'Label2', + type: 'multi-line-text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 1 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 2, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 2, + row: -1, + col: -1, + visibilityCondition: null } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': 'section2', - 'name': 'Section 2', - 'type': 'group', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 2 + fieldType: 'ContainerRepresentation', + id: 'section2', + name: 'Section 2', + type: 'group', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 2 }, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label4', - 'name': 'Label4', - 'type': 'integer', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'label4', + name: 'Label4', + type: 'integer', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label7', - 'name': 'Label7', - 'type': 'date', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'label7', + name: 'Label7', + type: 'date', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null } ], - '2': [ + 2: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label5', - 'name': 'Label5', - 'type': 'boolean', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1 + fieldType: 'FormFieldRepresentation', + id: 'label5', + name: 'Label5', + type: 'boolean', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 1 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label6', - 'name': 'Label6', - 'type': 'boolean', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1 + fieldType: 'FormFieldRepresentation', + id: 'label6', + name: 'Label6', + type: 'boolean', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 1 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }, { - 'fieldType': 'AmountFieldRepresentation', - 'id': 'label11', - 'name': 'Label11', - 'type': 'amount', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': '10', - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1 + fieldType: 'AmountFieldRepresentation', + id: 'label11', + name: 'Label11', + type: 'amount', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: '10', + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 1 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'enableFractions': false, - 'currency': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + enableFractions: false, + currency: null } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': 'section3', - 'name': 'Section 3', - 'type': 'group', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 2 + fieldType: 'ContainerRepresentation', + id: 'section3', + name: 'Section 3', + type: 'group', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 2 }, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'RestFieldRepresentation', - 'id': 'label9', - 'name': 'Label9', - 'type': 'dropdown', - 'value': 'Choose one...', - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': true, - 'options': [ + fieldType: 'RestFieldRepresentation', + id: 'label9', + name: 'Label9', + type: 'dropdown', + value: 'Choose one...', + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: true, + options: [ { - 'id': 'empty', - 'name': 'Choose one...' + id: 'empty', + name: 'Choose one...' } ], - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'endpoint': null, - 'requestHeaders': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + endpoint: null, + requestHeaders: null }, { - 'fieldType': 'RestFieldRepresentation', - 'id': 'label12', - 'name': 'Label12', - 'type': 'radio-buttons', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': [ + fieldType: 'RestFieldRepresentation', + id: 'label12', + name: 'Label12', + type: 'radio-buttons', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + 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' } ], - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'endpoint': null, - 'requestHeaders': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + endpoint: null, + requestHeaders: null } ], - '2': [ + 2: [ { - 'fieldType': 'RestFieldRepresentation', - 'id': 'label10', - 'name': 'Label10', - 'type': 'typeahead', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1 + fieldType: 'RestFieldRepresentation', + id: 'label10', + name: 'Label10', + type: 'typeahead', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 1 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'endpoint': null, - 'requestHeaders': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + endpoint: null, + requestHeaders: null } ] } } ], - 'outcomes': [], - 'javascriptEvents': [], - 'className': '', - 'style': '', - 'customFieldTemplates': {}, - 'metadata': {}, - 'variables': [ + outcomes: [], + javascriptEvents: [], + className: '', + style: '', + customFieldTemplates: {}, + metadata: {}, + variables: [ { - 'id': 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', - 'name': 'name1', - 'type': 'string', - 'value': '' + id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', + name: 'name1', + type: 'string', + value: '' }, { - 'id': '3ed9f28a-dbae-463f-b991-47ef06658bb6', - 'name': 'name2', - 'type': 'string', - 'value': '' + id: '3ed9f28a-dbae-463f-b991-47ef06658bb6', + name: 'name2', + type: 'string', + value: '' }, { - 'id': 'a7710978-1e9c-4b54-a19c-c6267d2b19a2', - 'name': 'input02', - 'type': 'integer' + id: 'a7710978-1e9c-4b54-a19c-c6267d2b19a2', + name: 'input02', + type: 'integer' } ], - 'gridsterForm': false, - 'globalDateFormat': 'D-M-YYYY' + gridsterForm: false, + globalDateFormat: 'D-M-YYYY' } }; simpleFormDefinition: any = { - 'formRepresentation': { - 'id': 1001, - 'name': 'SIMPLE_FORM_EXAMPLE', - 'description': '', - 'version': 1, - 'lastUpdatedBy': 2, - 'lastUpdatedByFullName': 'Test01 01Test', - 'lastUpdated': '2018-02-26T17:44:04.543+0000', - 'stencilSetId': 0, - 'referenceId': null, - 'taskId': '9999', - 'formDefinition': { - 'tabs': [], - 'fields': [ + formRepresentation: { + id: 1001, + name: 'SIMPLE_FORM_EXAMPLE', + description: '', + version: 1, + lastUpdatedBy: 2, + lastUpdatedByFullName: 'Test01 01Test', + lastUpdated: '2018-02-26T17:44:04.543+0000', + stencilSetId: 0, + referenceId: null, + taskId: '9999', + formDefinition: { + tabs: [], + fields: [ { - 'fieldType': 'ContainerRepresentation', - 'id': '1519666726245', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '1519666726245', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'RestFieldRepresentation', - 'id': 'typeaheadField', - 'name': 'TypeaheadField', - 'type': 'typeahead', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': 'https://jsonplaceholder.typicode.com/users', - 'restResponsePath': null, - 'restIdProperty': 'id', - 'restLabelProperty': 'name', - 'tab': null, - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'RestFieldRepresentation', + id: 'typeaheadField', + name: 'TypeaheadField', + type: 'typeahead', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: 'https://jsonplaceholder.typicode.com/users', + restResponsePath: null, + restIdProperty: 'id', + restLabelProperty: 'name', + tab: null, + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'endpoint': null, - 'requestHeaders': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + endpoint: null, + requestHeaders: null } ], - '2': [ + 2: [ { - 'fieldType': 'RestFieldRepresentation', - 'id': 'radioButton', - 'name': 'RadioButtons', - 'type': 'radio-buttons', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': [ + fieldType: 'RestFieldRepresentation', + id: 'radioButton', + name: 'RadioButtons', + type: 'radio-buttons', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + 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' }, { - 'id': 'option_3', - 'name': 'Option 3' + id: 'option_3', + name: 'Option 3' } ], - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 1 + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { + existingColspan: 1, + maxColspan: 1 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 2, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'endpoint': null, - 'requestHeaders': null + sizeX: 1, + sizeY: 2, + row: -1, + col: -1, + visibilityCondition: null, + endpoint: null, + requestHeaders: null } ] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1519666735185', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '1519666735185', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'RestFieldRepresentation', - 'id': 'selectBox', - 'name': 'SelectBox', - 'type': 'dropdown', - 'value': 'Choose one...', - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': 'manual', - 'hasEmptyValue': true, - 'options': [ + fieldType: 'RestFieldRepresentation', + id: 'selectBox', + name: 'SelectBox', + type: 'dropdown', + value: 'Choose one...', + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: 'manual', + hasEmptyValue: true, + options: [ { - 'id': 'empty', - 'name': 'Choose one...' + id: 'empty', + name: 'Choose one...' }, { - 'id': 'option_1', - 'name': '1' + id: 'option_1', + name: '1' }, { - 'id': 'option_2', - 'name': '2' + id: 'option_2', + name: '2' }, { - 'id': 'option_3', - 'name': '3' + id: 'option_3', + name: '3' } ], - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'endpoint': null, - 'requestHeaders': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + endpoint: null, + requestHeaders: null } ], - '2': [] + 2: [] } } ], - 'outcomes': [], - 'javascriptEvents': [], - 'className': '', - 'style': '', - 'customFieldTemplates': {}, - 'metadata': {}, - 'variables': [ + outcomes: [], + javascriptEvents: [], + className: '', + style: '', + customFieldTemplates: {}, + metadata: {}, + variables: [ { - 'id': 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', - 'name': 'name1', - 'type': 'string', - 'value': '' + id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', + name: 'name1', + type: 'string', + value: '' }, { - 'id': '3ed9f28a-dbae-463f-b991-47ef06658bb6', - 'name': 'name2', - 'type': 'string', - 'value': '' + id: '3ed9f28a-dbae-463f-b991-47ef06658bb6', + name: 'name2', + type: 'string', + value: '' }, { - 'id': 'a7710978-1e9c-4b54-a19c-c6267d2b19a2', - 'name': 'input02', - 'type': 'integer' + id: 'a7710978-1e9c-4b54-a19c-c6267d2b19a2', + name: 'input02', + type: 'integer' } ], - 'customFieldsValueInfo': {}, - 'gridsterForm': false + customFieldsValueInfo: {}, + gridsterForm: false } } }; cloudFormDefinition: any = { - 'formRepresentation': { - 'id': 'text-form', - 'name': 'test-start-form', - 'version': 0, - 'description': '', - 'formDefinition': { - 'tabs': [], - 'fields': [ + formRepresentation: { + id: 'text-form', + name: 'test-start-form', + version: 0, + description: '', + formDefinition: { + tabs: [], + fields: [ { - 'id': '1511517333638', - 'type': 'container', - 'fieldType': 'ContainerRepresentation', - 'name': 'Label', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + id: '1511517333638', + type: 'container', + fieldType: 'ContainerRepresentation', + name: 'Label', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'texttest', - 'name': 'texttest', - 'type': 'text', - 'value': null, - 'required': false, - 'placeholder': 'text', - 'params': { - 'existingColspan': 2, - 'maxColspan': 6, - 'inputMaskReversed': true, - 'inputMask': '0#', - 'inputMaskPlaceholder': '(0-9)' + fieldType: 'FormFieldRepresentation', + id: 'texttest', + name: 'texttest', + type: 'text', + value: null, + required: false, + placeholder: 'text', + params: { + existingColspan: 2, + maxColspan: 6, + inputMaskReversed: true, + inputMask: '0#', + inputMaskPlaceholder: '(0-9)' } } ], - '2': [{ - 'fieldType': 'AttachFileFieldRepresentation', - 'id': 'attachfiletest', - 'name': 'attachfiletest', - 'type': 'upload', - 'required': true, - 'colspan': 2, - 'placeholder': 'attachfile', - 'params': { - 'existingColspan': 2, - 'maxColspan': 2, - 'fileSource': { - 'serviceId': 'local-file', - 'name': 'Local File' + 2: [{ + fieldType: 'AttachFileFieldRepresentation', + id: 'attachfiletest', + name: 'attachfiletest', + type: 'upload', + required: true, + colspan: 2, + placeholder: 'attachfile', + params: { + existingColspan: 2, + maxColspan: 2, + fileSource: { + serviceId: 'local-file', + name: 'Local File' }, - 'multiple': true, - 'link': false + multiple: true, + link: false }, - 'visibilityCondition': { + visibilityCondition: { } }] } } ], - 'outcomes': [], - 'metadata': { - 'property1': 'value1', - 'property2': 'value2' + outcomes: [], + metadata: { + property1: 'value1', + property2: 'value2' }, - 'variables': [ + variables: [ { - 'name': 'variable1', - 'type': 'string', - 'value': 'value1' + name: 'variable1', + type: 'string', + value: 'value1' }, { - 'name': 'variable2', - 'type': 'string', - 'value': 'value2' + name: 'variable2', + type: 'string', + value: 'value2' } ] } diff --git a/lib/core/mock/form/form-definition-readonly.mock.ts b/lib/core/mock/form/form-definition-readonly.mock.ts index b1b5a4eb5e..a9ea43b174 100644 --- a/lib/core/mock/form/form-definition-readonly.mock.ts +++ b/lib/core/mock/form/form-definition-readonly.mock.ts @@ -59,7 +59,7 @@ export const formReadonlyTwoTextFields: any = { visibilityCondition: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { fieldType: 'FormFieldRepresentation', id: 'firstname', @@ -134,7 +134,7 @@ export const formReadonlyTwoTextFields: any = { visibilityCondition: null } ], - '2': [ + 2: [ { fieldType: 'FormFieldRepresentation', id: 'lastname', diff --git a/lib/core/mock/form/form-definition-visibility.mock.ts b/lib/core/mock/form/form-definition-visibility.mock.ts index 221cef9311..c25c657986 100644 --- a/lib/core/mock/form/form-definition-visibility.mock.ts +++ b/lib/core/mock/form/form-definition-visibility.mock.ts @@ -56,7 +56,7 @@ export const formDefVisibilitiFieldDependsOnNextOne: any = { visibilityCondition: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { fieldType: 'RestFieldRepresentation', id: 'country', @@ -123,7 +123,7 @@ export const formDefVisibilitiFieldDependsOnNextOne: any = { requestHeaders: null } ], - '2': [ + 2: [ { fieldType: 'FormFieldRepresentation', id: 'name', @@ -222,7 +222,7 @@ export const formDefVisibilitiFieldDependsOnPreviousOne: any = { visibilityCondition: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { fieldType: 'FormFieldRepresentation', id: 'name', @@ -265,7 +265,7 @@ export const formDefVisibilitiFieldDependsOnPreviousOne: any = { visibilityCondition: null } ], - '2': [ + 2: [ { fieldType: 'RestFieldRepresentation', id: 'country', diff --git a/lib/core/mock/form/form-definition.mock.ts b/lib/core/mock/form/form-definition.mock.ts index dc0ca93c55..9da0a12510 100644 --- a/lib/core/mock/form/form-definition.mock.ts +++ b/lib/core/mock/form/form-definition.mock.ts @@ -59,7 +59,7 @@ export const formDefinitionTwoTextFields: any = { visibilityCondition: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { fieldType: 'FormFieldRepresentation', id: 'firstname', @@ -102,7 +102,7 @@ export const formDefinitionTwoTextFields: any = { visibilityCondition: null } ], - '2': [ + 2: [ { fieldType: 'FormFieldRepresentation', id: 'lastname', @@ -204,7 +204,7 @@ export const formDefinitionDropdownField: any = { visibilityCondition: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { fieldType: 'RestFieldRepresentation', id: 'country', @@ -266,7 +266,7 @@ export const formDefinitionDropdownField: any = { requestHeaders: null } ], - '2': [] + 2: [] } } ], @@ -326,7 +326,7 @@ export const formDefinitionRequiredField: any = { visibilityCondition: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { fieldType: 'RestFieldRepresentation', id: 'country', @@ -388,7 +388,7 @@ export const formDefinitionRequiredField: any = { requestHeaders: null } ], - '2': [] + 2: [] } } ], diff --git a/lib/core/mock/form/form.service.mock.ts b/lib/core/mock/form/form.service.mock.ts index b3a18cf18c..9fde234bba 100644 --- a/lib/core/mock/form/form.service.mock.ts +++ b/lib/core/mock/form/form.service.mock.ts @@ -63,7 +63,7 @@ export const formModelTabs: any = { visibilityCondition: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { fieldType: 'AmountFieldRepresentation', id: 'label', @@ -108,7 +108,7 @@ export const formModelTabs: any = { currency: null } ], - '2': [ + 2: [ { fieldType: 'FormFieldRepresentation', id: 'label1', @@ -187,7 +187,7 @@ export const formModelTabs: any = { visibilityCondition: null, numberOfColumns: 2, fields: { - '1': [ + 1: [ { fieldType: 'FormFieldRepresentation', id: 'label2', @@ -230,7 +230,7 @@ export const formModelTabs: any = { visibilityCondition: null } ], - '2': [] + 2: [] } } ], diff --git a/lib/core/mock/form/widget-visibility-cloud.service.mock.ts b/lib/core/mock/form/widget-visibility-cloud.service.mock.ts index 01245459d6..ccfcae712d 100644 --- a/lib/core/mock/form/widget-visibility-cloud.service.mock.ts +++ b/lib/core/mock/form/widget-visibility-cloud.service.mock.ts @@ -17,7 +17,7 @@ import { FormModel, FormValues } from '../../form/components/widgets/core/index'; -export let formTest = new FormModel({}); +export const formTest = new FormModel({}); export const fakeTaskProcessVariableModels = [ { id: 'TEST_VAR_1', type: 'string', value: 'test_value_1' }, @@ -26,12 +26,12 @@ export const fakeTaskProcessVariableModels = [ ]; export const formValues: FormValues = { - 'test_1': 'value_1', - 'test_2': 'value_2', - 'test_3': 'value_1', - 'test_4': 'dropdown_id', - 'test_5': 'dropdown_label', - 'dropdown': { 'id': 'dropdown_id', 'name': 'dropdown_label' } + test_1: 'value_1', + test_2: 'value_2', + test_3: 'value_1', + test_4: 'dropdown_id', + test_5: 'dropdown_label', + dropdown: { id: 'dropdown_id', name: 'dropdown_label' } }; export const fakeFormJson: any = { @@ -96,373 +96,373 @@ export const fakeFormJson: any = { ], variables: [ { - 'id': 'e621e8ff-42a6-499c-8121-33c7c35d8641', - 'name': 'age', - 'type': 'integer', - 'value': 11 + id: 'e621e8ff-42a6-499c-8121-33c7c35d8641', + name: 'age', + type: 'integer', + value: 11 }, { - 'id': '4f8aa99e-8526-429c-9d99-809978489d96', - 'name': 'name', - 'type': 'string', - 'value': 'abc' + id: '4f8aa99e-8526-429c-9d99-809978489d96', + name: 'name', + type: 'string', + value: 'abc' }, { - 'id': '0207b649-ff07-4f3a-a589-d10afa507b9b', - 'name': 'dob', - 'type': 'date', - 'value': '2019-05-13' + id: '0207b649-ff07-4f3a-a589-d10afa507b9b', + name: 'dob', + type: 'date', + value: '2019-05-13' } ] }; export const complexVisibilityJsonVisible: any = { - 'id': 47591, - 'name': 'Test-visibility', - 'description': '', - 'version': 4, - 'lastUpdatedBy': 13, - 'lastUpdatedByFullName': 'romano romano', - 'lastUpdated': '2019-06-11T11:04:36.870+0000', - 'stencilSetId': 0, - 'referenceId': null, - 'formDefinition': { - 'tabs': [], - 'fields': [{ - 'fieldType': 'ContainerRepresentation', - 'id': '1560246123312', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label', - 'name': 'Label', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + id: 47591, + name: 'Test-visibility', + description: '', + version: 4, + lastUpdatedBy: 13, + lastUpdatedByFullName: 'romano romano', + lastUpdated: '2019-06-11T11:04:36.870+0000', + stencilSetId: 0, + referenceId: null, + formDefinition: { + tabs: [], + fields: [{ + fieldType: 'ContainerRepresentation', + id: '1560246123312', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label', + name: 'Label', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label1', - 'name': 'Label1', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label1', + name: 'Label1', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1560246128696', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label4', - 'name': 'Label4', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + fieldType: 'ContainerRepresentation', + id: '1560246128696', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label4', + name: 'Label4', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label3', - 'name': 'Label3', - 'type': 'text', - 'value': '', - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label3', + name: 'Label3', + type: 'text', + value: '', + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1560246126964', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label2', - 'name': 'Label2', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + fieldType: 'ContainerRepresentation', + id: '1560246126964', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label2', + name: 'Label2', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label5', - 'name': 'Label5', - 'type': 'boolean', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': { - 'leftType': 'label', - 'leftValue': null, - 'operator': '==', - 'rightValue': 'aaa', - 'rightType': null, - 'nextConditionOperator': 'and', - 'nextCondition': { - 'leftType': 'label1', - 'leftValue': null, - 'operator': '!=', - 'rightValue': 'aaa', - 'rightType': null, - 'nextConditionOperator': 'and', - 'nextCondition': { - 'leftType': 'label2', - 'leftValue': null, - 'operator': '!empty', - 'rightValue': null, - 'rightType': null, - 'nextConditionOperator': 'or', - 'nextCondition': { - 'leftType': 'label3', - 'leftValue': null, - 'operator': 'empty', - 'rightValue': null, - 'rightType': null, - 'nextConditionOperator': null, - 'nextCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label5', + name: 'Label5', + type: 'boolean', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: { + leftType: 'label', + leftValue: null, + operator: '==', + rightValue: 'aaa', + rightType: null, + nextConditionOperator: 'and', + nextCondition: { + leftType: 'label1', + leftValue: null, + operator: '!=', + rightValue: 'aaa', + rightType: null, + nextConditionOperator: 'and', + nextCondition: { + leftType: 'label2', + leftValue: null, + operator: '!empty', + rightValue: null, + rightType: null, + nextConditionOperator: 'or', + nextCondition: { + leftType: 'label3', + leftValue: null, + operator: 'empty', + rightValue: null, + rightType: null, + nextConditionOperator: null, + nextCondition: null } } } @@ -470,364 +470,364 @@ export const complexVisibilityJsonVisible: any = { }] } }], - 'outcomes': [], - 'javascriptEvents': [], - 'className': '', - 'style': '', - 'customFieldTemplates': {}, - 'metadata': {}, - 'variables': [], - 'customFieldsValueInfo': {}, - 'gridsterForm': false + outcomes: [], + javascriptEvents: [], + className: '', + style: '', + customFieldTemplates: {}, + metadata: {}, + variables: [], + customFieldsValueInfo: {}, + gridsterForm: false } }; export const complexVisibilityJsonNotVisible: any = { - 'id': 47591, - 'name': 'Test-visibility', - 'description': '', - 'version': 4, - 'lastUpdatedBy': 13, - 'lastUpdatedByFullName': 'romano romano', - 'lastUpdated': '2019-06-11T11:04:36.870+0000', - 'stencilSetId': 0, - 'referenceId': null, - 'formDefinition': { - 'tabs': [], - 'fields': [{ - 'fieldType': 'ContainerRepresentation', - 'id': '1560246123312', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label', - 'name': 'Label', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + id: 47591, + name: 'Test-visibility', + description: '', + version: 4, + lastUpdatedBy: 13, + lastUpdatedByFullName: 'romano romano', + lastUpdated: '2019-06-11T11:04:36.870+0000', + stencilSetId: 0, + referenceId: null, + formDefinition: { + tabs: [], + fields: [{ + fieldType: 'ContainerRepresentation', + id: '1560246123312', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label', + name: 'Label', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label1', - 'name': 'Label1', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label1', + name: 'Label1', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1560246128696', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label4', - 'name': 'Label4', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + fieldType: 'ContainerRepresentation', + id: '1560246128696', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label4', + name: 'Label4', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label3', - 'name': 'Label3', - 'type': 'text', - 'value': 'OPSSS', - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label3', + name: 'Label3', + type: 'text', + value: 'OPSSS', + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1560246126964', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label2', - 'name': 'Label2', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + fieldType: 'ContainerRepresentation', + id: '1560246126964', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label2', + name: 'Label2', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label5', - 'name': 'Label5', - 'type': 'boolean', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': { - 'leftType': 'label', - 'leftValue': 'label', - 'operator': '==', - 'rightValue': 'aaa', - 'rightType': 'variable', - 'nextConditionOperator': 'and', - 'nextCondition': { - 'leftType': 'field', - 'leftValue': 'label1', - 'operator': '!=', - 'rightValue': 'aaa', - 'rightType': 'variable', - 'nextConditionOperator': 'and', - 'nextCondition': { - 'leftType': 'field', - 'leftValue': 'label2', - 'operator': '!empty', - 'rightValue': null, - 'rightType': 'variable', - 'nextConditionOperator': 'or', - 'nextCondition': { - 'leftType': 'field', - 'leftValue': 'label3', - 'operator': 'empty', - 'rightValue': 'variable', - 'rightType': null, - 'nextConditionOperator': null, - 'nextCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label5', + name: 'Label5', + type: 'boolean', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: { + leftType: 'label', + leftValue: 'label', + operator: '==', + rightValue: 'aaa', + rightType: 'variable', + nextConditionOperator: 'and', + nextCondition: { + leftType: 'field', + leftValue: 'label1', + operator: '!=', + rightValue: 'aaa', + rightType: 'variable', + nextConditionOperator: 'and', + nextCondition: { + leftType: 'field', + leftValue: 'label2', + operator: '!empty', + rightValue: null, + rightType: 'variable', + nextConditionOperator: 'or', + nextCondition: { + leftType: 'field', + leftValue: 'label3', + operator: 'empty', + rightValue: 'variable', + rightType: null, + nextConditionOperator: null, + nextCondition: null } } } @@ -835,15 +835,15 @@ export const complexVisibilityJsonNotVisible: any = { }] } }], - 'outcomes': [], - 'javascriptEvents': [], - 'className': '', - 'style': '', - 'customFieldTemplates': {}, - 'metadata': {}, - 'variables': [], - 'customFieldsValueInfo': {}, - 'gridsterForm': false + outcomes: [], + javascriptEvents: [], + className: '', + style: '', + customFieldTemplates: {}, + metadata: {}, + variables: [], + customFieldsValueInfo: {}, + gridsterForm: false } }; @@ -857,96 +857,96 @@ export const nextConditionForm: any = { taskName: 'TEST', fields: [ { - 'id': '60114002-0da2-4513-ab65-845b4e55d3c8', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + id: '60114002-0da2-4513-ab65-845b4e55d3c8', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'id': 'Text1', - 'name': 'Text1', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'Text1', + name: 'Text1', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'value': 'multiline' + value: 'multiline' }, { - 'id': 'Text3', - 'name': 'Text3', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'Text3', + name: 'Text3', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'value': 'one' + value: 'one' } ], - '2': [ + 2: [ { - 'id': 'Text2', - 'name': 'Text2', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'Text2', + name: 'Text2', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'value': 'one' + value: 'one' }, { - 'id': 'Text4', - 'name': 'Text4', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': { - 'leftType': 'field', - 'leftValue': 'Text1', - 'operator': '==', - 'rightValue': 'multiline', - 'rightType': 'value', - 'nextConditionOperator': 'and', - 'nextCondition': { - 'leftType': 'field', - 'leftValue': 'Text2', - 'operator': '==', - 'rightValue': 'Text3', - 'rightType': 'field', - 'nextConditionOperator': '', - 'nextCondition': null + id: 'Text4', + name: 'Text4', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: { + leftType: 'field', + leftValue: 'Text1', + operator: '==', + rightValue: 'multiline', + rightType: 'value', + nextConditionOperator: 'and', + nextCondition: { + leftType: 'field', + leftValue: 'Text2', + operator: '==', + rightValue: 'Text3', + rightType: 'field', + nextConditionOperator: '', + nextCondition: null } }, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + params: { + existingColspan: 1, + maxColspan: 2 } } ] @@ -956,85 +956,85 @@ export const nextConditionForm: any = { }; export const headerVisibilityCond: any = { - 'id': 'form-f0823c05-51eb-4703-8634-75a6d5e15df5', - 'name': 'text_form', - 'description': '', - 'version': 0, - 'standalone': true, - 'formDefinition': { - 'tabs': [], - 'fields': [ + id: 'form-f0823c05-51eb-4703-8634-75a6d5e15df5', + name: 'text_form', + description: '', + version: 0, + standalone: true, + formDefinition: { + tabs: [], + fields: [ { - 'id': 'Header0hm6n0', - 'name': 'Header', - 'type': 'group', - 'tab': null, - 'params': { - 'allowCollapse': false, - 'collapseByDefault': false + id: 'Header0hm6n0', + name: 'Header', + type: 'group', + tab: null, + params: { + allowCollapse: false, + collapseByDefault: false }, - 'numberOfColumns': 1, - 'fields': { - '1': [] + numberOfColumns: 1, + fields: { + 1: [] }, - 'visibilityCondition': { - 'leftType': 'field', - 'leftValue': 'Text1', - 'operator': '==', - 'rightValue': 'Text2', - 'rightType': 'field', - 'nextConditionOperator': '', - 'nextCondition': null + visibilityCondition: { + leftType: 'field', + leftValue: 'Text1', + operator: '==', + rightValue: 'Text2', + rightType: 'field', + nextConditionOperator: '', + nextCondition: null } }, { - 'id': '19c3a066-c1bf-47f1-97f2-2b9420be3566', - 'name': 'Label', - 'type': 'container', - 'tab': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + id: '19c3a066-c1bf-47f1-97f2-2b9420be3566', + name: 'Label', + type: 'container', + tab: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'id': 'Text1', - 'name': 'Text1', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'Text1', + name: 'Text1', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'id': 'Text2', - 'name': 'Text2', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'Text2', + name: 'Text2', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ] } } ], - 'outcomes': [], - 'metadata': {}, - 'variables': [] + outcomes: [], + metadata: {}, + variables: [] } }; diff --git a/lib/core/mock/form/widget-visibility.service.mock.ts b/lib/core/mock/form/widget-visibility.service.mock.ts index 4449238c14..ba5c5fccab 100644 --- a/lib/core/mock/form/widget-visibility.service.mock.ts +++ b/lib/core/mock/form/widget-visibility.service.mock.ts @@ -17,7 +17,7 @@ import { FormModel, FormValues } from '../../form/components/widgets/core/index'; -export let formTest = new FormModel({}); +export const formTest = new FormModel({}); export const fakeTaskProcessVariableModels = [ { id: 'TEST_VAR_1', type: 'string', value: 'test_value_1' }, @@ -26,12 +26,12 @@ export const fakeTaskProcessVariableModels = [ ]; export const formValues: FormValues = { - 'test_1': 'value_1', - 'test_2': 'value_2', - 'test_3': 'value_1', - 'test_4': 'dropdown_id', - 'test_5': 'dropdown_label', - 'dropdown': { 'id': 'dropdown_id', 'name': 'dropdown_label' } + test_1: 'value_1', + test_2: 'value_2', + test_3: 'value_1', + test_4: 'dropdown_id', + test_5: 'dropdown_label', + dropdown: { id: 'dropdown_id', name: 'dropdown_label' } }; export const fakeFormJson: any = { @@ -96,22 +96,22 @@ export const fakeFormJson: any = { ], variables: [ { - 'id': 'e621e8ff-42a6-499c-8121-33c7c35d8641', - 'name': 'age', - 'type': 'integer', - 'value': 11 + id: 'e621e8ff-42a6-499c-8121-33c7c35d8641', + name: 'age', + type: 'integer', + value: 11 }, { - 'id': '4f8aa99e-8526-429c-9d99-809978489d96', - 'name': 'name', - 'type': 'string', - 'value': 'abc' + id: '4f8aa99e-8526-429c-9d99-809978489d96', + name: 'name', + type: 'string', + value: 'abc' }, { - 'id': '0207b649-ff07-4f3a-a589-d10afa507b9b', - 'name': 'dob', - 'type': 'date', - 'value': '2019-05-13' + id: '0207b649-ff07-4f3a-a589-d10afa507b9b', + name: 'dob', + type: 'date', + value: '2019-05-13' } ] }; @@ -790,381 +790,381 @@ export const fakeFormChainedVisibilityJson: any = { ], variables: [ { - 'id': 'e621e8ff-42a6-499c-8121-33c7c35d8641', - 'name': 'age', - 'type': 'integer', - 'value': 11 + id: 'e621e8ff-42a6-499c-8121-33c7c35d8641', + name: 'age', + type: 'integer', + value: 11 }, { - 'id': '4f8aa99e-8526-429c-9d99-809978489d96', - 'name': 'name', - 'type': 'string', - 'value': 'abc' + id: '4f8aa99e-8526-429c-9d99-809978489d96', + name: 'name', + type: 'string', + value: 'abc' }, { - 'id': '0207b649-ff07-4f3a-a589-d10afa507b9b', - 'name': 'dob', - 'type': 'date', - 'value': '2019-05-13' + id: '0207b649-ff07-4f3a-a589-d10afa507b9b', + name: 'dob', + type: 'date', + value: '2019-05-13' } ] }; export const complexVisibilityJsonVisible: any = { - 'id': 47591, - 'name': 'Test-visibility', - 'description': '', - 'version': 4, - 'lastUpdatedBy': 13, - 'lastUpdatedByFullName': 'romano romano', - 'lastUpdated': '2019-06-11T11: 04: 36.870+0000', - 'stencilSetId': 0, - 'referenceId': null, - 'formDefinition': { - 'tabs': [], - 'fields': [{ - 'fieldType': 'ContainerRepresentation', - 'id': '1560246123312', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label', - 'name': 'Label', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + id: 47591, + name: 'Test-visibility', + description: '', + version: 4, + lastUpdatedBy: 13, + lastUpdatedByFullName: 'romano romano', + lastUpdated: '2019-06-11T11: 04: 36.870+0000', + stencilSetId: 0, + referenceId: null, + formDefinition: { + tabs: [], + fields: [{ + fieldType: 'ContainerRepresentation', + id: '1560246123312', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label', + name: 'Label', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label1', - 'name': 'Label1', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label1', + name: 'Label1', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1560246128696', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label4', - 'name': 'Label4', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + fieldType: 'ContainerRepresentation', + id: '1560246128696', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label4', + name: 'Label4', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label3', - 'name': 'Label3', - 'type': 'text', - 'value': '', - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label3', + name: 'Label3', + type: 'text', + value: '', + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1560246126964', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label2', - 'name': 'Label2', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + fieldType: 'ContainerRepresentation', + id: '1560246126964', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label2', + name: 'Label2', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label5', - 'name': 'Label5', - 'type': 'boolean', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': { - 'leftFormFieldId': 'label', - 'leftRestResponseId': null, - 'operator': '==', - 'rightValue': 'aaa', - 'rightType': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': 'and', - 'nextCondition': { - 'leftFormFieldId': 'label1', - 'leftRestResponseId': null, - 'operator': '!=', - 'rightValue': 'aaa', - 'rightType': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': 'and', - 'nextCondition': { - 'leftFormFieldId': 'label2', - 'leftRestResponseId': null, - 'operator': '!empty', - 'rightValue': null, - 'rightType': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': 'or', - 'nextCondition': { - 'leftFormFieldId': 'label3', - 'leftRestResponseId': null, - 'operator': 'empty', - 'rightValue': null, - 'rightType': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': null, - 'nextCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label5', + name: 'Label5', + type: 'boolean', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: { + leftFormFieldId: 'label', + leftRestResponseId: null, + operator: '==', + rightValue: 'aaa', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: 'and', + nextCondition: { + leftFormFieldId: 'label1', + leftRestResponseId: null, + operator: '!=', + rightValue: 'aaa', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: 'and', + nextCondition: { + leftFormFieldId: 'label2', + leftRestResponseId: null, + operator: '!empty', + rightValue: null, + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: 'or', + nextCondition: { + leftFormFieldId: 'label3', + leftRestResponseId: null, + operator: 'empty', + rightValue: null, + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: null, + nextCondition: null } } } @@ -1172,369 +1172,369 @@ export const complexVisibilityJsonVisible: any = { }] } }], - 'outcomes': [], - 'javascriptEvents': [], - 'className': '', - 'style': '', - 'customFieldTemplates': {}, - 'metadata': {}, - 'variables': [], - 'customFieldsValueInfo': {}, - 'gridsterForm': false + outcomes: [], + javascriptEvents: [], + className: '', + style: '', + customFieldTemplates: {}, + metadata: {}, + variables: [], + customFieldsValueInfo: {}, + gridsterForm: false } }; export const complexVisibilityJsonNotVisible: any = { - 'id': 47591, - 'name': 'Test-visibility', - 'description': '', - 'version': 4, - 'lastUpdatedBy': 13, - 'lastUpdatedByFullName': 'romano romano', - 'lastUpdated': '2019-06-11T11: 04: 36.870+0000', - 'stencilSetId': 0, - 'referenceId': null, - 'formDefinition': { - 'tabs': [], - 'fields': [{ - 'fieldType': 'ContainerRepresentation', - 'id': '1560246123312', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label', - 'name': 'Label', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + id: 47591, + name: 'Test-visibility', + description: '', + version: 4, + lastUpdatedBy: 13, + lastUpdatedByFullName: 'romano romano', + lastUpdated: '2019-06-11T11: 04: 36.870+0000', + stencilSetId: 0, + referenceId: null, + formDefinition: { + tabs: [], + fields: [{ + fieldType: 'ContainerRepresentation', + id: '1560246123312', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label', + name: 'Label', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label1', - 'name': 'Label1', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label1', + name: 'Label1', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1560246128696', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label4', - 'name': 'Label4', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + fieldType: 'ContainerRepresentation', + id: '1560246128696', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label4', + name: 'Label4', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label3', - 'name': 'Label3', - 'type': 'text', - 'value': 'OPSSS', - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label3', + name: 'Label3', + type: 'text', + value: 'OPSSS', + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }] } }, { - 'fieldType': 'ContainerRepresentation', - 'id': '1560246126964', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label2', - 'name': 'Label2', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 2 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + fieldType: 'ContainerRepresentation', + id: '1560246126964', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [{ + fieldType: 'FormFieldRepresentation', + id: 'label2', + name: 'Label2', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null }], - '2': [{ - 'fieldType': 'FormFieldRepresentation', - 'id': 'label5', - 'name': 'Label5', - 'type': 'boolean', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': { - 'leftFormFieldId': 'label', - 'leftRestResponseId': null, - 'operator': '==', - 'rightValue': 'aaa', - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': 'and', - 'nextCondition': { - 'leftFormFieldId': 'label1', - 'leftRestResponseId': null, - 'operator': '!=', - 'rightValue': 'aaa', - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': 'and', - 'nextCondition': { - 'leftFormFieldId': 'label2', - 'leftRestResponseId': null, - 'operator': '!empty', - 'rightValue': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': 'or', - 'nextCondition': { - 'leftFormFieldId': 'label3', - 'leftRestResponseId': null, - 'operator': 'empty', - 'rightValue': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': null, - 'nextCondition': null + 2: [{ + fieldType: 'FormFieldRepresentation', + id: 'label5', + name: 'Label5', + type: 'boolean', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: { + leftFormFieldId: 'label', + leftRestResponseId: null, + operator: '==', + rightValue: 'aaa', + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: 'and', + nextCondition: { + leftFormFieldId: 'label1', + leftRestResponseId: null, + operator: '!=', + rightValue: 'aaa', + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: 'and', + nextCondition: { + leftFormFieldId: 'label2', + leftRestResponseId: null, + operator: '!empty', + rightValue: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: 'or', + nextCondition: { + leftFormFieldId: 'label3', + leftRestResponseId: null, + operator: 'empty', + rightValue: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: null, + nextCondition: null } } } @@ -1542,285 +1542,285 @@ export const complexVisibilityJsonNotVisible: any = { }] } }], - 'outcomes': [], - 'javascriptEvents': [], - 'className': '', - 'style': '', - 'customFieldTemplates': {}, - 'metadata': {}, - 'variables': [], - 'customFieldsValueInfo': {}, - 'gridsterForm': false + outcomes: [], + javascriptEvents: [], + className: '', + style: '', + customFieldTemplates: {}, + metadata: {}, + variables: [], + customFieldsValueInfo: {}, + gridsterForm: false } }; export const tabVisibilityJsonMock: any = { - 'id': 45231, - 'name': 'visibility-form', - 'description': '', - 'version': 2, - 'lastUpdatedBy': 4255, - 'lastUpdatedByFullName': 'first last', - 'lastUpdated': '2019-08-26T08: 04: 02.091+0000', - 'stencilSetId': null, - 'referenceId': null, - 'tabs': [ + id: 45231, + name: 'visibility-form', + description: '', + version: 2, + lastUpdatedBy: 4255, + lastUpdatedByFullName: 'first last', + lastUpdated: '2019-08-26T08: 04: 02.091+0000', + stencilSetId: null, + referenceId: null, + tabs: [ { - 'id': 'tab1', - 'title': 'tab1', - 'visibilityCondition': null + id: 'tab1', + title: 'tab1', + visibilityCondition: null }, { - 'id': 'tab2', - 'title': 'Tab2', - 'visibilityCondition': { - 'leftFormFieldId': 'label', - 'leftRestResponseId': null, - 'operator': '==', - 'rightValue': 'text', - 'rightType': null, - 'rightFormFieldId': '', - 'rightRestResponseId': '', - 'nextConditionOperator': '', - 'nextCondition': null + id: 'tab2', + title: 'Tab2', + visibilityCondition: { + leftFormFieldId: 'label', + leftRestResponseId: null, + operator: '==', + rightValue: 'text', + rightType: null, + rightFormFieldId: '', + rightRestResponseId: '', + nextConditionOperator: '', + nextCondition: null } } ], - 'formDefinition': { - 'fields': [ + formDefinition: { + fields: [ { - 'fieldType': 'ContainerRepresentation', - 'id': '1566806229182', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [ + fieldType: 'ContainerRepresentation', + id: '1566806229182', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + 1: [ { - 'fieldType': 'FormFieldRepresentation', - 'id': 'label', - 'name': 'Label', - 'type': 'text', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': 'tab1', - 'className': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + fieldType: 'FormFieldRepresentation', + id: 'label', + name: 'Label', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: 'tab1', + className: null, + params: { + existingColspan: 1, + maxColspan: 2 }, - 'dateDisplayFormat': null, - 'layout': { - 'row': -1, - 'column': -1, - 'colspan': 1 + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null } ], - '2': [ + 2: [ ] } } ], - 'outcomes': [ + outcomes: [ ], - 'javascriptEvents': [ + javascriptEvents: [ ], - 'className': '', - 'style': '', - 'customFieldTemplates': { + className: '', + style: '', + customFieldTemplates: { }, - 'metadata': { + metadata: { }, - 'variables': [ + variables: [ ], - 'customFieldsValueInfo': { + customFieldsValueInfo: { }, - 'gridsterForm': false + gridsterForm: false } }; export const tabInvalidFormVisibility: any = { - 'id': 'form-0668939d-34b2-440c-ab4d-01ab8b05a881', - 'name': 'tab-visibility', - 'description': '', - 'version': 0, - 'standalone': true, - 'tabs': [ + id: 'form-0668939d-34b2-440c-ab4d-01ab8b05a881', + name: 'tab-visibility', + description: '', + version: 0, + standalone: true, + tabs: [ { - 'id': 'a8a4718d-5019-4852-9645-bba9b8253d86', - 'title': 'tab1', - 'visibilityCondition': { - 'leftType': 'field', - 'leftValue': 'Text1', - 'operator': '==', - 'rightValue': 'showtab', - 'rightType': 'value', - 'nextConditionOperator': '', - 'nextCondition': null + id: 'a8a4718d-5019-4852-9645-bba9b8253d86', + title: 'tab1', + visibilityCondition: { + leftType: 'field', + leftValue: 'Text1', + operator: '==', + rightValue: 'showtab', + rightType: 'value', + nextConditionOperator: '', + nextCondition: null } }, { - 'id': 'bb9033ca-55ef-432a-8120-bffc8a179ebb', - 'title': 'tab2', - 'visibilityCondition': null + id: 'bb9033ca-55ef-432a-8120-bffc8a179ebb', + title: 'tab2', + visibilityCondition: null } ], - 'formDefinition': { - 'fields': [ + formDefinition: { + fields: [ { - 'id': '093270a5-6e28-4cf0-a72a-09731c0d59fd', - 'name': 'Label', - 'type': 'container', - 'tab': 'a8a4718d-5019-4852-9645-bba9b8253d86', - 'numberOfColumns': 2, - 'fields': { - '1': [ + id: '093270a5-6e28-4cf0-a72a-09731c0d59fd', + name: 'Label', + type: 'container', + tab: 'a8a4718d-5019-4852-9645-bba9b8253d86', + numberOfColumns: 2, + fields: { + 1: [ { - 'id': 'Number1', - 'name': 'Number1', - 'type': 'integer', - 'colspan': 1, - 'placeholder': null, - 'minValue': null, - 'maxValue': null, - 'required': false, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'Number1', + name: 'Number1', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } }, { - 'id': 'Number2', - 'name': 'Number2', - 'type': 'integer', - 'colspan': 1, - 'placeholder': null, - 'minValue': null, - 'maxValue': null, - 'required': false, - 'visibilityCondition': { - 'leftType': 'field', - 'leftValue': 'Text2', - 'operator': '==', - 'rightValue': 'shownumber', - 'rightType': 'value', - 'nextConditionOperator': '', - 'nextCondition': null + id: 'Number2', + name: 'Number2', + type: 'integer', + colspan: 1, + placeholder: null, + minValue: null, + maxValue: null, + required: false, + visibilityCondition: { + leftType: 'field', + leftValue: 'Text2', + operator: '==', + rightValue: 'shownumber', + rightType: 'value', + nextConditionOperator: '', + nextCondition: null }, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [ + 2: [ { - 'id': 'Text2', - 'name': 'Text2', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'Text2', + name: 'Text2', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ] } }, { - 'id': 'c33579eb-3514-42cc-832d-2998d06a3eab', - 'name': 'Label', - 'type': 'container', - 'tab': 'bb9033ca-55ef-432a-8120-bffc8a179ebb', - 'numberOfColumns': 2, - 'fields': { - '1': [ + id: 'c33579eb-3514-42cc-832d-2998d06a3eab', + name: 'Label', + type: 'container', + tab: 'bb9033ca-55ef-432a-8120-bffc8a179ebb', + numberOfColumns: 2, + fields: { + 1: [ { - 'id': 'Text1', - 'name': 'Text1', - 'type': 'text', - 'required': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'regexPattern': null, - 'visibilityCondition': null, - 'params': { - 'existingColspan': 1, - 'maxColspan': 2 + id: 'Text1', + name: 'Text1', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 } } ], - '2': [] + 2: [] } } ], - 'outcomes': [], - 'metadata': {}, - 'variables': [] + outcomes: [], + metadata: {}, + variables: [] } }; diff --git a/lib/core/mock/identity-group.mock.ts b/lib/core/mock/identity-group.mock.ts index 2dae1063df..9953c649a8 100644 --- a/lib/core/mock/identity-group.mock.ts +++ b/lib/core/mock/identity-group.mock.ts @@ -19,27 +19,27 @@ import { IdentityGroupModel, IdentityGroupCountModel } from '../models/identity- import { IdentityRoleModel } from '../models/identity-role.model'; import { IdentityJoinGroupRequestModel } from '../services/identity-user.service.interface'; -export const mockIdentityGroup1 = { +export const mockIdentityGroup1 = { id: 'mock-group-id-1', name: 'Mock Group 1', path: '/mock', subGroups: [] -}; +} as IdentityGroupModel; -export const mockIdentityGroup2 = { +export const mockIdentityGroup2 = { id: 'mock-group-id-2', name: 'Mock Group 2', path: '', subGroups: [] -}; +} as IdentityGroupModel; -export const mockIdentityGroup3 = { +export const mockIdentityGroup3 = { id: 'mock-group-id-3', name: 'Mock Group 3', path: '', subGroups: [] -}; +} as IdentityGroupModel; -export const mockIdentityGroup4 = { +export const mockIdentityGroup4 = { id: 'mock-group-id-4', name: 'Mock Group 4', path: '', subGroups: [] -}; +} as IdentityGroupModel; -export const mockIdentityGroup5 = { +export const mockIdentityGroup5 = { id: 'mock-group-id-5', name: 'Mock Group 5', path: '', subGroups: [] -}; +} as IdentityGroupModel; -export const mockIdentityGroupsCount = { count: 10 }; +export const mockIdentityGroupsCount = { count: 10 } as IdentityGroupCountModel; export const mockIdentityGroups = [ mockIdentityGroup1, mockIdentityGroup2, mockIdentityGroup3, mockIdentityGroup4, mockIdentityGroup5 @@ -62,15 +62,15 @@ export const clientRoles: IdentityRoleModel[] = [ export const mockJoinGroupRequest: IdentityJoinGroupRequestModel = {userId: 'mock-hser-id', groupId: 'mock-group-id', realm: 'mock-realm-name'}; -export const mockGroup1 = { +export const mockGroup1 = { id: 'mock-group-id-1', name: 'Mock Group 1', path: '/mock', subGroups: [] -}; +} as IdentityGroupModel; -export const mockGroup2 = { +export const mockGroup2 = { id: 'mock-group-id-2', name: 'Mock Group 2', path: '', subGroups: [] -}; +} as IdentityGroupModel; export const mockGroups = [ - { id: 'mock-group-id-1', name: 'Mock Group 1', path: '/mock', subGroups: [] }, - { id: 'mock-group-id-2', name: 'Mock Group 2', path: '', subGroups: [] } + { id: 'mock-group-id-1', name: 'Mock Group 1', path: '/mock', subGroups: [] } as IdentityGroupModel, + { id: 'mock-group-id-2', name: 'Mock Group 2', path: '', subGroups: [] } as IdentityGroupModel ]; diff --git a/lib/core/mock/identity-user.mock.ts b/lib/core/mock/identity-user.mock.ts index 7e7902e36b..22c02909c4 100644 --- a/lib/core/mock/identity-user.mock.ts +++ b/lib/core/mock/identity-user.mock.ts @@ -22,7 +22,7 @@ export const mockIdentityUser1: IdentityUserModel = { id: 'mock-user-id-1', user export const mockIdentityUser2: IdentityUserModel = { id: 'mock-user-id-2', username: 'userName2', firstName: 'first-name-2', lastName: 'last-name-2', email: 'abcd@xyz.com'}; export const mockIdentityUser3: IdentityUserModel = { id: 'mock-user-id-3', username: 'userName3', firstName: 'first-name-3', lastName: 'last-name-3', email: 'abcde@xyz.com' }; export const mockIdentityUser4: IdentityUserModel = { id: 'mock-user-id-4', username: 'userName4', firstName: 'first-name-4', lastName: 'last-name-4', email: 'abcde@xyz.com' }; -export let mockIdentityUser5: IdentityUserModel = { id: 'mock-user-id-5', username: 'userName5', firstName: 'first-name-5', lastName: 'last-name-5', email: 'abcde@xyz.com' }; +export const mockIdentityUser5: IdentityUserModel = { id: 'mock-user-id-5', username: 'userName5', firstName: 'first-name-5', lastName: 'last-name-5', email: 'abcde@xyz.com' }; export const mockIdentityUsers: IdentityUserModel[] = [ mockIdentityUser1, diff --git a/lib/core/mock/identity-user.service.mock.ts b/lib/core/mock/identity-user.service.mock.ts index 16f94b59f3..f590ea73a7 100644 --- a/lib/core/mock/identity-user.service.mock.ts +++ b/lib/core/mock/identity-user.service.mock.ts @@ -113,17 +113,13 @@ export class IdentityUserServiceMock implements IdentityUserServiceInterface { checkUserHasApplicationAccess(userId: string, applicationName: string): Observable { return this.getClientIdByApplicationName(applicationName).pipe( - switchMap((clientId: string) => { - return this.checkUserHasClientApp(userId, clientId); - }) + switchMap((clientId: string) => this.checkUserHasClientApp(userId, clientId)) ); } checkUserHasAnyApplicationRole(userId: string, applicationName: string, roleNames: string[]): Observable { return this.getClientIdByApplicationName(applicationName).pipe( - switchMap((clientId: string) => { - return this.checkUserHasAnyClientAppRole(userId, clientId, roleNames); - }) + switchMap((clientId: string) => this.checkUserHasAnyClientAppRole(userId, clientId, roleNames)) ); } @@ -173,9 +169,7 @@ export class IdentityUserServiceMock implements IdentityUserServiceInterface { private async userHasAnyRole(userId: string, roleNames: string[]): Promise { const userRoles = await this.getUserRoles(userId).toPromise(); const hasAnyRole = roleNames.some((roleName) => { - const filteredRoles = userRoles.filter((userRole) => { - return userRole.name.toLocaleLowerCase() === roleName.toLocaleLowerCase(); - }); + const filteredRoles = userRoles.filter((userRole) => userRole.name.toLocaleLowerCase() === roleName.toLocaleLowerCase()); return filteredRoles.length > 0; }); diff --git a/lib/core/mock/jwt-helper.service.spec.ts b/lib/core/mock/jwt-helper.service.spec.ts index 57d9f7e35a..3a2a4deb34 100644 --- a/lib/core/mock/jwt-helper.service.spec.ts +++ b/lib/core/mock/jwt-helper.service.spec.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let mockToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ' + +export const mockToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ' + 'zdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiZmFtaWx5X25hbWUiOiJEb2UiLCJnaXZ' + 'lbl9uYW1lIjoiSm9obiIsImFkbWluIjp0cnVlLCJlbWFpbCI6ImpvaG5Eb2VAZ21haWwuY29tIiwicHJ' + 'lZmVycmVkX3VzZXJuYW1lIjoiam9obkRvZTEiLCJqdGkiOiI2MmQ3YjA4NS1hNTJjLTRjZmEtYjA2Zi1' + diff --git a/lib/core/mock/oauth2.service.mock.ts b/lib/core/mock/oauth2.service.mock.ts index e59c5b2c4a..63c787f1ad 100644 --- a/lib/core/mock/oauth2.service.mock.ts +++ b/lib/core/mock/oauth2.service.mock.ts @@ -20,152 +20,114 @@ import { mockAssignedRoles, mockAvailableRoles, mockEffectiveRoles, mockIdentity export const queryUsersMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(mockIdentityUsers); - } + callCustomApi: () => Promise.resolve(mockIdentityUsers) } }; export const createUserMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(); - } + callCustomApi: () => Promise.resolve() } }; export const updateUserMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(); - } + callCustomApi: () => Promise.resolve() } }; export const deleteUserMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(); - } + callCustomApi: () => Promise.resolve() } }; export const getInvolvedGroupsMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(mockGroups); - } + callCustomApi: () => Promise.resolve(mockGroups) } }; export const joinGroupMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(); - } + callCustomApi: () => Promise.resolve() } }; export const leaveGroupMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(); - } + callCustomApi: () => Promise.resolve() } }; export const getAvailableRolesMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(mockAvailableRoles); - } + callCustomApi: () => Promise.resolve(mockAvailableRoles) } }; export const getAssignedRolesMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(mockAssignedRoles); - } + callCustomApi: () => Promise.resolve(mockAssignedRoles) } }; export const getEffectiveRolesMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(mockEffectiveRoles); - } + callCustomApi: () => Promise.resolve(mockEffectiveRoles) } }; export const assignRolesMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(); - } + callCustomApi: () => Promise.resolve() } }; export const removeRolesMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(); - } + callCustomApi: () => Promise.resolve() } }; export const roleMappingApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(roleMappingMock); - } + callCustomApi: () => Promise.resolve(roleMappingMock) } }; export const noRoleMappingApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve([]); - } + callCustomApi: () => Promise.resolve([]) } }; export const groupsMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(mockIdentityGroups); - } + callCustomApi: () => Promise.resolve(mockIdentityGroups) } }; export const createGroupMappingApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(); - } + callCustomApi: () => Promise.resolve() } }; export const updateGroupMappingApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(); - } + callCustomApi: () => Promise.resolve() } }; export const deleteGroupMappingApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve(); - } + callCustomApi: () => Promise.resolve() } }; export const applicationDetailsMockApi: any = { oauth2Auth: { - callCustomApi: () => { - return Promise.resolve([{id: 'mock-app-id', name: 'mock-app-name'}]); - } + callCustomApi: () => Promise.resolve([{id: 'mock-app-id', name: 'mock-app-name'}]) } }; diff --git a/lib/core/mock/renditions-service.mock.ts b/lib/core/mock/renditions-service.mock.ts index 249170af92..9411de92f4 100644 --- a/lib/core/mock/renditions-service.mock.ts +++ b/lib/core/mock/renditions-service.mock.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let fakeRendition = { +export const fakeRendition = { entry: { id: 'pdf', content: { @@ -26,7 +26,7 @@ export let fakeRendition = { } }; -export let fakeRenditionCreated = { +export const fakeRenditionCreated = { entry: { id: 'pdf', content: { @@ -37,7 +37,7 @@ export let fakeRenditionCreated = { } }; -export let fakeRenditionsList = { +export const fakeRenditionsList = { list: { pagination: { count: 6, @@ -111,7 +111,7 @@ export let fakeRenditionsList = { } }; -export let fakeRenditionsListWithACreated = { +export const fakeRenditionsListWithACreated = { list: { pagination: { count: 6, diff --git a/lib/core/mock/search.service.mock.ts b/lib/core/mock/search.service.mock.ts index cd68d988e0..4c81b2ebd2 100644 --- a/lib/core/mock/search.service.mock.ts +++ b/lib/core/mock/search.service.mock.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let fakeSearch = { +export const fakeSearch = { list: { pagination: { count: 1, @@ -44,7 +44,7 @@ export let fakeSearch = { } }; -export let mockError = { +export const mockError = { error: { errorKey: 'Search failed', statusCode: 400, @@ -54,7 +54,7 @@ export let mockError = { } }; -export let searchMockApi: any = { +export const searchMockApi: any = { findNodes: () => Promise.resolve(fakeSearch) diff --git a/lib/core/models/file.model.spec.ts b/lib/core/models/file.model.spec.ts index cbadf70a8c..1a95c6306b 100644 --- a/lib/core/models/file.model.spec.ts +++ b/lib/core/models/file.model.spec.ts @@ -22,25 +22,25 @@ describe('FileModel', () => { describe('extension', () => { it('should return the extension if file has it', () => { - const file = new FileModel( { name: 'tyrion-lannister.doc' }); + const file = new FileModel({ name: 'tyrion-lannister.doc' } as File); expect(file.extension).toBe('doc'); }); it('should return the empty string if file has NOT got it', () => { - const file = new FileModel( { name: 'daenerys-targaryen' }); + const file = new FileModel({ name: 'daenerys-targaryen' } as File); expect(file.extension).toBe(''); }); it('should return the empty string if file is starting with . and doesn\'t have extension', () => { - const file = new FileModel( { name: '.white-walkers' }); + const file = new FileModel({ name: '.white-walkers' } as File); expect(file.extension).toBe(''); }); it('should return the last extension string if file contains many dot', () => { - const file = new FileModel( { name: 'you.know.nothing.jon.snow.exe' }); + const file = new FileModel({ name: 'you.know.nothing.jon.snow.exe' } as File); expect(file.extension).toBe('exe'); }); diff --git a/lib/core/models/file.model.ts b/lib/core/models/file.model.ts index 32c06d6588..df55ae1886 100644 --- a/lib/core/models/file.model.ts +++ b/lib/core/models/file.model.ts @@ -74,6 +74,7 @@ export class FileUploadOptions { versioningEnabled?: boolean; } +// eslint-disable-next-line no-shadow export enum FileUploadStatus { Pending = 0, Complete = 1, diff --git a/lib/core/models/log-levels.model.ts b/lib/core/models/log-levels.model.ts index 7e073d4250..ea9122d99b 100644 --- a/lib/core/models/log-levels.model.ts +++ b/lib/core/models/log-levels.model.ts @@ -24,7 +24,7 @@ export class LogLevelsEnum extends Number { static SILENT: number = 0; } -export let logLevels: any[] = [ +export const logLevels: any[] = [ {level: LogLevelsEnum.TRACE, name: 'TRACE'}, {level: LogLevelsEnum.DEBUG, name: 'DEBUG'}, {level: LogLevelsEnum.INFO, name: 'INFO'}, diff --git a/lib/core/models/search-text-input.model.ts b/lib/core/models/search-text-input.model.ts index 10b4b3436e..275a97fccf 100644 --- a/lib/core/models/search-text-input.model.ts +++ b/lib/core/models/search-text-input.model.ts @@ -15,6 +15,7 @@ * limitations under the License. */ +// eslint-disable-next-line no-shadow export enum SearchTextStateEnum { expanded = 'expanded', collapsed = 'collapsed' diff --git a/lib/core/notifications/components/notification-history.component.spec.ts b/lib/core/notifications/components/notification-history.component.spec.ts index 62631ea780..eeded8aa53 100644 --- a/lib/core/notifications/components/notification-history.component.spec.ts +++ b/lib/core/notifications/components/notification-history.component.spec.ts @@ -34,12 +34,12 @@ describe('Notification History Component', () => { let overlayContainerElement: HTMLElement; let storage: StorageService; - function openNotification() { + const openNotification = () => { fixture.detectChanges(); - const button: HTMLButtonElement = element.querySelector('#adf-notification-history-open-button'); + const button = element.querySelector('#adf-notification-history-open-button'); button.click(); fixture.detectChanges(); - } + }; setupTestBed({ imports: [ @@ -86,7 +86,7 @@ describe('Notification History Component', () => { fixture.whenStable().then(() => { fixture.detectChanges(); expect(component.notifications.length).toBe(1); - const markAllAsRead = overlayContainerElement.querySelector('#adf-notification-history-mark-as-read'); + const markAllAsRead = overlayContainerElement.querySelector('#adf-notification-history-mark-as-read'); markAllAsRead.click(); fixture.detectChanges(); expect(storage.getItem(NotificationHistoryComponent.NOTIFICATION_STORAGE)).toBeNull(); @@ -124,7 +124,7 @@ describe('Notification History Component', () => { fixture.detectChanges(); fixture.whenStable().then(() => { fixture.detectChanges(); - const notification = overlayContainerElement.querySelector('.adf-notification-history-menu-item'); + const notification = overlayContainerElement.querySelector('.adf-notification-history-menu-item'); notification.click(); expect(callBackSpy).toHaveBeenCalled(); done(); @@ -142,7 +142,7 @@ describe('Notification History Component', () => { openNotification(); fixture.whenStable().then(() => { fixture.detectChanges(); - const loadMoreButton = overlayContainerElement.querySelector('.adf-notification-history-load-more'); + const loadMoreButton = overlayContainerElement.querySelector('.adf-notification-history-load-more'); expect(component.paginatedNotifications.length).toBe(5); expect(loadMoreButton).toBeDefined(); done(); @@ -160,7 +160,7 @@ describe('Notification History Component', () => { openNotification(); fixture.whenStable().then(() => { fixture.detectChanges(); - const notification = overlayContainerElement.querySelector('.adf-notification-history-menu-item'); + const notification = overlayContainerElement.querySelector('.adf-notification-history-menu-item'); expect(notification).toBeDefined(); done(); }); diff --git a/lib/core/notifications/helpers/notification.factory.ts b/lib/core/notifications/helpers/notification.factory.ts index 29eb524dec..bcfee9c267 100644 --- a/lib/core/notifications/helpers/notification.factory.ts +++ b/lib/core/notifications/helpers/notification.factory.ts @@ -26,29 +26,23 @@ export const rootInitiator: NotificationInitiator = { displayName: 'SYSTEM' }; -export function info(messages: string | string[], initiator: NotificationInitiator = rootInitiator): NotificationModel { - return { - type: NOTIFICATION_TYPE.INFO, - datetime: new Date(), - initiator, - messages: [].concat(messages) - }; -} +export const info = (messages: string | string[], initiator: NotificationInitiator = rootInitiator): NotificationModel => ({ + type: NOTIFICATION_TYPE.INFO, + datetime: new Date(), + initiator, + messages: [].concat(messages) +}); -export function warning(messages: string | string[], initiator: NotificationInitiator = rootInitiator): NotificationModel { - return { - type: NOTIFICATION_TYPE.WARN, - datetime: new Date(), - initiator, - messages: [].concat(messages) - }; -} +export const warning = (messages: string | string[], initiator: NotificationInitiator = rootInitiator): NotificationModel => ({ + type: NOTIFICATION_TYPE.WARN, + datetime: new Date(), + initiator, + messages: [].concat(messages) +}); -export function error(messages: string | string[], initiator: NotificationInitiator = rootInitiator): NotificationModel { - return { - type: NOTIFICATION_TYPE.ERROR, - datetime: new Date(), - initiator, - messages: [].concat(messages) - }; -} +export const error = (messages: string | string[], initiator: NotificationInitiator = rootInitiator): NotificationModel => ({ + type: NOTIFICATION_TYPE.ERROR, + datetime: new Date(), + initiator, + messages: [].concat(messages) +}); diff --git a/lib/core/notifications/models/notification.model.ts b/lib/core/notifications/models/notification.model.ts index 71100a3511..2fc48e15f7 100644 --- a/lib/core/notifications/models/notification.model.ts +++ b/lib/core/notifications/models/notification.model.ts @@ -15,6 +15,7 @@ * limitations under the License. */ +// eslint-disable-next-line no-shadow export enum NOTIFICATION_TYPE { INFO = 'info', WARN = 'warning', diff --git a/lib/core/notifications/services/notification.service.ts b/lib/core/notifications/services/notification.service.ts index 1b8baeee76..70dbb40a6f 100644 --- a/lib/core/notifications/services/notification.service.ts +++ b/lib/core/notifications/services/notification.service.ts @@ -44,6 +44,7 @@ export class NotificationService { /** * Opens a SnackBar notification to show a message. + * * @param message The message (or resource key) to show. * @param config Time before notification disappears after being shown or MatSnackBarConfig object * @param interpolateArgs The interpolation parameters to add for the translation @@ -55,6 +56,7 @@ export class NotificationService { /** * Opens a SnackBar notification with a message and a response button. + * * @param message The message (or resource key) to show. * @param action Caption for the response button * @param config Time before notification disappears after being shown or MatSnackBarConfig object @@ -67,6 +69,7 @@ export class NotificationService { /** * Rase error message + * * @param message Text message or translation key for the message. * @param action Action name * @param interpolateArgs The interpolation parameters to add for the translation @@ -77,6 +80,7 @@ export class NotificationService { /** * Rase info message + * * @param message Text message or translation key for the message. * @param action Action name * @param interpolateArgs The interpolation parameters to add for the translation @@ -87,6 +91,7 @@ export class NotificationService { /** * Rase warning message + * * @param message Text message or translation key for the message. * @param action Action name * @param interpolateArgs The interpolation parameters to add for the translation @@ -104,6 +109,7 @@ export class NotificationService { /** * Push new notification to Notification History + * * @param notification - Notification model to be pushed. */ pushToNotificationHistory(notification: NotificationModel) { diff --git a/lib/core/pagination/infinite-pagination.component.spec.ts b/lib/core/pagination/infinite-pagination.component.spec.ts index 8a3c47df7c..cef72bf042 100644 --- a/lib/core/pagination/infinite-pagination.component.spec.ts +++ b/lib/core/pagination/infinite-pagination.component.spec.ts @@ -37,7 +37,7 @@ class TestPaginatedComponent implements PaginatedComponent { get pagination(): BehaviorSubject { if (!this._pagination) { - const defaultPagination = { + const defaultPagination = { maxItems: 10, skipCount: 0, totalItems: 0, diff --git a/lib/core/pagination/infinite-pagination.component.ts b/lib/core/pagination/infinite-pagination.component.ts index dd3368c0d7..a7eefa9a22 100644 --- a/lib/core/pagination/infinite-pagination.component.ts +++ b/lib/core/pagination/infinite-pagination.component.ts @@ -34,7 +34,7 @@ import { takeUntil } from 'rxjs/operators'; @Component({ selector: 'adf-infinite-pagination', - host: { 'class': 'infinite-adf-pagination' }, + host: { class: 'infinite-adf-pagination' }, templateUrl: './infinite-pagination.component.html', styleUrls: ['./infinite-pagination.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, @@ -118,7 +118,7 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio if (this._target) { this.isLoading = true; - this._target.updatePagination( this.requestPaginationModel); + this._target.updatePagination(this.requestPaginationModel); } } diff --git a/lib/core/pagination/pagination.component.spec.ts b/lib/core/pagination/pagination.component.spec.ts index e0b9e46ba4..5b2ea01343 100644 --- a/lib/core/pagination/pagination.component.spec.ts +++ b/lib/core/pagination/pagination.component.spec.ts @@ -260,9 +260,9 @@ describe('PaginationComponent', () => { it('should take pagination from the external component', () => { const pagination: Pagination = {}; - const customComponent = { + const customComponent = { pagination: new BehaviorSubject({}) - }; + } as PaginatedComponent; component.target = customComponent; component.ngOnInit(); @@ -275,9 +275,9 @@ describe('PaginationComponent', () => { const pagination1: Pagination = {}; const pagination2: Pagination = {}; - const customComponent = { + const customComponent = { pagination: new BehaviorSubject({}) - }; + } as PaginatedComponent; component.target = customComponent; component.ngOnInit(); @@ -290,12 +290,12 @@ describe('PaginationComponent', () => { }); it('should send pagination event to paginated component', () => { - const customComponent = { + const customComponent = { pagination: new BehaviorSubject({}), - updatePagination() {}, + updatePagination: () => {}, supportedPageSizes: [], rows: [] - }; + } as PaginatedComponent; spyOn(customComponent, 'updatePagination').and.stub(); component.target = customComponent; @@ -310,11 +310,11 @@ describe('PaginationComponent', () => { }); it('should go to previous page if current page has 0 items', () => { - const customComponent = { - updatePagination() {}, + const customComponent = { + updatePagination: () => {}, pagination: new BehaviorSubject({}), rows: [] - }; + } as PaginatedComponent; component.target = customComponent; component.ngOnInit(); @@ -338,9 +338,9 @@ describe('PaginationComponent', () => { it('should not show pagination when external component count is zero', () => { const pagination: Pagination = {}; - const customComponent = { + const customComponent = { pagination: new BehaviorSubject({ count: 0, maxItems: 5, totalItems: 5 }) - }; + } as PaginatedComponent; component.target = customComponent; component.ngOnInit(); customComponent.pagination.next(pagination); diff --git a/lib/core/pipes/file-size.pipe.spec.ts b/lib/core/pipes/file-size.pipe.spec.ts index 0c06687ab3..5b388edbfc 100644 --- a/lib/core/pipes/file-size.pipe.spec.ts +++ b/lib/core/pipes/file-size.pipe.spec.ts @@ -23,7 +23,7 @@ describe('FileSizePipe', () => { beforeEach(() => { const translation: any = { - instant(key) { + instant: (key: string) => { const enUs = { 'CORE.FILE_SIZE.BYTES': 'Bytes', 'CORE.FILE_SIZE.KB': 'KB', diff --git a/lib/core/pipes/node-name-tooltip.pipe.spec.ts b/lib/core/pipes/node-name-tooltip.pipe.spec.ts index 32a5aa2f46..b92875bf0e 100644 --- a/lib/core/pipes/node-name-tooltip.pipe.spec.ts +++ b/lib/core/pipes/node-name-tooltip.pipe.spec.ts @@ -35,7 +35,7 @@ describe('NodeNameTooltipPipe', () => { }); it('should not transform when missing node entry', () => { - expect(pipe.transform( {})).toBe(null); + expect(pipe.transform({} as any)).toBe(null); }); it('should use title and description when all fields present', () => { @@ -57,8 +57,8 @@ describe('NodeNameTooltipPipe', () => { entry: { name: nodeName } - }; - const tooltip = pipe.transform( node); + } as NodeEntry; + const tooltip = pipe.transform(node); expect(tooltip).toBe(nodeName); }); diff --git a/lib/core/pipes/node-name-tooltip.pipe.ts b/lib/core/pipes/node-name-tooltip.pipe.ts index 18dd406d1d..87bc3d02ef 100644 --- a/lib/core/pipes/node-name-tooltip.pipe.ts +++ b/lib/core/pipes/node-name-tooltip.pipe.ts @@ -31,9 +31,7 @@ export class NodeNameTooltipPipe implements PipeTransform { } private containsLine(lines: string[], line: string): boolean { - return lines.some((item: string) => { - return item.toLowerCase() === line.toLowerCase(); - }); + return lines.some((item: string) => item.toLowerCase() === line.toLowerCase()); } private removeDuplicateLines(lines: string[]): string[] { diff --git a/lib/core/search-text/animations.ts b/lib/core/search-text/animations.ts index 964877ee94..8c198a6f79 100644 --- a/lib/core/search-text/animations.ts +++ b/lib/core/search-text/animations.ts @@ -21,13 +21,13 @@ export const searchAnimation: AnimationTriggerMetadata = trigger('transitionMess state('active', style({ 'margin-left': '{{ margin-left }}px', 'margin-right': '{{ margin-right }}px', - 'transform': '{{ transform }}' - }), { params: { 'margin-left': 0, 'margin-right': 0, 'transform': 'translateX(0%)' } }), + transform: '{{ transform }}' + }), { params: { 'margin-left': 0, 'margin-right': 0, transform: 'translateX(0%)' } }), state('inactive', style({ 'margin-left': '{{ margin-left }}px', 'margin-right': '{{ margin-right }}px', - 'transform': '{{ transform }}' - }), { params: { 'margin-left': 0, 'margin-right': 0, 'transform': 'translateX(0%)' } }), + transform: '{{ transform }}' + }), { params: { 'margin-left': 0, 'margin-right': 0, transform: 'translateX(0%)' } }), state('no-animation', style({ transform: 'translateX(0%)', width: '100%' })), transition('active <=> inactive', animate('400ms cubic-bezier(0.25, 0.8, 0.25, 1)')) ]); diff --git a/lib/core/search-text/search-text-input.component.spec.ts b/lib/core/search-text/search-text-input.component.spec.ts index 9d1bcc8c40..396824221c 100644 --- a/lib/core/search-text/search-text-input.component.spec.ts +++ b/lib/core/search-text/search-text-input.component.spec.ts @@ -216,7 +216,7 @@ describe('SearchTextInputComponent', () => { fixture.detectChanges(); tick(100); - expect(component.subscriptAnimationState.params).toEqual({ 'transform': 'translateX(82%)' }); + expect(component.subscriptAnimationState.params).toEqual({ transform: 'translateX(82%)' }); discardPeriodicTasks(); })); @@ -247,7 +247,7 @@ describe('SearchTextInputComponent', () => { fixture.detectChanges(); tick(100); - expect(component.subscriptAnimationState.params).toEqual({ 'transform': 'translateX(-82%)' }); + expect(component.subscriptAnimationState.params).toEqual({ transform: 'translateX(-82%)' }); discardPeriodicTasks(); })); diff --git a/lib/core/search-text/search-text-input.component.ts b/lib/core/search-text/search-text-input.component.ts index 84d1b2cf89..84ca05a33d 100644 --- a/lib/core/search-text/search-text-input.component.ts +++ b/lib/core/search-text/search-text-input.component.ts @@ -30,7 +30,7 @@ import { SearchTextStateEnum, SearchAnimationState, SearchAnimationDirection } f animations: [searchAnimation], encapsulation: ViewEncapsulation.None, host: { - 'class': 'adf-search-text-input' + class: 'adf-search-text-input' } }) export class SearchTextInputComponent implements OnInit, OnDestroy { @@ -127,11 +127,11 @@ export class SearchTextInputComponent implements OnInit, OnDestroy { animationStates: SearchAnimationDirection = { ltr : { active: { value: 'active', params: { 'margin-left': 13 } }, - inactive: { value: 'inactive', params: { 'transform': 'translateX(82%)' } } + inactive: { value: 'inactive', params: { transform: 'translateX(82%)' } } }, rtl: { active: { value: 'active', params: { 'margin-right': 13 } }, - inactive: { value: 'inactive', params: { 'transform': 'translateX(-82%)' } } + inactive: { value: 'inactive', params: { transform: 'translateX(-82%)' } } } }; @@ -141,7 +141,7 @@ export class SearchTextInputComponent implements OnInit, OnDestroy { private focusSubscription: Subscription; private valueChange = new Subject(); - constructor ( + constructor( private userPreferencesService: UserPreferencesService ) { this.toggleSearch @@ -192,11 +192,11 @@ export class SearchTextInputComponent implements OnInit, OnDestroy { if (this.dir === 'ltr') { return this.subscriptAnimationState.value === 'inactive' ? { value: 'active', params: { 'margin-left': 13 } } : - { value: 'inactive', params: { 'transform': 'translateX(82%)' } }; + { value: 'inactive', params: { transform: 'translateX(82%)' } }; } else { return this.subscriptAnimationState.value === 'inactive' ? { value: 'active', params: { 'margin-right': 13 } } : - { value: 'inactive', params: { 'transform': 'translateX(-82%)' } }; + { value: 'inactive', params: { transform: 'translateX(-82%)' } }; } } @@ -222,9 +222,7 @@ export class SearchTextInputComponent implements OnInit, OnDestroy { const focusEvents: Observable = this.focusListener .pipe( debounceTime(50), - filter(($event: any) => { - return this.isSearchBarActive() && ($event.type === 'blur' || $event.type === 'focusout' || $event.type === 'focus'); - }), + filter(($event: any) => this.isSearchBarActive() && ($event.type === 'blur' || $event.type === 'focusout' || $event.type === 'focus')), takeUntil(this.onDestroy$) ); diff --git a/lib/core/search-text/search-trigger.directive.ts b/lib/core/search-text/search-trigger.directive.ts index b67c3761f1..4d6afb58d5 100644 --- a/lib/core/search-text/search-trigger.directive.ts +++ b/lib/core/search-text/search-trigger.directive.ts @@ -48,7 +48,7 @@ export const SEARCH_AUTOCOMPLETE_VALUE_ACCESSOR: any = { // eslint-disable-next-line @angular-eslint/directive-selector selector: `input[searchAutocomplete], textarea[searchAutocomplete]`, host: { - 'role': 'combobox', + role: 'combobox', '[attr.autocomplete]': 'autocomplete', 'aria-autocomplete': 'list', '[attr.aria-expanded]': 'panelOpen.toString()', diff --git a/lib/core/services/apps-process.service.spec.ts b/lib/core/services/apps-process.service.spec.ts index 6b71f78f3b..07d9266d9c 100644 --- a/lib/core/services/apps-process.service.spec.ts +++ b/lib/core/services/apps-process.service.spec.ts @@ -63,7 +63,7 @@ describe('AppsProcessService', () => { ); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeApps) }); @@ -81,7 +81,7 @@ describe('AppsProcessService', () => { ); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeApps) }); @@ -99,7 +99,7 @@ describe('AppsProcessService', () => { ); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeApps) }); diff --git a/lib/core/services/apps-process.service.ts b/lib/core/services/apps-process.service.ts index acc1124c6b..a919534326 100644 --- a/lib/core/services/apps-process.service.ts +++ b/lib/core/services/apps-process.service.ts @@ -39,31 +39,34 @@ export class AppsProcessService { /** * Gets a list of deployed apps for this user. + * * @returns The list of deployed apps */ getDeployedApplications(): Observable { return from(this.appsApi.getAppDefinitions()) .pipe( - map((response: any) => response.data), + map((response: any) => response.data), catchError((err) => this.handleError(err)) ); } /** * Gets a list of deployed apps for this user, where the app name is `name`. + * * @param name Name of the app * @returns The list of deployed apps */ getDeployedApplicationsByName(name: string): Observable { return from(this.appsApi.getAppDefinitions()) .pipe( - map((response: any) => response.data.find((app) => app.name === name)), + map((response: any) => response.data.find((app) => app.name === name)), catchError((err) => this.handleError(err)) ); } /** * Gets the details for a specific app ID number. + * * @param appId ID of the target app * @returns Details of the app */ diff --git a/lib/core/services/auth-bearer.interceptor.ts b/lib/core/services/auth-bearer.interceptor.ts index ac3aae681a..9c82c2eecc 100644 --- a/lib/core/services/auth-bearer.interceptor.ts +++ b/lib/core/services/auth-bearer.interceptor.ts @@ -55,9 +55,7 @@ export class AuthBearerInterceptor implements HttpInterceptor { if (shallPass) { return next.handle(req) .pipe( - catchError((error) => { - return observableThrowError(error); - }) + catchError((error) => observableThrowError(error)) ); } @@ -68,9 +66,7 @@ export class AuthBearerInterceptor implements HttpInterceptor { const kcReq = req.clone({ headers: headerWithContentType}); return next.handle(kcReq) .pipe( - catchError((error) => { - return observableThrowError(error); - }) + catchError((error) => observableThrowError(error)) ); }) ); diff --git a/lib/core/services/auth-guard-bpm.service.spec.ts b/lib/core/services/auth-guard-bpm.service.spec.ts index 1e98b49f20..e8af06457f 100644 --- a/lib/core/services/auth-guard-bpm.service.spec.ts +++ b/lib/core/services/auth-guard-bpm.service.spec.ts @@ -68,7 +68,7 @@ describe('AuthGuardService BPM', () => { provider: 'BPM' }; - const route: RouterStateSnapshot = { url: 'abc' }; + const route = { url: 'abc' } as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeFalsy(); expect(authService.ssoImplicitLogin).toHaveBeenCalledTimes(1); @@ -76,7 +76,7 @@ describe('AuthGuardService BPM', () => { it('if the alfresco js api is logged in should canActivate be true', async () => { spyOn(authService, 'isBpmLoggedIn').and.returnValue(true); - const route = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeTruthy(); }); @@ -85,7 +85,7 @@ describe('AuthGuardService BPM', () => { spyOn(authService, 'isBpmLoggedIn').and.returnValue(true); appConfigService.config.auth.withCredentials = true; - const route = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeTruthy(); }); @@ -93,7 +93,7 @@ describe('AuthGuardService BPM', () => { it('if the alfresco js api is NOT logged in should canActivate be false', async () => { spyOn(authService, 'isBpmLoggedIn').and.returnValue(false); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeFalsy(); }); @@ -103,7 +103,7 @@ describe('AuthGuardService BPM', () => { spyOn(router, 'navigateByUrl'); spyOn(authService, 'isBpmLoggedIn').and.returnValue(false); - const route: RouterStateSnapshot = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeFalsy(); expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url')); @@ -114,7 +114,7 @@ describe('AuthGuardService BPM', () => { spyOn(authService, 'isBpmLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); appConfigService.config.oauth2.silentLogin = false; - const route = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeFalsy(); expect(router.navigateByUrl).toHaveBeenCalled(); @@ -125,7 +125,7 @@ describe('AuthGuardService BPM', () => { spyOn(authService, 'isBpmLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); appConfigService.config.oauth2.silentLogin = undefined; - const route = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeFalsy(); expect(router.navigateByUrl).toHaveBeenCalled(); @@ -134,7 +134,7 @@ describe('AuthGuardService BPM', () => { it('should set redirect url', () => { spyOn(authService, 'setRedirect').and.callThrough(); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; authGuard.canActivate(null, route); @@ -147,7 +147,7 @@ describe('AuthGuardService BPM', () => { it('should set redirect navigation commands with query params', () => { spyOn(authService, 'setRedirect').and.callThrough(); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url;q=123' }; + const route = { url: 'some-url;q=123' } as RouterStateSnapshot; authGuard.canActivate(null, route); @@ -160,7 +160,7 @@ describe('AuthGuardService BPM', () => { it('should set redirect navigation commands with query params', () => { spyOn(authService, 'setRedirect').and.callThrough(); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: '/' }; + const route = { url: '/' } as RouterStateSnapshot; authGuard.canActivate(null, route); @@ -174,7 +174,7 @@ describe('AuthGuardService BPM', () => { appConfigService.config.loginRoute = 'fakeLoginRoute'; spyOn(authService, 'setRedirect').and.callThrough(); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; authGuard.canActivate(null, route); @@ -191,7 +191,7 @@ describe('AuthGuardService BPM', () => { spyOn(authService, 'setRedirect').and.callThrough(); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; authGuard.canActivate(null, route); diff --git a/lib/core/services/auth-guard-ecm.service.spec.ts b/lib/core/services/auth-guard-ecm.service.spec.ts index 02b30c619e..6500ef8f30 100644 --- a/lib/core/services/auth-guard-ecm.service.spec.ts +++ b/lib/core/services/auth-guard-ecm.service.spec.ts @@ -51,53 +51,53 @@ describe('AuthGuardService ECM', () => { appConfigService.config.oauth2 = {}; }); - it('if the alfresco js api is logged in should canActivate be true', async() => { + it('if the alfresco js api is logged in should canActivate be true', async () => { spyOn(authService, 'isEcmLoggedIn').and.returnValue(true); - const route: RouterStateSnapshot = {url : 'some-url'}; + const route = {url : 'some-url'} as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeTruthy(); }); - it('if the alfresco js api is configured with withCredentials true should canActivate be true', async() => { + it('if the alfresco js api is configured with withCredentials true should canActivate be true', async () => { spyOn(authService, 'isBpmLoggedIn').and.returnValue(true); appConfigService.config.auth.withCredentials = true; - const route: RouterStateSnapshot = {url : 'some-url'}; + const route = {url : 'some-url'} as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeTruthy(); }); - it('if the alfresco js api is NOT logged in should canActivate be false', async() => { + it('if the alfresco js api is NOT logged in should canActivate be false', async () => { spyOn(authService, 'isEcmLoggedIn').and.returnValue(false); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeFalsy(); }); - it('if the alfresco js api is NOT logged in should trigger a redirect event', async() => { + it('if the alfresco js api is NOT logged in should trigger a redirect event', async () => { appConfigService.config.loginRoute = 'login'; spyOn(router, 'navigateByUrl'); spyOn(authService, 'isEcmLoggedIn').and.returnValue(false); - const route: RouterStateSnapshot = {url : 'some-url'}; + const route = {url : 'some-url'} as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeFalsy(); expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url')); }); - it('should redirect url if the alfresco js api is NOT logged in and isOAuthWithoutSilentLogin', async() => { + it('should redirect url if the alfresco js api is NOT logged in and isOAuthWithoutSilentLogin', async () => { spyOn(router, 'navigateByUrl').and.stub(); spyOn(authService, 'isEcmLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); appConfigService.config.oauth2.silentLogin = false; - const route: RouterStateSnapshot = {url : 'some-url'}; + const route = {url : 'some-url'} as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeFalsy(); expect(router.navigateByUrl).toHaveBeenCalled(); }); - it('should redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async() => { + it('should redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async () => { spyOn(authService, 'isEcmLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); spyOn(authService, 'isPublicUrl').and.returnValue(false); @@ -112,18 +112,18 @@ describe('AuthGuardService ECM', () => { scope: 'openid' }; - const route: RouterStateSnapshot = {url : 'abc'}; + const route = {url : 'abc'} as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeFalsy(); expect(authService.ssoImplicitLogin).toHaveBeenCalledTimes(1); }); - it('should not redirect url if NOT logged in and isOAuth but no silentLogin configured', async() => { + it('should not redirect url if NOT logged in and isOAuth but no silentLogin configured', async () => { spyOn(router, 'navigateByUrl').and.stub(); spyOn(authService, 'isEcmLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); appConfigService.config.oauth2.silentLogin = undefined; - const route: RouterStateSnapshot = {url : 'some-url'}; + const route = {url : 'some-url'} as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeFalsy(); expect(router.navigateByUrl).toHaveBeenCalled(); @@ -132,7 +132,7 @@ describe('AuthGuardService ECM', () => { it('should set redirect navigation commands', () => { spyOn(authService, 'setRedirect').and.callThrough(); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; authGuard.canActivate(null, route); @@ -145,7 +145,7 @@ describe('AuthGuardService ECM', () => { it('should set redirect navigation commands with query params', () => { spyOn(authService, 'setRedirect').and.callThrough(); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url;q=123' }; + const route = { url: 'some-url;q=123' } as RouterStateSnapshot; authGuard.canActivate(null, route); @@ -158,7 +158,7 @@ describe('AuthGuardService ECM', () => { it('should set redirect navigation commands with query params', () => { spyOn(authService, 'setRedirect').and.callThrough(); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: '/' }; + const route = { url: '/' } as RouterStateSnapshot; authGuard.canActivate(null, route); @@ -172,7 +172,7 @@ describe('AuthGuardService ECM', () => { appConfigService.config.loginRoute = 'fakeLoginRoute'; spyOn(authService, 'setRedirect').and.callThrough(); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; authGuard.canActivate(null, route); @@ -189,7 +189,7 @@ describe('AuthGuardService ECM', () => { spyOn(authService, 'setRedirect').and.callThrough(); spyOn(router, 'navigateByUrl').and.stub(); - const route: RouterStateSnapshot = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; authGuard.canActivate(null, route); diff --git a/lib/core/services/auth-guard-sso-role.service.spec.ts b/lib/core/services/auth-guard-sso-role.service.spec.ts index c1c2f78610..30771f7bf9 100644 --- a/lib/core/services/auth-guard-sso-role.service.spec.ts +++ b/lib/core/services/auth-guard-sso-role.service.spec.ts @@ -51,31 +51,31 @@ describe('Auth Guard SSO role service', () => { it('Should canActivate be true if the Role is present int the JWT token', async () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); - spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } }); + spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role1'] } }); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['role1', 'role2'] }; + router.data = { roles: ['role1', 'role2'] }; expect(await authGuard.canActivate(router)).toBeTruthy(); }); it('Should canActivate be false if the Role is not present int the JWT token', async () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); - spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role3'] } }); + spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role3'] } }); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['role1', 'role2'] }; + router.data = { roles: ['role1', 'role2'] }; expect(await authGuard.canActivate(router)).toBeFalsy(); }); it('Should not redirect if canActivate is', async () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); - spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } }); + spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role1'] } }); spyOn(routerService, 'navigate').and.stub(); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['role1', 'role2'] }; + router.data = { roles: ['role1', 'role2'] }; expect(await authGuard.canActivate(router)).toBeTruthy(); expect(routerService.navigate).not.toHaveBeenCalled(); @@ -83,7 +83,7 @@ describe('Auth Guard SSO role service', () => { it('Should canActivate return false if the data Role to check is empty', async () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); - spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1', 'role3'] } }); + spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role1', 'role3'] } }); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); @@ -105,7 +105,7 @@ describe('Auth Guard SSO role service', () => { spyOn(routerService, 'navigate').and.stub(); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['role1', 'role2'], 'redirectUrl': 'no-role-url' }; + router.data = { roles: ['role1', 'role2'], redirectUrl: 'no-role-url' }; expect(await authGuard.canActivate(router)).toBeFalsy(); expect(routerService.navigate).toHaveBeenCalledWith(['/no-role-url']); @@ -117,7 +117,7 @@ describe('Auth Guard SSO role service', () => { spyOn(routerService, 'navigate').and.stub(); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['role1', 'role2'] }; + router.data = { roles: ['role1', 'role2'] }; expect(await authGuard.canActivate(router)).toBeFalsy(); expect(routerService.navigate).not.toHaveBeenCalled(); @@ -129,7 +129,7 @@ describe('Auth Guard SSO role service', () => { spyOn(jwtHelperService, 'hasRealmRolesForClientRole').and.returnValue(false); route.params = { appName: 'fakeapp' }; - route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] }; + route.data = { clientRoles: ['appName'], roles: ['role1', 'role2'] }; expect(await authGuard.canActivate(route)).toBeFalsy(); }); @@ -140,7 +140,7 @@ describe('Auth Guard SSO role service', () => { spyOn(jwtHelperService, 'hasRealmRolesForClientRole').and.returnValue(true); route.params = { appName: 'fakeapp' }; - route.data = { 'clientRoles': ['fakeapp'], 'roles': ['role1', 'role2'] }; + route.data = { clientRoles: ['fakeapp'], roles: ['role1', 'role2'] }; expect(await authGuard.canActivate(route)).toBeFalsy(); }); @@ -150,12 +150,12 @@ describe('Auth Guard SSO role service', () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'decodeToken').and.returnValue({ - 'realm_access': { roles: ['role1'] }, - 'resource_access': { fakeapp: { roles: ['role2'] } } + realm_access: { roles: ['role1'] }, + resource_access: { fakeapp: { roles: ['role2'] } } }); route.params = { appName: 'fakeapp' }; - route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] }; + route.data = { clientRoles: ['appName'], roles: ['role1', 'role2'] }; expect(await authGuard.canActivate(route)).toBeTruthy(); }); @@ -165,12 +165,12 @@ describe('Auth Guard SSO role service', () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'decodeToken').and.returnValue({ - 'realm_access': { roles: ['role1'] }, - 'resource_access': { fakeapp: { roles: ['role3'] } } + realm_access: { roles: ['role1'] }, + resource_access: { fakeapp: { roles: ['role3'] } } }); route.params = { appName: 'fakeapp' }; - route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] }; + route.data = { clientRoles: ['appName'], roles: ['role1', 'role2'] }; expect(await authGuard.canActivate(route)).toBeFalsy(); }); @@ -185,7 +185,7 @@ describe('Auth Guard SSO role service', () => { spyOn(jwtHelperService, 'hasRealmRolesForClientRole').and.returnValue(false); route.params = { appName: 'fakeapp' }; - route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] }; + route.data = { clientRoles: ['appName'], roles: ['role1', 'role2'] }; expect(await authGuard.canActivate(route)).toBeFalsy(); expect(materialDialog.closeAll).toHaveBeenCalled(); @@ -201,7 +201,7 @@ describe('Auth Guard SSO role service', () => { spyOn(peopleContentService, 'getCurrentPerson').and.returnValue(of(getFakeUserWithContentAdminCapability())); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['ALFRESCO_ADMINISTRATORS'] }; + router.data = { roles: ['ALFRESCO_ADMINISTRATORS'] }; expect(await authGuard.canActivate(router)).toBeTruthy(); }); @@ -210,7 +210,7 @@ describe('Auth Guard SSO role service', () => { spyOn(peopleContentService, 'getCurrentPerson').and.returnValue(of(getFakeUserWithContentUserCapability())); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['ALFRESCO_ADMINISTRATORS'] }; + router.data = { roles: ['ALFRESCO_ADMINISTRATORS'] }; expect(await authGuard.canActivate(router)).toBeFalsy(); }); @@ -218,7 +218,7 @@ describe('Auth Guard SSO role service', () => { it('Should not call the service to check if the user has content admin capability when the roles do not contain ALFRESCO_ADMINISTRATORS', async () => { const getCurrentPersonSpy = spyOn(peopleContentService, 'getCurrentPerson').and.returnValue(of(getFakeUserWithContentAdminCapability())); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['fakeRole'] }; + router.data = { roles: ['fakeRole'] }; await authGuard.canActivate(router); @@ -230,20 +230,20 @@ describe('Auth Guard SSO role service', () => { it('Should canActivate be false when the user has one of the excluded roles', async () => { spyOn(peopleContentService, 'getCurrentPerson').and.returnValue(of(getFakeUserWithContentAdminCapability())); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); - spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } }); + spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role1'] } }); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['ALFRESCO_ADMINISTRATORS'], 'excludedRoles': ['role1'] }; + router.data = { roles: ['ALFRESCO_ADMINISTRATORS'], excludedRoles: ['role1'] }; expect(await authGuard.canActivate(router)).toBeFalsy(); }); it('Should canActivate be true when the user has none of the excluded roles', async () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); - spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role2'] } }); + spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role2'] } }); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['role1', 'role2'], 'excludedRoles': ['role3'] }; + router.data = { roles: ['role1', 'role2'], excludedRoles: ['role3'] }; expect(await authGuard.canActivate(router)).toBeTruthy(); }); @@ -251,10 +251,10 @@ describe('Auth Guard SSO role service', () => { it('Should canActivate be false when the user is a content admin and the ALFRESCO_ADMINISTRATORS role is excluded', async () => { spyOn(peopleContentService, 'getCurrentPerson').and.returnValue(of(getFakeUserWithContentAdminCapability())); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); - spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } }); + spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role1'] } }); const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot(); - router.data = { 'roles': ['role1'], 'excludedRoles': ['ALFRESCO_ADMINISTRATORS'] }; + router.data = { roles: ['role1'], excludedRoles: ['ALFRESCO_ADMINISTRATORS'] }; expect(await authGuard.canActivate(router)).toBeFalsy(); }); diff --git a/lib/core/services/auth-guard.service.spec.ts b/lib/core/services/auth-guard.service.spec.ts index c72f0d8074..e3223fcee3 100644 --- a/lib/core/services/auth-guard.service.spec.ts +++ b/lib/core/services/auth-guard.service.spec.ts @@ -74,7 +74,7 @@ describe('AuthGuardService', () => { spyOn(authService, 'isBpmLoggedIn').and.returnValue(true); appConfigService.config.auth.withCredentials = true; - const route: RouterStateSnapshot = { url: 'some-url' }; + const route = { url: 'some-url' } as RouterStateSnapshot; expect(await authGuard.canActivate(null, route)).toBeTruthy(); }); diff --git a/lib/core/services/authentication.service.spec.ts b/lib/core/services/authentication.service.spec.ts index 1f49111bd7..ca79cddb06 100644 --- a/lib/core/services/authentication.service.spec.ts +++ b/lib/core/services/authentication.service.spec.ts @@ -126,7 +126,7 @@ describe('AuthenticationService', () => { jasmine.Ajax.requests.mostRecent().respondWith({ status: 201, contentType: 'application/json', - responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } }) + responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } }) }); }); @@ -137,9 +137,9 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 201, + status: 201, contentType: 'application/json', - responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } }) + responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } }) }); }); @@ -155,14 +155,14 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 204 + status: 204 }); }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 201, + status: 201, contentType: 'application/json', - responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } }) + responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } }) }); }); @@ -251,7 +251,7 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json' }); }); @@ -268,12 +268,12 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200 + status: 200 }); }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200 + status: 200 }); }); @@ -288,7 +288,7 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 403 + status: 403 }); }); @@ -340,9 +340,9 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 201, + status: 201, contentType: 'application/json', - responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } }) + responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } }) }); }); @@ -356,9 +356,9 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 201, + status: 201, contentType: 'application/json', - responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } }) + responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } }) }); }); @@ -372,15 +372,15 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 403, + status: 403, contentType: 'application/json', responseText: JSON.stringify({ - 'error': { - 'errorKey': 'Login failed', - 'statusCode': 403, - 'briefSummary': '05150009 Login failed', - 'stackTrace': 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions.', - 'descriptionURL': 'https://api-explorer.alfresco.com' + error: { + errorKey: 'Login failed', + statusCode: 403, + briefSummary: '05150009 Login failed', + stackTrace: 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions.', + descriptionURL: 'https://api-explorer.alfresco.com' } }) }); @@ -408,13 +408,13 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.at(0).respondWith({ - 'status': 201, + status: 201, contentType: 'application/json', - responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } }) + responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } }) }); jasmine.Ajax.requests.at(1).respondWith({ - 'status': 200 + status: 200 }); }); @@ -432,11 +432,11 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.at(0).respondWith({ - 'status': 403 + status: 403 }); jasmine.Ajax.requests.at(1).respondWith({ - 'status': 200 + status: 200 }); }); @@ -453,13 +453,13 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.at(0).respondWith({ - 'status': 201, + status: 201, contentType: 'application/json', - responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } }) + responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } }) }); jasmine.Ajax.requests.at(1).respondWith({ - 'status': 403 + status: 403 }); }); @@ -477,11 +477,11 @@ describe('AuthenticationService', () => { }); jasmine.Ajax.requests.at(0).respondWith({ - 'status': 403 + status: 403 }); jasmine.Ajax.requests.at(1).respondWith({ - 'status': 403 + status: 403 }); }); diff --git a/lib/core/services/authentication.service.ts b/lib/core/services/authentication.service.ts index 57b7ba37ef..a6ace14636 100644 --- a/lib/core/services/authentication.service.ts +++ b/lib/core/services/authentication.service.ts @@ -92,6 +92,7 @@ export class AuthenticationService { /** * Checks if the user logged in. + * * @returns True if logged in, false otherwise */ isLoggedIn(): boolean { @@ -113,6 +114,7 @@ export class AuthenticationService { /** * Does kerberos enabled? + * * @returns True if enabled, false otherwise */ isKerberosEnabled(): boolean { @@ -121,6 +123,7 @@ export class AuthenticationService { /** * Does the provider support OAuth? + * * @returns True if supported, false otherwise */ isOauth(): boolean { @@ -133,6 +136,7 @@ export class AuthenticationService { /** * Does the provider support ECM? + * * @returns True if supported, false otherwise */ isECMProvider(): boolean { @@ -141,6 +145,7 @@ export class AuthenticationService { /** * Does the provider support BPM? + * * @returns True if supported, false otherwise */ isBPMProvider(): boolean { @@ -149,6 +154,7 @@ export class AuthenticationService { /** * Does the provider support both ECM and BPM? + * * @returns True if both are supported, false otherwise */ isALLProvider(): boolean { @@ -157,6 +163,7 @@ export class AuthenticationService { /** * Logs the user in. + * * @param username Username for the login * @param password Password for the login * @param rememberMe Stores the user's login details if true @@ -186,6 +193,7 @@ export class AuthenticationService { /** * Saves the "remember me" cookie as either a long-life cookie or a session cookie. + * * @param rememberMe Enables a long-life cookie */ private saveRememberMeCookie(rememberMe: boolean): void { @@ -202,6 +210,7 @@ export class AuthenticationService { /** * Checks whether the "remember me" cookie was set or not. + * * @returns True if set, false otherwise */ isRememberMeSet(): boolean { @@ -210,6 +219,7 @@ export class AuthenticationService { /** * Logs the user out. + * * @returns Response event called when logout is complete */ logout() { @@ -232,6 +242,7 @@ export class AuthenticationService { /** * Gets the ECM ticket stored in the Storage. + * * @returns The ticket or `null` if none was found */ getTicketEcm(): string | null { @@ -240,6 +251,7 @@ export class AuthenticationService { /** * Gets the BPM ticket stored in the Storage. + * * @returns The ticket or `null` if none was found */ getTicketBpm(): string | null { @@ -248,6 +260,7 @@ export class AuthenticationService { /** * Gets the BPM ticket from the Storage in Base 64 format. + * * @returns The ticket or `null` if none was found */ getTicketEcmBase64(): string | null { @@ -260,6 +273,7 @@ export class AuthenticationService { /** * Checks if the user is logged in on an ECM provider. + * * @returns True if logged in, false otherwise */ isEcmLoggedIn(): boolean { @@ -274,6 +288,7 @@ export class AuthenticationService { /** * Checks if the user is logged in on a BPM provider. + * * @returns True if logged in, false otherwise */ isBpmLoggedIn(): boolean { @@ -288,6 +303,7 @@ export class AuthenticationService { /** * Gets the ECM username. + * * @returns The ECM username */ getEcmUsername(): string { @@ -296,6 +312,7 @@ export class AuthenticationService { /** * Gets the BPM username + * * @returns The BPM username */ getBpmUsername(): string { @@ -303,6 +320,7 @@ export class AuthenticationService { } /** Sets the URL to redirect to after login. + * * @param url URL to redirect to */ setRedirect(url: RedirectionModel) { @@ -310,6 +328,7 @@ export class AuthenticationService { } /** Gets the URL to redirect to after login. + * * @returns The redirect URL */ getRedirect(): string { @@ -319,6 +338,7 @@ export class AuthenticationService { /** * Gets information about the user currently logged into APS. + * * @returns User information */ getBpmLoggedUser(): Observable { @@ -335,6 +355,7 @@ export class AuthenticationService { /** * Prints an error message in the console browser + * * @param error Error message * @returns Object representing the error message */ @@ -345,6 +366,7 @@ export class AuthenticationService { /** * Gets the set of URLs that the token bearer is excluded from. + * * @returns Array of URL strings */ getBearerExcludedUrls(): string[] { @@ -353,6 +375,7 @@ export class AuthenticationService { /** * Gets the auth token. + * * @returns Auth token string */ getToken(): string { @@ -361,6 +384,7 @@ export class AuthenticationService { /** * Adds the auth token to an HTTP header using the 'bearer' scheme. + * * @param headersArg Header that will receive the token * @returns The new header with the token added */ diff --git a/lib/core/services/automation.service.ts b/lib/core/services/automation.service.ts index 94695fac73..154d3bc7b3 100644 --- a/lib/core/services/automation.service.ts +++ b/lib/core/services/automation.service.ts @@ -38,9 +38,7 @@ export class CoreAutomationService { setup() { const adfProxy = window['adf'] || {}; - adfProxy.getConfigField = (field: string): any => { - return this.appConfigService.get(field); - }; + adfProxy.getConfigField = (field: string): any => this.appConfigService.get(field); adfProxy.setConfigField = (field: string, value: string) => { this.appConfigService.config[field] = JSON.parse(value); @@ -54,9 +52,7 @@ export class CoreAutomationService { this.storageService.removeItem(key); }; - adfProxy.getStorageItem = (key: string): string => { - return this.storageService.getItem(key); - }; + adfProxy.getStorageItem = (key: string): string => this.storageService.getItem(key); adfProxy.setUserPreference = (key: string, data: any) => { this.userPreferencesService.set(key, data); diff --git a/lib/core/services/bpm-user.service.spec.ts b/lib/core/services/bpm-user.service.spec.ts index 4fbbccb9c9..d74f7c2da4 100644 --- a/lib/core/services/bpm-user.service.spec.ts +++ b/lib/core/services/bpm-user.service.spec.ts @@ -59,7 +59,7 @@ describe('Bpm user service', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({ lastName: 'fake-last-name', diff --git a/lib/core/services/bpm-user.service.ts b/lib/core/services/bpm-user.service.ts index 57969e6ef5..3951859a15 100644 --- a/lib/core/services/bpm-user.service.ts +++ b/lib/core/services/bpm-user.service.ts @@ -21,7 +21,7 @@ import { AlfrescoApiService } from './alfresco-api.service'; import { LogService } from './log.service'; import { BpmUserModel } from '../models/bpm-user.model'; import { map, catchError } from 'rxjs/operators'; -import { UserProfileApi, UserRepresentation } from '@alfresco/js-api'; +import { UserProfileApi } from '@alfresco/js-api'; /** * @@ -33,7 +33,7 @@ import { UserProfileApi, UserRepresentation } from '@alfresco/js-api'; }) export class BpmUserService { - _profileApi: UserProfileApi; + private _profileApi: UserProfileApi; get profileApi(): UserProfileApi { this._profileApi = this._profileApi ?? new UserProfileApi(this.apiService.getInstance()); return this._profileApi; @@ -45,30 +45,26 @@ export class BpmUserService { /** * Gets information about the current user. + * * @returns User information object */ getCurrentUserInfo(): Observable { return from(this.profileApi.getProfile()) .pipe( - map((userRepresentation: UserRepresentation) => { - return new BpmUserModel(userRepresentation); - }), + map((userRepresentation) => new BpmUserModel(userRepresentation)), catchError((err) => this.handleError(err)) ); } /** * Gets the current user's profile image as a URL. + * * @returns URL string */ getCurrentUserProfileImage(): string { return this.profileApi.getProfilePictureUrl(); } - /** - * Throw the error - * @param error - */ private handleError(error: any) { // in a real world app, we may send the error to some remote logging infrastructure // instead of just logging it to the console diff --git a/lib/core/services/comment-content.service.spec.ts b/lib/core/services/comment-content.service.spec.ts index f3c6d32970..bbade52703 100644 --- a/lib/core/services/comment-content.service.spec.ts +++ b/lib/core/services/comment-content.service.spec.ts @@ -63,7 +63,7 @@ describe('Comment Content Service', () => { ); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeContentComment) }); @@ -81,7 +81,7 @@ describe('Comment Content Service', () => { ); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeContentComments) }); diff --git a/lib/core/services/comment-content.service.ts b/lib/core/services/comment-content.service.ts index fdef4763aa..302fa1cf23 100644 --- a/lib/core/services/comment-content.service.ts +++ b/lib/core/services/comment-content.service.ts @@ -40,6 +40,7 @@ export class CommentContentService { /** * Adds a comment to a node. + * * @param nodeId ID of the target node * @param message Text for the comment * @returns Details of the comment added @@ -47,20 +48,19 @@ export class CommentContentService { addNodeComment(nodeId: string, message: string): Observable { return from(this.commentsApi.createComment(nodeId, { content: message })) .pipe( - map((response: CommentEntry) => { - return new CommentModel({ - id: response.entry.id, - message: response.entry.content, - created: response.entry.createdAt, - createdBy: response.entry.createdBy - }); - }), + map((response: CommentEntry) => new CommentModel({ + id: response.entry.id, + message: response.entry.content, + created: response.entry.createdAt, + createdBy: response.entry.createdBy + })), catchError((err) => this.handleError(err)) ); } /** * Gets all comments that have been added to a node. + * * @param nodeId ID of the target node * @returns Details for each comment */ diff --git a/lib/core/services/comment-process.service.spec.ts b/lib/core/services/comment-process.service.spec.ts index 26ad894259..38bb283852 100644 --- a/lib/core/services/comment-process.service.spec.ts +++ b/lib/core/services/comment-process.service.spec.ts @@ -113,7 +113,7 @@ describe('Comment ProcessService Service', () => { it('should call service to add comment', () => { service.addProcessInstanceComment(processId, message); expect(addProcessInstanceComment).toHaveBeenCalledWith({ - message: message + message }, processId); }); @@ -158,7 +158,7 @@ describe('Comment ProcessService Service', () => { ); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify({ id: '111', message: 'fake-comment-message', @@ -180,7 +180,7 @@ describe('Comment ProcessService Service', () => { ); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeTasksComment) }); diff --git a/lib/core/services/comment-process.service.ts b/lib/core/services/comment-process.service.ts index 1a132c2b0d..e1a8912dc1 100644 --- a/lib/core/services/comment-process.service.ts +++ b/lib/core/services/comment-process.service.ts @@ -41,27 +41,27 @@ export class CommentProcessService { /** * Adds a comment to a task. + * * @param taskId ID of the target task * @param message Text for the comment * @returns Details about the comment */ addTaskComment(taskId: string, message: string): Observable { - return from(this.commentsApi.addTaskComment({ message: message }, taskId)) + return from(this.commentsApi.addTaskComment({ message }, taskId)) .pipe( - map((response) => { - return new CommentModel({ - id: response.id, - message: response.message, - created: response.created, - createdBy: response.createdBy - }); - }), + map((response) => new CommentModel({ + id: response.id, + message: response.message, + created: response.created, + createdBy: response.createdBy + })), catchError((err: any) => this.handleError(err)) ); } /** * Gets all comments that have been added to a task. + * * @param taskId ID of the target task * @returns Details for each comment */ @@ -87,6 +87,7 @@ export class CommentProcessService { /** * Gets all comments that have been added to a process instance. + * * @param processInstanceId ID of the target process instance * @returns Details for each comment */ @@ -112,22 +113,21 @@ export class CommentProcessService { /** * Adds a comment to a process instance. + * * @param processInstanceId ID of the target process instance * @param message Text for the comment * @returns Details of the comment added */ addProcessInstanceComment(processInstanceId: string, message: string): Observable { return from( - this.commentsApi.addProcessInstanceComment({ message: message }, processInstanceId) + this.commentsApi.addProcessInstanceComment({ message }, processInstanceId) ).pipe( - map((response) => { - return new CommentModel({ - id: response.id, - message: response.message, - created: response.created, - createdBy: response.createdBy - }); - }), + map((response) => new CommentModel({ + id: response.id, + message: response.message, + created: response.created, + createdBy: response.createdBy + })), catchError((err: any) => this.handleError(err)) ); } diff --git a/lib/core/services/content.service.spec.ts b/lib/core/services/content.service.spec.ts index ab54832f91..acb5fe5860 100644 --- a/lib/core/services/content.service.spec.ts +++ b/lib/core/services/content.service.spec.ts @@ -76,9 +76,9 @@ describe('ContentService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 201, + status: 201, contentType: 'application/json', - responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } }) + responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } }) }); }); @@ -91,9 +91,9 @@ describe('ContentService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 201, + status: 201, contentType: 'application/json', - responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } }) + responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } }) }); }); diff --git a/lib/core/services/content.service.ts b/lib/core/services/content.service.ts index cf8aa641dc..736d75a428 100644 --- a/lib/core/services/content.service.ts +++ b/lib/core/services/content.service.ts @@ -71,12 +71,13 @@ export class ContentService { /** * Creates a trusted object URL from the Blob. * WARNING: calling this method with untrusted user data exposes your application to XSS security risks! + * * @param blob Data to wrap into object URL * @returns URL string */ createTrustedUrl(blob: Blob): string { const url = window.URL.createObjectURL(blob); - return this.sanitizer.bypassSecurityTrustUrl(url); + return this.sanitizer.bypassSecurityTrustUrl(url) as string; } /** @@ -93,6 +94,7 @@ export class ContentService { /** * Gets a content URL for the given node. + * * @param node Node or Node ID to get URL for. * @param attachment Toggles whether to retrieve content as an attachment for download * @param ticket Custom ticket to use for authentication @@ -116,6 +118,7 @@ export class ContentService { /** * Gets content for the given node. + * * @param nodeId ID of the target node * @returns Content data */ @@ -128,6 +131,7 @@ export class ContentService { /** * Gets a Node via its node ID. + * * @param nodeId ID of the target node * @param opts Options supported by JS-API * @returns Details of the folder @@ -138,6 +142,7 @@ export class ContentService { /** * Checks if the user has permission on that node + * * @param node Node to check permissions * @param permission Required permission type * @param userId Optional current user id will be taken by default @@ -172,6 +177,7 @@ export class ContentService { /** * Checks if the user has permissions on that node + * * @param node Node to check allowableOperations * @param allowableOperation Create, delete, update, updatePermissions, !create, !delete, !update, !updatePermissions * @returns True if the user has the required permissions, false otherwise diff --git a/lib/core/services/cookie.service.ts b/lib/core/services/cookie.service.ts index 18732eef54..6813cefe5c 100644 --- a/lib/core/services/cookie.service.ts +++ b/lib/core/services/cookie.service.ts @@ -37,6 +37,7 @@ export class CookieService { /** * Checks if cookies are enabled. + * * @returns True if enabled, false otherwise */ isEnabled(): boolean { @@ -45,6 +46,7 @@ export class CookieService { /** * Retrieves a cookie by its key. + * * @param key Key to identify the cookie * @returns The cookie data or null if it is not found */ @@ -56,6 +58,7 @@ export class CookieService { /** * Sets a cookie. + * * @param key Key to identify the cookie * @param data Data value to set for the cookie * @param expiration Expiration date of the data @@ -69,6 +72,7 @@ export class CookieService { /** * Delete a cookie Key. + * * @param key Key to identify the cookie * @param path "Pathname" to store the cookie */ diff --git a/lib/core/services/deleted-nodes-api.service.ts b/lib/core/services/deleted-nodes-api.service.ts index 89a86782a0..91eeb908c7 100644 --- a/lib/core/services/deleted-nodes-api.service.ts +++ b/lib/core/services/deleted-nodes-api.service.ts @@ -48,6 +48,7 @@ export class DeletedNodesApiService { /** * Gets a list of nodes in the trash. + * * @param options Options for JS-API call * @returns List of nodes in the trash */ diff --git a/lib/core/services/directionality-config-factory.ts b/lib/core/services/directionality-config-factory.ts index b27bd57c02..44591a41a8 100644 --- a/lib/core/services/directionality-config-factory.ts +++ b/lib/core/services/directionality-config-factory.ts @@ -17,6 +17,7 @@ import { DirectionalityConfigService } from '../services/directionality-config.service'; +// eslint-disable-next-line prefer-arrow/prefer-arrow-functions export function directionalityConfigFactory(directionalityConfigService: DirectionalityConfigService) { return () => directionalityConfigService; } diff --git a/lib/core/services/directionality-config.service.ts b/lib/core/services/directionality-config.service.ts index 36e851f6a7..cbf1bb1e57 100644 --- a/lib/core/services/directionality-config.service.ts +++ b/lib/core/services/directionality-config.service.ts @@ -36,7 +36,7 @@ export class DirectionalityConfigService { .select('textOrientation') .subscribe((direction: Direction) => { renderer.setAttribute(this.document.body, 'dir', direction); - ( this.directionality).value = direction; + (this.directionality as any).value = direction; }); } } diff --git a/lib/core/services/discovery-api.service.ts b/lib/core/services/discovery-api.service.ts index 8259f246ab..be9310ec9b 100644 --- a/lib/core/services/discovery-api.service.ts +++ b/lib/core/services/discovery-api.service.ts @@ -49,9 +49,10 @@ export class DiscoveryApiService { /** * Gets product information for Content Services. + * * @returns ProductVersionModel containing product details */ - public getEcmProductInfo(): Observable { + getEcmProductInfo(): Observable { const discoveryApi = new DiscoveryApi(this.apiService.getInstance()); return from(discoveryApi.getRepositoryInformation()) @@ -63,9 +64,10 @@ export class DiscoveryApiService { /** * Gets product information for Process Services. + * * @returns ProductVersionModel containing product details */ - public getBpmProductInfo(): Observable { + getBpmProductInfo(): Observable { const aboutApi = new AboutApi(this.apiService.getInstance()); return from(aboutApi.getAppVersion()) @@ -75,7 +77,7 @@ export class DiscoveryApiService { ); } - public getBPMSystemProperties(): Observable { + getBPMSystemProperties(): Observable { const systemPropertiesApi = new SystemPropertiesApi(this.apiService.getInstance()); return from(systemPropertiesApi.getProperties()) diff --git a/lib/core/services/download-zip.service.ts b/lib/core/services/download-zip.service.ts index aad1cb86e0..cde08a77b3 100755 --- a/lib/core/services/download-zip.service.ts +++ b/lib/core/services/download-zip.service.ts @@ -27,7 +27,7 @@ import { catchError } from 'rxjs/operators'; }) export class DownloadZipService { - _downloadsApi: DownloadsApi; + private _downloadsApi: DownloadsApi; get downloadsApi(): DownloadsApi { this._downloadsApi = this._downloadsApi ?? new DownloadsApi(this.apiService.getInstance()); return this._downloadsApi; @@ -39,6 +39,7 @@ export class DownloadZipService { /** * Creates a new download. + * * @param payload Object containing the node IDs of the items to add to the ZIP file * @returns Status object for the download */ @@ -50,6 +51,7 @@ export class DownloadZipService { /** * Gets status information for a download node. + * * @param downloadId ID of the download node * @returns Status object for the download */ @@ -59,6 +61,7 @@ export class DownloadZipService { /** * Cancels a download. + * * @param downloadId ID of the target download node */ cancelDownload(downloadId: string) { diff --git a/lib/core/services/download.service.spec.ts b/lib/core/services/download.service.spec.ts index 48252c2a73..f86cccce69 100644 --- a/lib/core/services/download.service.spec.ts +++ b/lib/core/services/download.service.spec.ts @@ -28,6 +28,7 @@ describe('DownloadService', () => { it('Should use native msSaveOrOpenBlob if the browser is IE', (done) => { const navigatorAny: any = window.navigator; + // eslint-disable-next-line no-underscore-dangle navigatorAny.__defineGetter__('msSaveOrOpenBlob', () => { done(); }); diff --git a/lib/core/services/download.service.ts b/lib/core/services/download.service.ts index 9b616295b4..343a4ee624 100644 --- a/lib/core/services/download.service.ts +++ b/lib/core/services/download.service.ts @@ -24,12 +24,12 @@ export class DownloadService { private readonly saveData: any; constructor() { - this.saveData = (function() { + this.saveData = (() => { const a = document.createElement('a'); document.body.appendChild(a); a.style.display = 'none'; - return function(fileData, format, fileName) { + return (fileData, format, fileName) => { let blob = null; if (format === 'blob' || format === 'data') { @@ -42,10 +42,8 @@ export class DownloadService { } if (blob) { - if ( - typeof window.navigator !== 'undefined' && - window.navigator['msSaveOrOpenBlob'] - ) { + if (typeof window.navigator !== 'undefined' && + window.navigator['msSaveOrOpenBlob']) { window.navigator['msSaveOrOpenBlob'](blob, fileName); } else { const url = window.URL.createObjectURL(blob); @@ -62,6 +60,7 @@ export class DownloadService { /** * Invokes content download for a Blob with a file name. + * * @param blob Content to download. * @param fileName Name of the resulting file. */ @@ -71,6 +70,7 @@ export class DownloadService { /** * Invokes content download for a data array with a file name. + * * @param data Data to download. * @param fileName Name of the resulting file. */ @@ -80,6 +80,7 @@ export class DownloadService { /** * Invokes content download for a JSON object with a file name. + * * @param json JSON object to download. * @param fileName Name of the resulting file. */ @@ -89,6 +90,7 @@ export class DownloadService { /** * Invokes the download of the file by its URL address. + * * @param url Url address pointing to the file. * @param fileName Name of the file download. */ diff --git a/lib/core/services/dynamic-component-mapper.service.ts b/lib/core/services/dynamic-component-mapper.service.ts index abae906228..f8b36b6984 100644 --- a/lib/core/services/dynamic-component-mapper.service.ts +++ b/lib/core/services/dynamic-component-mapper.service.ts @@ -33,6 +33,7 @@ export abstract class DynamicComponentMapper { /** * Gets the currently active DynamicComponentResolveFunction for a field type. + * * @param type The type whose resolver you want * @param defaultValue Default type returned for types that are not yet mapped * @returns Resolver function @@ -46,6 +47,7 @@ export abstract class DynamicComponentMapper { /** * Sets or optionally replaces a DynamicComponentResolveFunction for a field type. + * * @param type The type whose resolver you want to set * @param resolver The new resolver function * @param override The new resolver will only replace an existing one if this parameter is true @@ -80,6 +82,7 @@ export abstract class DynamicComponentMapper { /** * Finds the component type that is needed to render a form field. + * * @param model Form field model for the field to render * @param defaultValue Default type returned for field types that are not yet mapped. * @returns Component type diff --git a/lib/core/services/ecm-user.service.ts b/lib/core/services/ecm-user.service.ts index f065542146..a4ca40c957 100644 --- a/lib/core/services/ecm-user.service.ts +++ b/lib/core/services/ecm-user.service.ts @@ -40,6 +40,7 @@ export class EcmUserService { /** * Gets information about a user identified by their username. + * * @param userName Target username * @returns User information */ @@ -52,6 +53,7 @@ export class EcmUserService { /** * Gets information about the user who is currently logged-in. + * * @returns User information as for getUserInfo */ getCurrentUserInfo() { @@ -60,6 +62,7 @@ export class EcmUserService { /** * Returns a profile image as a URL. + * * @param avatarId Target avatar * @returns Image URL */ diff --git a/lib/core/services/external-alfresco-api.service.ts b/lib/core/services/external-alfresco-api.service.ts index da933313a4..65e224daf1 100644 --- a/lib/core/services/external-alfresco-api.service.ts +++ b/lib/core/services/external-alfresco-api.service.ts @@ -59,7 +59,7 @@ export class ExternalAlfrescoApiService { provider: 'ECM', hostEcm: ecmHost, authType: 'BASIC', - contextRoot: contextRoot, + contextRoot, domainPrefix }; this.initAlfrescoApi(config); diff --git a/lib/core/services/favorites-api.service.ts b/lib/core/services/favorites-api.service.ts index 88a16d2bd2..f59d210bb7 100644 --- a/lib/core/services/favorites-api.service.ts +++ b/lib/core/services/favorites-api.service.ts @@ -53,7 +53,7 @@ export class FavoritesApiService { const entries: any[] = this .remapFavoriteEntries(data?.list?.entries || []); - return { + return { list: { entries, pagination } }; } @@ -69,6 +69,7 @@ export class FavoritesApiService { /** * Gets the favorites for a user. + * * @param personId ID of the user * @param options Options supported by JS-API * @returns List of favorites diff --git a/lib/core/services/get-type.ts b/lib/core/services/get-type.ts index bceb06b59c..e44712fd77 100644 --- a/lib/core/services/get-type.ts +++ b/lib/core/services/get-type.ts @@ -15,6 +15,4 @@ * limitations under the License. */ -export function getType(type: any): any { - return () => type; -} +export const getType = (type: any): any => () => type; diff --git a/lib/core/services/highlight-transform.service.ts b/lib/core/services/highlight-transform.service.ts index ace46bb4b8..52fefb3189 100644 --- a/lib/core/services/highlight-transform.service.ts +++ b/lib/core/services/highlight-transform.service.ts @@ -29,6 +29,7 @@ export class HighlightTransformService { /** * Searches for `search` string(s) within `text` and highlights all occurrences. + * * @param text Text to search within * @param search Text pattern to search for * @param wrapperClass CSS class used to provide highlighting style @@ -40,9 +41,7 @@ export class HighlightTransformService { if (search && text) { let pattern = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); - pattern = pattern.split(' ').filter((t) => { - return t.length > 0; - }).join('|'); + pattern = pattern.split(' ').filter((t) => t.length > 0).join('|'); const regex = new RegExp(pattern, 'gi'); result = text.replace(/<[^>]+>/g, '').replace(regex, (match) => { diff --git a/lib/core/services/identity-group.service.spec.ts b/lib/core/services/identity-group.service.spec.ts index 6234d3fe1d..371a84a71b 100644 --- a/lib/core/services/identity-group.service.spec.ts +++ b/lib/core/services/identity-group.service.spec.ts @@ -19,8 +19,6 @@ import { fakeAsync, TestBed } from '@angular/core/testing'; import { setupTestBed } from '../testing/setup-test-bed'; import { AlfrescoApiService } from './alfresco-api.service'; import { IdentityGroupService } from './identity-group.service'; -import { IdentityGroupSearchParam } from '../models/identity-group.model'; - import { HttpErrorResponse } from '@angular/common/http'; import { throwError, of } from 'rxjs'; import { @@ -59,7 +57,7 @@ describe('IdentityGroupService', () => { it('should be able to fetch groups based on group name', (done) => { spyOn(apiService, 'getInstance').and.returnValue(groupsMockApi); - service.findGroupsByName( {name: 'mock'}).subscribe((res) => { + service.findGroupsByName({name: 'mock'}).subscribe((res) => { expect(res).toBeDefined(); expect(res).not.toBeNull(); expect(res.length).toBe(5); diff --git a/lib/core/services/identity-group.service.ts b/lib/core/services/identity-group.service.ts index cbc5280725..55fa49983c 100644 --- a/lib/core/services/identity-group.service.ts +++ b/lib/core/services/identity-group.service.ts @@ -44,6 +44,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Gets all groups. + * * @returns Array of group information objects */ getGroups(): Observable { @@ -53,6 +54,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Gets available roles + * * @param groupId Id of the group. * @returns Array of available roles information objects */ @@ -63,6 +65,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Gets assigned roles + * * @param groupId Id of the group. * @returns Array of available roles */ @@ -73,6 +76,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Assigns roles to the group + * * @param groupId The ID of the group * @param roles Array of roles to assign */ @@ -85,6 +89,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Removes roles from the group + * * @param groupId The ID of the group * @param roles Array of roles to remove */ @@ -97,6 +102,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Get effective roles + * * @param groupId Id of the group * @returns Array of effective roles */ @@ -107,6 +113,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Queries groups. + * * @returns Array of user information objects */ queryGroups(requestQuery: IdentityGroupQueryCloudRequestModel): Observable { @@ -116,24 +123,23 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { return this.getTotalGroupsCount().pipe( switchMap((totalCount: IdentityGroupCountModel) => this.oAuth2Service.get({ url, queryParams }).pipe( - map((response) => { - return { - entries: response, - pagination: { - skipCount: requestQuery.first, - maxItems: requestQuery.max, - count: totalCount.count, - hasMoreItems: false, - totalItems: totalCount.count - } - }; - }) + map((response) => ({ + entries: response, + pagination: { + skipCount: requestQuery.first, + maxItems: requestQuery.max, + count: totalCount.count, + hasMoreItems: false, + totalItems: totalCount.count + } + } as IdentityGroupQueryResponse)) )) ); } /** * Gets groups total count. + * * @returns Number of groups count. */ getTotalGroupsCount(): Observable { @@ -143,6 +149,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Creates new group. + * * @param newGroup Object of containing the new group details. * @returns Empty response when the group created. */ @@ -155,6 +162,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Updates group details. + * * @param groupId Id of the targeted group. * @param updatedGroup Object of containing the group details * @returns Empty response when the group updated. @@ -168,6 +176,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Deletes Group. + * * @param groupId Id of the group. * @returns Empty response when the group deleted. */ @@ -178,6 +187,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Finds groups filtered by name. + * * @param searchParams Object containing the name filter string * @returns List of group information */ @@ -193,6 +203,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Gets details for a specified group. + * * @param groupId Id of the target group * @returns Group details */ @@ -203,6 +214,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Check that a group has one or more roles from the supplied list. + * * @param groupId Id of the target group * @param roleNames Array of role names * @returns True if the group has one or more of the roles, false otherwise @@ -225,6 +237,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Gets the client Id using the app name. + * * @param applicationName Name of the app * @returns client Id string */ @@ -239,6 +252,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Gets client roles. + * * @param groupId Id of the target group * @param clientId Id of the client * @returns List of roles @@ -250,6 +264,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Checks if a group has a client app. + * * @param groupId Id of the target group * @param clientId Id of the client * @returns True if the group has the client app, false otherwise @@ -262,6 +277,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface { /** * Check if a group has any of the client app roles in the supplied list. + * * @param groupId Id of the target group * @param clientId Id of the client * @param roleNames Array of role names to check diff --git a/lib/core/services/identity-role.service.spec.ts b/lib/core/services/identity-role.service.spec.ts index 38e2c4b2a3..91f1907a5f 100644 --- a/lib/core/services/identity-role.service.spec.ts +++ b/lib/core/services/identity-role.service.spec.ts @@ -21,19 +21,19 @@ import { TestBed } from '@angular/core/testing'; import { of, throwError } from 'rxjs'; import { IdentityRoleResponseModel, IdentityRoleService } from './identity-role.service'; -export let mockIdentityRole1 = { +export const mockIdentityRole1 = { id: 'mock-id-1', name: 'Mock_Role_1', description: 'Mock desc1', clientRole: true, composite: false }; -export let mockIdentityRole2 = { +export const mockIdentityRole2 = { id: 'mock-id-2', name: 'Mock_Role_2', description: 'Mock desc2', clientRole: false, composite: true }; -export let mockIdentityRole3 = { +export const mockIdentityRole3 = { id: 'mock-id-3', name: 'Mock_Role_3', description: 'Mock desc3', clientRole: false, composite: false }; -export let mockIdentityRoles = { +export const mockIdentityRoles = { entries: [ mockIdentityRole1, mockIdentityRole2, mockIdentityRole3 ], @@ -73,8 +73,8 @@ describe('IdentityRoleService', () => { it('should be able to add role', (done) => { const response = new HttpResponse({ body: [], - 'status': 201, - 'statusText': 'Created' + status: 201, + statusText: 'Created' }); spyOn(service, 'addRole').and.returnValue(of(response)); service.addRole(mockIdentityRole1).subscribe( @@ -107,8 +107,8 @@ describe('IdentityRoleService', () => { it('should be able to delete role', (done) => { const response = new HttpResponse({ body: [], - 'status': 204, - 'statusText': 'No Content' + status: 204, + statusText: 'No Content' }); spyOn(service, 'deleteRole').and.returnValue(of(response)); service.deleteRole(mockIdentityRole1).subscribe( diff --git a/lib/core/services/identity-role.service.ts b/lib/core/services/identity-role.service.ts index f56d57547f..0bd171f7e8 100644 --- a/lib/core/services/identity-role.service.ts +++ b/lib/core/services/identity-role.service.ts @@ -47,6 +47,7 @@ export class IdentityRoleService { /** * Ret all roles + * * @returns List of roles */ getRoles( @@ -54,9 +55,7 @@ export class IdentityRoleService { size: number = 5 ): Observable { return this.http.get(`${this.identityHost}/roles`).pipe( - map(res => { - return this.preparePaginationWithRoles(res, skipCount, size); - }), + map(res => this.preparePaginationWithRoles(res, skipCount, size)), catchError(error => this.handleError(error)) ); } @@ -69,7 +68,7 @@ export class IdentityRoleService { return { entries: roles.slice(skipCount, skipCount + size), pagination: { - skipCount: skipCount, + skipCount, maxItems: size, count: roles.length, hasMoreItems: false, @@ -80,6 +79,7 @@ export class IdentityRoleService { /** * Add new role + * * @param newRole Role model * @returns Server result payload */ @@ -95,6 +95,7 @@ export class IdentityRoleService { /** * Delete existing role + * * @param deletedRole Role model * @returns Server result payload */ @@ -106,6 +107,7 @@ export class IdentityRoleService { /** * Update existing role + * * @param updatedRole Role model * @param roleId Role id * @returns Server result payload diff --git a/lib/core/services/identity-user.service.spec.ts b/lib/core/services/identity-user.service.spec.ts index 13abba7876..f0b8ccc89f 100644 --- a/lib/core/services/identity-user.service.spec.ts +++ b/lib/core/services/identity-user.service.spec.ts @@ -76,12 +76,8 @@ describe('IdentityUserService', () => { beforeEach(() => { const store = {}; - spyOn(localStorage, 'getItem').and.callFake( (key: string): string => { - return store[key] || null; - }); - spyOn(localStorage, 'setItem').and.callFake((key: string, value: string): string => { - return store[key] = value; - }); + spyOn(localStorage, 'getItem').and.callFake( (key: string): string => store[key] || null); + spyOn(localStorage, 'setItem').and.callFake((key: string, value: string): string => store[key] = value); }); it('should fetch identity user info from Jwt id token', () => { diff --git a/lib/core/services/identity-user.service.ts b/lib/core/services/identity-user.service.ts index 7429468bfd..7095a7a185 100644 --- a/lib/core/services/identity-user.service.ts +++ b/lib/core/services/identity-user.service.ts @@ -46,6 +46,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets the name and other basic details of the current user. + * * @returns The user's details */ getCurrentUserInfo(): IdentityUserModel { @@ -53,11 +54,12 @@ export class IdentityUserService implements IdentityUserServiceInterface { const givenName = this.jwtHelperService.getValueFromLocalToken(JwtHelperService.GIVEN_NAME); const email = this.jwtHelperService.getValueFromLocalToken(JwtHelperService.USER_EMAIL); const username = this.jwtHelperService.getValueFromLocalToken(JwtHelperService.USER_PREFERRED_USERNAME); - return { firstName: givenName, lastName: familyName, email: email, username: username }; + return { firstName: givenName, lastName: familyName, email, username }; } /** * Find users based on search input. + * * @param search Search query string * @returns List of users */ @@ -66,13 +68,14 @@ export class IdentityUserService implements IdentityUserServiceInterface { return of([]); } const url = this.buildUserUrl(); - const queryParams = { search: search }; + const queryParams = { search }; return this.oAuth2Service.get({ url, queryParams }); } /** * Find users based on username input. + * * @param username Search query string * @returns List of users */ @@ -81,13 +84,14 @@ export class IdentityUserService implements IdentityUserServiceInterface { return of([]); } const url = this.buildUserUrl(); - const queryParams = { username: username }; + const queryParams = { username }; return this.oAuth2Service.get({url, queryParams }); } /** * Find users based on email input. + * * @param email Search query string * @returns List of users */ @@ -96,13 +100,14 @@ export class IdentityUserService implements IdentityUserServiceInterface { return of([]); } const url = this.buildUserUrl(); - const queryParams = { email: email }; + const queryParams = { email }; return this.oAuth2Service.get({ url, queryParams }); } /** * Find users based on id input. + * * @param id Search query string * @returns users object */ @@ -116,6 +121,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Get client roles of a user for a particular client. + * * @param userId ID of the target user * @param clientId ID of the client app * @returns List of client roles @@ -127,6 +133,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Checks whether user has access to a client app. + * * @param userId ID of the target user * @param clientId ID of the client app * @returns True if the user has access, false otherwise @@ -139,6 +146,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Checks whether a user has any of the client app roles. + * * @param userId ID of the target user * @param clientId ID of the client app * @param roleNames List of role names to check for @@ -165,6 +173,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets the client ID for an application. + * * @param applicationName Name of the application * @returns Client ID string */ @@ -181,20 +190,20 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Checks if a user has access to an application. + * * @param userId ID of the user * @param applicationName Name of the application * @returns True if the user has access, false otherwise */ checkUserHasApplicationAccess(userId: string, applicationName: string): Observable { return this.getClientIdByApplicationName(applicationName).pipe( - switchMap((clientId: string) => { - return this.checkUserHasClientApp(userId, clientId); - }) + switchMap((clientId: string) => this.checkUserHasClientApp(userId, clientId)) ); } /** * Checks if a user has any application role. + * * @param userId ID of the target user * @param applicationName Name of the application * @param roleNames List of role names to check for @@ -202,14 +211,13 @@ export class IdentityUserService implements IdentityUserServiceInterface { */ checkUserHasAnyApplicationRole(userId: string, applicationName: string, roleNames: string[]): Observable { return this.getClientIdByApplicationName(applicationName).pipe( - switchMap((clientId: string) => { - return this.checkUserHasAnyClientAppRole(userId, clientId, roleNames); - }) + switchMap((clientId: string) => this.checkUserHasAnyClientAppRole(userId, clientId, roleNames)) ); } /** * Gets details for all users. + * * @returns Array of user info objects */ getUsers(): Observable { @@ -219,6 +227,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets a list of roles for a user. + * * @param userId ID of the user * @returns Array of role info objects */ @@ -229,6 +238,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets an array of users (including the current user) who have any of the roles in the supplied list. + * * @param roleNames List of role names to look for * @returns Array of user info objects */ @@ -250,6 +260,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets an array of users (not including the current user) who have any of the roles in the supplied list. + * * @param roleNames List of role names to look for * @returns Array of user info objects */ @@ -275,9 +286,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { private async userHasAnyRole(userId: string, roleNames: string[]): Promise { const userRoles = await this.getUserRoles(userId).toPromise(); const hasAnyRole = roleNames.some((roleName) => { - const filteredRoles = userRoles.filter((userRole) => { - return userRole.name.toLocaleLowerCase() === roleName.toLocaleLowerCase(); - }); + const filteredRoles = userRoles.filter((userRole) => userRole.name.toLocaleLowerCase() === roleName.toLocaleLowerCase()); return filteredRoles.length > 0; }); @@ -287,6 +296,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Checks if a user has one of the roles from a list. + * * @param userId ID of the target user * @param roleNames Array of roles to check for * @returns True if the user has one of the roles, false otherwise @@ -309,6 +319,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets details for all users. + * * @returns Array of user information objects. */ queryUsers(requestQuery: IdentityUserQueryCloudRequestModel): Observable { @@ -318,18 +329,16 @@ export class IdentityUserService implements IdentityUserServiceInterface { return this.getTotalUsersCount().pipe( switchMap((totalCount) => this.oAuth2Service.get({ url, queryParams }).pipe( - map((response) => { - return { - entries: response, - pagination: { - skipCount: requestQuery.first, - maxItems: requestQuery.max, - count: totalCount, - hasMoreItems: false, - totalItems: totalCount - } - }; - }) + map((response) => ({ + entries: response, + pagination: { + skipCount: requestQuery.first, + maxItems: requestQuery.max, + count: totalCount, + hasMoreItems: false, + totalItems: totalCount + } + } as IdentityUserQueryResponse)) ) ) ); @@ -337,6 +346,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets users total count. + * * @returns Number of users count. */ getTotalUsersCount(): Observable { @@ -346,6 +356,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Creates new user. + * * @param newUser Object containing the new user details. * @returns Empty response when the user created. */ @@ -358,6 +369,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Updates user details. + * * @param userId Id of the user. * @param updatedUser Object containing the user details. * @returns Empty response when the user updated. @@ -371,6 +383,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Deletes User. + * * @param userId Id of the user. * @returns Empty response when the user deleted. */ @@ -381,6 +394,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Changes user password. + * * @param userId Id of the user. * @param credentials Details of user Credentials. * @returns Empty response when the password changed. @@ -394,6 +408,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets involved groups. + * * @param userId Id of the user. * @returns Array of involved groups information objects. */ @@ -406,6 +421,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Joins group. + * * @param joinGroupRequest Details of join group request (IdentityJoinGroupRequestModel). * @returns Empty response when the user joined the group. */ @@ -418,6 +434,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Leaves group. + * * @param userId Id of the user. * @param groupId Id of the group. * @returns Empty response when the user left the group. @@ -429,6 +446,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets available roles + * * @param userId Id of the user. * @returns Array of available roles information objects */ @@ -439,6 +457,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets assigned roles. + * * @param userId Id of the user. * @returns Array of assigned roles information objects */ @@ -451,6 +470,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Gets effective roles. + * * @param userId Id of the user. * @returns Array of composite roles information objects */ @@ -463,6 +483,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Assigns roles to the user. + * * @param userId Id of the user. * @param roles Array of roles. * @returns Empty response when the role assigned. @@ -476,6 +497,7 @@ export class IdentityUserService implements IdentityUserServiceInterface { /** * Removes assigned roles. + * * @param userId Id of the user. * @param roles Array of roles. * @returns Empty response when the role removed. diff --git a/lib/core/services/jwt-helper.service.spec.ts b/lib/core/services/jwt-helper.service.spec.ts index b3be3eb6f9..020a5efc58 100644 --- a/lib/core/services/jwt-helper.service.spec.ts +++ b/lib/core/services/jwt-helper.service.spec.ts @@ -52,7 +52,7 @@ describe('JwtHelperService', () => { spyOn(jwtHelperService, 'decodeToken').and.returnValue( { - 'realm_access': { roles: ['role1'] } + realm_access: { roles: ['role1'] } }); const result = jwtHelperService.hasRealmRole('role1'); @@ -64,7 +64,7 @@ describe('JwtHelperService', () => { spyOn(jwtHelperService, 'decodeToken').and.returnValue( { - 'realm_access': { roles: ['role1'] } + realm_access: { roles: ['role1'] } }); const result = jwtHelperService.hasRealmRoles(['role1', 'role2']); @@ -75,7 +75,7 @@ describe('JwtHelperService', () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'decodeToken').and.returnValue( { - 'realm_access': { roles: ['role3'] } + realm_access: { roles: ['role3'] } }); const result = jwtHelperService.hasRealmRole('role1'); expect(result).toBeFalsy(); @@ -85,7 +85,7 @@ describe('JwtHelperService', () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'decodeToken').and.returnValue( { - 'realm_access': { roles: ['role1'] } + realm_access: { roles: ['role1'] } }); const result = jwtHelperService.hasRealmRoles(['role3', 'role2']); expect(result).toBeFalsy(); @@ -99,7 +99,7 @@ describe('JwtHelperService', () => { spyOn(jwtHelperService, 'decodeToken').and.returnValue( { - 'resource_access': { fakeapp: { roles: ['role1'] } } + resource_access: { fakeapp: { roles: ['role1'] } } }); const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1']); @@ -111,7 +111,7 @@ describe('JwtHelperService', () => { spyOn(jwtHelperService, 'decodeToken').and.returnValue( { - 'resource_access': { fakeapp: { roles: ['role1'] } } + resource_access: { fakeapp: { roles: ['role1'] } } }); const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']); @@ -122,7 +122,7 @@ describe('JwtHelperService', () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'decodeToken').and.returnValue( { - 'resource_access': { fakeapp: { roles: ['role3'] } } + resource_access: { fakeapp: { roles: ['role3'] } } }); const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']); expect(result).toBeFalsy(); @@ -132,7 +132,7 @@ describe('JwtHelperService', () => { spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'decodeToken').and.returnValue( { - 'resource_access': { anotherfakeapp: { roles: ['role1'] } } + resource_access: { anotherfakeapp: { roles: ['role1'] } } }); const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']); expect(result).toBeFalsy(); diff --git a/lib/core/services/jwt-helper.service.ts b/lib/core/services/jwt-helper.service.ts index 46b5612a0d..9a4afabbe1 100644 --- a/lib/core/services/jwt-helper.service.ts +++ b/lib/core/services/jwt-helper.service.ts @@ -38,6 +38,7 @@ export class JwtHelperService { /** * Decodes a JSON web token into a JS object. + * * @param token Token in encoded form * @returns Decoded token data object */ @@ -79,6 +80,7 @@ export class JwtHelperService { /** * Gets a named value from the user access or id token. + * * @param key Key name of the field to retrieve * @returns Value from the token */ @@ -88,6 +90,7 @@ export class JwtHelperService { /** * Gets a named value from the user access token. + * * @param key Key name of the field to retrieve * @returns Value from the token */ @@ -97,6 +100,7 @@ export class JwtHelperService { /** * Gets access token + * * @returns access token */ getAccessToken(): string { @@ -105,6 +109,7 @@ export class JwtHelperService { /** * Gets a named value from the user id token. + * * @param key Key name of the field to retrieve * @returns Value from the token */ @@ -114,6 +119,7 @@ export class JwtHelperService { /** * Gets id token + * * @returns id token */ getIdToken(): string { @@ -122,6 +128,7 @@ export class JwtHelperService { /** * Gets a named value from the user access token. + * * @param accessToken your SSO access token where the value is encode * @param key Key name of the field to retrieve * @returns Value from the token @@ -132,11 +139,12 @@ export class JwtHelperService { const tokenPayload = this.decodeToken(token); value = tokenPayload[key]; } - return value; + return value; } /** * Gets realm roles. + * * @returns Array of realm roles */ getRealmRoles(): string[] { @@ -146,6 +154,7 @@ export class JwtHelperService { /** * Gets Client roles. + * * @returns Array of client roles */ getClientRoles(clientName: string): string[] { @@ -155,6 +164,7 @@ export class JwtHelperService { /** * Checks for single realm role. + * * @param role Role name to check * @returns True if it contains given role, false otherwise */ @@ -162,38 +172,35 @@ export class JwtHelperService { let hasRole = false; if (this.getAccessToken()) { const realmRoles = this.getRealmRoles(); - hasRole = realmRoles.some((currentRole) => { - return currentRole === role; - }); + hasRole = realmRoles.some((currentRole) => currentRole === role); } return hasRole; } /** * Checks for realm roles. + * * @param rolesToCheck List of role names to check * @returns True if it contains at least one of the given roles, false otherwise */ hasRealmRoles(rolesToCheck: string []): boolean { - return rolesToCheck.some((currentRole) => { - return this.hasRealmRole(currentRole); - }); + return rolesToCheck.some((currentRole) => this.hasRealmRole(currentRole)); } /** * Checks for client roles. + * * @param clientName Targeted client name * @param rolesToCheck List of role names to check * @returns True if it contains at least one of the given roles, false otherwise */ hasRealmRolesForClientRole(clientName: string, rolesToCheck: string []): boolean { - return rolesToCheck.some((currentRole) => { - return this.hasClientRole(clientName, currentRole); - }); + return rolesToCheck.some((currentRole) => this.hasClientRole(clientName, currentRole)); } /** * Checks for client role. + * * @param clientName Targeted client name * @param role Role name to check * @returns True if it contains given role, false otherwise @@ -202,9 +209,7 @@ export class JwtHelperService { let hasRole = false; if (this.getAccessToken()) { const clientRoles = this.getClientRoles(clientName); - hasRole = clientRoles.some((currentRole) => { - return currentRole === role; - }); + hasRole = clientRoles.some((currentRole) => currentRole === role); } return hasRole; } diff --git a/lib/core/services/language.service.ts b/lib/core/services/language.service.ts index 4e12210c02..4c0a26b737 100644 --- a/lib/core/services/language.service.ts +++ b/lib/core/services/language.service.ts @@ -25,23 +25,23 @@ import { UserPreferencesService } from './user-preferences.service'; export class LanguageService { private languages = new BehaviorSubject([ - {'key': 'de', 'label': 'Deutsch'}, - {'key': 'en', 'label': 'English'}, - {'key': 'es', 'label': 'Español'}, - {'key': 'fr', 'label': 'Français'}, - {'key': 'it', 'label': 'Italiano'}, - {'key': 'ja', 'label': '日本語'}, - {'key': 'nb', 'label': 'Bokmål'}, - {'key': 'nl', 'label': 'Nederlands'}, - {'key': 'pt-BR', 'label': 'Português (Brasil)'}, - {'key': 'ru', 'label': 'Русский'}, - {'key': 'zh-CN', 'label': '中文简体'}, - {'key': 'cs', 'label': 'Čeština'}, - {'key': 'da', 'label': 'Dansk'}, - {'key': 'fi', 'label': 'Suomi'}, - {'key': 'pl', 'label': 'Polski'}, - {'key': 'sv', 'label': 'Svenska'}, - {'key': 'ar', 'label': 'العربية', direction: 'rtl'} + {key: 'de', label: 'Deutsch'}, + {key: 'en', label: 'English'}, + {key: 'es', label: 'Español'}, + {key: 'fr', label: 'Français'}, + {key: 'it', label: 'Italiano'}, + {key: 'ja', label: '日本語'}, + {key: 'nb', label: 'Bokmål'}, + {key: 'nl', label: 'Nederlands'}, + {key: 'pt-BR', label: 'Português (Brasil)'}, + {key: 'ru', label: 'Русский'}, + {key: 'zh-CN', label: '中文简体'}, + {key: 'cs', label: 'Čeština'}, + {key: 'da', label: 'Dansk'}, + {key: 'fi', label: 'Suomi'}, + {key: 'pl', label: 'Polski'}, + {key: 'sv', label: 'Svenska'}, + {key: 'ar', label: 'العربية', direction: 'rtl'} ]); languages$ = this.languages.asObservable(); diff --git a/lib/core/services/lock.service.spec.ts b/lib/core/services/lock.service.spec.ts index 206ff80d11..c3bc2bbb85 100644 --- a/lib/core/services/lock.service.spec.ts +++ b/lib/core/services/lock.service.spec.ts @@ -29,9 +29,9 @@ describe('PeopleProcessService', () => { let service: LockService; let apiService: AlfrescoApiService; - const fakeNodeUnlocked: Node = { name: 'unlocked', isLocked: false, isFile: true }; - const fakeFolderNode: Node = { name: 'unlocked', isLocked: false, isFile: false, isFolder: true }; - const fakeNodeNoProperty: Node = { name: 'unlocked', isLocked: true, isFile: true, properties: {} }; + const fakeNodeUnlocked: Node = { name: 'unlocked', isLocked: false, isFile: true } as Node; + const fakeFolderNode: Node = { name: 'unlocked', isLocked: false, isFile: false, isFolder: true } as Node; + const fakeNodeNoProperty: Node = { name: 'unlocked', isLocked: true, isFile: true, properties: {} } as Node; setupTestBed({ imports: [ @@ -58,7 +58,7 @@ describe('PeopleProcessService', () => { }); describe('When the lock is readonly', () => { - const nodeReadonly: Node = { + const nodeReadonly: Node = { name: 'readonly-lock-node', isLocked: true, isFile: true, @@ -67,9 +67,9 @@ describe('PeopleProcessService', () => { 'cm:lockType': 'READ_ONLY_LOCK', 'cm:lockLifetime': 'PERSISTENT' } - }; + } as Node; - const nodeReadOnlyWithExpiredDate: Node = { + const nodeReadOnlyWithExpiredDate: Node = { name: 'readonly-lock-node', isLocked: true, isFile: true, @@ -80,9 +80,9 @@ describe('PeopleProcessService', () => { 'cm:lockOwner': { id: 'lock-owner-user' }, 'cm:expiryDate': moment().subtract(4, 'days') } - }; + } as Node; - const nodeReadOnlyWithActiveExpiration: Node = { + const nodeReadOnlyWithActiveExpiration: Node = { name: 'readonly-lock-node', isLocked: true, isFile: true, @@ -93,7 +93,7 @@ describe('PeopleProcessService', () => { 'cm:lockOwner': { id: 'lock-owner-user' }, 'cm:expiryDate': moment().add(4, 'days') } - }; + } as Node; it('should return true when readonly lock is active', () => { expect(service.isLocked(nodeReadonly)).toBeTruthy(); @@ -109,7 +109,7 @@ describe('PeopleProcessService', () => { }); describe('When only the lock owner is allowed', () => { - const nodeOwnerAllowedLock: Node = { + const nodeOwnerAllowedLock: Node = { name: 'readonly-lock-node', isLocked: true, isFile: true, @@ -119,9 +119,9 @@ describe('PeopleProcessService', () => { 'cm:lockLifetime': 'PERSISTENT', 'cm:lockOwner': { id: 'lock-owner-user' } } - }; + } as Node; - const nodeOwnerAllowedLockWithExpiredDate: Node = { + const nodeOwnerAllowedLockWithExpiredDate: Node = { name: 'readonly-lock-node', isLocked: true, isFile: true, @@ -132,9 +132,9 @@ describe('PeopleProcessService', () => { 'cm:lockOwner': { id: 'lock-owner-user' }, 'cm:expiryDate': moment().subtract(4, 'days') } - }; + } as Node; - const nodeOwnerAllowedLockWithActiveExpiration: Node = { + const nodeOwnerAllowedLockWithActiveExpiration: Node = { name: 'readonly-lock-node', isLocked: true, isFile: true, @@ -145,7 +145,7 @@ describe('PeopleProcessService', () => { 'cm:lockOwner': { id: 'lock-owner-user' }, 'cm:expiryDate': moment().add(4, 'days') } - }; + } as Node; it('should return false when the user is the lock owner', () => { spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('lock-owner-user'); diff --git a/lib/core/services/log.service.ts b/lib/core/services/log.service.ts index 067778993d..7154f5172a 100644 --- a/lib/core/services/log.service.ts +++ b/lib/core/services/log.service.ts @@ -45,6 +45,7 @@ export class LogService { /** * Logs a message at the "ERROR" level. + * * @param message Message to log * @param optionalParams Interpolation values for the message in "printf" format */ @@ -59,6 +60,7 @@ export class LogService { /** * Logs a message at the "DEBUG" level. + * * @param message Message to log * @param optionalParams Interpolation values for the message in "printf" format */ @@ -73,6 +75,7 @@ export class LogService { /** * Logs a message at the "INFO" level. + * * @param message Message to log * @param optionalParams Interpolation values for the message in "printf" format */ @@ -87,6 +90,7 @@ export class LogService { /** * Logs a message at any level from "TRACE" upwards. + * * @param message Message to log * @param optionalParams Interpolation values for the message in "printf" format */ @@ -101,6 +105,7 @@ export class LogService { /** * Logs a message at the "TRACE" level. + * * @param message Message to log * @param optionalParams Interpolation values for the message in "printf" format */ @@ -115,6 +120,7 @@ export class LogService { /** * Logs a message at the "WARN" level. + * * @param message Message to log * @param optionalParams Interpolation values for the message in "printf" format */ @@ -129,6 +135,7 @@ export class LogService { /** * Logs a message if a boolean test fails. + * * @param test Test value (typically a boolean expression) * @param message Message to show if test is false * @param optionalParams Interpolation values for the message in "printf" format @@ -144,6 +151,7 @@ export class LogService { /** * Starts an indented group of log messages. + * * @param groupTitle Title shown at the start of the group * @param optionalParams Interpolation values for the title in "printf" format */ @@ -164,23 +172,23 @@ export class LogService { /** * Converts a log level name string into its numeric equivalent. + * * @param level Level name * @returns Numeric log level */ getLogLevel(level: string): LogLevelsEnum { - const referencedLevel = logLevels.find((currentLevel: any) => { - return currentLevel.name.toLocaleLowerCase() === level.toLocaleLowerCase(); - }); + const referencedLevel = logLevels.find((currentLevel: any) => currentLevel.name.toLocaleLowerCase() === level.toLocaleLowerCase()); return referencedLevel ? referencedLevel.level : 5; } /** * Triggers notification callback for log messages. + * * @param text Message text * @param logLevel Log level for the message */ messageBus(text: string, logLevel: string) { - this.onMessage.next({ text: text, type: logLevel }); + this.onMessage.next({ text, type: logLevel }); } } diff --git a/lib/core/services/login-dialog.service.ts b/lib/core/services/login-dialog.service.ts index ea739fe10d..fae8818e02 100644 --- a/lib/core/services/login-dialog.service.ts +++ b/lib/core/services/login-dialog.service.ts @@ -31,6 +31,7 @@ export class LoginDialogService { /** * Opens a dialog to choose a file to upload. + * * @param actionName Name of the action to show in the title * @param title Title for the dialog * @returns Information about the chosen file(s) diff --git a/lib/core/services/nodes-api.service.ts b/lib/core/services/nodes-api.service.ts index 30d0ecb226..db1f242963 100644 --- a/lib/core/services/nodes-api.service.ts +++ b/lib/core/services/nodes-api.service.ts @@ -50,6 +50,7 @@ export class NodesApiService { /** * Gets the stored information about a node. + * * @param nodeId ID of the target node * @param options Optional parameters supported by JS-API * @returns Node information @@ -68,6 +69,7 @@ export class NodesApiService { /** * Gets the items contained in a folder node. + * * @param nodeId ID of the target node * @param options Optional parameters supported by JS-API * @returns List of child items from the folder @@ -87,6 +89,7 @@ export class NodesApiService { /** * Creates a new document node inside a folder. + * * @param parentNodeId ID of the parent folder node * @param nodeBody Data for the new node * @param options Optional parameters supported by JS-API @@ -101,6 +104,7 @@ export class NodesApiService { /** * Creates a new folder node inside a parent folder. + * * @param parentNodeId ID of the parent folder node * @param nodeBody Data for the new folder * @param options Optional parameters supported by JS-API @@ -113,6 +117,7 @@ export class NodesApiService { /** * Updates the information about a node. + * * @param nodeId ID of the target node * @param nodeBody New data for the node * @param options Optional parameters supported by JS-API @@ -132,6 +137,7 @@ export class NodesApiService { /** * Moves a node to the trashcan. + * * @param nodeId ID of the target node * @param options Optional parameters supported by JS-API * @returns Empty result that notifies when the deletion is complete @@ -144,6 +150,7 @@ export class NodesApiService { /** * Restores a node previously moved to the trashcan. + * * @param nodeId ID of the node to restore * @returns Details of the restored node */ @@ -156,6 +163,7 @@ export class NodesApiService { /** * Get the metadata and the nodeType for a nodeId cleaned by the prefix. + * * @param nodeId ID of the target node * @returns Node metadata */ @@ -166,6 +174,7 @@ export class NodesApiService { /** * Create a new Node from form metadata. + * * @param path Path to the node * @param nodeType Node type * @param name Node name @@ -186,6 +195,7 @@ export class NodesApiService { /** * Create a new Node inside `-root-` folder + * * @param name Node name * @param nodeType Node type * @param properties Node body properties @@ -194,16 +204,16 @@ export class NodesApiService { */ public createNodeInsideRoot(name: string, nodeType: string, properties: any, path: string): Observable { const body = { - name: name, - nodeType: nodeType, - properties: properties, + name, + nodeType, + properties, relativePath: path }; return from(this.nodesApi.createNode('-root-', body, {})); } private generateUuid() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { const r = Math.random() * 16 | 0; const v = c === 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); diff --git a/lib/core/services/page-title.service.ts b/lib/core/services/page-title.service.ts index 93f14cbe50..ddf8cf41d8 100644 --- a/lib/core/services/page-title.service.ts +++ b/lib/core/services/page-title.service.ts @@ -38,6 +38,7 @@ export class PageTitleService { /** * Sets the page title. + * * @param value The new title */ setTitle(value: string = '') { diff --git a/lib/core/services/people-content.service.ts b/lib/core/services/people-content.service.ts index 5818471ed9..1c11cf4b6d 100644 --- a/lib/core/services/people-content.service.ts +++ b/lib/core/services/people-content.service.ts @@ -23,6 +23,7 @@ import { PersonEntry, PeopleApi, PersonBodyCreate, Pagination, PersonBodyUpdate import { EcmUserModel } from '../models/ecm-user.model'; import { LogService } from './log.service'; +// eslint-disable-next-line no-shadow export enum ContentGroups { ALFRESCO_ADMINISTRATORS = 'ALFRESCO_ADMINISTRATORS' } @@ -50,7 +51,7 @@ export class PeopleContentService { private hasContentAdminRole: boolean = false; hasCheckedIsContentAdmin: boolean = false; - _peopleApi: PeopleApi; + private _peopleApi: PeopleApi; get peopleApi(): PeopleApi { this._peopleApi = this._peopleApi ?? new PeopleApi(this.apiService.getInstance()); return this._peopleApi; @@ -61,6 +62,7 @@ export class PeopleContentService { /** * Gets information about a user identified by their username. + * * @param personId ID of the target user * @returns User information */ @@ -74,6 +76,7 @@ export class PeopleContentService { /** * Gets information about the user who is currently logged in. + * * @returns User information */ getCurrentPerson(): Observable { @@ -82,6 +85,7 @@ export class PeopleContentService { /** * Gets a list of people. + * * @param requestQuery maxItems and skipCount parameters supported by JS-API * @returns Response containing pagination and list of entries */ @@ -94,31 +98,31 @@ export class PeopleContentService { const promise = this.peopleApi.listPeople(requestQueryParams); return from(promise).pipe( - map(response => { - return { - pagination: response.list.pagination, - entries: response.list.entries.map((person: PersonEntry) => person.entry) - }; - }), + map(response => ({ + pagination: response.list.pagination, + entries: response.list.entries.map((person) => person.entry as EcmUserModel) + })), catchError((err) => this.handleError(err)) ); } /** * Creates new person. + * * @param newPerson Object containing the new person details. * @param opts Optional parameters * @returns Created new person */ createPerson(newPerson: PersonBodyCreate, opts?: any): Observable { return from(this.peopleApi.createPerson(newPerson, opts)).pipe( - map((res: PersonEntry) => res?.entry), + map((res) => res?.entry as EcmUserModel), catchError((error) => this.handleError(error)) ); } /** * Updates the person details + * * @param personId The identifier of a person * @param details The person details * @param opts Optional parameters @@ -126,7 +130,7 @@ export class PeopleContentService { */ updatePerson(personId: string, details: PersonBodyUpdate, opts?: any): Observable { return from(this.peopleApi.updatePerson(personId, details, opts)).pipe( - map((res: PersonEntry) => res?.entry), + map((res) => res?.entry as EcmUserModel), catchError((error) => this.handleError(error)) ); } diff --git a/lib/core/services/people-process.service.ts b/lib/core/services/people-process.service.ts index 92b396cdaf..88502474c3 100644 --- a/lib/core/services/people-process.service.ts +++ b/lib/core/services/people-process.service.ts @@ -50,6 +50,7 @@ export class PeopleProcessService { /** * Gets information about users across all tasks. + * * @param taskId ID of the task * @param searchWord Filter text to search for * @returns Array of user information objects @@ -58,13 +59,14 @@ export class PeopleProcessService { const option = { excludeTaskId: taskId, filter: searchWord }; return from(this.getWorkflowUserApi(option)) .pipe( - map((response: any) => response.data || []), + map((response: any) => response.data || []), catchError((err) => this.handleError(err)) ); } /** * Gets the profile picture URL for the specified user. + * * @param user The target user * @returns Profile picture URL */ @@ -74,6 +76,7 @@ export class PeopleProcessService { /** * Sets a user to be involved with a task. + * * @param taskId ID of the target task * @param idToInvolve ID of the user to involve * @returns Empty response when the update completes @@ -88,6 +91,7 @@ export class PeopleProcessService { /** * Removes a user who is currently involved with a task. + * * @param taskId ID of the target task * @param idToRemove ID of the user to remove * @returns Empty response when the update completes @@ -116,10 +120,6 @@ export class PeopleProcessService { return this.userApi.getUserProfilePictureUrl(userId); } - /** - * Throw the error - * @param error - */ private handleError(error: any) { this.logService.error(error); return throwError(error || 'Server error'); diff --git a/lib/core/services/renditions.service.spec.ts b/lib/core/services/renditions.service.spec.ts index 96e301a522..215a0af20f 100644 --- a/lib/core/services/renditions.service.spec.ts +++ b/lib/core/services/renditions.service.spec.ts @@ -52,7 +52,7 @@ describe('RenditionsService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeRenditionsList) }); @@ -66,7 +66,7 @@ describe('RenditionsService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeRenditionsListWithACreated) }); @@ -79,7 +79,7 @@ describe('RenditionsService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeRenditionsList) }); @@ -93,7 +93,7 @@ describe('RenditionsService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: '' }); @@ -118,7 +118,7 @@ describe('RenditionsService', () => { ); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 403, + status: 403, contentType: 'application/json', responseText: 'error' }); @@ -131,7 +131,7 @@ describe('RenditionsService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeRendition) }); @@ -144,7 +144,7 @@ describe('RenditionsService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 403, + status: 403, contentType: 'application/json' }); }); @@ -156,7 +156,7 @@ describe('RenditionsService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeRenditionCreated) }); @@ -169,7 +169,7 @@ describe('RenditionsService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', responseText: JSON.stringify(fakeRendition) }); @@ -182,7 +182,7 @@ describe('RenditionsService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 400, + status: 400, contentType: 'application/json' }); }); diff --git a/lib/core/services/renditions.service.ts b/lib/core/services/renditions.service.ts index a5aa58eac9..d8db56334d 100644 --- a/lib/core/services/renditions.service.ts +++ b/lib/core/services/renditions.service.ts @@ -26,13 +26,13 @@ import { concatMap, switchMap, takeWhile, map } from 'rxjs/operators'; }) export class RenditionsService { - _renditionsApi: RenditionsApi; + private _renditionsApi: RenditionsApi; get renditionsApi(): RenditionsApi { this._renditionsApi = this._renditionsApi ?? new RenditionsApi(this.apiService.getInstance()); return this._renditionsApi; } - _contentApi: ContentApi; + private _contentApi: ContentApi; get contentApi(): ContentApi { this._contentApi = this._contentApi ?? new ContentApi(this.apiService.getInstance()); return this._contentApi; @@ -43,6 +43,7 @@ export class RenditionsService { /** * Gets the first available rendition found for a node. + * * @param nodeId ID of the target node * @returns Information object for the rendition */ @@ -58,6 +59,7 @@ export class RenditionsService { /** * Generates a rendition for a node using the first available encoding. + * * @param nodeId ID of the target node * @returns Null response to indicate completion */ @@ -75,6 +77,7 @@ export class RenditionsService { /** * Checks if the specified rendition is available for a node. + * * @param nodeId ID of the target node * @param encoding Name of the rendition encoding * @returns True if the rendition is available, false otherwise @@ -100,6 +103,7 @@ export class RenditionsService { /** * Checks if the node can be converted using the specified rendition. + * * @param nodeId ID of the target node * @param encoding Name of the rendition encoding * @returns True if the node can be converted, false otherwise @@ -121,6 +125,7 @@ export class RenditionsService { /** * Gets a URL linking to the specified rendition of a node. + * * @param nodeId ID of the target node * @param encoding Name of the rendition encoding * @returns URL string @@ -131,6 +136,7 @@ export class RenditionsService { /** * Gets information about a rendition of a node. + * * @param nodeId ID of the target node * @param encoding Name of the rendition encoding * @returns Information object about the rendition @@ -141,6 +147,7 @@ export class RenditionsService { /** * Gets a list of all renditions for a node. + * * @param nodeId ID of the target node * @returns Paged list of rendition details */ @@ -150,6 +157,7 @@ export class RenditionsService { /** * Creates a rendition for a node. + * * @param nodeId ID of the target node * @param encoding Name of the rendition encoding * @returns Null response to indicate completion @@ -160,6 +168,7 @@ export class RenditionsService { /** * Repeatedly attempts to create a rendition, through to success or failure. + * * @param nodeId ID of the target node * @param encoding Name of the rendition encoding * @param pollingInterval Time interval (in milliseconds) between checks for completion diff --git a/lib/core/services/search-configuration.service.ts b/lib/core/services/search-configuration.service.ts index ae04a1cff7..d51ce770c7 100644 --- a/lib/core/services/search-configuration.service.ts +++ b/lib/core/services/search-configuration.service.ts @@ -29,12 +29,13 @@ export class SearchConfigurationService implements SearchConfigurationInterface /** * Generates a QueryBody object with custom search parameters. + * * @param searchTerm Term text to search for * @param maxResults Maximum number of search results to show in a page * @param skipCount The offset of the start of the page within the results list * @returns Query body defined by the parameters */ - public generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody { + generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody { const defaultQueryBody: QueryBody = { query: { query: searchTerm ? `'${searchTerm}*' OR name:'${searchTerm}*'` : searchTerm @@ -42,7 +43,7 @@ export class SearchConfigurationService implements SearchConfigurationInterface include: ['path', 'allowableOperations'], paging: { maxItems: maxResults, - skipCount: skipCount + skipCount }, filterQueries: [ { query: `TYPE:'cm:folder' OR TYPE:'cm:content'` }, diff --git a/lib/core/services/search.service.ts b/lib/core/services/search.service.ts index 9bba13c911..3c8b485145 100644 --- a/lib/core/services/search.service.ts +++ b/lib/core/services/search.service.ts @@ -28,13 +28,13 @@ export class SearchService { dataLoaded: Subject = new Subject(); - _queriesApi: QueriesApi; + private _queriesApi: QueriesApi; get queriesApi(): QueriesApi { this._queriesApi = this._queriesApi ?? new QueriesApi(this.apiService.getInstance()); return this._queriesApi; } - _searchApi: SearchApi; + private _searchApi: SearchApi; get searchApi(): SearchApi { this._searchApi = this._searchApi ?? new SearchApi(this.apiService.getInstance()); return this._searchApi; @@ -46,6 +46,7 @@ export class SearchService { /** * Gets a list of nodes that match the given search criteria. + * * @param term Term to search for * @param options Options for delivery of the search results * @returns List of nodes resulting from the search @@ -62,6 +63,7 @@ export class SearchService { /** * Performs a search. + * * @param searchTerm Term to search for * @param maxResults Maximum number of items in the list of results * @param skipCount Number of higher-ranked items to skip over in the list @@ -80,6 +82,7 @@ export class SearchService { /** * Performs a search with its parameters supplied by a QueryBody object. + * * @param queryBody Object containing the search parameters * @returns List of search results */ diff --git a/lib/core/services/shared-links-api.service.ts b/lib/core/services/shared-links-api.service.ts index d0cdd6d67d..e88c3409f9 100644 --- a/lib/core/services/shared-links-api.service.ts +++ b/lib/core/services/shared-links-api.service.ts @@ -29,7 +29,7 @@ export class SharedLinksApiService { error = new Subject<{ statusCode: number; message: string }>(); - _sharedLinksApi: SharedlinksApi; + private _sharedLinksApi: SharedlinksApi; get sharedLinksApi(): SharedlinksApi { this._sharedLinksApi = this._sharedLinksApi ?? new SharedlinksApi(this.apiService.getInstance()); return this._sharedLinksApi; @@ -41,6 +41,7 @@ export class SharedLinksApiService { /** * Gets shared links available to the current user. + * * @param options Options supported by JS-API * @returns List of shared links */ @@ -60,12 +61,13 @@ export class SharedLinksApiService { /** * Creates a shared link available to the current user. + * * @param nodeId ID of the node to link to * @param options Options supported by JS-API * @returns The shared link just created */ createSharedLinks(nodeId: string, options: any = {}): Observable { - const promise = this.sharedLinksApi.createSharedLink({ nodeId: nodeId }, options); + const promise = this.sharedLinksApi.createSharedLink({ nodeId }, options); return from(promise).pipe( catchError((err) => of(err)) @@ -74,6 +76,7 @@ export class SharedLinksApiService { /** * Deletes a shared link. + * * @param sharedId ID of the link to delete * @returns Null response notifying when the operation is complete */ diff --git a/lib/core/services/sites.service.spec.ts b/lib/core/services/sites.service.spec.ts index 32f3e9cdc1..fd30948898 100644 --- a/lib/core/services/sites.service.spec.ts +++ b/lib/core/services/sites.service.spec.ts @@ -62,23 +62,23 @@ describe('Sites service', () => { status: 200, contentType: 'json', responseText: { - 'list': { - 'pagination': { - 'count': 1, - 'hasMoreItems': false, - 'totalItems': 1, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 1, + hasMoreItems: false, + totalItems: 1, + skipCount: 0, + maxItems: 100 }, - 'entries': [ + entries: [ { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'b4cff62a-664d-4d45-9302-98723eac1319', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'swsdp', - 'title': 'FAKE' + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'b4cff62a-664d-4d45-9302-98723eac1319', + description: 'This is a Sample Alfresco Team site.', + id: 'swsdp', + title: 'FAKE' } } ] @@ -97,14 +97,14 @@ describe('Sites service', () => { status: 200, contentType: 'json', responseText: { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'b4cff62a-664d-4d45-9302-98723eac1319', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'swsdp', - 'preset': 'site-dashboard', - 'title': 'FAKE-SINGLE-TITLE' + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'b4cff62a-664d-4d45-9302-98723eac1319', + description: 'This is a Sample Alfresco Team site.', + id: 'swsdp', + preset: 'site-dashboard', + title: 'FAKE-SINGLE-TITLE' } } }); @@ -121,35 +121,35 @@ describe('Sites service', () => { status: 200, contentType: 'json', responseText: { - 'list': { - 'pagination': { - 'count': 1, - 'hasMoreItems': false, - 'totalItems': 1, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 1, + hasMoreItems: false, + totalItems: 1, + skipCount: 0, + maxItems: 100 }, - 'entries': [ + entries: [ { - 'entry': { - 'id': 'site-id', - 'createdAt': '2020-05-13T07:46:36.180Z', - 'site': { - 'id': 'site-id', - 'guid': 'b4cff62a-664d-4d45-9302-98723eac1319', - 'title': 'Sample Site', - 'description': '', - 'visibility': 'MODERATED', - 'preset': 'preset', - 'role': 'Manager' + entry: { + id: 'site-id', + createdAt: '2020-05-13T07:46:36.180Z', + site: { + id: 'site-id', + guid: 'b4cff62a-664d-4d45-9302-98723eac1319', + title: 'Sample Site', + description: '', + visibility: 'MODERATED', + preset: 'preset', + role: 'Manager' }, - 'person': { - 'id': 'user-id', - 'firstName': 'string', - 'lastName': 'string', - 'displayName': 'string' + person: { + id: 'user-id', + firstName: 'string', + lastName: 'string', + displayName: 'string' }, - 'message': 'message' + message: 'message' } } ] diff --git a/lib/core/services/sites.service.ts b/lib/core/services/sites.service.ts index 9398fe510e..28fa58d201 100644 --- a/lib/core/services/sites.service.ts +++ b/lib/core/services/sites.service.ts @@ -40,7 +40,7 @@ import { LogService } from './log.service'; }) export class SitesService { - _sitesApi: SitesApi; + private _sitesApi: SitesApi; get sitesApi(): SitesApi { this._sitesApi = this._sitesApi ?? new SitesApi(this.apiService.getInstance()); return this._sitesApi; @@ -51,6 +51,7 @@ export class SitesService { /** * Create a site + * * @param siteBody SiteBodyCreate to create site * @returns site SiteEntry */ @@ -63,6 +64,7 @@ export class SitesService { /** * Gets a list of all sites in the repository. + * * @param opts Options supported by JS-API * @returns List of sites */ @@ -80,6 +82,7 @@ export class SitesService { /** * Gets the details for a site. + * * @param siteId ID of the target site * @param opts Options supported by JS-API * @returns Information about the site @@ -93,6 +96,7 @@ export class SitesService { /** * Deletes a site. + * * @param siteId Site to delete * @param permanentFlag True: deletion is permanent; False: site is moved to the trash * @returns Null response notifying when the operation is complete @@ -108,6 +112,7 @@ export class SitesService { /** * Gets a site's content. + * * @param siteId ID of the target site * @returns Site content */ @@ -117,6 +122,7 @@ export class SitesService { /** * Gets a list of all a site's members. + * * @param siteId ID of the target site * @returns Site members */ @@ -126,6 +132,7 @@ export class SitesService { /** * Gets a list of all a site's members. + * * @param siteId ID of the target site * @param opts Optional parameters supported by JS-API * @returns Observable @@ -136,6 +143,7 @@ export class SitesService { /** * Gets the username of the user currently logged into ACS. + * * @returns Username string */ getEcmCurrentLoggedUserName(): string { @@ -145,6 +153,7 @@ export class SitesService { /** * Looks for a site inside the path of a Node and returns its guid if it finds one. * (return an empty string if no site is found) + * * @param node Node to look for parent site * @returns Site guid */ @@ -162,6 +171,7 @@ export class SitesService { /** * Gets a list of site membership requests. + * * @param opts Options supported by JS-API * @returns Site membership requests */ @@ -174,6 +184,7 @@ export class SitesService { /** * Creates a site membership for person **personId** on site **siteId**. + * * @param siteId The identifier of a site * @param siteMembershipBodyCreate The person to add and their role * @param opts Optional parameters @@ -188,6 +199,7 @@ export class SitesService { /** * Update a site membership + * * @param siteId The identifier of a site. * @param personId The identifier of a person. * @param siteMembershipBodyUpdate The persons new role @@ -203,6 +215,7 @@ export class SitesService { /** * Delete a site membership + * * @param siteId The identifier of a site. * @param personId The identifier of a person. * @return Null response notifying when the operation is complete @@ -216,6 +229,7 @@ export class SitesService { /** * Accept site membership requests. + * * @param siteId The identifier of a site. * @param inviteeId The invitee user name. * @param opts Options supported by JS-API @@ -230,6 +244,7 @@ export class SitesService { /** * Reject site membership requests. + * * @param siteId The identifier of a site. * @param inviteeId The invitee user name. * @param opts Options supported by JS-API @@ -244,6 +259,7 @@ export class SitesService { /** * List group membership for site + * * @param siteId The identifier of a site. * @param opts Options supported by JS-API * @returns Observable @@ -257,6 +273,7 @@ export class SitesService { /** * Create a site membership for group + * * @param siteId The identifier of a site. * @param siteMembershipBodyCreate The Group to add and its role * @returns Observable @@ -270,6 +287,7 @@ export class SitesService { /** * Get information about site membership of group + * * @param siteId The identifier of a site. * @param groupId The authorityId of a group. * @return Observable @@ -283,6 +301,7 @@ export class SitesService { /** * Update site membership of group + * * @param siteId The identifier of a site. * @param groupId The authorityId of a group. * @param siteMembershipBodyUpdate The group new role @@ -297,6 +316,7 @@ export class SitesService { /** * Delete a group membership for site + * * @param siteId The identifier of a site. * @param groupId The authorityId of a group. * @return Observable diff --git a/lib/core/services/startup-service-factory.ts b/lib/core/services/startup-service-factory.ts index 99becc8460..45feb9d406 100644 --- a/lib/core/services/startup-service-factory.ts +++ b/lib/core/services/startup-service-factory.ts @@ -17,6 +17,7 @@ import { AlfrescoApiService } from './alfresco-api.service'; +// eslint-disable-next-line prefer-arrow/prefer-arrow-functions export function startupServiceFactory(alfrescoApiService: AlfrescoApiService) { return () => alfrescoApiService.load(); } diff --git a/lib/core/services/storage.service.ts b/lib/core/services/storage.service.ts index 651028533c..ca8d6a1f46 100644 --- a/lib/core/services/storage.service.ts +++ b/lib/core/services/storage.service.ts @@ -40,6 +40,7 @@ export class StorageService { /** * Gets an item. + * * @param key Key to identify the item * @returns The item (if any) retrieved by the key */ @@ -53,6 +54,7 @@ export class StorageService { /** * Stores an item + * * @param key Key to identify the item * @param data Data to store */ @@ -75,6 +77,7 @@ export class StorageService { /** * Removes a single item. + * * @param key Key to identify the item */ removeItem(key: string) { @@ -87,6 +90,7 @@ export class StorageService { /** * Is any item currently stored under `key`? + * * @param key Key identifying item to check * @returns True if key retrieves an item, false otherwise */ diff --git a/lib/core/services/thumbnail.service.ts b/lib/core/services/thumbnail.service.ts index 49b9c87ec5..a5684c4bec 100644 --- a/lib/core/services/thumbnail.service.ts +++ b/lib/core/services/thumbnail.service.ts @@ -149,18 +149,18 @@ export class ThumbnailService { 'application/vnd.visio': './assets/images/ft_ic_document.svg', 'application/wordperfect': './assets/images/ft_ic_document.svg', 'application/x-cpio': './assets/images/ft_ic_document.svg', - 'folder': './assets/images/ft_ic_folder.svg', - 'smartFolder': './assets/images/ft_ic_smart_folder.svg', - 'ruleFolder': './assets/images/ft_ic_folder_rule.svg', - 'linkFolder': './assets/images/ft_ic_folder_shortcut_link.svg', + folder: './assets/images/ft_ic_folder.svg', + smartFolder: './assets/images/ft_ic_smart_folder.svg', + ruleFolder: './assets/images/ft_ic_folder_rule.svg', + linkFolder: './assets/images/ft_ic_folder_shortcut_link.svg', 'disable/folder': './assets/images/ft_ic_folder_disable.svg', - 'selected': './assets/images/ft_ic_selected.svg', + selected: './assets/images/ft_ic_selected.svg', 'dynamic-feed': './assets/images/dynamic_feed-24px.svg', 'ic-process': './assets/images/ic-process.svg', - 'filter': './assets/images/ft_ic_filter.svg', + filter: './assets/images/ft_ic_filter.svg', 'save-as': './assets/images/save-as.svg', - 'save': './assets/images/save.svg', - 'task': './assets/images/task.svg' + save: './assets/images/save.svg', + task: './assets/images/task.svg' }; _contentApi: ContentApi; @@ -180,6 +180,7 @@ export class ThumbnailService { /** * Gets a thumbnail URL for the given document node. + * * @param node Node or Node ID to get URL for. * @param attachment Toggles whether to retrieve content as an attachment for download * @param ticket Custom ticket to use for authentication @@ -205,6 +206,7 @@ export class ThumbnailService { /** * Gets a thumbnail URL for a MIME type. + * * @param mimeType MIME type for the thumbnail * @returns URL string */ @@ -215,6 +217,7 @@ export class ThumbnailService { /** * Gets a "miscellaneous" thumbnail URL for types with no other icon defined. + * * @returns URL string */ public getDefaultMimeTypeIcon(): string { diff --git a/lib/core/services/translate-loader.service.ts b/lib/core/services/translate-loader.service.ts index 6fdb743660..0da70e8a9c 100644 --- a/lib/core/services/translate-loader.service.ts +++ b/lib/core/services/translate-loader.service.ts @@ -46,7 +46,7 @@ export class TranslateLoaderService implements TranslateLoader { if (registered) { registered.path = path; } else { - this.providers.push(new ComponentTranslationModel({ name: name, path: path })); + this.providers.push(new ComponentTranslationModel({ name, path })); } } @@ -131,14 +131,12 @@ export class TranslateLoaderService implements TranslateLoader { getTranslation(lang: string): Observable { let hasFailures = false; const batch = [ - ...this.getComponentToFetch(lang).map((observable) => { - return observable.pipe( - catchError((error) => { - hasFailures = true; - return of(error); - }) - ); - }) + ...this.getComponentToFetch(lang).map((observable) => observable.pipe( + catchError((error) => { + hasFailures = true; + return of(error); + }) + )) ]; return new Observable((observer) => { diff --git a/lib/core/services/translate-loader.spec.ts b/lib/core/services/translate-loader.spec.ts index c7d10def0e..4703348a8f 100644 --- a/lib/core/services/translate-loader.spec.ts +++ b/lib/core/services/translate-loader.spec.ts @@ -40,7 +40,7 @@ describe('TranslateLoader', () => { beforeEach(() => { translationService = TestBed.inject(TranslationService); - customLoader = translationService.translate.currentLoader; + customLoader = translationService.translate.currentLoader as TranslateLoaderService; jasmine.Ajax.install(); }); diff --git a/lib/core/services/translation.service.spec.ts b/lib/core/services/translation.service.spec.ts index 38f6ef5a45..502228b98c 100644 --- a/lib/core/services/translation.service.spec.ts +++ b/lib/core/services/translation.service.spec.ts @@ -75,9 +75,9 @@ describe('TranslationService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', - responseText: JSON.stringify({'TEST': 'This is a test', 'TEST2': 'This is another test'}) + responseText: JSON.stringify({TEST: 'This is a test', TEST2: 'This is another test'}) }); }); @@ -87,9 +87,9 @@ describe('TranslationService', () => { }); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'application/json', - responseText: JSON.stringify({'TEST': 'This is a test', 'TEST2': 'This is another test'}) + responseText: JSON.stringify({TEST: 'This is a test', TEST2: 'This is another test'}) }); }); diff --git a/lib/core/services/translation.service.ts b/lib/core/services/translation.service.ts index 7ddf741377..a13da74d7a 100644 --- a/lib/core/services/translation.service.ts +++ b/lib/core/services/translation.service.ts @@ -39,7 +39,7 @@ export class TranslationService { constructor(public translate: TranslateService, userPreferencesService: UserPreferencesService, @Optional() @Inject(TRANSLATION_PROVIDER) providers: TranslationProvider[]) { - this.customLoader = this.translate.currentLoader; + this.customLoader = this.translate.currentLoader as TranslateLoaderService; this.defaultLang = 'en'; translate.setDefaultLang(this.defaultLang); @@ -61,6 +61,7 @@ export class TranslationService { /** * Adds a new folder of translation source files. + * * @param name Name for the translation provider * @param path Path to the folder */ @@ -78,6 +79,7 @@ export class TranslationService { /** * Loads a translation file. + * * @param lang Language code for the language to load * @param fallback Language code to fall back to if the first one was unavailable */ @@ -97,17 +99,19 @@ export class TranslationService { /** * Triggers a notification callback when the translation language changes. + * * @param lang The new language code */ onTranslationChanged(lang: string): void { this.translate.onTranslationChange.next({ - lang: lang, + lang, translations: this.customLoader.getFullTranslationJSON(lang) }); } /** * Sets the target language for translations. + * * @param lang Code name for the language * @returns Translations available for the language */ @@ -118,6 +122,7 @@ export class TranslationService { /** * Gets the translation for the supplied key. + * * @param key Key to translate * @param interpolateParams String(s) to be interpolated into the main message * @returns Translated text @@ -128,6 +133,7 @@ export class TranslationService { /** * Directly returns the translation for the supplied key. + * * @param key Key to translate * @param interpolateParams String(s) to be interpolated into the main message * @returns Translated text diff --git a/lib/core/services/upload.service.spec.ts b/lib/core/services/upload.service.spec.ts index f866d5f8f0..4da38cb8c0 100644 --- a/lib/core/services/upload.service.spec.ts +++ b/lib/core/services/upload.service.spec.ts @@ -17,14 +17,14 @@ import { EventEmitter } from '@angular/core'; import { TestBed } from '@angular/core/testing'; -import { FileModel, FileUploadOptions, FileUploadStatus } from '../models/file.model'; +import { FileModel, FileUploadStatus } from '../models/file.model'; import { AppConfigModule } from '../app-config/app-config.module'; import { UploadService } from './upload.service'; import { AppConfigService } from '../app-config/app-config.service'; import { setupTestBed } from '../testing/setup-test-bed'; import { CoreTestingModule } from '../testing/core.testing.module'; -import { AssocChildBody, AssociationBody, RepositoryInfo } from '@alfresco/js-api'; +import { RepositoryInfo } from '@alfresco/js-api'; import { TranslateModule } from '@ngx-translate/core'; import { DiscoveryApiService } from './discovery-api.service'; import { BehaviorSubject } from 'rxjs'; @@ -93,26 +93,26 @@ describe('UploadService', () => { }); it('should add an element in the queue and returns it', () => { - const filesFake = new FileModel( { name: 'fake-name', size: 10 }); + const filesFake = new FileModel({ name: 'fake-name', size: 10 } as File); service.addToQueue(filesFake); expect(service.getQueue().length).toEqual(1); }); it('should add two elements in the queue and returns them', () => { const filesFake = [ - new FileModel( { name: 'fake-name', size: 10 }), - new FileModel( { name: 'fake-name2', size: 20 }) + new FileModel({ name: 'fake-name', size: 10 } as File), + new FileModel({ name: 'fake-name2', size: 20 } as File) ]; service.addToQueue(...filesFake); expect(service.getQueue().length).toEqual(2); }); it('should not have the queue uploading if all files are complete, cancelled, aborted, errored or deleted', () => { - const file1 = new FileModel( { name: 'fake-file-1', size: 10 }); - const file2 = new FileModel( { name: 'fake-file-2', size: 20 }); - const file3 = new FileModel( { name: 'fake-file-3', size: 30 }); - const file4 = new FileModel( { name: 'fake-file-4', size: 40 }); - const file5 = new FileModel( { name: 'fake-file-5', size: 50 }); + const file1 = new FileModel({ name: 'fake-file-1', size: 10 } as File); + const file2 = new FileModel({ name: 'fake-file-2', size: 20 } as File); + const file3 = new FileModel({ name: 'fake-file-3', size: 30 } as File); + const file4 = new FileModel({ name: 'fake-file-4', size: 40 } as File); + const file5 = new FileModel({ name: 'fake-file-5', size: 50 } as File); file1.status = FileUploadStatus.Complete; file2.status = FileUploadStatus.Cancelled; @@ -126,8 +126,8 @@ describe('UploadService', () => { }); it('should have the queue still uploading if some files are still pending, starting or in progress', () => { - const file1 = new FileModel( { name: 'fake-file-1', size: 10 }); - const file2 = new FileModel( { name: 'fake-file-2', size: 20 }); + const file1 = new FileModel({ name: 'fake-file-1', size: 10 } as File); + const file2 = new FileModel({ name: 'fake-file-2', size: 20 } as File); service.addToQueue(file1, file2); @@ -167,8 +167,8 @@ describe('UploadService', () => { done(); }); const fileFake = new FileModel( - { name: 'fake-name', size: 10 }, - { parentId: '-root-', path: 'fake-dir' } + { name: 'fake-name', size: 10 } as File, + { parentId: '-root-', path: 'fake-dir' } ); service.addToQueue(fileFake); service.uploadFilesInTheQueue(emitter); @@ -178,7 +178,7 @@ describe('UploadService', () => { expect(request.method).toBe('POST'); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'text/plain', responseText: 'File uploaded' }); @@ -193,8 +193,8 @@ describe('UploadService', () => { done(); }); const fileFake = new FileModel( - { name: 'fake-name', size: 10 }, - { parentId: '-root-' } + { name: 'fake-name', size: 10 } as File, + { parentId: '-root-' } ); service.addToQueue(fileFake); service.uploadFilesInTheQueue(null, emitter); @@ -202,7 +202,7 @@ describe('UploadService', () => { .toBe('http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations'); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 404, + status: 404, contentType: 'text/plain', responseText: 'Error file uploaded' }); @@ -217,7 +217,7 @@ describe('UploadService', () => { done(); }); - const fileFake = new FileModel( { name: 'fake-name', size: 10000000 }); + const fileFake = new FileModel({ name: 'fake-name', size: 10000000 } as File); service.addToQueue(fileFake); service.uploadFilesInTheQueue(emitter); @@ -237,14 +237,14 @@ describe('UploadService', () => { expect(deleteRequest.method).toBe('DELETE'); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'text/plain', responseText: 'File deleted' }); done(); }); - const fileFake = new FileModel( { name: 'fake-name', size: 10 }); + const fileFake = new FileModel({ name: 'fake-name', size: 10 } as File); service.addToQueue(fileFake); service.uploadFilesInTheQueue(emitter); @@ -256,7 +256,7 @@ describe('UploadService', () => { expect(request.method).toBe('POST'); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'json', responseText: { entry: { @@ -278,14 +278,14 @@ describe('UploadService', () => { expect(deleteRequest.method).toBe('DELETE'); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'text/plain', responseText: 'File deleted' }); done(); }); - const fileFake = new FileModel( {name: 'fake-name', size: 10}, null, 'fakeId'); + const fileFake = new FileModel({name: 'fake-name', size: 10} as File, null, 'fakeId'); service.addToQueue(fileFake); service.uploadFilesInTheQueue(emitter); @@ -297,7 +297,7 @@ describe('UploadService', () => { expect(request.method).toBe('PUT'); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'json', responseText: { entry: { @@ -313,7 +313,7 @@ describe('UploadService', () => { it('If newVersion is set, name should be a param', () => { const emitter = new EventEmitter(); const filesFake = new FileModel( - { name: 'fake-name', size: 10 }, + { name: 'fake-name', size: 10 } as File, { newVersion: true } ); service.addToQueue(filesFake); @@ -347,8 +347,8 @@ describe('UploadService', () => { done(); }); const filesFake = new FileModel( - { name: 'fake-file-name', size: 10 }, - { parentId: '123', path: 'fake-dir' } + { name: 'fake-file-name', size: 10 } as File, + { parentId: '123', path: 'fake-dir' } ); service.addToQueue(filesFake); service.uploadFilesInTheQueue(emitter); @@ -358,7 +358,7 @@ describe('UploadService', () => { expect(request.method).toBe('POST'); jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, + status: 200, contentType: 'text/plain', responseText: 'File uploaded' }); @@ -367,10 +367,8 @@ describe('UploadService', () => { describe('versioningEnabled', () => { it('should upload with "versioningEnabled" parameter taken from file options', () => { const model = new FileModel( - { name: 'file-name', size: 10 }, - { - versioningEnabled: true - } + { name: 'file-name', size: 10 } as File, + { versioningEnabled: true } ); service.addToQueue(model); @@ -395,8 +393,8 @@ describe('UploadService', () => { it('should not use "versioningEnabled" if not explicitly provided', () => { const model = new FileModel( - { name: 'file-name', size: 10 }, - {} + { name: 'file-name', size: 10 } as File, + {} ); service.addToQueue(model); @@ -421,13 +419,13 @@ describe('UploadService', () => { it('should append the extra upload options to the request', () => { const filesFake = new FileModel( - { name: 'fake-name', size: 10 }, - { + { name: 'fake-name', size: 10 } as File, + { parentId: '123', path: 'fake-dir', - secondaryChildren: [ { assocType: 'assoc-1', childId: 'child-id' }], + secondaryChildren: [{ assocType: 'assoc-1', childId: 'child-id' }], association: { assocType: 'fake-assoc' }, - targets: [ { assocType: 'target-assoc', targetId: 'fake-target-id' }] + targets: [{ assocType: 'target-assoc', targetId: 'fake-target-id' }] }); service.addToQueue(filesFake); service.uploadFilesInTheQueue(); @@ -443,9 +441,9 @@ describe('UploadService', () => { newVersion: false, parentId: '123', path: 'fake-dir', - secondaryChildren: [ { assocType: 'assoc-1', childId: 'child-id' }], + secondaryChildren: [ { assocType: 'assoc-1', childId: 'child-id' }], association: { assocType: 'fake-assoc' }, - targets: [ { assocType: 'target-assoc', targetId: 'fake-target-id' }] + targets: [{ assocType: 'target-assoc', targetId: 'fake-target-id' }] }, { renditions: 'doclib', @@ -465,8 +463,8 @@ describe('UploadService', () => { done(); }); - const fileFake1 = new FileModel( { name: 'fake-name1', size: 10 }); - const fileFake2 = new FileModel( { name: 'fake-name2', size: 10 }); + const fileFake1 = new FileModel({ name: 'fake-name1', size: 10 } as File); + const fileFake2 = new FileModel({ name: 'fake-name2', size: 10 } as File); const fileList = [fileFake1, fileFake2]; service.addToQueue(...fileList); service.uploadFilesInTheQueue(); @@ -511,7 +509,7 @@ describe('UploadService', () => { }); it('should call onUploadDeleted if file was deleted', () => { - const file = { status: FileUploadStatus.Deleted }; + const file = { status: FileUploadStatus.Deleted } as FileModel; spyOn(service.fileUploadDeleted, 'next'); service.cancelUpload(file); @@ -520,7 +518,7 @@ describe('UploadService', () => { }); it('should call fileUploadError if file has error status', () => { - const file = ({ status: FileUploadStatus.Error }); + const file = { status: FileUploadStatus.Error } as FileModel; spyOn(service.fileUploadError, 'next'); service.cancelUpload(file); @@ -529,7 +527,7 @@ describe('UploadService', () => { }); it('should call fileUploadCancelled if file is in pending', () => { - const file = ({ status: FileUploadStatus.Pending }); + const file = { status: FileUploadStatus.Pending } as FileModel; spyOn(service.fileUploadCancelled, 'next'); service.cancelUpload(file); @@ -541,7 +539,7 @@ describe('UploadService', () => { mockProductInfo.next({ status: { isThumbnailGenerationEnabled: false } } as RepositoryInfo); const filesFake = new FileModel( - { name: 'fake-name', size: 10 }, + { name: 'fake-name', size: 10 } as File, { newVersion: true} ); service.addToQueue(filesFake); diff --git a/lib/core/services/user-preferences.service.spec.ts b/lib/core/services/user-preferences.service.spec.ts index 734ea42345..8d71a3ca19 100644 --- a/lib/core/services/user-preferences.service.spec.ts +++ b/lib/core/services/user-preferences.service.spec.ts @@ -47,8 +47,8 @@ describe('UserPreferencesService', () => { appConfig = TestBed.inject(AppConfigService); appConfig.config = { pagination: { - 'size': 10, - 'supportedPageSizes': [5, 10, 15, 20] + size: 10, + supportedPageSizes: [5, 10, 15, 20] } }; diff --git a/lib/core/services/user-preferences.service.ts b/lib/core/services/user-preferences.service.ts index cd98548c4d..63e0f31599 100644 --- a/lib/core/services/user-preferences.service.ts +++ b/lib/core/services/user-preferences.service.ts @@ -24,6 +24,7 @@ import { distinctUntilChanged, map, filter } from 'rxjs/operators'; import { AlfrescoApiService } from './alfresco-api.service'; import { LanguageItem } from './language-item.interface'; +// eslint-disable-next-line no-shadow export enum UserPreferenceValues { PaginationSize = 'paginationSize', Locale = 'locale', @@ -78,6 +79,7 @@ export class UserPreferencesService { /** * Sets up a callback to notify when a property has changed. + * * @param property The property to watch * @returns Notification callback */ @@ -91,6 +93,7 @@ export class UserPreferencesService { /** * Gets a preference property. + * * @param property Name of the property * @param defaultValue Default to return if the property is not found * @returns Preference property @@ -106,6 +109,7 @@ export class UserPreferencesService { /** * Sets a preference property. + * * @param property Name of the property * @param value New value for the property */ @@ -123,6 +127,7 @@ export class UserPreferencesService { /** * Sets a preference property. + * * @param property Name of the property * @param value New value for the property */ @@ -136,6 +141,7 @@ export class UserPreferencesService { /** * Check if an item is present in the storage + * * @param property Name of the property * @returns True if the item is present, false otherwise */ @@ -150,6 +156,7 @@ export class UserPreferencesService { /** * Gets the active storage prefix for preferences. + * * @returns Storage prefix */ getStoragePrefix(): string { @@ -158,6 +165,7 @@ export class UserPreferencesService { /** * Sets the active storage prefix for preferences. + * * @param value Name of the prefix */ setStoragePrefix(value: string) { @@ -167,6 +175,7 @@ export class UserPreferencesService { /** * Gets the full property key with prefix. + * * @param property The property name * @returns Property key */ @@ -176,6 +185,7 @@ export class UserPreferencesService { /** * Gets an array containing the available page sizes. + * * @returns Array of page size values */ get supportedPageSizes(): number[] { @@ -218,17 +228,18 @@ export class UserPreferencesService { /** * Gets the default locale. + * * @returns Default locale language code */ - public getDefaultLocale(): string { + getDefaultLocale(): string { return this.appConfig.get(UserPreferenceValues.Locale) || this.translate.getBrowserCultureLang() || 'en'; } private getLanguageByKey(key: string): LanguageItem { return ( this.appConfig - .get>(AppConfigValues.APP_CONFIG_LANGUAGES_KEY, [ { key: 'en' }]) - .find((language) => key.includes(language.key)) || { key: 'en' } + .get>(AppConfigValues.APP_CONFIG_LANGUAGES_KEY, [{ key: 'en' } as LanguageItem]) + .find((language) => key.includes(language.key)) || { key: 'en' } as LanguageItem ); } } diff --git a/lib/core/services/version-compatibility-factory.ts b/lib/core/services/version-compatibility-factory.ts index 7044b2e285..8678d49a2f 100644 --- a/lib/core/services/version-compatibility-factory.ts +++ b/lib/core/services/version-compatibility-factory.ts @@ -17,6 +17,7 @@ import { VersionCompatibilityService } from './version-compatibility.service'; +// eslint-disable-next-line prefer-arrow/prefer-arrow-functions export function versionCompatibilityFactory(versionCompatibilityService: VersionCompatibilityService) { return () => versionCompatibilityService; } diff --git a/lib/core/services/version-compatibility.service.ts b/lib/core/services/version-compatibility.service.ts index dd61ec1226..321db5cd9b 100644 --- a/lib/core/services/version-compatibility.service.ts +++ b/lib/core/services/version-compatibility.service.ts @@ -72,9 +72,9 @@ export class VersionCompatibilityService { const patch = version.split('.')[2] || '0'; return { - major: major, - minor: minor, - patch: patch + major, + minor, + patch } as VersionInfo; } } diff --git a/lib/core/settings/host-settings.component.ts b/lib/core/settings/host-settings.component.ts index a7250b1771..ec0c7139f1 100644 --- a/lib/core/settings/host-settings.component.ts +++ b/lib/core/settings/host-settings.component.ts @@ -29,7 +29,7 @@ export const HOST_REGEX = '^(http|https):\/\/.*[^/]$'; selector: 'adf-host-settings', templateUrl: 'host-settings.component.html', host: { - 'class': 'adf-host-settings' + class: 'adf-host-settings' }, styleUrls: ['./host-settings.component.scss'], encapsulation: ViewEncapsulation.None @@ -77,7 +77,7 @@ export class HostSettingsComponent implements OnInit { this.form = this.formBuilder.group({ providersControl: [providerSelected, Validators.required], - authType: authType + authType }); this.addFormGroups(); diff --git a/lib/core/sorting-picker/sorting-picker.component.spec.ts b/lib/core/sorting-picker/sorting-picker.component.spec.ts index d2515ffa63..f8b3bc5cef 100644 --- a/lib/core/sorting-picker/sorting-picker.component.spec.ts +++ b/lib/core/sorting-picker/sorting-picker.component.spec.ts @@ -32,7 +32,7 @@ describe('SortingPickerComponent', () => { expect(key).toBe('key2'); done(); }); - component.onOptionChanged( { value: 'key2' }); + component.onOptionChanged({ value: 'key2' } as any); }); it('should raise changed event on changing direction', (done) => { diff --git a/lib/core/toolbar/toolbar-divider.component.ts b/lib/core/toolbar/toolbar-divider.component.ts index 193744a736..b8f4f111fd 100644 --- a/lib/core/toolbar/toolbar-divider.component.ts +++ b/lib/core/toolbar/toolbar-divider.component.ts @@ -20,7 +20,7 @@ import { Component, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/ @Component({ selector: 'adf-toolbar-divider', template: '
', - host: { 'class': 'adf-toolbar-divider' }, + host: { class: 'adf-toolbar-divider' }, styles: [` .adf-toolbar-divider > div { height: 24px; diff --git a/lib/core/toolbar/toolbar-title.component.ts b/lib/core/toolbar/toolbar-title.component.ts index d651b96f10..a3b4bffe8b 100644 --- a/lib/core/toolbar/toolbar-title.component.ts +++ b/lib/core/toolbar/toolbar-title.component.ts @@ -20,6 +20,6 @@ import { Component } from '@angular/core'; @Component({ selector: 'adf-toolbar-title', template: '', - host: { 'class': 'adf-toolbar-title' } + host: { class: 'adf-toolbar-title' } }) export class ToolbarTitleComponent {} diff --git a/lib/core/toolbar/toolbar.component.ts b/lib/core/toolbar/toolbar.component.ts index 79bd5fd225..c088d898a5 100644 --- a/lib/core/toolbar/toolbar.component.ts +++ b/lib/core/toolbar/toolbar.component.ts @@ -24,7 +24,7 @@ import { ThemePalette } from '@angular/material/core'; styleUrls: ['./toolbar.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, - host: { 'class': 'adf-toolbar' } + host: { class: 'adf-toolbar' } }) export class ToolbarComponent { diff --git a/lib/core/userinfo/components/user-info.component.spec.ts b/lib/core/userinfo/components/user-info.component.spec.ts index 8002e44205..dd846cfef4 100644 --- a/lib/core/userinfo/components/user-info.component.spec.ts +++ b/lib/core/userinfo/components/user-info.component.spec.ts @@ -79,18 +79,18 @@ describe('User info component', () => { const identityUserWithOutFirstNameMock = { firstName: null, lastName: 'fake-identity-last-name', email: 'fakeIdentity@email.com' }; const identityUserWithOutLastNameMock = { firstName: 'fake-identity-first-name', lastName: null, email: 'fakeIdentity@email.com' }; - function openUserInfo() { + const openUserInfo = () => { fixture.detectChanges(); - const imageButton: HTMLButtonElement = element.querySelector('#logged-user-img'); + const imageButton = element.querySelector('#logged-user-img'); imageButton.click(); fixture.detectChanges(); - } + }; - async function whenFixtureReady() { + const whenFixtureReady = async () => { fixture.detectChanges(); await fixture.whenStable(); fixture.detectChanges(); - } + }; setupTestBed({ imports: [ @@ -259,7 +259,7 @@ describe('User info component', () => { }); it('should show N/A when the job title is null', () => { - const imageButton: HTMLButtonElement = element.querySelector('#user-initials-image'); + const imageButton = element.querySelector('#user-initials-image'); imageButton.click(); fixture.detectChanges(); expect(element.querySelector('#userinfo_container')).not.toBeNull(); @@ -270,7 +270,7 @@ describe('User info component', () => { }); it('should not show the tabs', () => { - const imageButton: HTMLButtonElement = element.querySelector('#user-initials-image'); + const imageButton = element.querySelector('#user-initials-image'); imageButton.click(); fixture.detectChanges(); const tabHeader = fixture.debugElement.query(By.css('#tab-group-env')); @@ -511,7 +511,7 @@ describe('User info component', () => { it('should show full name next the user image', async () => { await whenFixtureReady(); - const imageButton: HTMLButtonElement = element.querySelector('#identity-user-image'); + const imageButton = element.querySelector('#identity-user-image'); imageButton.click(); fixture.detectChanges(); expect(element.querySelector('#userinfo_container')).not.toBeNull(); diff --git a/lib/core/utils/file-utils.ts b/lib/core/utils/file-utils.ts index fcde0f86ed..e579d4fe76 100644 --- a/lib/core/utils/file-utils.ts +++ b/lib/core/utils/file-utils.ts @@ -28,6 +28,7 @@ export class FileUtils { const files: FileInfo[] = []; return new Promise((resolve) => { const iterations = []; + // eslint-disable-next-line prefer-arrow/prefer-arrow-functions (function traverse() { reader.readEntries((entries) => { if (!entries.length) { @@ -36,10 +37,10 @@ export class FileUtils { iterations.push(Promise.all(entries.map((entry) => { if (entry.isFile) { return new Promise((resolveFile) => { - entry.file(function(file: File) { + entry.file((file: File) => { files.push({ - entry: entry, - file: file, + entry, + file, relativeFolder: entry.fullPath.replace(/\/[^\/]*$/, '') }); resolveFile(); diff --git a/lib/core/utils/moment-date-adapter.ts b/lib/core/utils/moment-date-adapter.ts index 9b3306610c..b0ae50fa2e 100644 --- a/lib/core/utils/moment-date-adapter.ts +++ b/lib/core/utils/moment-date-adapter.ts @@ -194,6 +194,7 @@ export class MomentDateAdapter extends DateAdapter { let isValidDateInstance = false; if (date) { + // eslint-disable-next-line no-underscore-dangle isValidDateInstance = date._isAMomentObject; } diff --git a/lib/core/utils/object-utils.ts b/lib/core/utils/object-utils.ts index 81af91ed27..3916434984 100644 --- a/lib/core/utils/object-utils.ts +++ b/lib/core/utils/object-utils.ts @@ -19,6 +19,7 @@ export class ObjectUtils { /** * Gets a value from an object by composed key * ObjectUtils.getValue({ item: { nodeType: 'cm:folder' }}, 'item.nodeType') ==> 'cm:folder' + * * @param target * @param key */ diff --git a/lib/core/viewer/components/img-viewer.component.spec.ts b/lib/core/viewer/components/img-viewer.component.spec.ts index 29f5ebef24..d62485aeab 100644 --- a/lib/core/viewer/components/img-viewer.component.spec.ts +++ b/lib/core/viewer/components/img-viewer.component.spec.ts @@ -31,10 +31,10 @@ describe('Test Img viewer component ', () => { let fixture: ComponentFixture; let element: HTMLElement; - function createFakeBlob() { + const createFakeBlob = () => { const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='); return new Blob([data], { type: 'image/png' }); - } + }; setupTestBed({ imports: [ @@ -86,7 +86,7 @@ describe('Test Img viewer component ', () => { it('If no url or blob are passed should thrown an error', () => { const change = new SimpleChange(null, null, true); expect(() => { - component.ngOnChanges({ 'blobFile': change }); + component.ngOnChanges({ blobFile: change }); }).toThrow(new Error('Attribute urlFile or blobFile is required')); }); @@ -109,7 +109,7 @@ describe('Test Img viewer component ', () => { spyOn(service, 'createTrustedUrl').and.returnValue('fake-blob-url'); const change = new SimpleChange(null, blob, true); expect(() => { - component.ngOnChanges({ 'blobFile': change }); + component.ngOnChanges({ blobFile: change }); }).not.toThrow(new Error('Attribute urlFile or blobFile is required')); expect(component.urlFile).toEqual('fake-blob-url'); }); @@ -163,7 +163,7 @@ describe('Test Img viewer component ', () => { component = fixture.componentInstance; component.blobFile = createFakeBlob(); const change = new SimpleChange(null, component.blobFile, true); - component.ngOnChanges({ 'blobFile': change }); + component.ngOnChanges({ blobFile: change }); fixture.detectChanges(); }); diff --git a/lib/core/viewer/components/img-viewer.component.ts b/lib/core/viewer/components/img-viewer.component.ts index 0a97251ca8..972373a48a 100644 --- a/lib/core/viewer/components/img-viewer.component.ts +++ b/lib/core/viewer/components/img-viewer.component.ts @@ -33,7 +33,7 @@ import Cropper from 'cropperjs'; selector: 'adf-img-viewer', templateUrl: './img-viewer.component.html', styleUrls: ['./img-viewer.component.scss'], - host: { 'class': 'adf-image-viewer' }, + host: { class: 'adf-image-viewer' }, encapsulation: ViewEncapsulation.None }) export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy { diff --git a/lib/core/viewer/components/media-player.component.ts b/lib/core/viewer/components/media-player.component.ts index 8791f29a67..69c946d1fd 100644 --- a/lib/core/viewer/components/media-player.component.ts +++ b/lib/core/viewer/components/media-player.component.ts @@ -24,7 +24,7 @@ import { ViewUtilService } from '../services/view-util.service'; selector: 'adf-media-player', templateUrl: './media-player.component.html', styleUrls: ['./media-player.component.scss'], - host: { 'class': 'adf-media-player' }, + host: { class: 'adf-media-player' }, encapsulation: ViewEncapsulation.None }) export class MediaPlayerComponent implements OnChanges { diff --git a/lib/core/viewer/components/pdf-viewer-thumb.component.ts b/lib/core/viewer/components/pdf-viewer-thumb.component.ts index bbf70f8753..cb3052ac69 100644 --- a/lib/core/viewer/components/pdf-viewer-thumb.component.ts +++ b/lib/core/viewer/components/pdf-viewer-thumb.component.ts @@ -51,7 +51,7 @@ export class PdfThumbComponent implements OnInit, FocusableOption { return page.render({ canvasContext: canvas.getContext('2d'), - viewport: page.getViewport({ scale: scale }) + viewport: page.getViewport({ scale }) }).promise.then(() => { const imageSource = canvas.toDataURL(); return this.sanitizer.bypassSecurityTrustUrl(imageSource); diff --git a/lib/core/viewer/components/pdf-viewer-thumbnails.component.spec.ts b/lib/core/viewer/components/pdf-viewer-thumbnails.component.spec.ts index 5feef6084d..9827a1fa48 100644 --- a/lib/core/viewer/components/pdf-viewer-thumbnails.component.spec.ts +++ b/lib/core/viewer/components/pdf-viewer-thumbnails.component.spec.ts @@ -30,12 +30,10 @@ describe('PdfThumbListComponent', () => { let fixture: ComponentFixture; let component: PdfThumbListComponent; - const page = (id) => { - return { - id, - getPage: Promise.resolve() - }; - }; + const page = (id) => ({ + id, + getPage: Promise.resolve() + }); const viewerMock = { _currentPageNumber: null, @@ -90,6 +88,7 @@ describe('PdfThumbListComponent', () => { fixture.detectChanges(); const renderedIds = component.renderItems.map((item) => item.id); + // eslint-disable-next-line no-underscore-dangle const rangeIds = viewerMock._pages.slice(0, 6).map((item) => item.id); expect(renderedIds).toEqual(rangeIds); @@ -101,6 +100,7 @@ describe('PdfThumbListComponent', () => { fixture.detectChanges(); const renderedIds = component.renderItems.map((item) => item.id); + // eslint-disable-next-line no-underscore-dangle const rangeIds = viewerMock._pages.slice(5, 12).map((item) => item.id); expect(renderedIds).toEqual(rangeIds); @@ -175,7 +175,7 @@ describe('PdfThumbListComponent', () => { describe('Keyboard events', () => { it('should select next page in the list on DOWN_ARROW event', () => { - const event = new KeyboardEvent('keydown', {'keyCode': DOWN_ARROW} as KeyboardEventInit); + const event = new KeyboardEvent('keydown', {keyCode: DOWN_ARROW} as KeyboardEventInit); fixture.detectChanges(); component.goTo(1); expect(document.activeElement.id).toBe('1'); @@ -185,7 +185,7 @@ describe('PdfThumbListComponent', () => { }); it('should select previous page in the list on UP_ARROW event', () => { - const event = new KeyboardEvent('keydown', {'keyCode': UP_ARROW} as KeyboardEventInit); + const event = new KeyboardEvent('keydown', {keyCode: UP_ARROW} as KeyboardEventInit); fixture.detectChanges(); component.goTo(2); expect(document.activeElement.id).toBe('2'); @@ -195,7 +195,7 @@ describe('PdfThumbListComponent', () => { }); it('should not select previous page if it is the first page', () => { - const event = new KeyboardEvent('keydown', {'keyCode': UP_ARROW} as KeyboardEventInit); + const event = new KeyboardEvent('keydown', {keyCode: UP_ARROW} as KeyboardEventInit); fixture.detectChanges(); component.goTo(1); expect(document.activeElement.id).toBe('1'); @@ -205,7 +205,7 @@ describe('PdfThumbListComponent', () => { }); it('should not select next item if it is the last page', () => { - const event = new KeyboardEvent('keydown', {'keyCode': DOWN_ARROW} as KeyboardEventInit); + const event = new KeyboardEvent('keydown', {keyCode: DOWN_ARROW} as KeyboardEventInit); fixture.detectChanges(); component.scrollInto(16); fixture.detectChanges(); @@ -218,7 +218,7 @@ describe('PdfThumbListComponent', () => { }); it('should emit on ESCAPE event', () => { - const event = new KeyboardEvent('keydown', {'keyCode': ESCAPE} as KeyboardEventInit); + const event = new KeyboardEvent('keydown', {keyCode: ESCAPE} as KeyboardEventInit); spyOn(component.close, 'emit'); fixture.detectChanges(); diff --git a/lib/core/viewer/components/pdf-viewer-thumbnails.component.ts b/lib/core/viewer/components/pdf-viewer-thumbnails.component.ts index 4442d01862..a73e1d9e7f 100644 --- a/lib/core/viewer/components/pdf-viewer-thumbnails.component.ts +++ b/lib/core/viewer/components/pdf-viewer-thumbnails.component.ts @@ -36,7 +36,7 @@ export class PdfThumbListComponent implements OnInit, AfterViewInit, OnDestroy { @Input() pdfViewer: any; @Output() - close: EventEmitter = new EventEmitter(); + close = new EventEmitter(); virtualHeight: number = 0; translateY: number = 0; @@ -149,14 +149,11 @@ export class PdfThumbListComponent implements OnInit, AfterViewInit, OnDestroy { } getPages() { + // eslint-disable-next-line no-underscore-dangle return this.pdfViewer._pages.map((page) => ({ id: page.id, - getWidth: () => { - return this.width; - }, - getHeight: () => { - return this.currentHeight; - }, + getWidth: () => this.width, + getHeight: () => this.currentHeight, getPage: () => this.pdfViewer.pdfDocument.getPage(page.id) })); } diff --git a/lib/core/viewer/components/pdf-viewer.component.spec.ts b/lib/core/viewer/components/pdf-viewer.component.spec.ts index 8920473dd6..e8eaaa72be 100644 --- a/lib/core/viewer/components/pdf-viewer.component.spec.ts +++ b/lib/core/viewer/components/pdf-viewer.component.spec.ts @@ -173,7 +173,7 @@ describe('Test PdfViewer component', () => { change = new SimpleChange(null, null, true); expect(() => { - component.ngOnChanges({ 'urlFile': change }); + component.ngOnChanges({ urlFile: change }); }).toThrow(new Error('Attribute urlFile or blobFile is required')); }); @@ -181,7 +181,7 @@ describe('Test PdfViewer component', () => { change = new SimpleChange(null, null, true); expect(() => { - component.ngOnChanges({ 'blobFile': change }); + component.ngOnChanges({ blobFile: change }); }).toThrow(new Error('Attribute urlFile or blobFile is required')); }); }); @@ -398,14 +398,12 @@ describe('Test PdfViewer component', () => { fixtureUrlTestPasswordComponent = TestBed.createComponent(UrlTestPasswordComponent); componentUrlTestPasswordComponent = fixtureUrlTestPasswordComponent.componentInstance; - spyOn(dialog, 'open').and.callFake(() => { - return { - afterClosed: () => { - done(); - return of(''); - } - } as any; - }); + spyOn(dialog, 'open').and.callFake(() => ({ + afterClosed: () => { + done(); + return of(''); + } + } as any)); spyOn(componentUrlTestPasswordComponent.pdfViewerComponent.close, 'emit'); diff --git a/lib/core/viewer/components/pdf-viewer.component.ts b/lib/core/viewer/components/pdf-viewer.component.ts index ea814a2da5..425723b349 100644 --- a/lib/core/viewer/components/pdf-viewer.component.ts +++ b/lib/core/viewer/components/pdf-viewer.component.ts @@ -48,7 +48,7 @@ declare const pdfjsViewer: any; templateUrl: './pdf-viewer.component.html', styleUrls: ['./pdf-viewer-host.component.scss', './pdf-viewer.component.scss'], providers: [RenderingQueueServices], - host: { 'class': 'adf-pdf-viewer' }, + host: { class: 'adf-pdf-viewer' }, encapsulation: ViewEncapsulation.None }) export class PdfViewerComponent implements OnChanges, OnDestroy { @@ -215,8 +215,8 @@ export class PdfViewerComponent implements OnChanges, OnDestroy { if (viewer && container) { this.pdfViewer = new pdfjsViewer.PDFViewer({ - container: container, - viewer: viewer, + container, + viewer, renderingQueue: this.renderingQueueServices, eventBus: this.eventBus }); @@ -364,7 +364,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy { if (!this.isSameScale(this.currentScale, newScale)) { this.currentScale = newScale; - this.pdfViewer._pages.forEach(function(currentPage) { + this.pdfViewer._pages.forEach((currentPage) => { currentPage.update(newScale); }); } @@ -530,6 +530,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy { /** * Keyboard Event Listener + * * @param KeyboardEvent event */ @HostListener('document:keydown', ['$event']) @@ -543,7 +544,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy { } private generateUuid() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { const r = Math.random() * 16 | 0; const v = c === 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); diff --git a/lib/core/viewer/components/txt-viewer.component.spec.ts b/lib/core/viewer/components/txt-viewer.component.spec.ts index a6000eef0e..16a3d36495 100644 --- a/lib/core/viewer/components/txt-viewer.component.spec.ts +++ b/lib/core/viewer/components/txt-viewer.component.spec.ts @@ -49,7 +49,7 @@ describe('Text View component', () => { const urlFile = './fake-test-file.txt'; const change = new SimpleChange(null, urlFile, true); - component.ngOnChanges({ 'urlFile': change }).then(() => { + component.ngOnChanges({ urlFile: change }).then(() => { fixture.detectChanges(); fixture.whenStable().then(() => { expect(element.querySelector('.adf-txt-viewer-content').textContent).toContain('example'); @@ -63,7 +63,7 @@ describe('Text View component', () => { const change = new SimpleChange(null, blobFile, true); - component.ngOnChanges({ 'blobFile': change }).then(() => { + component.ngOnChanges({ blobFile: change }).then(() => { fixture.detectChanges(); fixture.whenStable().then(() => { expect(element.querySelector('.adf-txt-viewer-content').textContent).toContain('example'); diff --git a/lib/core/viewer/components/txt-viewer.component.ts b/lib/core/viewer/components/txt-viewer.component.ts index 9866ddc6d0..da4c92ca81 100644 --- a/lib/core/viewer/components/txt-viewer.component.ts +++ b/lib/core/viewer/components/txt-viewer.component.ts @@ -23,7 +23,7 @@ import { AppConfigService } from './../../app-config/app-config.service'; selector: 'adf-txt-viewer', templateUrl: './txt-viewer.component.html', styleUrls: ['./txt-viewer.component.scss'], - host: { 'class': 'adf-txt-viewer' }, + host: { class: 'adf-txt-viewer' }, encapsulation: ViewEncapsulation.None }) export class TxtViewerComponent implements OnChanges { diff --git a/lib/core/viewer/components/viewer.component.spec.ts b/lib/core/viewer/components/viewer.component.spec.ts index 64b94c6787..a82d7202d7 100644 --- a/lib/core/viewer/components/viewer.component.spec.ts +++ b/lib/core/viewer/components/viewer.component.spec.ts @@ -156,9 +156,7 @@ describe('ViewerComponent', () => { providers: [ { provide: RenditionsService, useValue: { - getRendition: () => { - return throwError('thrown'); - } + getRendition: () => throwError('thrown') } }, RenderingQueueServices, @@ -560,15 +558,15 @@ describe('ViewerComponent', () => { expect(component.fileTitle).toBe('file1'); - alfrescoApiService.nodeUpdated.next( { id: 'id1', name: 'file2' }); + alfrescoApiService.nodeUpdated.next({ id: 'id1', name: 'file2' } as any); fixture.detectChanges(); expect(component.fileTitle).toBe('file2'); - alfrescoApiService.nodeUpdated.next( { id: 'id1', name: 'file3' }); + alfrescoApiService.nodeUpdated.next({ id: 'id1', name: 'file3' } as any); fixture.detectChanges(); expect(component.fileTitle).toBe('file3'); - alfrescoApiService.nodeUpdated.next( { id: 'id2', name: 'file4' }); + alfrescoApiService.nodeUpdated.next({ id: 'id2', name: 'file4' } as any); fixture.detectChanges(); expect(component.fileTitle).toBe('file3'); expect(component.nodeId).toBe('id1'); diff --git a/lib/core/viewer/components/viewer.component.ts b/lib/core/viewer/components/viewer.component.ts index 012b227200..8db5b10878 100644 --- a/lib/core/viewer/components/viewer.component.ts +++ b/lib/core/viewer/components/viewer.component.ts @@ -49,7 +49,7 @@ import { FileModel } from '../../models'; selector: 'adf-viewer', templateUrl: './viewer.component.html', styleUrls: ['./viewer.component.scss'], - host: { 'class': 'adf-viewer' }, + host: { class: 'adf-viewer' }, encapsulation: ViewEncapsulation.None }) export class ViewerComponent implements OnChanges, OnInit, OnDestroy { @@ -320,11 +320,9 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy { ngOnInit() { this.apiService.nodeUpdated.pipe( - filter((node) => { - return node && node.id === this.nodeId && + filter((node) => node && node.id === this.nodeId && (node.name !== this.fileName || - this.getNodeVersionProperty(this.nodeEntry.entry) !== this.getNodeVersionProperty(node)); - }), + this.getNodeVersionProperty(this.nodeEntry.entry) !== this.getNodeVersionProperty(node))), takeUntil(this.onDestroy$) ).subscribe((node) => this.onNodeUpdated(node)); @@ -739,11 +737,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy { if (typeof extensionAllowed === 'string') { return this.extension.toLowerCase() === extensionAllowed.toLowerCase(); } else if (extensionAllowed.length > 0) { - return extensionAllowed.find((currentExtension) => { - return this.extension.toLowerCase() === currentExtension.toLowerCase(); - }); + return extensionAllowed.find((currentExtension) => this.extension.toLowerCase() === currentExtension.toLowerCase()); } - } onSubmitFile(newImageBlob: Blob) { diff --git a/lib/core/viewer/directives/viewer-extension.directive.ts b/lib/core/viewer/directives/viewer-extension.directive.ts index 321301e70c..2f9f7fbadb 100644 --- a/lib/core/viewer/directives/viewer-extension.directive.ts +++ b/lib/core/viewer/directives/viewer-extension.directive.ts @@ -74,10 +74,7 @@ export class ViewerExtensionDirective implements AfterContentInit, OnDestroy { let supportedExtension: string; if (this.supportedExtensions && (this.supportedExtensions instanceof Array)) { - supportedExtension = this.supportedExtensions.find((extension) => { - return extension.toLowerCase() === fileExtension; - - }); + supportedExtension = this.supportedExtensions.find((extension) => extension.toLowerCase() === fileExtension); } return !!supportedExtension; diff --git a/lib/core/viewer/services/rendering-queue.services.ts b/lib/core/viewer/services/rendering-queue.services.ts index 61482cdb21..41b2e2ec70 100644 --- a/lib/core/viewer/services/rendering-queue.services.ts +++ b/lib/core/viewer/services/rendering-queue.services.ts @@ -139,6 +139,7 @@ export class RenderingQueueServices { * Render a page or thumbnail view. This calls the appropriate function * based on the views state. If the view is already rendered it will return * false. + * * @param view */ renderView(view: any) { @@ -155,7 +156,7 @@ export class RenderingQueueServices { break; case this.renderingStates.INITIAL: this.highestPriorityPage = view.renderingId; - const continueRendering = function () { + const continueRendering = function() { this.renderHighestPriority(); }.bind(this); view.draw().then(continueRendering, continueRendering); diff --git a/lib/core/viewer/services/view-util.service.ts b/lib/core/viewer/services/view-util.service.ts index dd032c83c0..a9de81cfc7 100644 --- a/lib/core/viewer/services/view-util.service.ts +++ b/lib/core/viewer/services/view-util.service.ts @@ -285,9 +285,7 @@ export class ViewUtilService { clearInterval(intervalId); return resolve(rendition); } - }, () => { - return reject(); - }); + }, () => reject()); } else { this.renditionsApi.getRendition(nodeId, renditionId).then((rendition: RenditionEntry) => { const status: string = rendition.entry.status.toString(); @@ -297,9 +295,7 @@ export class ViewUtilService { clearInterval(intervalId); return resolve(rendition); } - }, () => { - return reject(); - }); + }, () => reject()); } } else { clearInterval(intervalId);