Improved ESLint configuration, integrated spellcheck and error fixes (#8931)

* integrate cspell with eslint, improved configuration

* core: fix linting errors

* core: fix lint warnings

* content: lint fixes

* process service lint fixes

* lint: process services cloud

* lint: insights

* lint: extensions

* [ci:force] lint: cli fixes

* [ci:force] comment out dead code

* [ci:force] exclude dead code

* fix code and tests

* rollback some changes

* fix testing lib

* fix demo shell

* minor lint warning fixes

* minor lint fixes

* fix process services
This commit is contained in:
Denys Vuika 2023-09-26 13:46:53 +01:00 committed by GitHub
parent 8370a3de66
commit ef551a9c71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
134 changed files with 2436 additions and 2269 deletions

View File

@ -1,4 +1,3 @@
path = require('path');
module.exports = { module.exports = {
root: true, root: true,
ignorePatterns: [ ignorePatterns: [
@ -11,20 +10,36 @@ module.exports = {
'**/scripts', '**/scripts',
'**/docs' '**/docs'
], ],
plugins: ['@nrwl/nx'],
overrides: [ overrides: [
{ {
files: ['*.ts'], files: ['*.ts'],
parserOptions: { parserOptions: {
project: [path.join(__dirname, 'tsconfig.json'), path.join(__dirname, 'e2e/tsconfig.e2e.json')], project: ['tsconfig.json', 'e2e/tsconfig.e2e.json'],
createDefaultProgram: true createDefaultProgram: true
}, },
extends: [ extends: [
'plugin:@nrwl/nx/typescript',
'plugin:@nrwl/nx/angular',
'plugin:@cspell/recommended',
'plugin:@angular-eslint/ng-cli-compat', 'plugin:@angular-eslint/ng-cli-compat',
'plugin:@angular-eslint/ng-cli-compat--formatting-add-on', 'plugin:@angular-eslint/ng-cli-compat--formatting-add-on',
'plugin:@angular-eslint/template/process-inline-templates' 'plugin:@angular-eslint/template/process-inline-templates'
], ],
plugins: ['eslint-plugin-unicorn', 'eslint-plugin-rxjs', 'ban', 'license-header'], plugins: [
'eslint-plugin-unicorn',
'eslint-plugin-rxjs',
'prettier',
'ban',
'license-header',
'@cspell',
'eslint-plugin-import',
'@angular-eslint/eslint-plugin',
'@typescript-eslint'
],
rules: { rules: {
// Uncomment this to enable prettier checks as part of the ESLint
// 'prettier/prettier': 'error',
'ban/ban': [ 'ban/ban': [
'error', 'error',
{ name: 'eval', message: 'Calls to eval is not allowed.' }, { name: 'eval', message: 'Calls to eval is not allowed.' },

View File

@ -210,16 +210,6 @@
"demo-shell/**/*.html" "demo-shell/**/*.html"
] ]
} }
},
"spellcheck": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx cspell 'demo-shell/**/*.ts'"
}
]
}
} }
} }
}, },
@ -346,16 +336,6 @@
} }
} }
}, },
"spellcheck": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx cspell 'lib/core/**/*.ts'"
}
]
}
},
"stylelint": { "stylelint": {
"executor": "nx:run-commands", "executor": "nx:run-commands",
"options": { "options": {
@ -484,16 +464,6 @@
} }
} }
}, },
"spellcheck": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx cspell 'lib/content-services/**/*.ts'"
}
]
}
},
"stylelint": { "stylelint": {
"executor": "nx:run-commands", "executor": "nx:run-commands",
"options": { "options": {
@ -560,26 +530,6 @@
] ]
} }
}, },
"spellcheck": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx cspell 'lib/process-services/**/*.ts'"
}
]
},
"stylelint": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx stylelint lib/process-services/**/*.scss --config stylelint-config.json"
}
]
}
}
},
"stylelint": { "stylelint": {
"executor": "nx:run-commands", "executor": "nx:run-commands",
"options": { "options": {
@ -699,16 +649,6 @@
] ]
} }
}, },
"spellcheck": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx cspell 'lib/process-services-cloud/**/*.ts'"
}
]
}
},
"stylelint": { "stylelint": {
"executor": "nx:run-commands", "executor": "nx:run-commands",
"options": { "options": {
@ -775,16 +715,6 @@
] ]
} }
}, },
"spellcheck": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx cspell 'lib/insights/**/*.ts'"
}
]
}
},
"stylelint": { "stylelint": {
"executor": "nx:run-commands", "executor": "nx:run-commands",
"options": { "options": {
@ -848,17 +778,6 @@
"lib/extensions/**/*.ts", "lib/extensions/**/*.ts",
"lib/extensions/**/*.html" "lib/extensions/**/*.html"
] ]
},
"dependsOn": ["spellcheck"]
},
"spellcheck": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx cspell 'lib/extensions/**/*.ts'"
}
]
} }
}, },
"npm-publish": { "npm-publish": {

View File

@ -139,7 +139,8 @@
"webscript", "webscript",
"Whitespaces", "Whitespaces",
"xdescribe", "xdescribe",
"xsrf" "xsrf",
"Undeployed"
], ],
"dictionaries": [ "dictionaries": [
"html", "html",

View File

@ -53,7 +53,7 @@ export class CloudFiltersDemoComponent implements OnInit {
this.currentProcessFilter$ = this.cloudLayoutService.processFilter$; this.currentProcessFilter$ = this.cloudLayoutService.processFilter$;
let root = ''; let root = '';
if (this.route.snapshot && this.route.snapshot.firstChild) { if (this.route.snapshot?.firstChild) {
root = this.route.snapshot.firstChild.url[0].path; root = this.route.snapshot.firstChild.url[0].path;
if (root === 'tasks') { if (root === 'tasks') {
this.expandTaskFilter = true; this.expandTaskFilter = true;

View File

@ -41,7 +41,7 @@ export class CloudLayoutComponent implements OnInit {
this.appName = params.appName; this.appName = params.appName;
}); });
if (this.route.snapshot && this.route.snapshot.firstChild) { if (this.route.snapshot?.firstChild) {
root = this.route.snapshot.firstChild.url[0].path; root = this.route.snapshot.firstChild.url[0].path;
} }

View File

@ -185,7 +185,7 @@ export class ProcessesCloudDemoComponent implements OnInit, OnDestroy {
} }
private loadFilter(model: ProcessFilterCloudModel) { private loadFilter(model: ProcessFilterCloudModel) {
if (model && model.appName && model.id) { if (model?.appName && model.id) {
this.editedFilter = model; this.editedFilter = model;
} }
} }

View File

@ -84,7 +84,7 @@ export class FileViewComponent implements OnInit {
if (id) { if (id) {
this.nodeApiService.getNode(id).subscribe( this.nodeApiService.getNode(id).subscribe(
(node) => { (node) => {
if (node && node.isFile) { if (node?.isFile) {
this.isCommentEnabled = this.contentServices.hasPermissions(node, PermissionsEnum.NOT_CONSUMER) || this.isCommentEnabled = this.contentServices.hasPermissions(node, PermissionsEnum.NOT_CONSUMER) ||
this.contentServices.hasAllowableOperations(node, AllowableOperationsEnum.UPDATE); this.contentServices.hasAllowableOperations(node, AllowableOperationsEnum.UPDATE);
this.nodeId = id; this.nodeId = id;

View File

@ -231,7 +231,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
showFile(event) { showFile(event) {
const entry = event.value.entry; const entry = event.value.entry;
if (entry && entry.isFile) { if (entry?.isFile) {
this.preview.showResource(entry.id); this.preview.showResource(entry.id);
} }
} }
@ -296,7 +296,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
if (changes.nodeResult && changes.nodeResult.currentValue) { if (changes.nodeResult?.currentValue) {
this.nodeResult = changes.nodeResult.currentValue; this.nodeResult = changes.nodeResult.currentValue;
this.pagination = this.nodeResult.list.pagination; this.pagination = this.nodeResult.list.pagination;
} }
@ -468,7 +468,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
if (selection && selection.length === 1) { if (selection && selection.length === 1) {
const entry = selection[0].entry; const entry = selection[0].entry;
if (entry && entry.isFolder) { if (entry?.isFolder) {
return this.contentService.hasAllowableOperations(entry, 'update'); return this.contentService.hasAllowableOperations(entry, 'update');
} }
} }
@ -570,7 +570,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
} }
searchResultsHighlight(search: SearchEntry): string { searchResultsHighlight(search: SearchEntry): string {
if (search && search.highlight) { if (search?.highlight) {
return search.highlight.map((currentHighlight) => currentHighlight.snippets).join(', '); return search.highlight.map((currentHighlight) => currentHighlight.snippets).join(', ');
} }
return ''; return '';
@ -588,7 +588,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
const objectFromMap = {}; const objectFromMap = {};
activeFilters.forEach((filter: FilterSearch) => { activeFilters.forEach((filter: FilterSearch) => {
let paramValue = null; let paramValue = null;
if (filter.value && filter.value.from && filter.value.to) { if (filter.value?.from && filter.value.to) {
paramValue = `${filter.value.from}||${filter.value.to}`; paramValue = `${filter.value.from}||${filter.value.to}`;
} else { } else {
paramValue = filter.value; paramValue = filter.value;

View File

@ -41,9 +41,9 @@ export class VersionManagerDialogAdapterComponent {
private containingDialog?: MatDialogRef<VersionManagerDialogAdapterComponent> private containingDialog?: MatDialogRef<VersionManagerDialogAdapterComponent>
) { ) {
this.contentEntry = data.contentEntry; this.contentEntry = data.contentEntry;
this.newFileVersion = data.hasOwnProperty('newFileVersion') ? data.newFileVersion : this.newFileVersion; this.newFileVersion = Object.prototype.hasOwnProperty.call(data, 'newFileVersion') ? data.newFileVersion : this.newFileVersion;
this.showComments = data.hasOwnProperty('showComments') ? data.showComments : this.showComments; this.showComments = Object.prototype.hasOwnProperty.call(data, 'showComments') ? data.showComments : this.showComments;
this.allowDownload = data.hasOwnProperty('allowDownload') ? data.allowDownload : this.allowDownload; this.allowDownload = Object.prototype.hasOwnProperty.call(data, 'allowDownload') ? data.allowDownload : this.allowDownload;
} }
uploadError(event: FileUploadErrorEvent) { uploadError(event: FileUploadErrorEvent) {

View File

@ -124,7 +124,7 @@ export class ProcessListDemoComponent implements OnInit, OnDestroy {
} }
isFormValid() { isFormValid() {
return this.processListForm && this.processListForm.dirty && this.processListForm.valid; return this.processListForm?.dirty && this.processListForm.valid;
} }
resetProcessForm() { resetProcessForm() {

View File

@ -93,7 +93,7 @@ export class ProcessAttachmentsComponent implements OnInit, OnChanges, OnDestroy
} }
isCompletedProcess(): boolean { isCompletedProcess(): boolean {
return this.processInstance && this.processInstance.ended !== undefined && this.processInstance.ended !== null; return this.processInstance?.ended != null;
} }
} }

View File

@ -180,7 +180,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
.subscribe( .subscribe(
(validateDynamicTableRowEvent: ValidateDynamicTableRowEvent) => { (validateDynamicTableRowEvent: ValidateDynamicTableRowEvent) => {
const row: DynamicTableRow = validateDynamicTableRowEvent.row; const row: DynamicTableRow = validateDynamicTableRowEvent.row;
if (row && row.value && row.value.name === 'admin') { if (row?.value && row.value.name === 'admin') {
validateDynamicTableRowEvent.summary.isValid = false; validateDynamicTableRowEvent.summary.isValid = false;
validateDynamicTableRowEvent.summary.message = 'Sorry, wrong value. You cannot use "admin".'; validateDynamicTableRowEvent.summary.message = 'Sorry, wrong value. You cannot use "admin".';
validateDynamicTableRowEvent.preventDefault(); validateDynamicTableRowEvent.preventDefault();

View File

@ -92,7 +92,7 @@ export class TaskAttachmentsComponent implements OnInit, OnChanges, OnDestroy {
} }
isCompletedTask(): boolean { isCompletedTask(): boolean {
return this.taskDetails && this.taskDetails.endDate !== undefined && this.taskDetails.endDate !== null; return this.taskDetails?.endDate != null;
} }
} }

View File

@ -51,7 +51,7 @@ export class SearchFilterChipsComponent implements OnInit, OnDestroy {
.pipe(takeUntil(this.onDestroy$)) .pipe(takeUntil(this.onDestroy$))
.subscribe(([params, searchConfig]) => { .subscribe(([params, searchConfig]) => {
this.updateSearchSetting(searchConfig); this.updateSearchSetting(searchConfig);
this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null; this.searchedWord = Object.prototype.hasOwnProperty.call(params, this.queryParamName) ? params[this.queryParamName] : null;
const query = this.formatSearchQuery(this.searchedWord, searchConfig['app:fields']); const query = this.formatSearchQuery(this.searchedWord, searchConfig['app:fields']);
if (query) { if (query) {
this.queryBuilder.userQuery = query; this.queryBuilder.userQuery = query;
@ -87,7 +87,7 @@ export class SearchFilterChipsComponent implements OnInit, OnDestroy {
if (this.route) { if (this.route) {
this.route.params.forEach((params: Params) => { this.route.params.forEach((params: Params) => {
this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null; this.searchedWord = Object.prototype.hasOwnProperty.call(params, this.queryParamName) ? params[this.queryParamName] : null;
if (this.searchedWord) { if (this.searchedWord) {
this.queryBuilder.update(); this.queryBuilder.update();
} else { } else {

View File

@ -50,7 +50,7 @@ export class SearchResultComponent implements OnInit, OnDestroy {
combineLatest([this.route.params, this.queryBuilder.configUpdated]) combineLatest([this.route.params, this.queryBuilder.configUpdated])
.pipe(takeUntil(this.onDestroy$)) .pipe(takeUntil(this.onDestroy$))
.subscribe(([params, searchConfig]) => { .subscribe(([params, searchConfig]) => {
this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null; this.searchedWord = Object.prototype.hasOwnProperty.call(params, this.queryParamName) ? params[this.queryParamName] : null;
const query = this.formatSearchQuery(this.searchedWord, searchConfig['app:fields']); const query = this.formatSearchQuery(this.searchedWord, searchConfig['app:fields']);
if (query) { if (query) {
this.queryBuilder.userQuery = query; this.queryBuilder.userQuery = query;
@ -86,7 +86,7 @@ export class SearchResultComponent implements OnInit, OnDestroy {
if (this.route) { if (this.route) {
this.route.params.forEach((params: Params) => { this.route.params.forEach((params: Params) => {
this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null; this.searchedWord = Object.prototype.hasOwnProperty.call(params, this.queryParamName) ? params[this.queryParamName] : null;
if (this.searchedWord) { if (this.searchedWord) {
this.queryBuilder.update(); this.queryBuilder.update();
} else { } else {

View File

@ -21,7 +21,7 @@ import { AppConfigService, AppConfigValues, StorageService, AlfrescoApiService,
import { ENTER } from '@angular/cdk/keycodes'; import { ENTER } from '@angular/cdk/keycodes';
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field'; import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
export const HOST_REGEX = '^(http|https):\/\/.*[^/]$'; export const HOST_REGEX = '^(http|https)://.*[^/]$';
@Component({ @Component({
providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { floatLabel: 'always' } }], providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { floatLabel: 'always' } }],

View File

@ -190,7 +190,7 @@ export class TaskListDemoComponent implements OnInit, OnDestroy {
} }
isFormValid() { isFormValid() {
return this.taskListForm && this.taskListForm.dirty && this.taskListForm.valid; return this.taskListForm?.dirty && this.taskListForm.valid;
} }
private getControl<T extends AbstractControl>(key: string): T { private getControl<T extends AbstractControl>(key: string): T {

View File

@ -15,9 +15,9 @@
* limitations under the License. * limitations under the License.
*/ */
import { AlfrescoApi, NodesApi, UploadApi } from '@alfresco/js-api'; import { AlfrescoApi /*, NodesApi, UploadApi*/ } from '@alfresco/js-api';
import { argv, exit } from 'node:process'; import { argv, exit } from 'node:process';
import { Buffer } from 'node:buffer'; // import { Buffer } from 'node:buffer';
const program = require('commander'); const program = require('commander');
import { logger } from './logger'; import { logger } from './logger';
const MAX_RETRY = 3; const MAX_RETRY = 3;
@ -71,7 +71,8 @@ async function checkEnv() {
} }
} }
// @ts-ignore // TODO: https://alfresco.atlassian.net/browse/ACS-5873
/*
async function checkDiskSpaceFullEnv() { async function checkDiskSpaceFullEnv() {
logger.info(`Start Check disk full space`); logger.info(`Start Check disk full space`);
@ -108,6 +109,7 @@ async function checkDiskSpaceFullEnv() {
} }
} }
} }
*/
function sleep(delay: number) { function sleep(delay: number) {
const start = new Date().getTime(); const start = new Date().getTime();

View File

@ -497,7 +497,7 @@ async function checkDescriptorExist(name: string): Promise<boolean> {
logger.info(`Check descriptor ${name} exist in the list `); logger.info(`Check descriptor ${name} exist in the list `);
const descriptorList = await getDescriptors(); const descriptorList = await getDescriptors();
if (descriptorList && descriptorList.list && descriptorList.entries) { if (descriptorList?.list && descriptorList.entries) {
for (const descriptor of descriptorList.list.entries) { for (const descriptor of descriptorList.list.entries) {
if (descriptor.entry.name === name) { if (descriptor.entry.name === name) {
if (descriptor.entry.deployed === false) { if (descriptor.entry.deployed === false) {

View File

@ -56,24 +56,29 @@ async function initializeDefaultFiles() {
for (let j = 0; j < ACS_DEFAULT.files.length; j++) { for (let j = 0; j < ACS_DEFAULT.files.length; j++) {
const fileInfo = ACS_DEFAULT.files[j]; const fileInfo = ACS_DEFAULT.files[j];
switch (fileInfo.action) { switch (fileInfo.action) {
case 'UPLOAD': case 'UPLOAD': {
await uploadFile(fileInfo.name, parentFolderId); await uploadFile(fileInfo.name, parentFolderId);
break; break;
case 'LOCK': }
case 'LOCK': {
const fileToLock = await uploadFile(fileInfo.name, parentFolderId); const fileToLock = await uploadFile(fileInfo.name, parentFolderId);
await lockFile(fileToLock.entry.id); await lockFile(fileToLock.entry.id);
break; break;
case 'SHARE': }
case 'SHARE': {
const fileToShare = await uploadFile(fileInfo.name, parentFolderId); const fileToShare = await uploadFile(fileInfo.name, parentFolderId);
await shareFile(fileToShare.entry.id); await shareFile(fileToShare.entry.id);
break; break;
case 'FAVORITE': }
case 'FAVORITE': {
const fileToFav = await uploadFile(fileInfo.name, parentFolderId); const fileToFav = await uploadFile(fileInfo.name, parentFolderId);
await favoriteFile(fileToFav.entry.id); await favoriteFile(fileToFav.entry.id);
break; break;
default: }
default: {
logger.error('No action found for file ', fileInfo.name, parentFolderId); logger.error('No action found for file ', fileInfo.name, parentFolderId);
break; break;
}
} }
} }
} }

View File

@ -117,8 +117,8 @@ async function main() {
async function initializeDefaultApps() { async function initializeDefaultApps() {
for (let x = 0; x < ACTIVITI_APPS.apps.length; x++) { for (let x = 0; x < ACTIVITI_APPS.apps.length; x++) {
const appInfo = ACTIVITI_APPS.apps[x]; const appInfo = ACTIVITI_APPS.apps[x];
const isDefaultAppDepl = await isDefaultAppDeployed(appInfo.name); const isDeployed = await isDefaultAppDeployed(appInfo.name);
if (isDefaultAppDepl !== undefined && !isDefaultAppDepl) { if (isDeployed !== undefined && !isDeployed) {
const appDefinition = await importPublishApp(`${appInfo.name}`); const appDefinition = await importPublishApp(`${appInfo.name}`);
await deployApp(appDefinition.appDefinition.id); await deployApp(appDefinition.appDefinition.id);
} else { } else {
@ -248,7 +248,7 @@ async function isDefaultAppDeployed(appName: string) {
try { try {
const runtimeAppDefinitionsApi = new RuntimeAppDefinitionsApi(alfrescoJsApi); const runtimeAppDefinitionsApi = new RuntimeAppDefinitionsApi(alfrescoJsApi);
const availableApps = await runtimeAppDefinitionsApi.getAppDefinitions(); const availableApps = await runtimeAppDefinitionsApi.getAppDefinitions();
const defaultApp = availableApps.data && availableApps.data.filter(app => app.name && app.name.includes(appName)); const defaultApp = availableApps.data?.filter(app => app.name?.includes(appName));
return defaultApp && defaultApp.length > 0; return defaultApp && defaultApp.length > 0;
} catch (error) { } catch (error) {
logger.error(`Aps app failed to import/Publish!`); logger.error(`Aps app failed to import/Publish!`);
@ -262,8 +262,8 @@ async function importPublishApp(appName: string) {
const fileContent = createReadStream(pathFile); const fileContent = createReadStream(pathFile);
try { try {
const appdefinitionsApi = new AppDefinitionsApi(alfrescoJsApi); const appDefinitionsApi = new AppDefinitionsApi(alfrescoJsApi);
const result = await appdefinitionsApi.importAndPublishApp(fileContent, {renewIdmEntries: true}); const result = await appDefinitionsApi.importAndPublishApp(fileContent, {renewIdmEntries: true});
logger.info(`Aps app imported and published!`); logger.info(`Aps app imported and published!`);
return result; return result;
} catch (error) { } catch (error) {
@ -398,7 +398,7 @@ async function authorizeUserToContentRepo(user: any) {
['application/json'], ['application/json'],
['application/json'] ['application/json']
); );
logger.info(`Found ${content.data && content.data.length} contents`); logger.info(`Found ${content.data?.length} contents`);
if (content.data) { if (content.data) {
for (let i = 0; i < content.data.length; i++) { for (let i = 0; i < content.data.length; i++) {
if (content.data[i].authenticationType === 'basic') { if (content.data[i].authenticationType === 'basic') {

View File

@ -63,6 +63,7 @@ export const deletePod = (args: KubeArgs) => {
export const getNamespaces = (): string[] => { export const getNamespaces = (): string[] => {
logger.info('Perform get namespaces name...'); logger.info('Perform get namespaces name...');
const result = exec('kubectl', [`get`, `namespaces`, `-l`, `type=application`, `-o`, `name`], {}); const result = exec('kubectl', [`get`, `namespaces`, `-l`, `type=application`, `-o`, `name`], {});
// eslint-disable-next-line no-useless-escape
const namespaces = result.replace(/namespace[\/]+/g, '').split(/\r?\n/); const namespaces = result.replace(/namespace[\/]+/g, '').split(/\r?\n/);
logger.info(`namespaces found: ${namespaces}`); logger.info(`namespaces found: ${namespaces}`);
return namespaces; return namespaces;

View File

@ -51,12 +51,12 @@ const missingRepositories = {
function licenseWithMDLinks(licenseExp: string): string { function licenseWithMDLinks(licenseExp: string): string {
let licenseUrl = ''; let licenseUrl = '';
if (licenseList[licenseExp] && licenseList[licenseExp]['url']) { if (licenseList[licenseExp]?.['url']) {
licenseUrl = licenseList[licenseExp]['url']; licenseUrl = licenseList[licenseExp]['url'];
} else { } else {
const substituteLicString = nonStandardLicenses[licenseExp.toLowerCase()]; const substituteLicString = nonStandardLicenses[licenseExp.toLowerCase()];
if (licenseList[substituteLicString] && licenseList[substituteLicString]['url']) { if (licenseList[substituteLicString]?.['url']) {
licenseUrl = licenseList[substituteLicString]['url']; licenseUrl = licenseList[substituteLicString]['url'];
} }
} }
@ -125,7 +125,7 @@ export default function main(_args: string[], workingDir: string) {
const pack = packages[packageName]; const pack = packages[packageName];
pack['licenseExp'] = pack['licenses'].toString() pack['licenseExp'] = pack['licenses'].toString()
.replace(/\*/, '') .replace(/\*/, '')
.replace(/[a-zA-Z0-9\-\.]+/g, (match: string) => { .replace(/[a-zA-Z0-9\-.]+/g, (match: string) => {
const lowerMatch = match.toLowerCase(); const lowerMatch = match.toLowerCase();
if ((lowerMatch !== 'and') && (lowerMatch !== 'or') && (lowerMatch !== 'with')) { if ((lowerMatch !== 'and') && (lowerMatch !== 'or') && (lowerMatch !== 'with')) {

View File

@ -32,7 +32,7 @@ export class ProcessAutomationHealth {
const url = `${this.plugInInfo.host}/${this.plugInInfo.appName}/ui/${this.plugInInfo.uiName}/app.config.json`; const url = `${this.plugInInfo.host}/${this.plugInInfo.appName}/ui/${this.plugInInfo.uiName}/app.config.json`;
const appConfig = await this.config.getAppConfig(url); const appConfig = await this.config.getAppConfig(url);
let isEnabled = true; let isEnabled = true;
if (appConfig && appConfig.plugins && appConfig.plugins[this.plugInInfo.name]) { if (appConfig?.plugins?.[this.plugInInfo.name]) {
logger.info(`The plugin ${this.plugInInfo.name} has been correctly configured in app.config.json`); logger.info(`The plugin ${this.plugInInfo.name} has been correctly configured in app.config.json`);
} else { } else {
this.logConfigurationError(); this.logConfigurationError();

View File

@ -32,7 +32,7 @@ export class ProcessServiceHealth {
const url = `${this.plugInInfo.host}/app.config.json`; const url = `${this.plugInInfo.host}/app.config.json`;
const appConfig = await this.config.getAppConfig(url); const appConfig = await this.config.getAppConfig(url);
let isEnabled = true; let isEnabled = true;
if (appConfig && appConfig.plugins && appConfig.plugins[this.plugInInfo.name]) { if (appConfig?.plugins?.[this.plugInInfo.name]) {
logger.info(`The plugin ${this.plugInInfo.name} has been correctly configured in app.config.json`); logger.info(`The plugin ${this.plugInInfo.name} has been correctly configured in app.config.json`);
} else { } else {
this.logConfigurationError(); this.logConfigurationError();

View File

@ -38,6 +38,7 @@ function getSha(args: CommitArgs): string {
function replacePerform(args: CommitArgs, sha: string) { function replacePerform(args: CommitArgs, sha: string) {
logger.info(`Replace commit ${sha} in package...`); logger.info(`Replace commit ${sha} in package...`);
// eslint-disable-next-line no-useless-escape
const sedRule = `s/\"commit\": \".*\"/\"commit\": \"${sha}\"/g`; const sedRule = `s/\"commit\": \".*\"/\"commit\": \"${sha}\"/g`;
if (args.skipGnu) { if (args.skipGnu) {

View File

@ -129,9 +129,9 @@ describe('AspectListComponent', () => {
}); });
it('should show the loading spinner when result is loading', () => { it('should show the loading spinner when result is loading', () => {
const delayReusult = of(null).pipe(delay(0)); const delayResult = of(null).pipe(delay(0));
spyOn(nodeService, 'getNode').and.returnValue(delayReusult); spyOn(nodeService, 'getNode').and.returnValue(delayResult);
spyOn(aspectListService, 'getAspects').and.returnValue(delayReusult); spyOn(aspectListService, 'getAspects').and.returnValue(delayResult);
fixture.detectChanges(); fixture.detectChanges();
const spinner = fixture.nativeElement.querySelector('#adf-aspect-spinner'); const spinner = fixture.nativeElement.querySelector('#adf-aspect-spinner');
expect(spinner).toBeDefined(); expect(spinner).toBeDefined();

View File

@ -140,9 +140,9 @@ describe('CategoriesManagementComponent', () => {
}); });
it('should unassign/remove specific category after clicking at remove icon and emit categories change', () => { it('should unassign/remove specific category after clicking at remove icon and emit categories change', () => {
const removeBtns = getRemoveCategoryButtons(); const removeButtons = getRemoveCategoryButtons();
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit'); const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit');
removeBtns[0].click(); removeButtons[0].click();
fixture.detectChanges(); fixture.detectChanges();
@ -156,9 +156,9 @@ describe('CategoriesManagementComponent', () => {
it('should disable unassigning/removing categories when disableRemoval is set', () => { it('should disable unassigning/removing categories when disableRemoval is set', () => {
component.disableRemoval = true; component.disableRemoval = true;
fixture.detectChanges(); fixture.detectChanges();
const removeBtns = getRemoveCategoryButtons(); const removeButtons = getRemoveCategoryButtons();
const allBtnsDisabled = removeBtns.every((removeBtn) => removeBtn.disabled); const allButtonsDisabled = removeButtons.every((removeBtn) => removeBtn.disabled);
expect(allBtnsDisabled).toBeTrue(); expect(allButtonsDisabled).toBeTrue();
}); });
}); });
@ -269,8 +269,8 @@ describe('CategoriesManagementComponent', () => {
}); });
it('should have correct remove category title', () => { it('should have correct remove category title', () => {
const removeBtns = getRemoveCategoryButtons(); const removeButtons = getRemoveCategoryButtons();
const isTitleCorrect = removeBtns.every((removeBtn) => removeBtn.attributes.getNamedItem('title').textContent === 'CATEGORIES_MANAGEMENT.UNASSIGN_CATEGORY'); const isTitleCorrect = removeButtons.every((removeBtn) => removeBtn.attributes.getNamedItem('title').textContent === 'CATEGORIES_MANAGEMENT.UNASSIGN_CATEGORY');
expect(isTitleCorrect).toBeTrue(); expect(isTitleCorrect).toBeTrue();
}); });
@ -329,8 +329,8 @@ describe('CategoriesManagementComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit').and.callThrough(); const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit').and.callThrough();
const removeCategoryBtns = getRemoveCategoryButtons(); const removeCategoryButtons = getRemoveCategoryButtons();
removeCategoryBtns[2].click(); removeCategoryButtons[2].click();
fixture.detectChanges(); fixture.detectChanges();
expect(component.categories.length).toBe(2); expect(component.categories.length).toBe(2);
@ -345,8 +345,8 @@ describe('CategoriesManagementComponent', () => {
typeCategory('test'); typeCategory('test');
expect(component.existingCategories.length).toBe(2); expect(component.existingCategories.length).toBe(2);
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit').and.callThrough(); const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit').and.callThrough();
const removeCategoryBtns = getRemoveCategoryButtons(); const removeCategoryButtons = getRemoveCategoryButtons();
removeCategoryBtns[0].click(); removeCategoryButtons[0].click();
fixture.detectChanges(); fixture.detectChanges();
expect(component.categories.length).toBe(1); expect(component.categories.length).toBe(1);
@ -375,8 +375,8 @@ describe('CategoriesManagementComponent', () => {
}); });
it('should have correct remove category title', () => { it('should have correct remove category title', () => {
const removeBtns = getRemoveCategoryButtons(); const removeButtons = getRemoveCategoryButtons();
const isTitleCorrect = removeBtns.every((removeBtn) => removeBtn.attributes.getNamedItem('title').textContent === 'CATEGORIES_MANAGEMENT.DELETE_CATEGORY'); const isTitleCorrect = removeButtons.every((removeBtn) => removeBtn.attributes.getNamedItem('title').textContent === 'CATEGORIES_MANAGEMENT.DELETE_CATEGORY');
expect(isTitleCorrect).toBeTrue(); expect(isTitleCorrect).toBeTrue();
}); });
@ -434,8 +434,8 @@ describe('CategoriesManagementComponent', () => {
createCategory('test'); createCategory('test');
const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit'); const categoriesChangeSpy = spyOn(component.categoriesChange, 'emit');
const removeCategoryBtns = getRemoveCategoryButtons(); const removeCategoryButtons = getRemoveCategoryButtons();
removeCategoryBtns[2].click(); removeCategoryButtons[2].click();
fixture.detectChanges(); fixture.detectChanges();
expect(component.categories.length).toBe(2); expect(component.categories.length).toBe(2);

View File

@ -64,17 +64,15 @@ export class CategoryTreeDatasourceService extends TreeService<CategoryNode> {
.join(pathSeparator); .join(pathSeparator);
return this.categoryService.getCategory(category.entry.id).pipe( return this.categoryService.getCategory(category.entry.id).pipe(
map((res) => { map((res) => ({
return { id: category.entry.id,
id: category.entry.id, nodeName: path ? `${path}/${category.entry.name}` : category.entry.name,
nodeName: path ? `${path}/${category.entry.name}` : category.entry.name, parentId: category.entry.parentId,
parentId: category.entry.parentId, level: 0,
level: 0, nodeType: TreeNodeType.RegularNode,
nodeType: TreeNodeType.RegularNode, hasChildren: res.entry.hasChildren,
hasChildren: res.entry.hasChildren, isLoading: false
isLoading: false }))
};
})
); );
}), }),
toArray(), toArray(),

View File

@ -610,7 +610,7 @@ describe('ContentMetadataComponent', () => {
let classesApi: ClassesApi; let classesApi: ClassesApi;
let expectedNode: Node; let expectedNode: Node;
const versionableResponse: PropertyGroup = { const verResponse: PropertyGroup = {
name: 'cm:versionable', name: 'cm:versionable',
title: 'Versionable', title: 'Versionable',
properties: { properties: {
@ -705,7 +705,7 @@ describe('ContentMetadataComponent', () => {
'cm:versionable': '*' 'cm:versionable': '*'
}); });
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse)); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) }); component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
fixture.detectChanges(); fixture.detectChanges();
@ -713,9 +713,9 @@ describe('ContentMetadataComponent', () => {
await component.groupedProperties$.toPromise(); await component.groupedProperties$.toPromise();
fixture.detectChanges(); fixture.detectChanges();
const versionableProp = queryDom(fixture, 'Versionable'); const verProp = queryDom(fixture, 'Versionable');
expect(versionableProp).toBeTruthy(); expect(verProp).toBeTruthy();
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable'); expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
}); });
@ -725,7 +725,7 @@ describe('ContentMetadataComponent', () => {
'cm:versionable': '*' 'cm:versionable': '*'
}); });
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse)); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) }); component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
fixture.detectChanges(); fixture.detectChanges();
@ -733,9 +733,9 @@ describe('ContentMetadataComponent', () => {
await component.groupedProperties$.toPromise(); await component.groupedProperties$.toPromise();
fixture.detectChanges(); fixture.detectChanges();
const versionableProps = fixture.debugElement.queryAll(By.css('[data-automation-id="adf-metadata-group-Versionable"]')); const verProps = fixture.debugElement.queryAll(By.css('[data-automation-id="adf-metadata-group-Versionable"]'));
expect(versionableProps.length).toEqual(2); expect(verProps.length).toEqual(2);
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable'); expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
}); });
@ -745,7 +745,7 @@ describe('ContentMetadataComponent', () => {
exclude: 'cm:versionable' exclude: 'cm:versionable'
}); });
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse)); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) }); component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
fixture.detectChanges(); fixture.detectChanges();
@ -753,9 +753,9 @@ describe('ContentMetadataComponent', () => {
await component.groupedProperties$.toPromise(); await component.groupedProperties$.toPromise();
fixture.detectChanges(); fixture.detectChanges();
const versionableProp = queryDom(fixture, 'Versionable'); const verProp = queryDom(fixture, 'Versionable');
expect(versionableProp).toBeNull(); expect(verProp).toBeNull();
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable'); expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
}); });
@ -766,7 +766,7 @@ describe('ContentMetadataComponent', () => {
'cm:versionable': '*' 'cm:versionable': '*'
}); });
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse)); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) }); component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
fixture.detectChanges(); fixture.detectChanges();
@ -774,9 +774,9 @@ describe('ContentMetadataComponent', () => {
await component.groupedProperties$.toPromise(); await component.groupedProperties$.toPromise();
fixture.detectChanges(); fixture.detectChanges();
const versionableProp = queryDom(fixture, 'Versionable'); const verProp = queryDom(fixture, 'Versionable');
expect(versionableProp).toBeTruthy(); expect(verProp).toBeTruthy();
expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable'); expect(classesApi.getClass).toHaveBeenCalledWith('cm_versionable');
}); });
@ -786,7 +786,7 @@ describe('ContentMetadataComponent', () => {
exclude: ['cm:versionable', 'cm:auditable'] exclude: ['cm:versionable', 'cm:auditable']
}); });
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse)); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) }); component.ngOnChanges({ node: new SimpleChange(node, expectedNode, false) });
fixture.detectChanges(); fixture.detectChanges();
@ -794,8 +794,8 @@ describe('ContentMetadataComponent', () => {
await component.groupedProperties$.toPromise(); await component.groupedProperties$.toPromise();
fixture.detectChanges(); fixture.detectChanges();
const versionableProp = queryDom(fixture, 'Versionable'); const verProp = queryDom(fixture, 'Versionable');
expect(versionableProp).toBeNull(); expect(verProp).toBeNull();
const auditableProp = queryDom(fixture, 'Auditable'); const auditableProp = queryDom(fixture, 'Auditable');
expect(auditableProp).toBeNull(); expect(auditableProp).toBeNull();
@ -825,17 +825,17 @@ describe('ContentMetadataComponent', () => {
exifProp.nativeElement.click(); exifProp.nativeElement.click();
const pixelXDimentionElement = fixture.debugElement.query( const pixelXDimensionElement = fixture.debugElement.query(
By.css('[data-automation-id="card-textitem-label-properties.exif:pixelXDimension"]') By.css('[data-automation-id="card-textitem-label-properties.exif:pixelXDimension"]')
); );
expect(pixelXDimentionElement).toBeTruthy(); expect(pixelXDimensionElement).toBeTruthy();
expect(pixelXDimentionElement.nativeElement.textContent.trim()).toEqual('Image Width'); expect(pixelXDimensionElement.nativeElement.textContent.trim()).toEqual('Image Width');
const pixelYDimentionElement = fixture.debugElement.query( const pixelYDimensionElement = fixture.debugElement.query(
By.css('[data-automation-id="card-textitem-label-properties.exif:pixelYDimension"]') By.css('[data-automation-id="card-textitem-label-properties.exif:pixelYDimension"]')
); );
expect(pixelYDimentionElement).toBeTruthy(); expect(pixelYDimensionElement).toBeTruthy();
expect(pixelYDimentionElement.nativeElement.textContent.trim()).toEqual('Image Height'); expect(pixelYDimensionElement.nativeElement.textContent.trim()).toEqual('Image Height');
}); });
it('should show Exif twice when includeAll is set to true', async () => { it('should show Exif twice when includeAll is set to true', async () => {

View File

@ -330,7 +330,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
this.loadTagsForNode(this.node.id); this.loadTagsForNode(this.node.id);
} }
if (this.displayCategories && !!result.LinkingCategories) { if (this.displayCategories && !!result.LinkingCategories) {
this.assignedCategories = !!result.LinkingCategories.list ? this.assignedCategories = result.LinkingCategories.list ?
result.LinkingCategories.list.entries.map((entry: CategoryEntry) => entry.entry) : result.LinkingCategories.list.entries.map((entry: CategoryEntry) => entry.entry) :
[result.LinkingCategories.entry]; [result.LinkingCategories.entry];
} }

View File

@ -110,7 +110,7 @@ describe('ContentMetaDataService', () => {
} }
}; };
const versionableResponse: PropertyGroup = { const verResponse: PropertyGroup = {
name: 'cm:versionable', name: 'cm:versionable',
title: 'Versionable', title: 'Versionable',
properties: { properties: {
@ -232,7 +232,7 @@ describe('ContentMetaDataService', () => {
'cm:versionable': '*' 'cm:versionable': '*'
}); });
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse)); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise(); const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
@ -249,7 +249,7 @@ describe('ContentMetaDataService', () => {
'cm:versionable': '*' 'cm:versionable': '*'
}); });
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse)); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise(); const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
@ -267,7 +267,7 @@ describe('ContentMetaDataService', () => {
exclude: 'cm:versionable' exclude: 'cm:versionable'
}); });
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse)); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise(); const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
expect(groupedProperties.length).toEqual(0); expect(groupedProperties.length).toEqual(0);
@ -283,7 +283,7 @@ describe('ContentMetaDataService', () => {
'cm:versionable': '*' 'cm:versionable': '*'
}); });
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse)); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise(); const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
expect(groupedProperties.length).toEqual(1); expect(groupedProperties.length).toEqual(1);
@ -299,7 +299,7 @@ describe('ContentMetaDataService', () => {
exclude: ['cm:versionable', 'cm:auditable'] exclude: ['cm:versionable', 'cm:auditable']
}); });
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(versionableResponse)); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(verResponse));
const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise(); const groupedProperties = await service.getGroupedProperties(fakeContentNode).toPromise();
expect(groupedProperties.length).toEqual(0); expect(groupedProperties.length).toEqual(0);

View File

@ -147,9 +147,9 @@ describe('Content Type Dialog Component', () => {
}); });
it('should show the property with the aspect prefix not the inherited ones', async () => { it('should show the property with the aspect prefix not the inherited ones', async () => {
const showPropertyAccordon: HTMLButtonElement = fixture.nativeElement.querySelector('.adf-content-type-accordion .mat-expansion-panel-header'); const showPropertyAccordion: HTMLButtonElement = fixture.nativeElement.querySelector('.adf-content-type-accordion .mat-expansion-panel-header');
expect(showPropertyAccordon).toBeDefined(); expect(showPropertyAccordion).toBeDefined();
showPropertyAccordon.click(); showPropertyAccordion.click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const propertyShowed: NodeList = fixture.nativeElement.querySelectorAll('.adf-content-type-table .mat-row'); const propertyShowed: NodeList = fixture.nativeElement.querySelectorAll('.adf-content-type-table .mat-row');

View File

@ -20,6 +20,7 @@ import { UntypedFormControl } from '@angular/forms';
const I18N_ERRORS_PATH = 'CORE.FOLDER_DIALOG.FOLDER_NAME.ERRORS'; const I18N_ERRORS_PATH = 'CORE.FOLDER_DIALOG.FOLDER_NAME.ERRORS';
export const forbidSpecialCharacters = ({ value }: UntypedFormControl) => { export const forbidSpecialCharacters = ({ value }: UntypedFormControl) => {
// eslint-disable-next-line no-useless-escape
const specialCharacters: RegExp = /([\*\"\<\>\\\/\?\:\|])/; const specialCharacters: RegExp = /([\*\"\<\>\\\/\?\:\|])/;
const isValid: boolean = !specialCharacters.test(value); const isValid: boolean = !specialCharacters.test(value);

View File

@ -59,7 +59,7 @@ export class NodeLockDialogComponent implements OnInit {
isLocked: node.isLocked || false, isLocked: node.isLocked || false,
allowOwner: node.properties['cm:lockType'] === 'WRITE_LOCK', allowOwner: node.properties['cm:lockType'] === 'WRITE_LOCK',
isTimeLock: !!node.properties['cm:expiryDate'], isTimeLock: !!node.properties['cm:expiryDate'],
time: !!node.properties['cm:expiryDate'] ? moment(node.properties['cm:expiryDate']) : moment() time: node.properties['cm:expiryDate'] ? moment(node.properties['cm:expiryDate']) : moment()
}); });
} }

View File

@ -24,10 +24,10 @@ import { TranslateModule } from '@ngx-translate/core';
@Component({ @Component({
template: `<div tabindex="0" adf-auto-focus> Test</div>` template: `<div tabindex="0" adf-auto-focus> Test</div>`
}) })
class AutoFoucsTestComponent {} class AutoFocusTestComponent {}
describe('AutoFocusDirective', () => { describe('AutoFocusDirective', () => {
let fixture: ComponentFixture<AutoFoucsTestComponent>; let fixture: ComponentFixture<AutoFocusTestComponent>;
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
@ -36,10 +36,10 @@ describe('AutoFocusDirective', () => {
], ],
declarations: [ declarations: [
AutoFocusDirective, AutoFocusDirective,
AutoFoucsTestComponent AutoFocusTestComponent
] ]
}); });
fixture = TestBed.createComponent(AutoFoucsTestComponent); fixture = TestBed.createComponent(AutoFocusTestComponent);
}); });
it('should focus the element after content is initialized', fakeAsync(() => { it('should focus the element after content is initialized', fakeAsync(() => {

View File

@ -118,7 +118,7 @@ export class NodeDeleteDirective implements OnChanges {
let promise: Promise<any>; let promise: Promise<any>;
if (node.entry.hasOwnProperty('archivedAt') && node.entry['archivedAt']) { if (Object.prototype.hasOwnProperty.call(node.entry, 'archivedAt') && node.entry['archivedAt']) {
promise = this.trashcanApi.deleteDeletedNode(id); promise = this.trashcanApi.deleteDeletedNode(id);
} else { } else {
promise = this.nodesApi.deleteNode(id, { permanent: this.permanent }); promise = this.nodesApi.deleteNode(id, { permanent: this.permanent });

View File

@ -130,7 +130,7 @@ export class NodeFavoriteDirective implements OnChanges {
const node: Node | SharedLink = selected.entry; const node: Node | SharedLink = selected.entry;
// ACS 6.x with 'isFavorite' include // ACS 6.x with 'isFavorite' include
if (node?.hasOwnProperty('isFavorite')) { if (node && Object.prototype.hasOwnProperty.call(node, 'isFavorite')) {
return of(selected); return of(selected);
} }

View File

@ -39,11 +39,11 @@ export class ContentActionModel {
this.permission = obj.permission; this.permission = obj.permission;
this.disableWithNoPermission = obj.disableWithNoPermission; this.disableWithNoPermission = obj.disableWithNoPermission;
if (obj.hasOwnProperty('disabled')) { if (Object.prototype.hasOwnProperty.call(obj, 'disabled')) {
this.disabled = obj.disabled; this.disabled = obj.disabled;
} }
if (obj.hasOwnProperty('visible')) { if (Object.prototype.hasOwnProperty.call(obj, 'visible')) {
this.visible = obj.visible; this.visible = obj.visible;
} }
} }

View File

@ -56,7 +56,7 @@ export class AddPermissionDialogComponent {
this.selectedMembers.forEach((member) => { this.selectedMembers.forEach((member) => {
const existingMember = this.existingMembers.find(({authorityId}) => authorityId === member.id); const existingMember = this.existingMembers.find(({authorityId}) => authorityId === member.id);
if (!!existingMember) { if (existingMember) {
member.role = existingMember.name; member.role = existingMember.name;
member.accessStatus = existingMember.accessStatus; member.accessStatus = existingMember.accessStatus;
member.readonly = true; // make role non editable member.readonly = true; // make role non editable
@ -66,7 +66,7 @@ export class AddPermissionDialogComponent {
} }
canCloseDialog() { canCloseDialog() {
if (!!this.selectedMembers.length) { if (this.selectedMembers.length) {
this.disableSearch(); this.disableSearch();
} else { } else {
this.dialogRef.close(); this.dialogRef.close();

View File

@ -54,7 +54,7 @@ export class SearchPermissionConfigurationService implements SearchConfiguration
if (this.queryProvider?.query) { if (this.queryProvider?.query) {
query = this.queryProvider.query.replace(new RegExp(/\${([^}]+)}/g), searchTerm); query = this.queryProvider.query.replace(new RegExp(/\${([^}]+)}/g), searchTerm);
} else { } else {
query = `(email:*${searchTerm}* OR firstName:*${searchTerm}* OR lastName:*${searchTerm}* OR displayName:*${searchTerm}* OR authorityName:*${searchTerm}* OR authorityDisplayName:*${searchTerm}*) AND ANAME:(\"0/APP.DEFAULT\")`; query = `(email:*${searchTerm}* OR firstName:*${searchTerm}* OR lastName:*${searchTerm}* OR displayName:*${searchTerm}* OR authorityName:*${searchTerm}* OR authorityDisplayName:*${searchTerm}*) AND ANAME:("0/APP.DEFAULT")`;
} }
return query; return query;
} }

View File

@ -65,6 +65,7 @@ export class NodePermissionService {
/** /**
* Get permissions for a given node * Get permissions for a given node
*
* @param node Node to check permissions for * @param node Node to check permissions for
*/ */
getNodePermissions(node: Node): PermissionDisplayModel[] { getNodePermissions(node: Node): PermissionDisplayModel[] {

View File

@ -89,7 +89,7 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
fieldQuery += field + '"' + this.searchCondition[key].trim() + '"'; fieldQuery += field + '"' + this.searchCondition[key].trim() + '"';
} else { } else {
this.searchCondition[key].split(' ').filter((condition: string) => condition !== '').forEach((phrase: string) => { this.searchCondition[key].split(' ').filter((condition: string) => condition !== '').forEach((phrase: string) => {
const refinedPhrase = '\"' + phrase + '\"'; const refinedPhrase = '"' + phrase + '"';
fieldQuery += fieldQuery === '(' ? fieldQuery += fieldQuery === '(' ?
`${key === LogicalSearchFields.EXCLUDE ? 'NOT ' : ''}${field}${refinedPhrase}` : `${key === LogicalSearchFields.EXCLUDE ? 'NOT ' : ''}${field}${refinedPhrase}` :
` ${connector} ${field}${refinedPhrase}`; ` ${connector} ${field}${refinedPhrase}`;

View File

@ -49,15 +49,15 @@ export class SearchSliderComponent implements SearchWidget, OnInit {
ngOnInit() { ngOnInit() {
if (this.settings) { if (this.settings) {
if (this.settings.hasOwnProperty('min')) { if (Object.prototype.hasOwnProperty.call(this.settings, 'min')) {
this.min = this.settings['min']; this.min = this.settings['min'];
} }
if (this.settings.hasOwnProperty('max')) { if (Object.prototype.hasOwnProperty.call(this.settings, 'max')) {
this.max = this.settings['max']; this.max = this.settings['max'];
} }
if (this.settings.hasOwnProperty('step')) { if (Object.prototype.hasOwnProperty.call(this.settings, 'step')) {
this.step = this.settings['step']; this.step = this.settings['step'];
} }

View File

@ -150,7 +150,7 @@ export abstract class BaseQueryBuilderService {
default: configuration.default || false, default: configuration.default || false,
selected: this.selectedConfiguration !== undefined ? index === this.selectedConfiguration : configuration.default selected: this.selectedConfiguration !== undefined ? index === this.selectedConfiguration : configuration.default
})); }));
} else if (!!configurations) { } else if (configurations) {
return [ return [
{ {
index: 0, index: 0,

View File

@ -103,7 +103,7 @@ export abstract class UploadBase implements OnInit, OnDestroy {
*/ */
uploadFiles(files: File[]): void { uploadFiles(files: File[]): void {
const filteredFiles: FileModel[] = files const filteredFiles: FileModel[] = files
.map<FileModel>((file: File) => this.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^\/]*$/, ''))); .map<FileModel>((file: File) => this.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^/]*$/, '')));
this.uploadQueue(filteredFiles); this.uploadQueue(filteredFiles);
} }

View File

@ -306,7 +306,7 @@ describe('UploadDragAreaComponent', () => {
}); });
it('should upload a file to a specific target folder when dropped onto one', () => { it('should upload a file to a specific target folder when dropped onto one', () => {
const fakePippoItem = { const fakePngItem = {
fullPath: '/folder-fake/file-fake.png', fullPath: '/folder-fake/file-fake.png',
isDirectory: false, isDirectory: false,
isFile: true, isFile: true,
@ -321,7 +321,7 @@ describe('UploadDragAreaComponent', () => {
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', { const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
detail: { detail: {
data: getFakeShareDataRow(), data: getFakeShareDataRow(),
files: [fakePippoItem] files: [fakePngItem]
} }
}); });

View File

@ -39,7 +39,7 @@ export class UploadVersionButtonComponent extends UploadButtonComponent implemen
node: Node; node: Node;
protected createFileModel(file: File): FileModel { protected createFileModel(file: File): FileModel {
const fileModel = super.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^\/]*$/, ''), this.node.id); const fileModel = super.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^/]*$/, ''), this.node.id);
if (!this.isFileAcceptable(fileModel)) { if (!this.isFileAcceptable(fileModel)) {
const message = this.translationService.instant('FILE_UPLOAD.VERSION.MESSAGES.INCOMPATIBLE_VERSION'); const message = this.translationService.instant('FILE_UPLOAD.VERSION.MESSAGES.INCOMPATIBLE_VERSION');

View File

@ -52,7 +52,7 @@ describe('VersionCompatibilityDirective', () => {
let fixture: ComponentFixture<TestComponent>; let fixture: ComponentFixture<TestComponent>;
let versionCompatibilityService: VersionCompatibilityService; let versionCompatibilityService: VersionCompatibilityService;
const acsResponceMock = new VersionInfo({ const acsResponseMock = new VersionInfo({
display: '7.0.1', display: '7.0.1',
major: '7', major: '7',
minor: '0', minor: '0',
@ -70,7 +70,7 @@ describe('VersionCompatibilityDirective', () => {
}); });
fixture = TestBed.createComponent(TestComponent); fixture = TestBed.createComponent(TestComponent);
versionCompatibilityService = TestBed.inject(VersionCompatibilityService); versionCompatibilityService = TestBed.inject(VersionCompatibilityService);
spyOn(versionCompatibilityService, 'getAcsVersion').and.returnValue(acsResponceMock); spyOn(versionCompatibilityService, 'getAcsVersion').and.returnValue(acsResponseMock);
}); });
it('should display component when the version is supported', () => { it('should display component when the version is supported', () => {

View File

@ -28,7 +28,7 @@ describe('VersionCompatibilityService', () => {
let discoveryApiService: DiscoveryApiService; let discoveryApiService: DiscoveryApiService;
const mockProductInfo = new BehaviorSubject<RepositoryInfo>(null); const mockProductInfo = new BehaviorSubject<RepositoryInfo>(null);
const acsResponceMock = { const acsResponseMock = {
version: { version: {
display: '7.0.1', display: '7.0.1',
major: '7', major: '7',
@ -54,7 +54,7 @@ describe('VersionCompatibilityService', () => {
}); });
discoveryApiService = TestBed.inject(DiscoveryApiService); discoveryApiService = TestBed.inject(DiscoveryApiService);
versionCompatibilityService = TestBed.inject(VersionCompatibilityService); versionCompatibilityService = TestBed.inject(VersionCompatibilityService);
mockProductInfo.next(acsResponceMock as RepositoryInfo); mockProductInfo.next(acsResponseMock as RepositoryInfo);
versionCompatibilityService = new VersionCompatibilityService(discoveryApiService); versionCompatibilityService = new VersionCompatibilityService(discoveryApiService);
}); });

View File

@ -151,18 +151,22 @@ export class AdfHttpClient implements ee.Emitter,JsApiHttpClient {
private addPromiseListeners<T = any>(promise: Promise<T>, eventEmitter: any) { private addPromiseListeners<T = any>(promise: Promise<T>, eventEmitter: any) {
const eventPromise = Object.assign(promise, { const eventPromise = Object.assign(promise, {
on() { on() {
// eslint-disable-next-line prefer-spread, prefer-rest-params
eventEmitter.on.apply(eventEmitter, arguments); eventEmitter.on.apply(eventEmitter, arguments);
return this; return this;
}, },
once() { once() {
// eslint-disable-next-line prefer-spread, prefer-rest-params
eventEmitter.once.apply(eventEmitter, arguments); eventEmitter.once.apply(eventEmitter, arguments);
return this; return this;
}, },
emit() { emit() {
// eslint-disable-next-line prefer-spread, prefer-rest-params
eventEmitter.emit.apply(eventEmitter, arguments); eventEmitter.emit.apply(eventEmitter, arguments);
return this; return this;
}, },
off() { off() {
// eslint-disable-next-line prefer-spread, prefer-rest-params
eventEmitter.off.apply(eventEmitter, arguments); eventEmitter.off.apply(eventEmitter, arguments);
return this; return this;
} }

View File

@ -52,8 +52,8 @@ describe('AppLayoutComponent', () => {
hideSidenavConditions: [], hideSidenavConditions: [],
minimizeSidenavConditions: [], minimizeSidenavConditions: [],
preferencesService: { preferencesService: {
get: (_key: string) => 'true', get: () => 'true',
set: (_key: string, _value: any) => {} set: () => {}
} }
}; };

View File

@ -27,10 +27,7 @@ describe('AboutGithubLinkComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [TranslateModule.forRoot(), CoreTestingModule]
TranslateModule.forRoot(),
CoreTestingModule
]
}); });
fixture = TestBed.createComponent(AboutGithubLinkComponent); fixture = TestBed.createComponent(AboutGithubLinkComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
@ -62,7 +59,7 @@ describe('AboutGithubLinkComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]'); const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]');
expect(githubUrl.innerText).toEqual(aboutGithubDetails.defualrUrl); expect(githubUrl.innerText).toEqual(aboutGithubDetails.defaultUrl);
}); });
it('should display the github link', async () => { it('should display the github link', async () => {

View File

@ -43,7 +43,7 @@ export const mockPlugins = [
export const aboutGithubDetails = { export const aboutGithubDetails = {
url: 'https://github.com/componany/repository/commits/', url: 'https://github.com/componany/repository/commits/',
defualrUrl: 'https://github.com/Alfresco/alfresco-ng2-components/commits/', defaultUrl: 'https://github.com/Alfresco/alfresco-ng2-components/commits/',
version: '0.0.7', version: '0.0.7',
ecmHost: 'https://mock.ecmhost.com', ecmHost: 'https://mock.ecmhost.com',
bpmHost: 'https://mock.bpmhost.com', bpmHost: 'https://mock.bpmhost.com',
@ -56,65 +56,65 @@ export const aboutAPSMockDetails = {
type: 'bpmSuite', type: 'bpmSuite',
majorVersion: '1', majorVersion: '1',
minorVersion: '10' minorVersion: '10'
}; };
export const mockModules: any = { export const mockModules: any = {
edition: 'Enterprise', edition: 'Enterprise',
version: { version: {
major: '6', major: '6',
minor: '2', minor: '2',
patch: '0', patch: '0',
hotfix: '0', hotfix: '0',
schema: 13001, schema: 13001,
label: 'ra498a911-b5', label: 'ra498a911-b5',
display: '6.2.0.0' display: '6.2.0.0'
}, },
license: { license: {
issuedAt: '2018-12-20T12:07:31.276+0000', issuedAt: '2018-12-20T12:07:31.276+0000',
expiresAt: '2019-05-31T23:00:00.000+0000', expiresAt: '2019-05-31T23:00:00.000+0000',
remainingDays: 100, remainingDays: 100,
holder: 'CompanyQA', holder: 'CompanyQA',
mode: 'ENTERPRISE', mode: 'ENTERPRISE',
entitlements: { entitlements: {
isClusterEnabled: true, isClusterEnabled: true,
isCryptodocEnabled: true isCryptodocEnabled: true
} }
}, },
status: { status: {
isReadOnly: false, isReadOnly: false,
isAuditEnabled: true, isAuditEnabled: true,
isQuickShareEnabled: true, isQuickShareEnabled: true,
isThumbnailGenerationEnabled: true isThumbnailGenerationEnabled: true
}, },
modules: [ modules: [
{ {
id: 'mock-id', id: 'mock-id',
title: 'ABC Repo', title: 'ABC Repo',
description: 'ABC Repository Extension', description: 'ABC Repository Extension',
version: '3.2.0', version: '3.2.0',
installState: 'UNKNOWN', installState: 'UNKNOWN',
versionMin: '6.1', versionMin: '6.1',
versionMax: '999' versionMax: '999'
}, },
{ {
id: 'aos-module-id', id: 'aos-module-id',
title: 'AOFS Module', title: 'AOFS Module',
description: 'Allows applications that can talk to a SharePoint server to talk to your Alfresco installation', description: 'Allows applications that can talk to a SharePoint server to talk to your Alfresco installation',
version: '1.3.0', version: '1.3.0',
installDate: '2019-02-07T12:26:13.271+0000', installDate: '2019-02-07T12:26:13.271+0000',
installState: 'INSTALLED', installState: 'INSTALLED',
versionMin: '6.0', versionMin: '6.0',
versionMax: '999' versionMax: '999'
}, },
{ {
id: 'mock-saml-repo', id: 'mock-saml-repo',
title: 'SAML Repository Module', title: 'SAML Repository Module',
description: 'The Repository piece of the Alfresco SAML Module', description: 'The Repository piece of the Alfresco SAML Module',
version: '1.1.1', version: '1.1.1',
installDate: '2019-02-07T12:26:12.565+0000', installDate: '2019-02-07T12:26:12.565+0000',
installState: 'INSTALLED', installState: 'INSTALLED',
versionMin: '6.0', versionMin: '6.0',
versionMax: '6.99' versionMax: '6.99'
} }
] ]
}; };

View File

@ -185,7 +185,7 @@ export class AppConfigService {
* @returns Notification when loading is complete * @returns Notification when loading is complete
*/ */
load(): Promise<any> { load(): Promise<any> {
return new Promise(async (resolve) => { return new Promise((resolve) => {
const configUrl = `app.config.json?v=${Date.now()}`; const configUrl = `app.config.json?v=${Date.now()}`;
if (this.status === Status.INIT) { if (this.status === Status.INIT) {
@ -218,7 +218,7 @@ export class AppConfigService {
* @returns Discovery configuration * @returns Discovery configuration
*/ */
loadWellKnown(hostIdp: string): Promise<OpenidConfiguration> { loadWellKnown(hostIdp: string): Promise<OpenidConfiguration> {
return new Promise(async (resolve, reject) => { return new Promise((resolve, reject) => {
this.http this.http
.get<OpenidConfiguration>(`${hostIdp}/.well-known/openid-configuration`) .get<OpenidConfiguration>(`${hostIdp}/.well-known/openid-configuration`)
.subscribe({ .subscribe({

View File

@ -40,7 +40,7 @@ export class AuthBearerInterceptor implements HttpInterceptor {
this.authService = this.injector.get(AuthenticationService); this.authService = this.injector.get(AuthenticationService);
if (!this.authService || !this.authService.getBearerExcludedUrls()) { if (!this.authService?.getBearerExcludedUrls()) {
return next.handle(req); return next.handle(req);
} }

View File

@ -97,10 +97,10 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'decodeToken').and.returnValue( spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{ {
resource_access: { fakeapp: { roles: ['role1'] } } resource_access: { fakeApp: { roles: ['role1'] } }
}); });
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1']); const result = jwtHelperService.hasRealmRolesForClientRole('fakeApp', ['role1']);
expect(result).toBeTruthy(); expect(result).toBeTruthy();
}); });
@ -109,10 +109,10 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'decodeToken').and.returnValue( spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{ {
resource_access: { fakeapp: { roles: ['role1'] } } resource_access: { fakeApp: { roles: ['role1'] } }
}); });
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']); const result = jwtHelperService.hasRealmRolesForClientRole('fakeApp', ['role1', 'role2']);
expect(result).toBeTruthy(); expect(result).toBeTruthy();
}); });
@ -120,9 +120,9 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue( spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{ {
resource_access: { fakeapp: { roles: ['role3'] } } resource_access: { fakeApp: { roles: ['role3'] } }
}); });
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']); const result = jwtHelperService.hasRealmRolesForClientRole('fakeApp', ['role1', 'role2']);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
@ -130,9 +130,9 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token'); spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue( spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{ {
resource_access: { anotherfakeapp: { roles: ['role1'] } } resource_access: { anotherFakeApp: { roles: ['role1'] } }
}); });
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']); const result = jwtHelperService.hasRealmRolesForClientRole('fakeApp', ['role1', 'role2']);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
}); });

View File

@ -46,10 +46,7 @@ describe('CardViewArrayItemComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [TranslateModule.forRoot(), CoreTestingModule]
TranslateModule.forRoot(),
CoreTestingModule
]
}); });
fixture = TestBed.createComponent(CardViewArrayItemComponent); fixture = TestBed.createComponent(CardViewArrayItemComponent);
service = TestBed.inject(CardViewUpdateService); service = TestBed.inject(CardViewUpdateService);
@ -87,8 +84,8 @@ describe('CardViewArrayItemComponent', () => {
}); });
it('should NOT call service on chip list container click', () => { it('should NOT call service on chip list container click', () => {
const chiplistContainer: HTMLElement = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-list-container"]'); const chipListContainer: HTMLElement = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-list-container"]');
chiplistContainer.dispatchEvent(new Event('click')); chipListContainer.dispatchEvent(new Event('click'));
expect(serviceSpy).not.toHaveBeenCalled(); expect(serviceSpy).not.toHaveBeenCalled();
}); });
@ -110,11 +107,11 @@ describe('CardViewArrayItemComponent', () => {
}); });
fixture.detectChanges(); fixture.detectChanges();
const chiplistContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]')); const chipListContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
const chip1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] span'); const chip1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] span');
const chip2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] span'); const chip2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] span');
expect(chiplistContainer).not.toBeNull(); expect(chipListContainer).not.toBeNull();
expect(chip1.innerText).toEqual('Zlatan'); expect(chip1.innerText).toEqual('Zlatan');
expect(chip2.innerText).toEqual('Lionel Messi'); expect(chip2.innerText).toEqual('Lionel Messi');
}); });
@ -126,13 +123,13 @@ describe('CardViewArrayItemComponent', () => {
}); });
fixture.detectChanges(); fixture.detectChanges();
const chiplistContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]')); const chipListContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
const chip1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] span'); const chip1 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] span');
const chip1Icon = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] mat-icon'); const chip1Icon = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"] mat-icon');
const chip2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] span'); const chip2 = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] span');
const chip2Icon = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] mat-icon'); const chip2Icon = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Lionel Messi"] mat-icon');
expect(chiplistContainer).not.toBeNull(); expect(chipListContainer).not.toBeNull();
expect(chip1.innerText).toEqual('Zlatan'); expect(chip1.innerText).toEqual('Zlatan');
expect(chip1Icon.innerText).toEqual('person'); expect(chip1Icon.innerText).toEqual('person');
expect(chip2.innerText).toEqual('Lionel Messi'); expect(chip2.innerText).toEqual('Lionel Messi');
@ -145,9 +142,9 @@ describe('CardViewArrayItemComponent', () => {
clickable: true clickable: true
}); });
fixture.detectChanges(); fixture.detectChanges();
const editicon = fixture.nativeElement.querySelector('[data-automation-id="card-array-item-clickable-icon-array"]'); const editIcon = fixture.nativeElement.querySelector('[data-automation-id="card-array-item-clickable-icon-array"]');
expect(editicon).toBeDefined(); expect(editIcon).toBeDefined();
expect(editicon.innerText).toBe('edit'); expect(editIcon.innerText).toBe('edit');
}); });
it('should not render defined icon if clickable set to false', () => { it('should not render defined icon if clickable set to false', () => {
@ -156,18 +153,18 @@ describe('CardViewArrayItemComponent', () => {
clickable: false clickable: false
}); });
fixture.detectChanges(); fixture.detectChanges();
const editicon = fixture.nativeElement.querySelector('[data-automation-id="card-array-item-clickable-icon-array"]'); const editIcon = fixture.nativeElement.querySelector('[data-automation-id="card-array-item-clickable-icon-array"]');
expect(editicon).toBeNull(); expect(editIcon).toBeNull();
}); });
it('should render all values if noOfItemsToDisplay is not defined', () => { it('should render all values if noOfItemsToDisplay is not defined', () => {
fixture.detectChanges(); fixture.detectChanges();
const chiplistContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]')); const chipListContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
const moreElement = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-more-chip"]')); const moreElement = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-more-chip"]'));
const chip = fixture.nativeElement.querySelectorAll('mat-chip'); const chip = fixture.nativeElement.querySelectorAll('mat-chip');
expect(chiplistContainer).not.toBeNull(); expect(chipListContainer).not.toBeNull();
expect(moreElement).toBeNull(); expect(moreElement).toBeNull();
expect(chip.length).toBe(4); expect(chip.length).toBe(4);
}); });
@ -179,10 +176,10 @@ describe('CardViewArrayItemComponent', () => {
}); });
fixture.detectChanges(); fixture.detectChanges();
const chiplistContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]')); const chipListContainer = fixture.debugElement.query(By.css('[data-automation-id="card-arrayitem-chip-list-container"]'));
const chip = fixture.debugElement.queryAll(By.css('mat-chip')); const chip = fixture.debugElement.queryAll(By.css('mat-chip'));
expect(chiplistContainer).not.toBeNull(); expect(chipListContainer).not.toBeNull();
expect(chip.length).toBe(3); expect(chip.length).toBe(3);
expect(chip[2].nativeElement.innerText).toBe('2 CORE.CARDVIEW.MORE'); expect(chip[2].nativeElement.innerText).toBe('2 CORE.CARDVIEW.MORE');
}); });

View File

@ -41,7 +41,7 @@ describe('CardViewBoolItemComponent', () => {
component.property = new CardViewBoolItemModel({ component.property = new CardViewBoolItemModel({
label: 'Boolean label', label: 'Boolean label',
value: true, value: true,
key: 'boolkey', key: 'boolKey',
default: false, default: false,
editable: false editable: false
}); });
@ -207,7 +207,7 @@ describe('CardViewBoolItemComponent', () => {
const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe( const disposableUpdate = cardViewUpdateService.itemUpdated$.subscribe(
(updateNotification) => { (updateNotification) => {
expect(updateNotification.target).toEqual(property); expect(updateNotification.target).toEqual(property);
expect(updateNotification.changed).toEqual({ boolkey: true }); expect(updateNotification.changed).toEqual({ boolKey: true });
disposableUpdate.unsubscribe(); disposableUpdate.unsubscribe();
done(); done();
} }

View File

@ -118,6 +118,7 @@ export class CardViewItemDispatcherComponent implements OnChanges {
private proxy(methodName, ...args) { private proxy(methodName, ...args) {
if (this.componentReference.instance[methodName]) { if (this.componentReference.instance[methodName]) {
// eslint-disable-next-line prefer-spread
this.componentReference.instance[methodName].apply(this.componentReference.instance, args); this.componentReference.instance[methodName].apply(this.componentReference.instance, args);
} }
} }

View File

@ -45,7 +45,7 @@ describe('CardViewBaseItemModel', () => {
expect(itemModel.data).toBe(properties.data); expect(itemModel.data).toBe(properties.data);
}); });
it('should persist the params\' properties as own properties', () => { it('should persist the params properties as own properties', () => {
const allProperties = { const allProperties = {
...properties, ...properties,
default: 'default-value', default: 'default-value',

View File

@ -40,6 +40,7 @@ export class HighlightTransformService {
let result = text; let result = text;
if (search && text) { if (search && text) {
// eslint-disable-next-line no-useless-escape
let pattern = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); let pattern = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
pattern = pattern.split(' ').filter((t) => t.length > 0).join('|'); pattern = pattern.split(' ').filter((t) => t.length > 0).join('|');

View File

@ -24,12 +24,7 @@ interface TestSortableByCategoryItem extends SortableByCategoryItem {
describe('SortByCategoryMapperService', () => { describe('SortByCategoryMapperService', () => {
let mapper: SortByCategoryMapperService<TestSortableByCategoryItem>; let mapper: SortByCategoryMapperService<TestSortableByCategoryItem>;
const DEFAULT_CATEGORIES = [ const DEFAULT_CATEGORIES = ['', 'DefaultCategory1', 'DefaultCategory2', 'DefaultCategory3'];
'',
'DefaultCategory1',
'DefaultCategory2',
'DefaultCategory3'
];
beforeEach(() => { beforeEach(() => {
mapper = new SortByCategoryMapperService(); mapper = new SortByCategoryMapperService();
@ -57,25 +52,29 @@ describe('SortByCategoryMapperService', () => {
}); });
it('should set all items under default category', () => { it('should set all items under default category', () => {
const defaulValues: TestSortableByCategoryItem[] = [{ const defaultValues: TestSortableByCategoryItem[] = [
name: 'name-a', {
id: 'id', name: 'name-a',
category: DEFAULT_CATEGORIES[1] id: 'id',
}, { category: DEFAULT_CATEGORIES[1]
name: 'name-b', },
id: 'id2', {
category: DEFAULT_CATEGORIES[2] name: 'name-b',
}, { id: 'id2',
name: 'name-c', category: DEFAULT_CATEGORIES[2]
id: 'id3', },
category: DEFAULT_CATEGORIES[0] {
}]; name: 'name-c',
id: 'id3',
category: DEFAULT_CATEGORIES[0]
}
];
const result = mapper.mapItems(defaulValues, DEFAULT_CATEGORIES); const result = mapper.mapItems(defaultValues, DEFAULT_CATEGORIES);
expect(result.length).toBe(1); expect(result.length).toBe(1);
expect(result[0].category).toBe(''); expect(result[0].category).toBe('');
expect(result[0].items.length).toBe(defaulValues.length); expect(result[0].items.length).toBe(defaultValues.length);
}); });
it('should work if no items are present', () => { it('should work if no items are present', () => {
@ -85,7 +84,7 @@ describe('SortByCategoryMapperService', () => {
}); });
it('should work if the default categories are empty', () => { it('should work if the default categories are empty', () => {
const result = mapper.mapItems([{id: 'id', name: 'name', category: ''}], []); const result = mapper.mapItems([{ id: 'id', name: 'name', category: '' }], []);
expect(result.length).toBe(1); expect(result.length).toBe(1);
expect(result[0].category).toBe(''); expect(result[0].category).toBe('');

View File

@ -21,7 +21,6 @@ import { Injectable } from '@angular/core';
providedIn: 'root' providedIn: 'root'
}) })
export class StorageService { export class StorageService {
private memoryStore: { [key: string]: any } = {}; private memoryStore: { [key: string]: any } = {};
private readonly useLocalStorage: boolean = false; private readonly useLocalStorage: boolean = false;
private _prefix: string = ''; private _prefix: string = '';
@ -48,7 +47,7 @@ export class StorageService {
if (this.useLocalStorage) { if (this.useLocalStorage) {
return localStorage.getItem(this.prefix + key); return localStorage.getItem(this.prefix + key);
} else { } else {
return this.memoryStore.hasOwnProperty(this.prefix + key) ? this.memoryStore[this.prefix + key] : null; return Object.prototype.hasOwnProperty.call(this.memoryStore, this.prefix + key) ? this.memoryStore[this.prefix + key] : null;
} }
} }
@ -96,9 +95,9 @@ export class StorageService {
*/ */
hasItem(key: string): boolean { hasItem(key: string): boolean {
if (this.useLocalStorage) { if (this.useLocalStorage) {
return localStorage.getItem(this.prefix + key) ? true : false; return !!localStorage.getItem(this.prefix + key);
} else { } else {
return this.memoryStore.hasOwnProperty(key); return Object.prototype.hasOwnProperty.call(this.memoryStore, key);
} }
} }

View File

@ -41,7 +41,7 @@ export class FileUtils {
files.push({ files.push({
entry, entry,
file, file,
relativeFolder: entry.fullPath.replace(/\/[^\/]*$/, '') relativeFolder: entry.fullPath.replace(/\/[^/]*$/, '')
}); });
resolveFile(); resolveFile();
}); });

View File

@ -40,7 +40,7 @@ export class ObjectDataTableAdapter implements DataTableAdapter {
if (typeof rowToExamine === 'object') { if (typeof rowToExamine === 'object') {
for (const key in rowToExamine) { for (const key in rowToExamine) {
if (rowToExamine.hasOwnProperty(key)) { if (Object.prototype.hasOwnProperty.call(rowToExamine, key)) {
schema.push({ schema.push({
type: 'text', type: 'text',
key, key,

View File

@ -51,26 +51,24 @@ export class ResizableDirective implements OnInit, OnDestroy {
mousemove = new Subject<IResizeMouseEvent>(); mousemove = new Subject<IResizeMouseEvent>();
private pointerDown: Observable<IResizeMouseEvent>; private readonly pointerDown: Observable<IResizeMouseEvent>;
private readonly pointerMove: Observable<IResizeMouseEvent>;
private pointerMove: Observable<IResizeMouseEvent>; private readonly pointerUp: Observable<IResizeMouseEvent>;
private pointerUp: Observable<IResizeMouseEvent>;
private startingRect: BoundingRectangle; private startingRect: BoundingRectangle;
private currentRect: BoundingRectangle; private currentRect: BoundingRectangle;
private unlistenMouseDown?: () => void; private unsubscribeMouseDown?: () => void;
private unlistenMouseMove?: () => void; private unsubscribeMouseMove?: () => void;
private unlistenMouseUp?: () => void; private unsubscribeMouseUp?: () => void;
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();
constructor(private readonly renderer: Renderer2, private readonly element: ElementRef<HTMLElement>, private readonly zone: NgZone) { constructor(private readonly renderer: Renderer2, private readonly element: ElementRef<HTMLElement>, private readonly zone: NgZone) {
this.pointerDown = new Observable((observer: Observer<IResizeMouseEvent>) => { this.pointerDown = new Observable((observer: Observer<IResizeMouseEvent>) => {
zone.runOutsideAngular(() => { zone.runOutsideAngular(() => {
this.unlistenMouseDown = renderer.listen('document', 'mousedown', (event: MouseEvent) => { this.unsubscribeMouseDown = renderer.listen('document', 'mousedown', (event: MouseEvent) => {
observer.next(event); observer.next(event);
}); });
}); });
@ -78,7 +76,7 @@ export class ResizableDirective implements OnInit, OnDestroy {
this.pointerMove = new Observable((observer: Observer<IResizeMouseEvent>) => { this.pointerMove = new Observable((observer: Observer<IResizeMouseEvent>) => {
zone.runOutsideAngular(() => { zone.runOutsideAngular(() => {
this.unlistenMouseMove = renderer.listen('document', 'mousemove', (event: MouseEvent) => { this.unsubscribeMouseMove = renderer.listen('document', 'mousemove', (event: MouseEvent) => {
observer.next(event); observer.next(event);
}); });
}); });
@ -86,7 +84,7 @@ export class ResizableDirective implements OnInit, OnDestroy {
this.pointerUp = new Observable((observer: Observer<IResizeMouseEvent>) => { this.pointerUp = new Observable((observer: Observer<IResizeMouseEvent>) => {
zone.runOutsideAngular(() => { zone.runOutsideAngular(() => {
this.unlistenMouseUp = renderer.listen('document', 'mouseup', (event: MouseEvent) => { this.unsubscribeMouseUp = renderer.listen('document', 'mouseup', (event: MouseEvent) => {
observer.next(event); observer.next(event);
}); });
}); });
@ -101,7 +99,7 @@ export class ResizableDirective implements OnInit, OnDestroy {
const mouseDrag: Observable<IResizeMouseEvent | ICoordinateX> = mousedown$ const mouseDrag: Observable<IResizeMouseEvent | ICoordinateX> = mousedown$
.pipe( .pipe(
mergeMap(({ clientX = 0 }) => mergeMap(({ clientX = 0 }) =>
merge(mousemove$.pipe(take(1)).pipe(map((coords) => [, coords])), mousemove$.pipe(pairwise())) merge(mousemove$.pipe(take(1)).pipe(map((coords) => [undefined, coords])), mousemove$.pipe(pairwise()))
.pipe( .pipe(
map(([previousCoords = {}, newCoords = {}]) => [ map(([previousCoords = {}, newCoords = {}]) => [
{ clientX: previousCoords.clientX - clientX }, { clientX: previousCoords.clientX - clientX },
@ -170,9 +168,9 @@ export class ResizableDirective implements OnInit, OnDestroy {
this.mousedown.complete(); this.mousedown.complete();
this.mousemove.complete(); this.mousemove.complete();
this.mouseup.complete(); this.mouseup.complete();
this.unlistenMouseDown?.(); this.unsubscribeMouseDown?.();
this.unlistenMouseMove?.(); this.unsubscribeMouseMove?.();
this.unlistenMouseUp?.(); this.unsubscribeMouseUp?.();
this.destroy$.next(); this.destroy$.next();
} }

View File

@ -30,7 +30,7 @@ import {
numberMinMaxForm, numberMinMaxForm,
textWidgetVisibility, textWidgetVisibility,
numberWidgetVisibilityForm, numberWidgetVisibilityForm,
radioWidgetVisibiltyForm, radioWidgetVisibilityForm,
customWidgetForm, customWidgetForm,
formDateVisibility, formDateVisibility,
customWidgetFormWithVisibility, customWidgetFormWithVisibility,
@ -86,7 +86,6 @@ const expectElementToBeValid = (fieldId: string, fixture: ComponentFixture<FormR
}; };
describe('Form Renderer Component', () => { describe('Form Renderer Component', () => {
let formRendererComponent: FormRendererComponent<any>; let formRendererComponent: FormRendererComponent<any>;
let fixture: ComponentFixture<FormRendererComponent<any>>; let fixture: ComponentFixture<FormRendererComponent<any>>;
let formService: FormService; let formService: FormService;
@ -95,11 +94,7 @@ describe('Form Renderer Component', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [TranslateModule.forRoot(), CoreTestingModule, FormBaseModule]
TranslateModule.forRoot(),
CoreTestingModule,
FormBaseModule
]
}); });
fixture = TestBed.createComponent(FormRendererComponent); fixture = TestBed.createComponent(FormRendererComponent);
formRendererComponent = fixture.componentInstance; formRendererComponent = fixture.componentInstance;
@ -287,7 +282,6 @@ describe('Form Renderer Component', () => {
}); });
describe('Number widget', () => { describe('Number widget', () => {
it('[C315169] - Should be able to complete a task with a form with number widgets', async () => { it('[C315169] - Should be able to complete a task with a form with number widgets', async () => {
formRendererComponent.formDefinition = formService.parseForm(formNumberWidgetVisibility.formRepresentation.formDefinition); formRendererComponent.formDefinition = formService.parseForm(formNumberWidgetVisibility.formRepresentation.formDefinition);
fixture.detectChanges(); fixture.detectChanges();
@ -364,8 +358,8 @@ describe('Form Renderer Component', () => {
await fixture.whenStable(); await fixture.whenStable();
numberContainerElement = fixture.nativeElement.querySelector('#field-Number2-container'); numberContainerElement = fixture.nativeElement.querySelector('#field-Number2-container');
expectElementToBeHidden(numberContainerElement); expectElementToBeHidden(numberContainerElement);
const errorWidetText: HTMLDivElement = fixture.nativeElement.querySelector('#field-Number1-container error-widget .adf-error-text'); const errorWidgetText: HTMLDivElement = fixture.nativeElement.querySelector('#field-Number1-container error-widget .adf-error-text');
expect(errorWidetText.textContent).toBe(`FORM.FIELD.VALIDATOR.NOT_GREATER_THAN`); expect(errorWidgetText.textContent).toBe(`FORM.FIELD.VALIDATOR.NOT_GREATER_THAN`);
expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should not be valid without mandatory field'); expect(formRendererComponent.formDefinition.isValid).toBe(false, 'Form should not be valid without mandatory field');
}); });
@ -397,12 +391,16 @@ describe('Form Renderer Component', () => {
await fixture.whenStable(); await fixture.whenStable();
const formSizedElement = fixture.nativeElement.querySelector('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container div.adf-grid-list'); const formSizedElement = fixture.nativeElement.querySelector('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container div.adf-grid-list');
expectElementToBeVisible(formSizedElement); expectElementToBeVisible(formSizedElement);
const sectionGridElement: HTMLElement[] = fixture.nativeElement.querySelectorAll('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container div .adf-grid-list-item'); const sectionGridElement: HTMLElement[] = fixture.nativeElement.querySelectorAll(
'#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container div .adf-grid-list-item'
);
sectionGridElement.forEach((element) => { sectionGridElement.forEach((element) => {
expect(element.style['grid-area']).toBe('auto / auto / span 1 / span 1', 'Elemens is wrong sized for this section'); expect(element.style['grid-area']).toBe('auto / auto / span 1 / span 1', 'Elemens is wrong sized for this section');
}); });
const fullWidthElement = fixture.nativeElement.querySelector('#field-d52ada4e-cbdc-4f0c-a480-5b85fa00e4f8-container div.adf-grid-list .adf-grid-list-item'); const fullWidthElement = fixture.nativeElement.querySelector(
'#field-d52ada4e-cbdc-4f0c-a480-5b85fa00e4f8-container div.adf-grid-list .adf-grid-list-item'
);
expect(fullWidthElement.style['grid-area']).toBe('auto / auto / span 1 / span 2'); expect(fullWidthElement.style['grid-area']).toBe('auto / auto / span 1 / span 2');
}); });
@ -410,13 +408,19 @@ describe('Form Renderer Component', () => {
formRendererComponent.formDefinition = formService.parseForm(colspanForm.formRepresentation.formDefinition, null, false, false); formRendererComponent.formDefinition = formService.parseForm(colspanForm.formRepresentation.formDefinition, null, false, false);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const formSizedElement = fixture.nativeElement.querySelector('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container section.adf-grid-list-column-view'); const formSizedElement = fixture.nativeElement.querySelector(
'#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container section.adf-grid-list-column-view'
);
expectElementToBeVisible(formSizedElement); expectElementToBeVisible(formSizedElement);
const sectionGridElement: HTMLElement[] = fixture.nativeElement.querySelectorAll('#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container section .adf-grid-list-single-column'); const sectionGridElement: HTMLElement[] = fixture.nativeElement.querySelectorAll(
'#field-2bc275fb-e113-4d7d-885f-6e74a7332d40-container section .adf-grid-list-single-column'
);
sectionGridElement.forEach((element) => { sectionGridElement.forEach((element) => {
expect(element.style['width']).toBe('50%', 'Elemens is wrong sized for this section'); expect(element.style['width']).toBe('50%', 'Elemens is wrong sized for this section');
}); });
const fullWidthElement = fixture.nativeElement.querySelector('#field-d52ada4e-cbdc-4f0c-a480-5b85fa00e4f8-container section.adf-grid-list-column-view .adf-grid-list-single-column'); const fullWidthElement = fixture.nativeElement.querySelector(
'#field-d52ada4e-cbdc-4f0c-a480-5b85fa00e4f8-container section.adf-grid-list-column-view .adf-grid-list-single-column'
);
expect(fullWidthElement.style['width']).toBe('100%'); expect(fullWidthElement.style['width']).toBe('100%');
}); });
@ -587,11 +591,9 @@ describe('Form Renderer Component', () => {
expectInputElementValueIs(testTwoInput, 'aaa'); expectInputElementValueIs(testTwoInput, 'aaa');
expectElementToBeHidden(numberFieldContainer); expectElementToBeHidden(numberFieldContainer);
}); });
}); });
describe('Text widget', () => { describe('Text widget', () => {
it('[C309669] - Should be able to set visibility conditions for Text widget', async () => { it('[C309669] - Should be able to set visibility conditions for Text widget', async () => {
formRendererComponent.formDefinition = formService.parseForm(textWidgetVisibility.formRepresentation.formDefinition); formRendererComponent.formDefinition = formService.parseForm(textWidgetVisibility.formRepresentation.formDefinition);
fixture.detectChanges(); fixture.detectChanges();
@ -630,13 +632,11 @@ describe('Form Renderer Component', () => {
expectElementToBeVisible(elementFourContainer); expectElementToBeVisible(elementFourContainer);
expectElementToBeHidden(elementThreeContainer); expectElementToBeHidden(elementThreeContainer);
}); });
}); });
describe('Radio widget', () => { describe('Radio widget', () => {
it('[C310352] - Should be able to set visibility conditions for Radio Button widget', async () => { it('[C310352] - Should be able to set visibility conditions for Radio Button widget', async () => {
formRendererComponent.formDefinition = formService.parseForm(radioWidgetVisibiltyForm.formRepresentation.formDefinition); formRendererComponent.formDefinition = formService.parseForm(radioWidgetVisibilityForm.formRepresentation.formDefinition);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const textInputElement = fixture.nativeElement.querySelector('#Text0cee7g'); const textInputElement = fixture.nativeElement.querySelector('#Text0cee7g');
@ -651,11 +651,9 @@ describe('Form Renderer Component', () => {
radioButtonContainer = fixture.nativeElement.querySelector('#field-Radiobuttons03rkbo-container'); radioButtonContainer = fixture.nativeElement.querySelector('#field-Radiobuttons03rkbo-container');
expectElementToBeVisible(radioButtonContainer); expectElementToBeVisible(radioButtonContainer);
}); });
}); });
describe('Custom Widget', () => { describe('Custom Widget', () => {
it('Should be able to correctly display a custom process cloud widget', async () => { 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); formRendererComponent.formDefinition = formService.parseForm(customWidgetForm.formRepresentation.formDefinition);
@ -681,7 +679,6 @@ describe('Form Renderer Component', () => {
customWidgetElementContainer = fixture.nativeElement.querySelector('#field-bananaforevah0k8gui-container'); customWidgetElementContainer = fixture.nativeElement.querySelector('#field-bananaforevah0k8gui-container');
expectElementToBeVisible(customWidgetElementContainer); expectElementToBeVisible(customWidgetElementContainer);
}); });
}); });
describe('Form rules', () => { describe('Form rules', () => {

View File

@ -84,7 +84,7 @@ export class FormRendererComponent<T> implements OnChanges, OnDestroy {
const maxColumnFieldsSize = this.getMaxColumnFieldSize(content); const maxColumnFieldsSize = this.getMaxColumnFieldSize(content);
for (let rowIndex = 0; rowIndex < maxColumnFieldsSize; rowIndex++) { for (let rowIndex = 0; rowIndex < maxColumnFieldsSize; rowIndex++) {
content?.columns.flatMap((currentColumn) => { content?.columns.flatMap((currentColumn) => {
if (!!currentColumn?.fields[rowIndex]) { if (currentColumn?.fields[rowIndex]) {
serialisedFormFields.push(currentColumn?.fields[rowIndex]); serialisedFormFields.push(currentColumn?.fields[rowIndex]);
} else { } else {
const firstRowElementColSpan = currentColumn?.fields[0]?.colspan; const firstRowElementColSpan = currentColumn?.fields[0]?.colspan;

View File

@ -38,13 +38,11 @@ import { FormModel } from './form.model';
declare let moment: any; declare let moment: any;
describe('FormFieldValidator', () => { describe('FormFieldValidator', () => {
describe('RequiredFieldValidator', () => { describe('RequiredFieldValidator', () => {
let validator: RequiredFieldValidator; let validator: RequiredFieldValidator;
beforeEach(() => { beforeEach(() => {
validator = new RequiredFieldValidator(); validator = new RequiredFieldValidator();
}); });
it('should require [required] setting', () => { it('should require [required] setting', () => {
@ -71,9 +69,7 @@ describe('FormFieldValidator', () => {
const field = new FormFieldModel(new FormModel(), { const field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.DROPDOWN, type: FormFieldTypes.DROPDOWN,
value: '<empty>', value: '<empty>',
options: [ options: [{ id: 'empty', name: 'Choose option...' }],
{id: 'empty', name: 'Choose option...'}
],
hasEmptyValue: true, hasEmptyValue: true,
required: true required: true
}); });
@ -241,10 +237,9 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
}); });
}); });
describe('NumberFieldValidator', () => { describe('NumberFieldValidator', () => {
let validator: NumberFieldValidator; let validator: NumberFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -305,10 +300,9 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
expect(field.validationSummary).not.toBeNull(); expect(field.validationSummary).not.toBeNull();
}); });
}); });
describe('MinLengthFieldValidator', () => { describe('MinLengthFieldValidator', () => {
let validator: MinLengthFieldValidator; let validator: MinLengthFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -357,10 +351,9 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
expect(field.validationSummary).not.toBeNull(); expect(field.validationSummary).not.toBeNull();
}); });
}); });
describe('MaxLengthFieldValidator', () => { describe('MaxLengthFieldValidator', () => {
let validator: MaxLengthFieldValidator; let validator: MaxLengthFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -412,7 +405,6 @@ describe('FormFieldValidator', () => {
}); });
describe('MinValueFieldValidator', () => { describe('MinValueFieldValidator', () => {
let validator: MinValueFieldValidator; let validator: MinValueFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -480,10 +472,9 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
expect(field.validationSummary).not.toBeNull(); expect(field.validationSummary).not.toBeNull();
}); });
}); });
describe('MaxValueFieldValidator', () => { describe('MaxValueFieldValidator', () => {
let validator: MaxValueFieldValidator; let validator: MaxValueFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -551,10 +542,9 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
expect(field.validationSummary).not.toBeNull(); expect(field.validationSummary).not.toBeNull();
}); });
}); });
describe('RegExFieldValidator', () => { describe('RegExFieldValidator', () => {
let validator: RegExFieldValidator; let validator: RegExFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -610,10 +600,9 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
}); });
}); });
describe('FixedValueFieldValidator', () => { describe('FixedValueFieldValidator', () => {
let validator: FixedValueFieldValidator; let validator: FixedValueFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -647,7 +636,10 @@ describe('FormFieldValidator', () => {
const field = new FormFieldModel(new FormModel(), { const field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.TYPEAHEAD, type: FormFieldTypes.TYPEAHEAD,
value: '1', value: '1',
options: [{id: '1', name: 'Leanne Graham'}, {id: '2', name: 'Ervin Howell'}] options: [
{ id: '1', name: 'Leanne Graham' },
{ id: '2', name: 'Ervin Howell' }
]
}); });
expect(validator.validate(field)).toBeTruthy(); expect(validator.validate(field)).toBeTruthy();
@ -657,15 +649,17 @@ describe('FormFieldValidator', () => {
const field = new FormFieldModel(new FormModel(), { const field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.TYPEAHEAD, type: FormFieldTypes.TYPEAHEAD,
value: 'Lean', value: 'Lean',
options: [{id: '1', name: 'Leanne Graham'}, {id: '2', name: 'Ervin Howell'}] options: [
{ id: '1', name: 'Leanne Graham' },
{ id: '2', name: 'Ervin Howell' }
]
}); });
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
}); });
}); });
describe('MaxDateTimeFieldValidator', () => { describe('MaxDateTimeFieldValidator', () => {
let validator: MaxDateTimeFieldValidator; let validator: MaxDateTimeFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -788,10 +782,9 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
expect(field.validationSummary).not.toBeNull(); expect(field.validationSummary).not.toBeNull();
}); });
}); });
describe('MinDateTimeFieldValidator', () => { describe('MinDateTimeFieldValidator', () => {
let validator: MinDateTimeFieldValidator; let validator: MinDateTimeFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -914,10 +907,9 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
expect(field.validationSummary).not.toBeNull(); expect(field.validationSummary).not.toBeNull();
}); });
}); });
describe('MaxDateFieldValidator', () => { describe('MaxDateFieldValidator', () => {
let validator: MaxDateFieldValidator; let validator: MaxDateFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -1007,10 +999,9 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
expect(field.validationSummary).not.toBeNull(); expect(field.validationSummary).not.toBeNull();
}); });
}); });
describe('MinDateFieldValidator', () => { describe('MinDateFieldValidator', () => {
let validator: MinDateFieldValidator; let validator: MinDateFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -1100,10 +1091,9 @@ describe('FormFieldValidator', () => {
expect(validator.validate(field)).toBeFalsy(); expect(validator.validate(field)).toBeFalsy();
expect(field.validationSummary).not.toBeNull(); expect(field.validationSummary).not.toBeNull();
}); });
}); });
describe('DateTimeFieldValidator', () => { describe('DateTimeFieldValidator', () => {
let validator: DateTimeFieldValidator; let validator: DateTimeFieldValidator;
beforeEach(() => { beforeEach(() => {
@ -1114,7 +1104,7 @@ describe('FormFieldValidator', () => {
const field = new FormFieldModel(new FormModel(), { const field = new FormFieldModel(new FormModel(), {
type: FormFieldTypes.DATETIME, type: FormFieldTypes.DATETIME,
value: '2021-06-09 14:10', value: '2021-06-09 14:10',
dateDisplayFormay: 'YYYY-MM-DD HH:mm' dateDisplayFormat: 'YYYY-MM-DD HH:mm'
}); });
expect(validator.validate(field)).toBeTruthy(); expect(validator.validate(field)).toBeTruthy();

View File

@ -272,11 +272,10 @@ export class FormFieldModel extends FormWidgetModel {
if (json.fields) { if (json.fields) {
for (const currentField in json.fields) { for (const currentField in json.fields) {
if (json.fields.hasOwnProperty(currentField)) { if (Object.prototype.hasOwnProperty.call(json.fields, currentField)) {
const col = new ContainerColumnModel(); const col = new ContainerColumnModel();
const fields: FormFieldModel[] = (json.fields[currentField] || []).map((field) => new FormFieldModel(form, field)); col.fields = (json.fields[currentField] || []).map((field) => new FormFieldModel(form, field));
col.fields = fields;
col.rowspan = json.fields[currentField].length; col.rowspan = json.fields[currentField].length;
col.fields.forEach((colFields: any) => { col.fields.forEach((colFields: any) => {
@ -291,7 +290,7 @@ export class FormFieldModel extends FormWidgetModel {
} }
parseValue(json: any): any { parseValue(json: any): any {
let value = json.hasOwnProperty('value') && json.value !== undefined ? json.value : null; let value = Object.prototype.hasOwnProperty.call(json, 'value') && json.value !== undefined ? json.value : null;
/* /*
This is needed due to Activiti issue related to reading dropdown values as value string This is needed due to Activiti issue related to reading dropdown values as value string
@ -363,7 +362,7 @@ export class FormFieldModel extends FormWidgetModel {
} }
switch (this.type) { switch (this.type) {
case FormFieldTypes.DROPDOWN: case FormFieldTypes.DROPDOWN: {
if (!this.value) { if (!this.value) {
this.form.values[this.id] = null; this.form.values[this.id] = null;
break; break;
@ -390,13 +389,15 @@ export class FormFieldModel extends FormWidgetModel {
} }
} }
break; break;
case FormFieldTypes.RADIO_BUTTONS: }
case FormFieldTypes.RADIO_BUTTONS: {
const radioButton: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value); const radioButton: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value);
if (radioButton.length > 0) { if (radioButton.length > 0) {
this.form.values[this.id] = radioButton[0]; this.form.values[this.id] = radioButton[0];
} }
break; break;
case FormFieldTypes.UPLOAD: }
case FormFieldTypes.UPLOAD: {
this.form.hasUpload = true; this.form.hasUpload = true;
if (this.value && this.value.length > 0) { if (this.value && this.value.length > 0) {
this.form.values[this.id] = Array.isArray(this.value) ? this.value.map((elem) => elem.id).join(',') : [this.value]; this.form.values[this.id] = Array.isArray(this.value) ? this.value.map((elem) => elem.id).join(',') : [this.value];
@ -404,7 +405,8 @@ export class FormFieldModel extends FormWidgetModel {
this.form.values[this.id] = null; this.form.values[this.id] = null;
} }
break; break;
case FormFieldTypes.TYPEAHEAD: }
case FormFieldTypes.TYPEAHEAD: {
const typeAheadEntry: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value || opt.name === this.value); const typeAheadEntry: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value || opt.name === this.value);
if (typeAheadEntry.length > 0) { if (typeAheadEntry.length > 0) {
this.form.values[this.id] = typeAheadEntry[0]; this.form.values[this.id] = typeAheadEntry[0];
@ -412,7 +414,8 @@ export class FormFieldModel extends FormWidgetModel {
this.form.values[this.id] = null; this.form.values[this.id] = null;
} }
break; break;
case FormFieldTypes.DATE: }
case FormFieldTypes.DATE: {
if (typeof this.value === 'string' && this.value === 'today') { if (typeof this.value === 'string' && this.value === 'today') {
this.value = moment(new Date()).format(this.dateDisplayFormat); this.value = moment(new Date()).format(this.dateDisplayFormat);
} }
@ -425,7 +428,8 @@ export class FormFieldModel extends FormWidgetModel {
this._value = this.value; this._value = this.value;
} }
break; break;
case FormFieldTypes.DATETIME: }
case FormFieldTypes.DATETIME: {
if (typeof this.value === 'string' && this.value === 'now') { if (typeof this.value === 'string' && this.value === 'now') {
this.value = moment(new Date()).utc().format(this.dateDisplayFormat); this.value = moment(new Date()).utc().format(this.dateDisplayFormat);
} }
@ -439,21 +443,27 @@ export class FormFieldModel extends FormWidgetModel {
this._value = this.value; this._value = this.value;
} }
break; break;
case FormFieldTypes.NUMBER: }
case FormFieldTypes.NUMBER: {
this.form.values[this.id] = this.enableFractions ? parseFloat(this.value) : parseInt(this.value, 10); this.form.values[this.id] = this.enableFractions ? parseFloat(this.value) : parseInt(this.value, 10);
break; break;
case FormFieldTypes.AMOUNT: }
case FormFieldTypes.AMOUNT: {
this.form.values[this.id] = this.enableFractions ? parseFloat(this.value) : parseInt(this.value, 10); this.form.values[this.id] = this.enableFractions ? parseFloat(this.value) : parseInt(this.value, 10);
break; break;
case FormFieldTypes.BOOLEAN: }
case FormFieldTypes.BOOLEAN: {
this.form.values[this.id] = this.value !== null && this.value !== undefined ? this.value : false; this.form.values[this.id] = this.value !== null && this.value !== undefined ? this.value : false;
break; break;
case FormFieldTypes.PEOPLE: }
case FormFieldTypes.PEOPLE: {
this.form.values[this.id] = this.value ? this.value : null; this.form.values[this.id] = this.value ? this.value : null;
break; break;
case FormFieldTypes.FUNCTIONAL_GROUP: }
case FormFieldTypes.FUNCTIONAL_GROUP: {
this.form.values[this.id] = this.value ? this.value : null; this.form.values[this.id] = this.value ? this.value : null;
break; break;
}
default: default:
if (!FormFieldTypes.isReadOnlyType(this.type) && !this.isInvalidFieldType(this.type)) { if (!FormFieldTypes.isReadOnlyType(this.type) && !this.isInvalidFieldType(this.type)) {
this.form.values[this.id] = this.value; this.form.values[this.id] = this.value;

View File

@ -265,7 +265,7 @@ export class FormModel implements ProcessFormModel {
getDefaultFormVariableValue(identifier: string): any { getDefaultFormVariableValue(identifier: string): any {
const variable = this.getFormVariable(identifier); const variable = this.getFormVariable(identifier);
if (variable?.hasOwnProperty('value')) { if (variable && Object.prototype.hasOwnProperty.call(variable, 'value')) {
return this.parseValue(variable.type, variable.value); return this.parseValue(variable.type, variable.value);
} }
@ -420,7 +420,7 @@ export class FormModel implements ProcessFormModel {
const visibilityRule: WidgetVisibilityModel = new WidgetVisibilityModel(); const visibilityRule: WidgetVisibilityModel = new WidgetVisibilityModel();
const field = this.getFieldById(fieldId); const field = this.getFieldById(fieldId);
if (!!field) { if (field) {
visibilityRule.operator = visibility ? 'empty' : '!empty'; visibilityRule.operator = visibility ? 'empty' : '!empty';
visibilityRule.leftType = WidgetTypeEnum.field; visibilityRule.leftType = WidgetTypeEnum.field;
field.visibilityCondition = visibilityRule; field.visibilityCondition = visibilityRule;
@ -430,28 +430,28 @@ export class FormModel implements ProcessFormModel {
changeFieldDisabled(fieldId: string, disabled: boolean): void { changeFieldDisabled(fieldId: string, disabled: boolean): void {
const field = this.getFieldById(fieldId); const field = this.getFieldById(fieldId);
if (!!field) { if (field) {
field.readOnly = this.readOnly || disabled; field.readOnly = this.readOnly || disabled;
} }
} }
changeFieldRequired(fieldId: string, required: boolean): void { changeFieldRequired(fieldId: string, required: boolean): void {
const field = this.getFieldById(fieldId); const field = this.getFieldById(fieldId);
if (!!field) { if (field) {
field.required = required; field.required = required;
} }
} }
changeFieldValue(fieldId: string, value: any): void { changeFieldValue(fieldId: string, value: any): void {
const field = this.getFieldById(fieldId); const field = this.getFieldById(fieldId);
if (!!field) { if (field) {
field.value = value; field.value = value;
} }
} }
changeVariableValue(variableId: string, value: any): void { changeVariableValue(variableId: string, value: any): void {
const variable = this.getFormVariable(variableId); const variable = this.getFormVariable(variableId);
if (!!variable) { if (variable) {
variable.value = value; variable.value = value;
} }
} }

View File

@ -33,7 +33,7 @@ export function formRulesManagerFactory<T>(injector: Injector): FormRulesManager
} }
export abstract class FormRulesManager<T> { export abstract class FormRulesManager<T> {
constructor(private formService: FormService) { } constructor(private formService: FormService) {}
protected formModel: FormModel; protected formModel: FormModel;
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
@ -50,12 +50,13 @@ export abstract class FormRulesManager<T> {
if (!this.formModel.readOnly) { if (!this.formModel.readOnly) {
const rules = this.getRules(); const rules = this.getRules();
if (!!rules) { if (rules) {
this.formService.formRulesEvent this.formService.formRulesEvent
.pipe( .pipe(
filter(event => !!event?.form?.id && event.form.id === formModel?.id), filter((event) => !!event?.form?.id && event.form.id === formModel?.id),
takeUntil(this.onDestroy$) takeUntil(this.onDestroy$)
).subscribe(event => { )
.subscribe((event) => {
this.handleRuleEvent(event, rules); this.handleRuleEvent(event, rules);
}); });
@ -76,7 +77,6 @@ export abstract class FormRulesManager<T> {
} }
export class ByPassFormRuleManager<T> extends FormRulesManager<T> { export class ByPassFormRuleManager<T> extends FormRulesManager<T> {
protected getRules(): T { protected getRules(): T {
return null; return null;
} }

View File

@ -43,7 +43,7 @@ export class WidgetVisibilityModel {
return WidgetTypeEnum.field; return WidgetTypeEnum.field;
} else if (this.leftRestResponseId) { } else if (this.leftRestResponseId) {
return WidgetTypeEnum.variable; return WidgetTypeEnum.variable;
} else if (!!this.json.leftType) { } else if (this.json.leftType) {
return this.json.leftType; return this.json.leftType;
} }
return null; return null;
@ -68,7 +68,7 @@ export class WidgetVisibilityModel {
} }
get rightType(): string { get rightType(): string {
if (!!this.json.rightType) { if (this.json.rightType) {
return this.json.rightType; return this.json.rightType;
} else if (this.json.rightValue) { } else if (this.json.rightValue) {
return WidgetTypeEnum.value; return WidgetTypeEnum.value;

View File

@ -68,7 +68,7 @@ export class WidgetVisibilityService {
} }
} }
public isFieldVisible(form: FormModel, visibilityObj: WidgetVisibilityModel, accumulator: any[] = [], result: boolean = false): boolean { public isFieldVisible(form: FormModel, visibilityObj: WidgetVisibilityModel, accumulator: any[] = [], result?: boolean): boolean {
const leftValue = this.getLeftValue(form, visibilityObj); const leftValue = this.getLeftValue(form, visibilityObj);
const rightValue = this.getRightValue(form, visibilityObj); const rightValue = this.getRightValue(form, visibilityObj);
const actualResult = this.evaluateCondition(leftValue, rightValue, visibilityObj.operator); const actualResult = this.evaluateCondition(leftValue, rightValue, visibilityObj.operator);
@ -88,7 +88,7 @@ export class WidgetVisibilityService {
} }
private transformToLiteralExpression(currentExpression: any): string { private transformToLiteralExpression(currentExpression: any): string {
const currentTransformedValue = !!currentExpression.value ? 'true' : 'false'; const currentTransformedValue = currentExpression.value ? 'true' : 'false';
return currentTransformedValue.concat(this.transformToLiteralOperator(currentExpression.operator)); return currentTransformedValue.concat(this.transformToLiteralOperator(currentExpression.operator));
} }
@ -206,9 +206,9 @@ export class WidgetVisibilityService {
const containers = this.getFormTabContainers(form); const containers = this.getFormTabContainers(form);
let isVisible: boolean = true; let isVisible: boolean = true;
containers.map((container: ContainerModel) => { containers.map((container: ContainerModel) => {
if (!!this.getCurrentFieldFromTabById(container, currentFormField.id)) { if (this.getCurrentFieldFromTabById(container, currentFormField.id)) {
const currentTab = form.tabs.find((tab: TabModel) => tab.id === container.tab); const currentTab = form.tabs.find((tab: TabModel) => tab.id === container.tab);
if (!!currentTab) { if (currentTab) {
isVisible = currentTab.isVisible; isVisible = currentTab.isVisible;
} }
} }
@ -230,7 +230,7 @@ export class WidgetVisibilityService {
} }
private getFormTabContainers(form: FormModel): ContainerModel[] { private getFormTabContainers(form: FormModel): ContainerModel[] {
if (!!form) { if (form) {
return form.fields.filter((field) => field.type === 'container' && field.tab) as ContainerModel[]; return form.fields.filter((field) => field.type === 'container' && field.tab) as ContainerModel[];
} }
return []; return [];

View File

@ -15,6 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable @cspell/spellchecker */
export const mockTabText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam urna odio, sagittis vel nulla vel, condimentum egestas dolor. export const mockTabText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam urna odio, sagittis vel nulla vel, condimentum egestas dolor.
Interdum et malesuada fames ac ante ipsum primis in faucibus. Mauris eu hendrerit lectus. Aliquam et ex imperdiet, sodales tellus finibus, malesuada eros. Interdum et malesuada fames ac ante ipsum primis in faucibus. Mauris eu hendrerit lectus. Aliquam et ex imperdiet, sodales tellus finibus, malesuada eros.
Vestibulum aliquet eros sed diam euismod tincidunt. Vestibulum aliquet eros sed diam euismod tincidunt.

View File

@ -38,7 +38,7 @@ export class CookieServiceMock extends CookieService {
/** @override */ /** @override */
clear() { clear() {
Object.keys(this).forEach((key) => { Object.keys(this).forEach((key) => {
if (this.hasOwnProperty(key) && typeof this[key] !== 'function') { if (Object.prototype.hasOwnProperty.call(this, key) && typeof this[key] !== 'function') {
this[key] = undefined; this[key] = undefined;
} }
}); });

View File

@ -16,7 +16,6 @@
*/ */
export class DemoForm { export class DemoForm {
easyForm: any = { easyForm: any = {
formRepresentation: { formRepresentation: {
id: 1001, id: 1001,
@ -1859,10 +1858,10 @@ export class DemoForm {
id: 'my1r7YmMOs', id: 'my1r7YmMOs',
type: 'paragraph', type: 'paragraph',
data: { data: {
text: `<font color="#000000">Is simply a redonly</font><mark class="cdx-marker"> text: `<font color="#000000">Is simply a readonly</font><mark class="cdx-marker">
<font color="#000000">dummy </font><b>text</b></mark><b></b><font color="#000000"> <font color="#000000">dummy </font><b>text</b></mark><b></b><font color="#000000">
of the </font><i>printing and typesetting</i><font color="#000000"> industry.\n of the </font><i>printing and typesetting</i><font color="#000000"> industry.\n
</font><b><i>Lorem</i></b><font color="#000000"> Ipsum has been the industry\'s standard du</font><b> </font><b><i>Lorem</i></b><font color="#000000"> Ipsum has been the industry's standard du</font><b>
<i>mmy text ever since the 1500s,\n when an unknown printer took a galley of type <i>mmy text ever since the 1500s,\n when an unknown printer took a galley of type
and scrambled it to make a type specime</i></b><font color="#000000">n book. </font><font color="#ff1300"> and scrambled it to make a type specime</i></b><font color="#000000">n book. </font><font color="#ff1300">
It has survived not only five centuries</font><font color="#000000">,\n It has survived not only five centuries</font><font color="#000000">,\n
@ -1880,10 +1879,7 @@ export class DemoForm {
type: 'list', type: 'list',
data: { data: {
style: 'unordered', style: 'unordered',
items: [ items: ['Unordered list example', 'Unordered list example']
'Unordered list example',
'Unordered list example'
]
} }
}, },
{ {
@ -1954,5 +1950,4 @@ export class DemoForm {
getFormCloudDefinition(): any { getFormCloudDefinition(): any {
return this.cloudFormDefinition; return this.cloudFormDefinition;
} }
} }

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
export const formDefVisibilitiFieldDependsOnNextOne: any = { export const formDefVisibilityFieldDependsOnNextOne: any = {
id: 19, id: 19,
processDefinitionId: 'visibility:1:148', processDefinitionId: 'visibility:1:148',
processDefinitionName: 'visibility', processDefinitionName: 'visibility',

View File

@ -173,13 +173,12 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
const urlFile = changes['urlFile']; const urlFile = changes['urlFile'];
if (urlFile?.currentValue) { if (urlFile?.currentValue) {
const pdfOptions = { const pdfOptions: any = {
...this.pdfjsDefaultOptions, ...this.pdfjsDefaultOptions,
url: urlFile.currentValue, url: urlFile.currentValue,
withCredentials: this.appConfigService.get<boolean>('auth.withCredentials', undefined) withCredentials: this.appConfigService.get<boolean>('auth.withCredentials', undefined)
}; };
if (this.cacheType) { if (this.cacheType) {
// @ts-ignore
pdfOptions.httpHeaders = { pdfOptions.httpHeaders = {
'Cache-Control': this.cacheType 'Cache-Control': this.cacheType
}; };

View File

@ -24,7 +24,6 @@ import { Injectable } from '@angular/core';
*/ */
@Injectable() @Injectable()
export class RenderingQueueServices { export class RenderingQueueServices {
renderingStates = { renderingStates = {
INITIAL: 0, INITIAL: 0,
RUNNING: 1, RUNNING: 1,
@ -149,22 +148,27 @@ export class RenderingQueueServices {
renderView(view: any) { renderView(view: any) {
const state = view.renderingState; const state = view.renderingState;
switch (state) { switch (state) {
case this.renderingStates.FINISHED: case this.renderingStates.FINISHED: {
return false; return false;
case this.renderingStates.PAUSED: }
case this.renderingStates.PAUSED: {
this.highestPriorityPage = view.renderingId; this.highestPriorityPage = view.renderingId;
view.resume(); view.resume();
break; break;
case this.renderingStates.RUNNING: }
case this.renderingStates.RUNNING: {
this.highestPriorityPage = view.renderingId; this.highestPriorityPage = view.renderingId;
break; break;
case this.renderingStates.INITIAL: }
case this.renderingStates.INITIAL: {
this.highestPriorityPage = view.renderingId; this.highestPriorityPage = view.renderingId;
const continueRendering = function() { // eslint-disable-next-line space-before-function-paren
const continueRendering = function () {
this.renderHighestPriority(); this.renderHighestPriority();
}.bind(this); }.bind(this);
view.draw().then(continueRendering, continueRendering); view.draw().then(continueRendering, continueRendering);
break; break;
}
default: default:
break; break;
} }

View File

@ -22,7 +22,6 @@ import { AppExtensionService, ViewerExtensionRef } from '@alfresco/adf-extension
providedIn: 'root' providedIn: 'root'
}) })
export class ViewUtilService { export class ViewUtilService {
// Extensions that are supported by the Viewer without conversion // Extensions that are supported by the Viewer without conversion
private extensions = { private extensions = {
image: ['png', 'jpg', 'jpeg', 'gif', 'bpm', 'svg'], image: ['png', 'jpg', 'jpeg', 'gif', 'bpm', 'svg'],
@ -50,11 +49,10 @@ export class ViewUtilService {
* Provides a list of file extensions supported by external plugins. * Provides a list of file extensions supported by external plugins.
*/ */
get externalExtensions(): string[] { get externalExtensions(): string[] {
return this.viewerExtensions.map(ext => ext.fileExtension); return this.viewerExtensions.map((ext) => ext.fileExtension);
} }
constructor(private extensionService: AppExtensionService) { constructor(private extensionService: AppExtensionService) {}
}
/** /**
* get File name from url * get File name from url
@ -64,9 +62,7 @@ export class ViewUtilService {
getFilenameFromUrl(url: string): string { getFilenameFromUrl(url: string): string {
const anchor = url.indexOf('#'); const anchor = url.indexOf('#');
const query = url.indexOf('?'); const query = url.indexOf('?');
const end = Math.min( const end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
anchor > 0 ? anchor : url.length,
query > 0 ? query : url.length);
return url.substring(url.lastIndexOf('/', end) + 1, end); return url.substring(url.lastIndexOf('/', end) + 1, end);
} }
@ -80,13 +76,13 @@ export class ViewUtilService {
*/ */
getFileExtension(fileName: string): string { getFileExtension(fileName: string): string {
if (fileName) { if (fileName) {
const match = fileName.match(/\.([^\./\?\#]+)($|\?|\#)/); const match = fileName.match(/\.([^./?#]+)($|\?|#)/);
return match ? match[1] : null; return match ? match[1] : null;
} }
return null; return null;
} }
getViewerType(extension: string, mimeType: string): string { getViewerType(extension: string, mimeType: string): string {
let viewerType = this.getViewerTypeByExtension(extension); let viewerType = this.getViewerTypeByExtension(extension);
if (viewerType === 'unknown') { if (viewerType === 'unknown') {
@ -143,7 +139,7 @@ export class ViewUtilService {
} }
private isExternalViewer(): boolean { private isExternalViewer(): boolean {
return !!this.viewerExtensions.find(ext => ext.fileExtension === '*'); return !!this.viewerExtensions.find((ext) => ext.fileExtension === '*');
} }
isCustomViewerExtension(extension: string): boolean { isCustomViewerExtension(extension: string): boolean {
@ -156,5 +152,4 @@ export class ViewUtilService {
return false; return false;
} }
} }

View File

@ -94,7 +94,7 @@ export class DynamicColumnComponent implements OnInit, OnChanges, OnDestroy {
} }
private updateInstance() { private updateInstance() {
if (this.componentRef && this.componentRef.instance) { if (this.componentRef?.instance) {
this.componentRef.instance.context = this.context; this.componentRef.instance.context = this.context;
} }
} }

View File

@ -89,8 +89,9 @@ export class DynamicExtensionComponent implements OnChanges, OnDestroy {
} }
} }
private proxy(lifecycleMethod, ...args) { private proxy(lifecycleMethod: string, ...args: any[]) {
if (this.componentCreated() && this.lifecycleHookIsImplemented(lifecycleMethod)) { if (this.componentCreated() && this.lifecycleHookIsImplemented(lifecycleMethod)) {
// eslint-disable-next-line prefer-spread
this.componentRef.instance[lifecycleMethod].apply(this.componentRef.instance, args); this.componentRef.instance[lifecycleMethod].apply(this.componentRef.instance, args);
} }
} }

View File

@ -80,7 +80,7 @@ export class DynamicTabComponent implements OnInit, OnChanges, OnDestroy {
} }
private updateInstance() { private updateInstance() {
if (this.componentRef && this.componentRef.instance) { if (this.componentRef?.instance) {
this.componentRef.instance.node = this.node; this.componentRef.instance.node = this.node;
} }
} }

View File

@ -87,7 +87,7 @@ export class PreviewExtensionComponent implements OnInit, OnChanges, OnDestroy {
} }
private updateInstance() { private updateInstance() {
if (this.componentRef && this.componentRef.instance) { if (this.componentRef?.instance) {
const instance = this.componentRef.instance; const instance = this.componentRef.instance;
instance.url = this.url; instance.url = this.url;

View File

@ -135,7 +135,7 @@ export const mergeArrays = (left: any[], right: any[]): any[] => {
(left || []).forEach((entry) => { (left || []).forEach((entry) => {
const element = entry; const element = entry;
if (element && element.hasOwnProperty('id')) { if (element && Object.prototype.hasOwnProperty.call(element, 'id')) {
map[element.id] = element; map[element.id] = element;
} else { } else {
result.push(element); result.push(element);
@ -144,7 +144,7 @@ export const mergeArrays = (left: any[], right: any[]): any[] => {
(right || []).forEach((entry) => { (right || []).forEach((entry) => {
const element = entry; const element = entry;
if (element && element.hasOwnProperty('id') && map[element.id]) { if (element && Object.prototype.hasOwnProperty.call(element, 'id') && map[element.id]) {
const merged = mergeObjects(map[element.id], element); const merged = mergeObjects(map[element.id], element);
map[element.id] = merged; map[element.id] = merged;
} else { } else {

View File

@ -79,7 +79,7 @@ export class AppExtensionService {
return true; return true;
} }
if (extension.rules && extension.rules.disabled) { if (extension.rules?.disabled) {
return this.extensionService.evaluateRule(extension.rules.disabled); return this.extensionService.evaluateRule(extension.rules.disabled);
} }
} }

View File

@ -42,7 +42,7 @@ export class ExtensionLoaderService {
config = JSON.parse(override); config = JSON.parse(override);
} }
if (!config.$references || !config.$references.length) { if (!config.$references?.length) {
config.$references = this.filterIgnoredExtensions(extensions || [], config.$ignoreReferenceList); config.$references = this.filterIgnoredExtensions(extensions || [], config.$ignoreReferenceList);
} else { } else {
config.$references = this.filterIgnoredExtensions(config.$references, config.$ignoreReferenceList); config.$references = this.filterIgnoredExtensions(config.$references, config.$ignoreReferenceList);
@ -102,7 +102,7 @@ export class ExtensionLoaderService {
} }
getRules(config: ExtensionConfig): Array<RuleRef> { getRules(config: ExtensionConfig): Array<RuleRef> {
if (config && config.rules) { if (config?.rules) {
return config.rules; return config.rules;
} }
return []; return [];
@ -170,10 +170,10 @@ export class ExtensionLoaderService {
} }
private filterIgnoredExtensions(extensions: Array<string | ExtensionRef>, ignoreReferenceList: string[]): Array<string | ExtensionRef> { private filterIgnoredExtensions(extensions: Array<string | ExtensionRef>, ignoreReferenceList: string[]): Array<string | ExtensionRef> {
if (!ignoreReferenceList || !ignoreReferenceList.length) { if (!ignoreReferenceList?.length) {
return extensions; return extensions;
} }
return extensions.map((file: string) => file.match('(?!.*\/).+')[0]).filter((fileName: string) => !ignoreReferenceList.includes(fileName)); return extensions.map((file: string) => file.match('(?!.*/).+')[0]).filter((fileName: string) => !ignoreReferenceList.includes(fileName));
} }
} }

View File

@ -68,8 +68,8 @@ describe('ExtensionService', () => {
} }
}); });
const requestedFeatue = service.getFeature('searchedArrayFeature'); const requestedFeature = service.getFeature('searchedArrayFeature');
expect(requestedFeatue).toEqual(searchedArrayFeature); expect(requestedFeature).toEqual(searchedArrayFeature);
}); });
it('should return object if seached feature is an object', async () => { it('should return object if seached feature is an object', async () => {
@ -81,16 +81,16 @@ describe('ExtensionService', () => {
} }
}); });
const requestedFeatue = service.getFeature<{ test: string }>('searchedObjectFeature'); const requestedFeature = service.getFeature<{ test: string }>('searchedObjectFeature');
expect(requestedFeatue).toEqual(searchedObjectFeature); expect(requestedFeature).toEqual(searchedObjectFeature);
}); });
it('should return default value if feature is not found', async () => { it('should return default value if feature is not found', async () => {
const defaultValue = {}; const defaultValue = {};
service.setup(blankConfig); service.setup(blankConfig);
const requestedFeatue = service.getFeature<{ test: string }>('searchedFeature', defaultValue); const requestedFeature = service.getFeature<{ test: string }>('searchedFeature', defaultValue);
expect(requestedFeatue).toEqual(defaultValue); expect(requestedFeature).toEqual(defaultValue);
}); });
}); });

View File

@ -123,7 +123,7 @@ export class ExtensionService {
*/ */
getFeature<T = any[]>(key: string | string[], defaultValue: any = []): T { getFeature<T = any[]>(key: string | string[], defaultValue: any = []): T {
const properties: string[] = Array.isArray(key) ? key : key.split('.'); const properties: string[] = Array.isArray(key) ? key : key.split('.');
return properties.reduce((prev, curr) => prev && prev[curr], this.features) || defaultValue; return properties.reduce((prev, curr) => prev?.[curr], this.features) || defaultValue;
} }
getElements<T extends ExtensionElement>(key: string, fallback: Array<T> = []): Array<T> { getElements<T extends ExtensionElement>(key: string, fallback: Array<T> = []): Array<T> {

View File

@ -62,7 +62,7 @@ export class RuleService {
* @returns RuleEvaluator or null if not found * @returns RuleEvaluator or null if not found
*/ */
getEvaluator(key: string): RuleEvaluator { getEvaluator(key: string): RuleEvaluator {
if (key && key.startsWith('!')) { if (key?.startsWith('!')) {
const fn = this.evaluators[key.substring(1)]; const fn = this.evaluators[key.substring(1)];
return (context: RuleContext, ...args: RuleParameter[]): boolean => !fn(context, ...args); return (context: RuleContext, ...args: RuleParameter[]): boolean => !fn(context, ...args);
} }

View File

@ -175,7 +175,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
onValueChanged(values: any) { onValueChanged(values: any) {
this.formValueChanged.emit(values); this.formValueChanged.emit(values);
if (this.reportForm && this.reportForm.valid) { if (this.reportForm?.valid) {
this.submit(values); this.submit(values);
} }
} }
@ -306,7 +306,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
} }
ngAfterContentChecked() { ngAfterContentChecked() {
if (this.reportForm && this.reportForm.valid) { if (this.reportForm?.valid) {
this.reportForm.markAsDirty(); this.reportForm.markAsDirty();
} }
} }
@ -320,7 +320,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
} }
isFormValid() { isFormValid() {
return this.reportForm && this.reportForm.dirty && this.reportForm.valid; return this.reportForm?.dirty && this.reportForm.valid;
} }
get taskGroup(): UntypedFormGroup { get taskGroup(): UntypedFormGroup {

View File

@ -117,7 +117,7 @@ export class DiagramComponent implements OnChanges {
setMetricValueToDiagramElement(diagram: DiagramModel, metrics: any, metricType: string) { setMetricValueToDiagramElement(diagram: DiagramModel, metrics: any, metricType: string) {
for (const key in metrics) { for (const key in metrics) {
if (metrics.hasOwnProperty(key)) { if (Object.prototype.hasOwnProperty.call(metrics, key)) {
const foundElement: DiagramElementModel = diagram.elements.find( const foundElement: DiagramElementModel = diagram.elements.find(
(element: DiagramElementModel) => element.id === key); (element: DiagramElementModel) => element.id === key);
if (foundElement) { if (foundElement) {

View File

@ -40,8 +40,8 @@ export class BarChart extends Chart {
constructor(obj?: any) { constructor(obj?: any) {
super(obj); super(obj);
this.xAxisType = obj && obj.xAxisType || null; this.xAxisType = obj?.xAxisType || null;
this.yAxisType = obj && obj.yAxisType || null; this.yAxisType = obj?.yAxisType || null;
this.options.scales.xAxes[0].ticks.callback = this.xAxisTickFormatFunction(this.xAxisType); this.options.scales.xAxes[0].ticks.callback = this.xAxisTickFormatFunction(this.xAxisType);
this.options.scales.yAxes[0].ticks.callback = this.yAxisTickFormatFunction(this.yAxisType); this.options.scales.yAxes[0].ticks.callback = this.yAxisTickFormatFunction(this.yAxisType);
if (obj.values) { if (obj.values) {

View File

@ -34,7 +34,7 @@ export class DiagramColorService {
} }
getFillColour(key: string) { getFillColour(key: string) {
if (this.totalColors?.hasOwnProperty(key)) { if (this.totalColors && Object.prototype.hasOwnProperty.call(this.totalColors, key)) {
const colorPercentage = this.totalColors[key]; const colorPercentage = this.totalColors[key];
return this.convertColorToHsb(colorPercentage); return this.convertColorToHsb(colorPercentage);
} else { } else {

View File

@ -578,7 +578,7 @@ describe('FormCloudComponent', () => {
spyOn(formComponent, 'handleError').and.stub(); spyOn(formComponent, 'handleError').and.stub();
spyOn(formCloudService, 'getTaskForm').and.callFake(() => throwError(error)); spyOn(formCloudService, 'getTaskForm').and.callFake(() => throwError(error));
formComponent.getFormByTaskId('test-app', '123').then((_) => { formComponent.getFormByTaskId('test-app', '123').then(() => {
expect(formComponent.handleError).toHaveBeenCalledWith(error); expect(formComponent.handleError).toHaveBeenCalledWith(error);
done(); done();
}); });
@ -1049,7 +1049,7 @@ describe('FormCloudComponent', () => {
pfx_property_five: 'orange', pfx_property_five: 'orange',
pfx_property_none: 'no_form_field' pfx_property_none: 'no_form_field'
}, 'Complete', 123).subscribe({ }, 'Complete', 123).subscribe({
next: _ => done.fail('expected an error, not data'), next: () => done.fail('expected an error, not data'),
error: error => { error: error => {
expect(error).toBe(errorMessage); expect(error).toBe(errorMessage);
expect(formComponent.disableSaveButton).toBeFalse(); expect(formComponent.disableSaveButton).toBeFalse();

View File

@ -94,7 +94,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
this.contentModelFormFileHandler(files[0]); this.contentModelFormFileHandler(files[0]);
} }
this.field.params.displayableCMProperties = this.field.params.displayableCMProperties ?? []; this.field.params.displayableCMProperties = this.field.params.displayableCMProperties ?? [];
this.displayedColumns.splice(2, 0, ...this.field.params.displayableCMProperties?.map(property => property?.name)); this.displayedColumns.splice(2, 0, ...(this.field.params.displayableCMProperties?.map(property => property?.name) || []));
} }
isPathStaticType(): boolean { isPathStaticType(): boolean {

Some files were not shown because too many files have changed in this diff Show More