AAE-36664 additional linting rules, cleanup (#11084)

This commit is contained in:
Denys Vuika
2025-08-13 08:01:09 -04:00
committed by GitHub
parent e83c8f7fd7
commit b16e326ac3
71 changed files with 235 additions and 2994 deletions
@@ -1,37 +0,0 @@
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { StorageService } from '../common/services/storage.service';
import { AppConfigService, AppConfigValues } from './app-config.service';
@Injectable()
export class DebugAppConfigService extends AppConfigService {
constructor(private storage: StorageService) {
super();
}
get<T>(key: string, defaultValue?: T): T {
if (key === AppConfigValues.OAUTHCONFIG) {
return JSON.parse(this.storage.getItem(key)) || super.get<T>(key, defaultValue);
} else if (key === AppConfigValues.APPLICATION) {
return undefined;
} else {
return (this.storage.getItem(key) as any) || super.get<T>(key, defaultValue);
}
}
}
@@ -16,7 +16,6 @@
*/
export * from './app-config.service';
export * from './debug-app-config.service';
export * from './app-config.pipe';
export * from './app-config-storage-prefix.factory';
@@ -76,20 +76,6 @@ export const clientRoles: IdentityRoleModel[] = [
export const mockJoinGroupRequest: IdentityJoinGroupRequestModel = { userId: 'mock-hser-id', groupId: 'mock-group-id', realm: 'mock-realm-name' };
export const mockGroup1 = {
id: 'mock-group-id-1',
name: 'Mock Group 1',
path: '/mock',
subGroups: []
} as IdentityGroupModel;
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: [] } as IdentityGroupModel,
{ id: 'mock-group-id-2', name: 'Mock Group 2', path: '', subGroups: [] } as IdentityGroupModel
@@ -1,142 +0,0 @@
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { mockIdentityGroups, mockIdentityGroupsCount, mockIdentityRoles } from './identity-group.mock';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { IdentityGroupServiceInterface } from '../interfaces/identity-group.interface';
import {
IdentityGroupModel,
IdentityGroupQueryResponse,
IdentityGroupQueryCloudRequestModel,
IdentityGroupSearchParam,
IdentityGroupCountModel
} from '../models/identity-group.model';
import { IdentityRoleModel } from '../models/identity-role.model';
Injectable({ providedIn: 'root' });
export class IdentityGroupServiceMock implements IdentityGroupServiceInterface {
getGroups(): Observable<IdentityGroupModel[]> {
return of(mockIdentityGroups);
}
getAvailableRoles(_groupId: string): Observable<IdentityRoleModel[]> {
return of(mockIdentityRoles);
}
getAssignedRoles(_groupId: string): Observable<IdentityRoleModel[]> {
return of(mockIdentityRoles);
}
assignRoles(_groupId: string, _roles: IdentityRoleModel[]): Observable<any> {
return of();
}
removeRoles(_groupId: string, _roles: IdentityRoleModel[]): Observable<any> {
return of();
}
getEffectiveRoles(_groupId: string): Observable<IdentityRoleModel[]> {
return of(mockIdentityRoles);
}
queryGroups(_requestQuery: IdentityGroupQueryCloudRequestModel): Observable<IdentityGroupQueryResponse> {
return of();
}
getTotalGroupsCount(): Observable<IdentityGroupCountModel> {
return of(mockIdentityGroupsCount);
}
createGroup(_newGroup: IdentityGroupModel): Observable<any> {
return of();
}
updateGroup(_groupId: string, _updatedGroup: IdentityGroupModel): Observable<any> {
return of();
}
deleteGroup(_groupId: string): Observable<any> {
return of();
}
findGroupsByName(searchParams: IdentityGroupSearchParam): Observable<IdentityGroupModel[]> {
if (searchParams.name === '') {
return of([]);
}
return of(mockIdentityGroups.filter((group) => group.name.toUpperCase().includes(searchParams.name.toUpperCase())));
}
getGroupRoles(_groupId: string): Observable<IdentityRoleModel[]> {
return of(mockIdentityRoles);
}
checkGroupHasRole(groupId: string, roleNames: string[]): Observable<boolean> {
return this.getGroupRoles(groupId).pipe(
map((groupRoles) => {
let hasRole = false;
if (groupRoles?.length > 0) {
roleNames.forEach((roleName: string) => {
const role = groupRoles.find(({ name }) => roleName === name);
if (role) {
hasRole = true;
return;
}
});
}
return hasRole;
})
);
}
getClientIdByApplicationName(_applicationName: string): Observable<string> {
return of('fake-client-id');
}
getClientRoles(groupId: string, _clientId: string): Observable<IdentityRoleModel[]> {
if (['mock-group-id-1', 'mock-group-id-2'].includes(groupId)) {
return of([{ id: 'mock-role-id', name: 'MOCK-ADMIN-ROLE' }]);
}
return of([{ id: 'mock-role-id', name: 'MOCK-USER-ROLE' }]);
}
checkGroupHasClientApp(groupId: string, clientId: string): Observable<boolean> {
return this.getClientRoles(groupId, clientId).pipe(map((response) => response && response.length > 0));
}
checkGroupHasAnyClientAppRole(groupId: string, clientId: string, roleNames: string[]): Observable<boolean> {
return this.getClientRoles(groupId, clientId).pipe(
map((clientRoles: any[]) => {
let hasRole = false;
if (clientRoles.length > 0) {
roleNames.forEach((roleName) => {
const role = clientRoles.find(({ name }) => name === roleName);
if (role) {
hasRole = true;
return;
}
});
}
return hasRole;
})
);
}
}
@@ -1,133 +0,0 @@
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { mockGroups, mockIdentityGroups, roleMappingMock } from './identity-group.mock';
import { mockAssignedRoles, mockAvailableRoles, mockEffectiveRoles, mockIdentityUsers } from './identity-user.mock';
export const queryUsersMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(mockIdentityUsers)
}
};
export const createUserMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
}
};
export const updateUserMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
}
};
export const deleteUserMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
}
};
export const getInvolvedGroupsMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(mockGroups)
}
};
export const joinGroupMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
}
};
export const leaveGroupMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
}
};
export const getAvailableRolesMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(mockAvailableRoles)
}
};
export const getAssignedRolesMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(mockAssignedRoles)
}
};
export const getEffectiveRolesMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(mockEffectiveRoles)
}
};
export const assignRolesMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
}
};
export const removeRolesMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
}
};
export const roleMappingApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(roleMappingMock)
}
};
export const noRoleMappingApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve([])
}
};
export const groupsMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve(mockIdentityGroups)
}
};
export const createGroupMappingApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
}
};
export const updateGroupMappingApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
}
};
export const deleteGroupMappingApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve()
}
};
export const applicationDetailsMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve([{ id: 'mock-app-id', name: 'mock-app-name' }])
}
};
@@ -60,10 +60,9 @@ describe('OidcAuthGuard', () => {
try {
await TestBed.runInInjectionContext(() => OidcAuthGuard(route, state));
expect(routerSpy.navigateByUrl).toHaveBeenCalledWith('/', { replaceUrl: true });
} catch (error) {
} catch {
fail('Expected no error to be thrown');
}
});
it('should throw an error if loginCallback fails and logout event is emitted', async () => {
@@ -89,7 +88,7 @@ describe('OidcAuthGuard', () => {
fakeLogoutSubject.next();
await runInInjectionContext;
expect(routerSpy.navigateByUrl).toHaveBeenCalledWith('/test-route', { replaceUrl: true });
} catch (error) {
} catch {
fail('Expected no error to be thrown');
}
});
@@ -211,7 +211,7 @@ describe('RedirectAuthService', () => {
try {
await service.loginCallback();
fail('Expected to throw an error');
} catch (error) {
} catch {
expect(oauthServiceSpy.logOut).toHaveBeenCalledTimes(1);
}
});
@@ -281,7 +281,7 @@ describe('RedirectAuthService', () => {
try {
await service.loginCallback();
expect(oauthServiceSpy.logOut).not.toHaveBeenCalled();
} catch (error) {
} catch {
fail('Expected not to throw an error');
}
});
@@ -135,7 +135,7 @@ export class StorageService {
storage.setItem(key, key);
storage.removeItem(key, key);
return true;
} catch (e) {
} catch {
return false;
}
}
File diff suppressed because it is too large Load Diff
@@ -2188,37 +2188,6 @@ export const mockSectionWithFields = {
colspan: 1
};
export const mockFormWithSimpleSection = {
id: 'form-363114eb-35f6-40d0-9908-8bbbe776c3e6',
name: 'simplest section',
key: 'simplest-section-uzvc7',
description: '',
version: 0,
formDefinition: {
tabs: [],
fields: [
{
id: 'Group0wuwv7',
name: 'Group',
type: 'group',
tab: null,
params: {
hideHeader: false,
allowCollapse: false,
collapseByDefault: false
},
numberOfColumns: 1,
fields: {
1: [mockSectionWithFields]
}
}
],
outcomes: [],
metadata: {},
variables: []
}
};
export const mockSectionVisibilityForm = {
id: 'form-65e9f07c-44d9-4469-8f5d-74aba3bd7326',
name: 'section visibility',
File diff suppressed because it is too large Load Diff
@@ -488,7 +488,7 @@ export class FormFieldModel extends FormWidgetModel {
let dateValue;
try {
dateValue = DateFnsUtils.parseDate(this.value, this.dateDisplayFormat);
} catch (e) {
} catch {
dateValue = new Date('error');
}
@@ -24,11 +24,11 @@ import { FormService } from '../services/form.service';
import { ByPassFormRuleManager, FORM_RULES_MANAGER, FormRulesManager, formRulesManagerFactory } from './form-rules.model';
class CustomRuleManager extends FormRulesManager<any> {
protected getRules() {
getRules(): any {
return null;
}
protected handleRuleEvent(): void {
handleRuleEvent(): void {
return;
}
}
@@ -67,8 +67,8 @@ describe('Form Rules', () => {
it('should send the form loaded event when initialized', () => {
const rulesManager = new CustomRuleManager(formService);
const getRulesSpy = spyOn<any>(rulesManager, 'getRules').and.returnValue({});
const handleRuleEventSpy = spyOn<any>(rulesManager, 'handleRuleEvent');
const getRulesSpy = spyOn(rulesManager, 'getRules').and.returnValue({});
const handleRuleEventSpy = spyOn(rulesManager, 'handleRuleEvent');
const formModel = new FormModel({ id: 'mock' }, {}, false);
const formEvent = new FormEvent(formModel);
const event = new FormRulesEvent('formLoaded', formEvent);
@@ -82,8 +82,8 @@ describe('Form Rules', () => {
it('should not receive the form event when event has no form', () => {
const rulesManager = new CustomRuleManager(formService);
spyOn<any>(rulesManager, 'getRules').and.returnValue({});
const handleRuleEventSpy = spyOn<any>(rulesManager, 'handleRuleEvent');
spyOn(rulesManager, 'getRules').and.returnValue({});
const handleRuleEventSpy = spyOn(rulesManager, 'handleRuleEvent');
const formModel = new FormModel({ id: 'mock' }, {}, false);
const formEvent = new FormEvent(new FormModel(null));
const event = new FormRulesEvent('formLoaded', formEvent);
@@ -105,8 +105,8 @@ describe('Form Rules', () => {
beforeEach(() => {
injector = TestBed.inject(Injector);
rulesManager = formRulesManagerFactory<any>(injector);
getRulesSpy = spyOn<any>(rulesManager, 'getRules');
rulesManager = formRulesManagerFactory(injector);
getRulesSpy = spyOn(rulesManager as any, 'getRules');
});
it('factory function should return bypass service', () => {
-23
View File
@@ -15,31 +15,8 @@
* limitations under the License.
*/
import { DataColumn } from '../datatable/data/data-column.model';
import { mockPathInfos } from '../datatable/components/mocks/datatable.mock';
export const getDataColumnMock = <T = unknown>(column: Partial<DataColumn<T>> = {}): DataColumn<T> => ({
id: 'columnId',
key: 'key',
type: 'text',
format: 'format',
sortable: false,
title: 'title',
srTitle: 'srTitle',
cssClass: 'cssClass',
template: undefined,
copyContent: false,
editable: false,
focus: false,
sortingKey: 'sortingKey',
header: undefined,
draggable: false,
resizable: true,
isHidden: false,
customData: undefined,
...column
});
export const textColumnRows = [{ firstname: 'John' }, { firstname: 'Henry' }, { firstname: 'David' }, { firstname: 'Thomas' }];
export const dateColumnRows = [
@@ -1,225 +0,0 @@
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const formReadonlyTwoTextFields: any = {
id: 22,
name: 'formTextDefinition',
processDefinitionId: 'textDefinition:3:182',
processDefinitionName: 'textDefinition',
processDefinitionKey: 'textDefinition',
taskId: '188',
taskDefinitionKey: 'sid-D941F49F-2B04-4FBB-9B49-9E95991993E8',
tabs: [],
fields: [
{
fieldType: 'ContainerRepresentation',
id: '1507044399260',
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: 'firstname',
name: 'firstName',
type: 'readonly',
value: 'fakeFirstName',
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,
field: {
id: 'firstname',
name: 'firstName',
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,
dateDisplayFormat: null,
layout: null,
sizeX: 0,
sizeY: 0,
row: 0,
col: 0,
visibilityCondition: null
}
},
dateDisplayFormat: null,
layout: {
row: -1,
column: -1,
colspan: 1
},
sizeX: 1,
sizeY: 1,
row: -1,
col: -1,
visibilityCondition: null
}
],
'2': [
{
fieldType: 'FormFieldRepresentation',
id: 'lastname',
name: 'lastName',
type: 'readonly',
value: 'fakeLastName',
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,
field: {
id: 'lastname',
name: 'lastName',
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,
dateDisplayFormat: null,
layout: null,
sizeX: 0,
sizeY: 0,
row: 0,
col: 0,
visibilityCondition: null
}
},
dateDisplayFormat: null,
layout: {
row: -1,
column: -1,
colspan: 1
},
sizeX: 1,
sizeY: 1,
row: -1,
col: -1,
visibilityCondition: null
}
]
}
}
],
outcomes: [],
javascriptEvents: [],
className: '',
style: '',
customFieldTemplates: {},
metadata: {},
variables: [],
customFieldsValueInfo: {},
gridsterForm: false,
globalDateFormat: 'D-M-YYYY'
};
@@ -1,348 +0,0 @@
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const formDefVisibilityFieldDependsOnNextOne: any = {
id: 19,
processDefinitionId: 'visibility:1:148',
processDefinitionName: 'visibility',
processDefinitionKey: 'visibility',
tabs: [],
fields: [
{
fieldType: 'ContainerRepresentation',
id: '1506960847579',
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: 'country',
name: 'country',
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: 'option_1',
name: 'france'
},
{
id: 'option_2',
name: 'uk'
}
],
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: {
leftType: 'field',
leftValue: 'name',
operator: '==',
rightValue: 'italy',
rightFormFieldId: '',
rightRestResponseId: '',
nextConditionOperator: '',
nextCondition: null
},
endpoint: null,
requestHeaders: null
}
],
'2': [
{
fieldType: 'FormFieldRepresentation',
id: 'name',
name: 'name',
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
}
]
}
}
],
outcomes: [],
javascriptEvents: [],
className: '',
style: '',
customFieldTemplates: {},
metadata: {},
variables: [],
customFieldsValueInfo: {},
gridsterForm: false,
globalDateFormat: 'D-M-YYYY'
};
export const formDefVisibilitiFieldDependsOnPreviousOne: any = {
id: 19,
processDefinitionId: 'visibility:1:148',
processDefinitionName: 'visibility',
processDefinitionKey: 'visibility',
tabs: [],
fields: [
{
fieldType: 'ContainerRepresentation',
id: '1506960847579',
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: 'name',
name: 'name',
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: 'RestFieldRepresentation',
id: 'country',
name: 'country',
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: 'option_1',
name: 'france'
},
{
id: 'option_2',
name: 'uk'
}
],
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: {
leftType: 'field',
leftValue: 'name',
operator: '==',
rightValue: 'italy',
rightFormFieldId: '',
rightRestResponseId: '',
nextConditionOperator: '',
nextCondition: null
},
endpoint: null,
requestHeaders: null
}
]
}
}
],
outcomes: [],
javascriptEvents: [],
className: '',
style: '',
customFieldTemplates: {},
metadata: {},
variables: [],
customFieldsValueInfo: {},
gridsterForm: false,
globalDateFormat: 'D-M-YYYY'
};
@@ -1,405 +0,0 @@
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const formDefinitionTwoTextFields: any = {
id: 20,
name: 'formTextDefinition',
processDefinitionId: 'textDefinition:1:153',
processDefinitionName: 'textDefinition',
processDefinitionKey: 'textDefinition',
taskId: '159',
taskDefinitionKey: 'sid-D941F49F-2B04-4FBB-9B49-9E95991993E8',
tabs: [],
fields: [
{
fieldType: 'ContainerRepresentation',
id: '1507044399260',
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: 'firstname',
name: 'firstName',
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: 'lastname',
name: 'lastName',
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
}
]
}
}
],
outcomes: [],
javascriptEvents: [],
className: '',
style: '',
customFieldTemplates: {},
metadata: {},
variables: [],
customFieldsValueInfo: {},
gridsterForm: false,
globalDateFormat: 'D-M-YYYY'
};
export const formDefinitionDropdownField: any = {
id: 21,
name: 'dropdownDefinition',
processDefinitionId: 'textDefinition:2:163',
processDefinitionName: 'textDefinition',
processDefinitionKey: 'textDefinition',
taskId: '169',
taskDefinitionKey: 'sid-D941F49F-2B04-4FBB-9B49-9E95991993E8',
tabs: [],
fields: [
{
fieldType: 'ContainerRepresentation',
id: '1507046026940',
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: 'country',
name: 'country',
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: 'option_1',
name: 'united kingdom'
},
{
id: 'option_2',
name: 'italy'
},
{
id: 'option_3',
name: 'france'
}
],
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,
endpoint: null,
requestHeaders: null
}
],
'2': []
}
}
],
outcomes: [],
javascriptEvents: [],
className: '',
style: '',
customFieldTemplates: {},
metadata: {},
variables: [],
customFieldsValueInfo: {},
gridsterForm: false,
globalDateFormat: 'D-M-YYYY'
};
export const formDefinitionRequiredField: any = {
id: 21,
name: 'dropdownDefinition',
processDefinitionId: 'textDefinition:2:163',
processDefinitionName: 'textDefinition',
processDefinitionKey: 'textDefinition',
taskId: '169',
taskDefinitionKey: 'sid-D941F49F-2B04-4FBB-9B49-9E95991993E8',
tabs: [],
fields: [
{
fieldType: 'ContainerRepresentation',
id: '1507046026940',
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: 'country',
name: 'country',
type: 'dropdown',
value: 'Choose one...',
required: true,
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: 'option_1',
name: 'united kingdom'
},
{
id: 'option_2',
name: 'italy'
},
{
id: 'option_3',
name: 'france'
}
],
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,
endpoint: null,
requestHeaders: null
}
],
'2': []
}
}
],
outcomes: [],
javascriptEvents: [],
className: '',
style: '',
customFieldTemplates: {},
metadata: {},
variables: [],
customFieldsValueInfo: {},
gridsterForm: false,
globalDateFormat: 'D-M-YYYY'
};
@@ -1,275 +0,0 @@
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const fakeForm: any = {
id: 1001,
name: 'ISSUE_FORM',
processDefinitionId: 'ISSUE_APP:1:2504',
processDefinitionName: 'ISSUE_APP',
processDefinitionKey: 'ISSUE_APP',
taskId: '7506',
taskDefinitionKey: 'sid-F67A2996-1684-4774-855A-4591490081FD',
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: 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: 'dropdownId',
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: 'option_1',
name: 'test1'
},
{
id: 'option_2',
name: 'test2'
},
{
id: 'option_3',
name: 'test3'
}
],
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,
endpoint: null,
requestHeaders: null
}
],
'2': [
{
fieldType: 'RestFieldRepresentation',
id: 'radio',
name: 'radio',
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_2',
name: 'Option 2'
},
{
id: 'option_3',
name: 'Option 3'
}
],
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: 2,
row: -1,
col: -1,
visibilityCondition: null,
endpoint: null,
requestHeaders: null
}
]
}
},
{
fieldType: 'ContainerRepresentation',
id: '1498212413062',
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: '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: 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': []
}
}
],
outcomes: [],
javascriptEvents: [],
className: '',
style: '',
customFieldTemplates: {},
metadata: {},
variables: [],
customFieldsValueInfo: {},
gridsterForm: false,
globalDateFormat: 'D-M-YYYY'
};
@@ -19,12 +19,6 @@ import { FormModel, FormValues } from '../../form/components/widgets/core';
export const formTest = new FormModel({});
export const fakeTaskProcessVariableModels = [
{ id: 'TEST_VAR_1', type: 'string', value: 'test_value_1' },
{ id: 'TEST_VAR_2', type: 'string', value: 'test_value_2' },
{ id: 'TEST_VAR_3', type: 'string', value: 'test_value_3' }
];
export const formValues: FormValues = {
test_1: 'value_1',
test_2: 'value_2',
-4
View File
@@ -19,10 +19,6 @@ export * from './cookie.service.mock';
export * from './event.mock';
export * from './translation.service.mock';
export * from './form/form.component.mock';
export * from './form/form-definition.mock';
export * from './form/form-definition-readonly.mock';
export * from './form/form-definition-visibility.mock';
export * from './form/form.service.mock';
export * from './form/widget-visibility.service.mock';
+5 -42
View File
@@ -24,7 +24,7 @@ import { MatChipGridHarness, MatChipHarness, MatChipListboxHarness } from '@angu
import { MatButtonHarness } from '@angular/material/button/testing';
import { MatIconHarness } from '@angular/material/icon/testing';
import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
import { MatErrorHarness, MatFormFieldHarness } from '@angular/material/form-field/testing';
import { MatFormFieldHarness } from '@angular/material/form-field/testing';
import { MatInputHarness } from '@angular/material/input/testing';
import { MatAutocompleteHarness } from '@angular/material/autocomplete/testing';
import { ComponentFixture } from '@angular/core/testing';
@@ -34,7 +34,10 @@ import { MatSnackBarHarness } from '@angular/material/snack-bar/testing';
import { MatProgressBarHarness } from '@angular/material/progress-bar/testing';
export class UnitTestingUtils {
constructor(private debugElement?: DebugElement, private loader?: HarnessLoader) {
constructor(
private debugElement?: DebugElement,
private loader?: HarnessLoader
) {
this.debugElement = debugElement;
this.loader = loader;
}
@@ -75,10 +78,6 @@ export class UnitTestingUtils {
return this.debugElement.query(By.directive(directive));
}
getAllByDirective(directive: Type<any>): DebugElement[] {
return this.debugElement.queryAll(By.directive(directive));
}
/** Perform actions */
clickByCSS(selector: string): void {
@@ -243,10 +242,6 @@ export class UnitTestingUtils {
return this.loader.getHarness(MatIconHarness.with({ ancestor: selector }));
}
async getMatIconWithAncestorByCSSAndName(selector: string, name: string): Promise<MatIconHarness> {
return this.loader.getHarness(MatIconHarness.with({ ancestor: selector, name }));
}
async checkIfMatIconExistsWithAncestorByDataAutomationId(dataAutomationId: string): Promise<boolean> {
return this.loader.hasHarness(MatIconHarness.with({ ancestor: `[data-automation-id="${dataAutomationId}"]` }));
}
@@ -339,10 +334,6 @@ export class UnitTestingUtils {
return this.loader.getHarness(MatInputHarness);
}
async getMatInputByCSS(selector: string): Promise<MatInputHarness> {
return this.loader.getHarness(MatInputHarness.with({ selector }));
}
async getMatInputByDataAutomationId(dataAutomationId: string): Promise<MatInputHarness> {
return this.loader.getHarness(MatInputHarness.with({ selector: `[data-automation-id="${dataAutomationId}"]` }));
}
@@ -360,14 +351,6 @@ export class UnitTestingUtils {
return this.loader.hasHarness(MatInputHarness);
}
async checkIfMatInputExistsWithCSS(selector: string): Promise<boolean> {
return this.loader.hasHarness(MatInputHarness.with({ selector }));
}
async checkIfMatInputExistsWithDataAutomationId(dataAutomationId: string): Promise<boolean> {
return this.loader.hasHarness(MatInputHarness.with({ selector: `[data-automation-id="${dataAutomationId}"]` }));
}
async checkIfMatInputExistsWithPlaceholder(placeholder: string): Promise<boolean> {
return this.loader.hasHarness(MatInputHarness.with({ placeholder }));
}
@@ -383,11 +366,6 @@ export class UnitTestingUtils {
await input.setValue(value);
}
async fillMatInputByCSS(selector: string, value: string): Promise<void> {
const input = await this.getMatInputByCSS(selector);
await input.setValue(value);
}
async fillMatInputByDataAutomationId(dataAutomationId: string, value: string): Promise<void> {
const input = await this.getMatInputByDataAutomationId(dataAutomationId);
await input.setValue(value);
@@ -409,11 +387,6 @@ export class UnitTestingUtils {
return input.getValue();
}
async getMatInputValueByDataAutomationId(dataAutomationId: string): Promise<string> {
const input = await this.getMatInputByDataAutomationId(dataAutomationId);
return input.getValue();
}
async sendKeysToMatInput(keys: (string | TestKey)[]): Promise<void> {
const input = await this.getMatInput();
const host = await input.host();
@@ -430,16 +403,6 @@ export class UnitTestingUtils {
return autocomplete.getOptions();
}
/** MatError related methods */
async getMatErrorByCSS(selector: string): Promise<MatErrorHarness> {
return this.loader.getHarness(MatErrorHarness.with({ selector }));
}
async getMatErrorByDataAutomationId(dataAutomationId: string): Promise<MatErrorHarness> {
return this.loader.getHarness(MatErrorHarness.with({ selector: `[data-automation-id="${dataAutomationId}"]` }));
}
/** MatTabGroup related methods */
async getSelectedTabFromMatTabGroup(): Promise<MatTabHarness> {
@@ -54,7 +54,7 @@ export class TranslateLoaderService implements TranslateLoader {
}
providerRegistered(name: string): boolean {
return !!this.providers.find((x) => x.name === name);
return this.providers.some((x) => x.name === name);
}
fetchLanguageFile(lang: string, component: ComponentTranslationModel, fallbackUrl?: string): Observable<void> {
@@ -75,7 +75,7 @@ export class TranslateLoaderService implements TranslateLoader {
return this.fetchLanguageFile(lang, component, url);
}
}
return throwError(`Failed to load ${translationUrl}`);
return throwError(() => new Error(`Failed to load ${translationUrl}`));
})
);
}
@@ -85,13 +85,13 @@ export class TranslateLoaderService implements TranslateLoader {
if (!this.queue[lang]) {
this.queue[lang] = [];
}
this.providers.forEach((component) => {
for (const component of this.providers) {
if (!this.isComponentInQueue(lang, component.name)) {
this.queue[lang].push(component.name);
observableBatch.push(this.fetchLanguageFile(lang, component));
}
});
}
return observableBatch;
}
@@ -102,8 +102,8 @@ export class TranslateLoaderService implements TranslateLoader {
}
}
isComponentInQueue(lang: string, name: string) {
return !!(this.queue[lang] || []).find((x) => x === name);
isComponentInQueue(lang: string, name: string): boolean {
return (this.queue[lang] || []).some((x) => x === name);
}
getFullTranslationJSON(lang: string): any {
@@ -144,8 +144,8 @@ export class TranslateLoaderService implements TranslateLoader {
return new Observable((observer) => {
if (batch.length > 0) {
forkJoin(batch).subscribe(
() => {
forkJoin(batch).subscribe({
next: () => {
const fullTranslation = this.getFullTranslationJSON(lang);
if (fullTranslation) {
observer.next(fullTranslation);
@@ -156,10 +156,10 @@ export class TranslateLoaderService implements TranslateLoader {
observer.complete();
}
},
() => {
error: () => {
observer.error('Failed to load some resources');
}
);
});
} else {
const fullTranslation = this.getFullTranslationJSON(lang);
if (fullTranslation) {
@@ -88,31 +88,38 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
@HostListener('document:keydown', ['$event'])
onKeyDown(event: KeyboardEvent) {
switch (event.key) {
case 'ArrowLeft':
case 'ArrowLeft': {
event.preventDefault();
this.cropper.move(-3, 0);
break;
case 'ArrowUp':
}
case 'ArrowUp': {
event.preventDefault();
this.cropper.move(0, -3);
break;
case 'ArrowRight':
}
case 'ArrowRight': {
event.preventDefault();
this.cropper.move(3, 0);
break;
case 'ArrowDown':
}
case 'ArrowDown': {
event.preventDefault();
this.cropper.move(0, 3);
break;
case 'i':
}
case 'i': {
this.zoomIn();
break;
case 'o':
}
case 'o': {
this.zoomOut();
break;
case 'r':
}
case 'r': {
this.rotateImage();
break;
}
default:
}
}
@@ -132,7 +139,10 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
return Math.round(this.scale * 100) + '%';
}
constructor(private appConfigService: AppConfigService, private urlService: UrlService) {
constructor(
private readonly appConfigService: AppConfigService,
private readonly urlService: UrlService
) {
this.initializeScaling();
}
@@ -222,7 +232,7 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
this.cropper.clear();
this.cropper.reset();
this.cropper.setDragMode('move');
this.scale = 1.0;
this.scale = 1;
this.updateCanvasContainer();
}
@@ -27,7 +27,7 @@ import { UnitTestingUtils, provideCoreAuthTesting } from '../../../testing';
import { RenderingQueueServices } from '../../services/rendering-queue.services';
import { PdfThumbListComponent } from '../pdf-viewer-thumbnails/pdf-viewer-thumbnails.component';
import { PDFJS_MODULE, PDFJS_VIEWER_MODULE, PdfViewerComponent } from './pdf-viewer.component';
import pdfjsLibMock from '../mock/pdfjs-lib.mock';
import pdfjsLibraryMock from '../mock/pdfjs-lib.mock';
declare const pdfjsLib: any;
@@ -441,7 +441,7 @@ describe('Test PdfViewer - User interaction', () => {
},
RenderingQueueServices,
{ provide: PDFJS_VIEWER_MODULE, useValue: pdfViewerSpy },
{ provide: PDFJS_MODULE, useValue: pdfjsLibMock }
{ provide: PDFJS_MODULE, useValue: pdfjsLibraryMock }
]
});
@@ -545,9 +545,9 @@ describe('ViewerComponent', () => {
keyCode: 27
} as KeyboardEventInit);
const dialogRef = dialog.open(DummyDialogComponent);
const dialogReference = dialog.open(DummyDialogComponent);
dialogRef.afterClosed().subscribe(() => {
dialogReference.afterClosed().subscribe(() => {
EventMock.keyDown(27);
fixture.detectChanges();
expect(testingUtils.getByCSS('.adf-viewer-content')).toBeNull();
@@ -245,7 +245,7 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
@Input()
nodeId: string = null;
/** Original node mime type, should be provided when renditiona mime type is different. */
/** Original node mime type, should be provided when renditions mime type is different. */
@Input()
nodeMimeType: string = undefined;
@@ -60,7 +60,7 @@ export class ViewerExtensionDirective implements AfterContentInit {
isVisible(fileExtension: string): boolean {
let supportedExtension: string;
if (this.supportedExtensions && this.supportedExtensions instanceof Array) {
if (Array.isArray(this.supportedExtensions)) {
supportedExtension = this.supportedExtensions.find((extension) => extension.toLowerCase() === fileExtension);
}
@@ -31,16 +31,16 @@ export class RenderingQueueServices {
FINISHED: 3
};
CLEANUP_TIMEOUT: number = 30000;
CLEANUP_TIMEOUT: number = 30_000;
pdfViewer: any = null;
pdfThumbnailViewer: any = null;
onIdle: any = null;
highestPriorityPage: any = null;
highestPriorityPage: string | null = null;
idleTimeout: any = null;
printing: any = false;
isThumbnailViewEnabled: any = false;
isThumbnailViewEnabled = false;
/**
* Set the instance of the PDF Viewer
@@ -81,10 +81,8 @@ export class RenderingQueueServices {
return;
}
// No pages needed rendering so check thumbnails.
if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
if (this.pdfThumbnailViewer.forceRendering()) {
return;
}
if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled && this.pdfThumbnailViewer.forceRendering()) {
return;
}
if (this.printing) {
@@ -106,11 +104,11 @@ export class RenderingQueueServices {
// 2 if last scrolled up page before the visible pages
const visibleViews = visible.views;
const numVisible = visibleViews.length;
if (numVisible === 0) {
const numberVisible = visibleViews.length;
if (numberVisible === 0) {
return false;
}
for (let i = 0; i < numVisible; ++i) {
for (let i = 0; i < numberVisible; ++i) {
const view = visibleViews[i].view;
if (!this.isViewFinished(view)) {
return view;
@@ -180,8 +178,9 @@ export class RenderingQueueServices {
view.draw().then(continueRendering, continueRendering);
break;
}
default:
default: {
break;
}
}
return true;
}
@@ -53,7 +53,7 @@ export class ViewUtilService {
* @returns list of extensions
*/
get externalExtensions(): string[] {
return this.viewerExtensions.map((ext) => ext.fileExtension);
return this.viewerExtensions.map((extension) => extension.fileExtension);
}
constructor(private extensionService: AppExtensionService) {}
@@ -85,7 +85,7 @@ export class ViewUtilService {
const match = fileName.match(/\.([^./?#]+)($|\?|#)/);
return match ? match[1] : null;
}
return null;
return undefined;
}
getViewerType(extension: string, mimeType: string, extensionsSupportedByTemplates?: string[]): string {
@@ -104,7 +104,7 @@ export class ViewUtilService {
const editorTypes = Object.keys(this.mimeTypes);
for (const type of editorTypes) {
if (this.mimeTypes[type].indexOf(mimeType) >= 0) {
if (this.mimeTypes[type].includes(mimeType)) {
return type;
}
}
@@ -125,19 +125,19 @@ export class ViewUtilService {
return 'custom';
}
if (this.extensions.image.indexOf(extension) >= 0) {
if (this.extensions.image.includes(extension)) {
return 'image';
}
if (this.extensions.media.indexOf(extension) >= 0) {
if (this.extensions.media.includes(extension)) {
return 'media';
}
if (this.extensions.text.indexOf(extension) >= 0) {
if (this.extensions.text.includes(extension)) {
return 'text';
}
if (this.extensions.pdf.indexOf(extension) >= 0) {
if (this.extensions.pdf.includes(extension)) {
return 'pdf';
}
@@ -145,7 +145,7 @@ export class ViewUtilService {
}
private isExternalViewer(): boolean {
return !!this.viewerExtensions.find((ext) => ext.fileExtension === '*');
return this.viewerExtensions.some((extension) => extension.fileExtension === '*');
}
isCustomViewerExtension(extension: string, extensionsSupportedByTemplates?: string[]): boolean {
@@ -156,7 +156,7 @@ export class ViewUtilService {
if (extension && extensions.length > 0) {
extension = extension.toLowerCase();
return extensions.flat().indexOf(extension) >= 0;
return extensions.flat().includes(extension);
}
return false;